#!/bin/bash # # syntax: mkbootp [nobuild] [startpkg] # version numbers of packages to use libc="glibc-2.3.2-r9" #busybox="busybox-0.60.3-r1" busybox="busybox-1.0.0_pre20040726" util="util-linux-2.12-r4" #kernel="vanilla-sources-2.4.26" kernel="alpha-sources-2.4.21-r10" e2fs="e2fsprogs-1.35" reiserfs="reiserfsprogs-3.6.17" xfs="xfsprogs-2.6.3" instdir=`pwd` target=${instdir}/rootdisk # should double-check libc version with what is currently installed. if [[ $1 == nobuild ]]; then ebuild() { true; } shift fi if [[ -z $1 ]]; then echo Create clean install target rm -rf initrd* ${target} mkdir ${target} /bin/tar -C skel -cf - . --exclude CVS | /bin/tar -C ${target} -xvf - else start=$1 fi # override some /etc/make.conf settings so that what we build here will # work on as many alpha boxes as possible export CHOST="alpha-unknown-linux-gnu" export CFLAGS="-mcpu=ev4 -O3 -pipe" export CXXFLAGS="$CFLAGS" export USE="-* build bootstrap" # This is for the sake of finding ebuilds below eval $(grep ^PORTDIR= /etc/make.conf) main() { declare pkg for pkg in e2fs xfs reiser libc busybox util kernel; do [[ -n ${start} && ${start} != ${pkg} ]] && continue echo "--- Build ${pkg} ---" ${pkg} || exit 1 unset start done } e2fs() { ebuild ${PORTDIR}/sys-fs/e2fsprogs/${e2fs}.ebuild clean compile install || return 1 cp -av /var/tmp/portage/${e2fs}/image/lib/* ${target}/lib/ || return 1 cp -av /var/tmp/portage/${e2fs}/image/bin/* ${target}/bin/ || return 1 cp -av /var/tmp/portage/${e2fs}/image/sbin/* ${target}/sbin/ || return 1 } xfs() { ebuild ${PORTDIR}/sys-fs/xfsprogs/${xfs}.ebuild clean compile install || return 1 cp -av /var/tmp/portage/${xfs}/image/lib/* ${target}/lib/ || return 1 cp -av /var/tmp/portage/${xfs}/image/bin/* ${target}/bin/ || return 1 cp -av /var/tmp/portage/${xfs}/image/sbin/* ${target}/sbin/ || return 1 } reiser() { ebuild ${PORTDIR}/sys-fs/reiserfsprogs/${reiserfs}.ebuild clean compile install || return 1 cp -av /var/tmp/portage/${reiserfs}/image/sbin/* ${target}/sbin/ || return 1 } libc() { ebuild ${PORTDIR}/sys-libs/glibc/${libc}.ebuild clean compile install || return 1 cp -av /var/tmp/portage/${libc}/image/lib/libc.so.* ${target}/lib/ || return 1 cp -av /var/tmp/portage/${libc}/image/lib/ld-linux.so.* ${target}/lib/ || return 1 } util() { ebuild ${PORTDIR}/sys-apps/util-linux/${util}.ebuild clean compile install || return 1 cp -av /var/tmp/portage/${util}/image/sbin/fdisk ${target}/bin/ || return 1 } busybox() { #ebuild ${PORTDIR}/sys-apps/busybox/${busybox}.ebuild clean unpack || return 1 #cp -v config-${busybox} /var/tmp/portage/${busybox}/work/*/Config.h || return 1 ebuild ${PORTDIR}/sys-apps/busybox/${busybox}.ebuild clean compile install || return 1 cp -av /var/tmp/portage/${busybox}/image/bin/busybox ${target}/bin/ || return 1 sed "s:^:${target}:" /var/tmp/portage/${busybox}/work/*/busybox.links \ | xargs -n1 ln -svfn /bin/busybox } kernel() { ebuild ${PORTDIR}/sys-kernel/${kernel%%-[0-9]*}/${kernel}.ebuild clean install || return 1 linuxsrc=`echo "/var/tmp/portage/${kernel}/image/usr/src/linux"*` make -C ${linuxsrc} mrproper || return 1 cp config-${kernel} ${linuxsrc}/.config || return 1 #yes '' | make -C ${linuxsrc} oldconfig dep || return 1 # Only uncomment if you want to use kernel modules -- not really supported #make -C ${linuxsrc} modules modules_install INSTALL_MOD_PATH="${target}" size=$(( $(du -s ${target} | cut -f1) * 11 / 10 )) echo Building root disk of ${size}k dd if=/dev/zero of=initrd.img bs=1k count=${size} || return 1 mke2fs -F initrd.img || return 1 mkdir -p initrd || return 1 mount initrd.img initrd -o loop || return 1 cp -a ${target}/* initrd || return 1 umount initrd || return 1 gzip -9 initrd.img || return 1 make -C ${linuxsrc} vmlinux bootpfile \ INITRD="${instdir}/initrd.img.gz" \ HPATH="${linuxsrc}/include" || return 1 cp ${linuxsrc}/arch/alpha/boot/bootpfile . echo "Your bootp/tftp file is complete:" ls -l bootpfile } main