2009-01-03 05:38:53 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Plugbox Linux Distribution Image Builder
|
|
|
|
#
|
|
|
|
# Licensed under the GPLv2.
|
|
|
|
#
|
2010-06-28 06:06:13 +00:00
|
|
|
# This script builds a Plugbox distribution/image.
|
|
|
|
# First, it downloads and installs packages to the workingdir,
|
|
|
|
# then configures some basics, sets the root password to "root",
|
|
|
|
# and then creates a rootts.tar.gz and/or a UBI image, ready to flash.
|
|
|
|
#
|
2010-06-14 03:45:27 +00:00
|
|
|
# Usage: ./distro-builder workingdir
|
|
|
|
#
|
|
|
|
# NOTE: This script is interactive.
|
|
|
|
# Agree to installing packages and answer "y" to cleaning the Pacman database.
|
2009-01-03 05:38:53 +00:00
|
|
|
#
|
2010-07-30 06:41:52 +00:00
|
|
|
# NOTE: Make sure the package "mtd-utils" is installed for making UBI images.
|
|
|
|
#
|
2009-01-03 05:38:53 +00:00
|
|
|
# ==== Variables to set ====
|
2010-07-08 01:51:59 +00:00
|
|
|
PLUGSCRIPTDIR=/media/Plugbox/builder/plugapps/scripts/plugscripts
|
2010-08-03 23:56:04 +00:00
|
|
|
INSTALLEDPKGS="base kernel26-withlinux file openssh openssl heimdal"
|
2010-10-28 00:16:50 +00:00
|
|
|
RELEASEVER=2010.11
|
2010-06-17 13:58:10 +00:00
|
|
|
MAKETARGZ=1
|
2010-06-28 06:06:13 +00:00
|
|
|
MAKEUBIIMG=1
|
2009-01-03 05:38:53 +00:00
|
|
|
# ==== The Process ====
|
|
|
|
mkdir -p $1
|
2010-06-14 03:45:27 +00:00
|
|
|
echo -e "\033[1mInstalling packages...\033[0m"
|
2009-01-03 05:38:53 +00:00
|
|
|
mkdir -p $1/var/lib/pacman
|
2010-07-02 13:21:26 +00:00
|
|
|
pacman -Syy --noconfirm --noprogressbar -r $1 $INSTALLEDPKGS
|
2010-06-14 03:45:27 +00:00
|
|
|
|
2010-10-28 00:16:50 +00:00
|
|
|
echo -e "\033[1mSetting the password to 'root' and cleaning up:\033[0m"
|
2009-01-03 05:38:53 +00:00
|
|
|
echo -e "root\nroot\n" | chroot $1/ /usr/bin/passwd root
|
2010-06-14 03:52:37 +00:00
|
|
|
rm $1/dev/{console,null,zero}
|
|
|
|
chroot $1/ mknod -m 600 /dev/console c 5 1
|
|
|
|
chroot $1/ mknod -m 666 /dev/null c 1 3
|
|
|
|
chroot $1/ mknod -m 666 /dev/zero c 1 5
|
2010-06-14 04:14:23 +00:00
|
|
|
rm $1/etc/locale.gen
|
|
|
|
echo "en_US.UTF-8 UTF-8" >> $1/etc/locale.gen
|
|
|
|
echo "en_US ISO-8859-1" >> $1/etc/locale.gen
|
2010-07-08 13:57:05 +00:00
|
|
|
echo "de_DE ISO-8859-1" >> $1/etc/locale.gen
|
|
|
|
echo "de_DE@euro ISO-8859-15" >> $1/etc/locale.gen
|
2010-06-14 03:52:37 +00:00
|
|
|
chroot $1/ /usr/sbin/locale-gen
|
2010-07-02 13:21:26 +00:00
|
|
|
chroot $1/ /usr/bin/pacman -Scc --noconfirm
|
2010-06-17 13:14:19 +00:00
|
|
|
echo $RELEASEVER > $1/etc/plugbox-version
|
2010-07-30 06:41:52 +00:00
|
|
|
cp -R $PLUGSCRIPTDIR $1/usr/share/plugapps/
|
2010-06-14 03:45:27 +00:00
|
|
|
|
2010-06-17 13:14:19 +00:00
|
|
|
# Here is the rootfs.tar.gz part if you set MAKETARGZ to 1
|
|
|
|
if [ $MAKETARGZ = 1 ]; then
|
|
|
|
echo -e "\033[1mCreating a rootfs.tar.gz...\033[0m"
|
|
|
|
cd $1
|
2010-07-02 13:21:26 +00:00
|
|
|
tar czf ../Plugbox-Linux-$RELEASEVER-rootfs.tar.gz ./*
|
2010-06-17 13:14:19 +00:00
|
|
|
cd ../
|
|
|
|
else
|
|
|
|
echo -e "\033[1mNot creating a rootfs.tar.gz...\033[0m"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Here is the UBI image part if you set MAKEUBIIMG to 1
|
2010-06-28 06:06:13 +00:00
|
|
|
if [ $MAKEUBIIMG = 1 ]; then
|
|
|
|
echo -e "\033[1mCreating a rootfs.ubi.img...\033[0m"
|
2010-06-17 13:14:19 +00:00
|
|
|
cat << EOF > ./ubi.cfg
|
|
|
|
[ubifs]
|
|
|
|
mode=ubi
|
|
|
|
image=rootfs.ubifs.img
|
|
|
|
vol_id=0
|
|
|
|
vol_size=356MiB
|
|
|
|
vol_type=dynamic
|
|
|
|
vol_name=rootfs
|
|
|
|
vol_flags=autoresize
|
|
|
|
EOF
|
|
|
|
mkfs.ubifs -x zlib -m 2048 -e 129024 -c 4096 -r $1 rootfs.ubifs.img
|
|
|
|
ubinize -o rootfs.ubi.img -m 2048 -p 128KiB -s 512 ./ubi.cfg
|
|
|
|
rm -f ubi.cfg rootfs.ubifs.img
|
|
|
|
else
|
2010-06-28 06:06:13 +00:00
|
|
|
echo -e "\033[1mNot creating UBI image...\033[0m"
|
2010-06-17 13:14:19 +00:00
|
|
|
fi
|
2010-06-17 13:58:10 +00:00
|
|
|
|
|
|
|
echo -e "\033[1mCleaning up...\033[0m"
|
|
|
|
rm -rf $1
|