PKGBUILDs/scripts/distro-builder
2010-06-27 23:01:25 -07:00

69 lines
1.9 KiB
Bash
Executable file

#!/bin/bash
#
# Plugbox Linux Distribution Image Builder
# Version 0.2.1
#
# Licensed under the GPLv2.
#
# Usage: ./distro-builder workingdir
#
# NOTE: This script is interactive.
# Agree to installing packages and answer "y" to cleaning the Pacman database.
#
# ==== Variables to set ====
INSTALLEDPKGS="base kernel26-withlinux openssh openssl heimdal"
RELEASEVER=1.1
MAKETARGZ=1
MAKEUBIIMGSHEEVA=0
MAKEUBIIMGGURU=1
# ==== The Process ====
mkdir -p $1
echo -e "\033[1mInstalling packages...\033[0m"
mkdir -p $1/var/lib/pacman
pacman -Syy -r $1 $INSTALLEDPKGS
echo -e "\033[1mSetting the password to 'root' and cleaning up:\033[0m"
echo -e "root\nroot\n" | chroot $1/ /usr/bin/passwd root
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
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
chroot $1/ /usr/sbin/locale-gen
chroot $1/ /usr/bin/pacman -Scc
echo $RELEASEVER > $1/etc/plugbox-version
# 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
tar czf ../Plugbox-Linux-$RELEASEVER.tar.gz ./*
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
if [ $MAKEUBIIMGGURU = 1 ]; then
echo -e "\033[1mCreating a rootfs.ubi.img for GuruPlug...\033[0m"
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
echo -e "\033[1mNot creating UBI image for GuruPlug...\033[0m"
fi
echo -e "\033[1mCleaning up...\033[0m"
rm -rf $1