#
# size of the image in MB
#
-# 2GB - 48MB
-IMGSIZE=2000
+IMGSIZE=3600
#
# target architecture / suite
#
-ARCH=armhf
-#ARCH=armel
-MAKEOPT="ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-"
+#ARCH=armhf
+ARCH=armel
#MAKEOPT="ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-"
+MAKEOPT="ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-"
EMU=qemu-arm-static
SUITE=unstable
# name
-NAME=beagleboard
-#NAME=nellboard
+#NAME=beagleboard
+NAME=nellboard
#
# filesystems
#
ROOTFS=xfs
-#ROOTFS=ext4
-BOOTFS=ext3
+ROOTFS=ext4
+#BOOTFS=ext3
# debian mirror
DEBMIRROR=http://ftp.de.debian.org/debian
KERVER="2.6.33"
KERPATCH="linux-2.6.33_lpc313x-v1.01.patch"
KERCONF="ea313x_defconfig"
-KERHOOK="
- sed 's/# CONFIG_DEVTMPFS.*/CONFIG_DEVTMPFS=y/' -i \
- ./arch/arm/configs/ea313x_defconfig;
- sed 's/# CONFIG_EXT4_FS.*/CONFIG_EXT4_FS=y/' -i \
- ./arch/arm/configs/ea313x_defconfig; \
- cp ../files/lpc313x/ea313x.c arch/arm/mach-lpc313x/;"
+KERHOOKS="nellboard_kernel_hooks.sh"
#
# u-boot patch and target
else
echo "building debian image, first stage ..."
# image
- validimg="no"
if [ -f ./rootfs.img ]; then
size=`ls -al ./rootfs.img | awk '{ print $5/1048576 }'`
if [ "$size" = "$IMGSIZE" ]; then
echo "rootfs.img exists"
- validimg="yes"
else
echo "creating rootfs.img"
+ dd if=/dev/zero of=./rootfs.img \
+ bs=1M count=$IMGSIZE
fi
fi
- if [ "$validimg" = "no" ]; then
- dd if=/dev/zero of=./rootfs.img bs=1M count=$IMGSIZE
- fi
# make fs and mount
umount_if_mounted rootfs.mnt
- mkfs.${ROOTFS} -f -L rootfs ./rootfs.img
+ FORCEFS="-F"
+ [ "$ROOTFS" = "xfs" ] && FORCEFS="-f"
+ mkfs.${ROOTFS} $FORCEFS -L rootfs ./rootfs.img
rm -rf rootfs.mnt
mkdir rootfs.mnt
mount -o loop ./rootfs.img ./rootfs.mnt
# copy myself
cp -v ./build.sh ./rootfs.mnt
cp -v ./build.config ./rootfs.mnt
+ mkdir -p ./rootfs.mnt/post_routines
+ cp -v ./post_routines/$NAME/* ./rootfs.mnt/post_routines
+ mkdir -p ./rootfs.mnt/files
+ cp -rv ./files/$NAME/* ./rootfs.mnt/files
if [ ! -f .build_stage2 ]; then
# prepare/run second stage
modprobe binfmt_misc
# cleanup
rm -v ./rootfs.mnt/build.sh
rm -v ./rootfs.mnt/build.config
+ rm -rfv ./rootfs.mnt/post_routines
+ rm -rfv ./rootfs.mnt/files
+ fi
+ # final things
+ echo
+ echo -en "build completed! want me to umount everything? [Y,n]: "
+ read answer
+ if [ "$answer" != "n" ]; then
+ mnts="rootfs.mnt/dev/pts rootfs.mnt/proc rootfs.mnt"
+ for mnt in $mnts; do
+ umount_if_mounted $mnt
+ done
fi
}
echo -en "auto lo\niface lo inet loopback\n" > /etc/network/interfaces
echo -en "auto eth0\niface eth0 inet dhcp\n" >> /etc/network/interfaces
echo -en "auto usb0\niface usb0 inet dhcp\n" >> /etc/network/interfaces
- # login on serial console
- num=`echo $GETTY | sed 's/\([a-zA-Z].*\)\([0-9].*\)/\2/'`
- echo "T${num}:2345:respawn:/sbin/getty -L $GETTY 115200 linux" >> \
- /etc/inittab
# hostname
echo $NAME > /etc/hostname
# root
echo "/dev/root / $ROOTFS defaults 0 1" > /etc/fstab
- # behavior of boot scripts
- echo "HWCLOCKACCESS=no" >> /etc/default/rcS
+ # determine init type
+ if [ "`file /sbin/init | awk '{ print $2 }'`" = "symbolic" ]; then
+ symlink=`ls -al /sbin/init | awk -F'->' '{ print $2 }'`
+ inittype=`basename $symlink`
+ else
+ inittype=sysvinit
+ fi
+ # serial console
+ num=`echo $GETTY | sed 's/\([a-zA-Z].*\)\([0-9].*\)/\2/'`
+ case "$inittype" in
+ systemd)
+ # nothing required to enable serial console
+ ;;
+ sysvinit)
+ echo -en "T${num}:2345:respawn:/sbin/getty -L " >> \ /etc/inittab
+ echo -en "$GETTY 115200 linux" >> /etc/inittab;;
+ *)
+ echo "unsupported init system: $inittype";;
+ esac
+ # more boot scripts
+ echo -en "\nHWCLOCKACCESS=no\n" >> /etc/default/rcS
echo "CONCURRENCY=shell" >> /etc/default/rcS
# additional packages
apt-get -y install $ADDPKGS
passwd -d root
# profile
echo -en "\nalias l='ls -al --color'\n\n" >> /etc/profile
+ # post install hooks
+ for file in 'ls /post_routines'; do
+ . /post_routines/$file
+ done
}
#
if [ "$nopatch" = "0" ]; then
if [ ! -z "$UBPATCH" ]; then
for patch in $UBPATCH; do
- patch -Nfp1 < ../patches/$patch
+ patch -Nfp1 < ../patches/$NAME/$patch
done
fi
fi
if [ "$nopatch" = "0" ]; then
if [ ! -z "$KERPATCH" ]; then
for patch in $KERPATCH; do
- patch -Nfp1 < ../patches/$patch
+ patch -Nfp1 < ../patches/$NAME/$patch
done
fi
fi
make $MAKEOPT mrproper
fi
if [ "$nohook" = "0" ]; then
- if [ ! -z "$KERHOOK" ]; then
- $KERHOOK
+ if [ ! -z "$KERHOOKS" ]; then
+ for hook in $KERHOOKS; do
+ . ../hooks/$hook
+ done
fi
fi
if [ ! -z "$KERCONF" ]; then