--- elwix/build_uboot.sh 2014/01/20 13:05:17 1.1 +++ elwix/build_uboot.sh 2014/09/15 19:06:42 1.2 @@ -0,0 +1,182 @@ +#!/bin/sh +# +# ELWIX Build script for ELWIX u-boot base firmware +# +# (C) AITNET ltd - Sofia/Bulgaria +# by Michael Pounov +# +# $Id: build_uboot.sh,v 1.2 2014/09/15 19:06:42 misho Exp $ +# + +[ -r ./config/rc.elwix ] && . ./config/rc.elwix +if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then + echo + echo "ELWIX project is not configured !?!" + echo + exit 1 +fi + +if [ ! -d ${BSDSRC} ]; then + echo + echo "ELWIX project is not configured - missing BSD sources !?!" + echo + exit 1 +fi + +if [ "${USER}" != "root" ]; then + echo + echo "ELWIX project is not configured - base must build under root !?!" + echo + exit 1 +fi + +clean_ubfs() +{ + echo "+++ Clean ELWIX u-boot firmware ..." + chflags -Rf noschg $UBFS $UBOOT_FS + rm -rf $UBFS $UBOOT_FS ${REL}/${UBOOT_OS} ${REL}/kernel.lzma +} + +build_ubfs() +{ + echo "+++ Build ELWIX u-boot directory ..." + mkdir -p $UBFS + + cd $UBFS + + install -d bin; + install -d boot; + install -d boot/firmware; + install -d boot/modules; + install -d dev; + install -d elwix; + install -d elwix/altroot; + install -d elwix/altroot/var; + install -d elwix/cf; + install -d elwix/etc; + install -d -o 883 -g 883 elwix/etc/mqtt; + install -d elwix/exports; + install -d elwix/home; + install -d -m 0750 elwix/root; + install -d -m 0750 elwix/root/.ssh; + install -d elwix/tftpboot; + ln -fs /elwix/etc etc; + ln -fs /elwix/exports exports; + ln -fs /elwix/home home; + ln -fs /elwix/root root; + ln -fs /elwix/tftpboot tftpboot; + install -d mnt; + install -d -m 0555 proc; + install -d sbin; + install -d tmp; + install -d usr; + install -d usr/bin; + install -d usr/lib; + ln -fs /usr/lib lib; + install -d usr/lib/engines; + install -d usr/lib/geom; + install -d usr/libdata; + install -d usr/libexec; + install -d usr/libexec/casper; + ln -fs /usr/libexec libexec; + install -d usr/local; + install -d usr/local/bin; + install -d usr/local/lib; + install -d usr/local/libdata; + install -d usr/local/libexec; + install -d usr/local/sbin; + install -d usr/sbin; + install -d usr/share; + install -d usr/share/misc; + install -d usr/share/skel; + install -d usr/share/zoneinfo; + install -d var; + + chown -hR root:wheel . + cd - +} + +install_ubfs() +{ + LIBS="${UBFS}/usr/lib" + LIBEXEC="${UBFS}/usr/libexec" + LIBDATA="${UBFS}/usr/libdata" + BIN="${UBFS}/bin" + UBIN="${UBFS}/usr/bin" + SBIN="${UBFS}/sbin" + USBIN="${UBFS}/usr/sbin" + SHARE="${UBFS}/usr/share" + SKEL="${SHARE}/skel" + MISC="${SHARE}/misc" + + echo "+++ Install ELWIX u-boot software ..." + if [ -r ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap ]; then + install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap $MISC; + install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/services $MISC; + else + install -v -m 644 ${BSDSRC}/etc/termcap.small $MISC/termcap; + install -v -m 644 ${BSDSRC}/etc/services $MISC; + fi + + install -v ${CFGDIR}/root.skel/cshrc $SKEL/dot.cshrc; + install -v ${CFGDIR}/root.skel/login $SKEL/dot.login; + install -v ${CFGDIR}/root.skel/logout $SKEL/dot.logout; + install -v ${CFGDIR}/root.skel/profile $SKEL/dot.profile; + install -v ${CFGDIR}/root.skel/vimrc $SKEL/dot.vimrc; + + find ${WORLD}/libexec -type f -name ld-elf.so\* -exec install {} $LIBEXEC \; + + InstallList ${ELWIX_UBFS} ${WORLD} ${UBFS} + InstallLibs ${WORLD} ${UBFS} + InstallDir ${WORLD}/libexec/casper $LIBEXEC/casper + + chown -R root:wheel $SBIN $BIN $USBIN $UBIN $LIBDATA $LIBEXEC $LIBS +} + +prepare_fs() +{ + echo "+++ Prepare ELWIX fs ..." + mkdir -p $1 + + if [ -d ${UBFS} ]; then + cd ${UBFS} + pax -rw -pe -X . $1 + cd - + fi +} + +create_etc_fstab() +{ + cat >$1/etc/fstab <<_EOF +# Automatic generated fstab for ELWIX $2 at ${BUILD_DATE} +# +/dev/map/rootfs.uncompress / ufs ro 0 0 +md0 /tmp mfs rw,-s1m,-oasync,-S 0 0 +md1 /var mfs rw,-s2m,-S 0 0 +/var/db /elwix/etc unionfs rw,noauto,-onoatime 0 0 +_EOF +} + +install_fs() +{ + cd $1 + echo "+++ Install ELWIX u-boot $1 in bundle OS install file ..." + tar -czvf ${REL}/${UBOOT_OS} . + cd - +} + +### main() +clean_ubfs +build_ubfs + +install_ubfs + +# build fs +prepare_fs ${UBOOT_FS} +MakeFS_home ${UBOOT_FS}/elwix +MakeFS_var ${UBOOT_FS}/elwix ${UBOOT_ETC} +MakeFS_etc ${UBOOT_FS}/elwix ${UBOOT_ETC} uboot +create_etc_fstab ${UBOOT_FS}/elwix uboot +install_fs ${UBOOT_FS} + +echo "+++ Complete build ELWIX u-boot"