--- elwix/build_rootfs.sh 2012/02/09 01:36:21 1.2.4.3 +++ elwix/build_rootfs.sh 2014/09/15 19:06:42 1.9 @@ -5,7 +5,7 @@ # (C) AITNET ltd - Sofia/Bulgaria # by Michael Pounov # -# $Id: build_rootfs.sh,v 1.2.4.3 2012/02/09 01:36:21 misho Exp $ +# $Id: build_rootfs.sh,v 1.9 2014/09/15 19:06:42 misho Exp $ # [ -r ./config/rc.elwix ] && . ./config/rc.elwix @@ -30,18 +30,25 @@ if [ "${USER}" != "root" ]; then exit 1 fi -NEWKERN="${REL}/kernel" +KRNNAME="kernel_rootfs" +NEWKERN="${REL}/${KRNNAME}" +MKF="Makefile.elwix" +MKH="Makefile.inc" +# Set TARGET_CPUTYPE only for world compiling. Don't use this in kernel build! +X_TARGET_CPUTYPE="TARGET_CPUTYPE=${TARGET_CPUTYPE}" + clean_elwix() { - echo "+++ Clean csh from ELWIX World ..." - rm -rf ${BSDOBJ}/usr/src/bin/csh/* + echo "+++ Clean elwix binary from ELWIX World ..." + rm -rf $BSDOBJ/elwix echo "+++ Clean ELWIX RootFS firmware ..." - rm -rf $MKDIR - mkdir $MKDIR + rm -rf $ROOTFS_MKDIR + mkdir $ROOTFS_MKDIR echo "+++ Clean RootFS directory ..." + chflags -R noschg $ROOTFS rm -rf $ROOTFS mkdir $ROOTFS @@ -52,35 +59,50 @@ clean_elwix() prepare_elwix() { echo "+++ Prepair ELWIX RootFS firmware ..." - cd $MKDIR + cd $ROOTFS_MKDIR cat >$MKH <<_EOF # Auto-generated Makefile include for crungegen # !!! Dont edit by hand !!! # -#BUILDOPTS += TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} MAKEOBJDIRPREFIX=${BSDOBJ} -CRUNCH_SUPPRESS_LINK_-sh= 1 -CRUNCH_SUPPRESS_LINK_-csh= 1 -CRUNCH_SUPPRESS_LINK_-tcsh= 1 + LIBS += -L${WORLD}/lib -L${WORLD}/usr/lib _EOF cat >$ROOTFS_CONF <<_EOF +srcdirs ${BSDSRC}/tools/tools ${BSDSRC}/tools/tools/ath +srcdirs ${BSDSRC}/release/picobsd/tinyware srcdirs ${BSDSRC}/bin ${BSDSRC}/sbin ${BSDSRC}/libexec ${BSDSRC}/cddl/sbin ${BSDSRC}/sbin/ggate -srcdirs ${BSDSRC}/usr.bin ${BSDSRC}/usr.sbin ${BSDSRC}/crypto/openssh -#buildopts -DRESCUE CRUNCH_CFLAGS=-DRESCUE TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} MAKEOBJDIRPREFIX=${BSDOBJ} -buildopts TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} MAKEOBJDIRPREFIX=${BSDOBJ} +srcdirs ${BSDSRC}/usr.bin ${BSDSRC}/usr.sbin ${BSDSRC}/usr.sbin/wpa +srcdirs ${BSDSRC}/secure/usr.bin ${BSDSRC}/secure/usr.sbin ${BSDSRC}/secure/libexec + +buildopts TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} ${X_TARGET_CPUTYPE} __MAKE_CONF=${MAKECONF} +buildopts -DNO_PAM -DNO_KERBEROS WITHOUT_PAM_SUPPORT=yes WITHOUT_KERBEROS_SUPPORT=yes WITHOUT_KERBEROS=yes +buildopts -DMK_CASPER=no WITHOUT_CASPER=yes _EOF cat $CFGDIR/$ROOTFS_CONF >>$ROOTFS_CONF - crunchgen -f -p $BSDOBJ -h $MKDIR/$MKH -m $MKF -c elwix.c -e elwix $ROOTFS_CONF + install -d ${BSDOBJ}/elwix + env MAKEOBJDIRPREFIX=${BSDOBJ}/elwix crunchgen -f \ + -h $ROOTFS_MKDIR/$MKH -m $MKF \ + -c elwix.c -e elwix $ROOTFS_CONF + if [ $? -ne 0 ]; then + exit 1 + fi cd - } build_elwix() { echo "+++ Build ELWIX RootFS firmware ..." - cd $MKDIR - make -f $MKF clean - make -f $MKF + cd $ROOTFS_MKDIR + env MAKEOBJDIRPREFIX=${BSDOBJ}/elwix make -f $MKF \ + TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ + ${X_TARGET_CPUTYPE} __MAKE_CONF=${MAKECONF} clean + env MAKEOBJDIRPREFIX=${BSDOBJ}/elwix make -f $MKF \ + TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ + ${X_TARGET_CPUTYPE} __MAKE_CONF=${MAKECONF} + if [ $? -ne 0 ]; then + exit 1 + fi cd - } @@ -93,16 +115,20 @@ build_rootdir() install -d dev; install -d elwix; install -d elwix/etc; + install -d libexec; install -d mnt; install -d -m 0555 proc; install -d sbin; - install -d system; install -d -m 1777 tmp; install -d usr; + install -d usr/bin; + install -d usr/lib; + install -d usr/libexec; + install -d usr/sbin; install -d var; + install -d var/sys; ln -fs /usr/lib lib; - ln -fs /usr/libexec libexec; ln -fs /elwix/etc etc; ln -fs /elwix/exports exports; @@ -115,14 +141,17 @@ build_rootdir() install_rootfs() { - PRG="/sbin/elwix" BIN="${ROOTFS}/bin" SBIN="${ROOTFS}/sbin" - LIBEXEC="${ROOTFS}/libexec" + UBIN="${ROOTFS}/usr/bin" + LIBEXEC="${ROOTFS}/usr/libexec" ETC="${ROOTFS}/elwix/etc" + PRG="/sbin/elwix" + LNPRG="${SBIN}/elwix" + echo "+++ Install ELWIX into RootFS directory ..." - install $MKDIR/elwix $SBIN + install $ROOTFS_MKDIR/elwix $SBIN InstallList ${ELWIX_ROOTFS} ${WORLD} ${ROOTFS} @@ -137,17 +166,16 @@ install_rootfs() ln -s $PRG $BIN/chio ln -s $PRG $BIN/chmod ln -s $PRG $BIN/cp -# ln -s $PRG $BIN/csh -# ln -s $PRG $BIN/tcsh - ln -s /bin/tcsh $BIN/-tcsh - ln -s /bin/csh $BIN/-csh + ln -s $PRG $BIN/csh + ln -s $PRG $BIN/-csh + ln -s $PRG $BIN/tcsh + ln -s $PRG $BIN/-tcsh ln -s $PRG $BIN/date ln -s $PRG $BIN/dd ln -s $PRG $BIN/df ln -s $PRG $BIN/domainname ln -s $PRG $BIN/echo ln -s $PRG $BIN/expr - ln -s $PRG $BIN/getfacl ln -s $PRG $BIN/hostname ln -s $PRG $BIN/kenv ln -s $PRG $BIN/kill @@ -168,19 +196,11 @@ install_rootfs() ln -s $PRG $BIN/rm ln -s $PRG $BIN/unlink ln -s $PRG $BIN/rmdir - ln -s $PRG $BIN/setfacl ln -s $PRG $BIN/sleep ln -s $PRG $BIN/stty ln -s $PRG $BIN/sync ln -s $PRG $BIN/uuidgen - ln $PRG $BIN/su - chmod u+s $BIN/su - ln $PRG $BIN/login - chmod u+s $BIN/login - ln $PRG $BIN/netstat - chmod g+s $BIN/netstat - ln -s $PRG $BIN/true ln -s $PRG $BIN/false ln -s $PRG $BIN/basename @@ -192,21 +212,16 @@ install_rootfs() ln -s $PRG $BIN/tset ln -s $PRG $BIN/vmstat ln -s $PRG $BIN/systat - ln -s $PRG $BIN/bsdtar - ln -s $PRG $BIN/bsdcpio ln -s $PRG $BIN/tput - ln -s $PRG $BIN/bsdgrep ln -s $PRG $BIN/grep ln -s $PRG $BIN/awk ln -s $PRG $BIN/less - ln -s $PRG $BIN/passwd ln -s $PRG $BIN/gzip ln -s $PRG $BIN/cap_mkdb ln -s $PRG $BIN/sed ln -s $PRG $BIN/vi ln -s $PRG $BIN/du ln -s $PRG $BIN/getopt - ln -s $PRG $BIN/cu ln -s $PRG $BIN/logger ln -s $PRG $BIN/nice ln -s $PRG $BIN/nohup @@ -218,39 +233,26 @@ install_rootfs() ln -s $PRG $BIN/touch ln -s $PRG $BIN/wc ln -s $PRG $BIN/xargs - ln -s $PRG $BIN/ssh - ln -s $PRG $BIN/scp - ln -s $PRG $BIN/sftp - ln -s $PRG $BIN/ssh-keygen ln -s $PRG $BIN/printenv - ln -s $PRG $BIN/slogin ln -s $PRG $BIN/egrep ln -s $PRG $BIN/fgrep ln -s $PRG $BIN/tar ln -s $PRG $BIN/cpio ln -s $PRG $BIN/nawk ln -s $PRG $BIN/gunzip + ln -s $PRG $BIN/gzcat + ln -s $PRG $BIN/zcat ln -s $PRG $BIN/more ln -s $PRG $BIN/reset ln -s $PRG $BIN/readlink ln -s $PRG $BIN/uptime - ln -s $PRG $BIN/tip + ln -s $PRG $BIN/bzip2 + ln -s $PRG $BIN/bunzip2 + ln -s $PRG $BIN/bzcat - - ln $PRG $SBIN/ping - chmod u+s $SBIN/ping - ln $PRG $SBIN/ping6 - chmod u+s $SBIN/ping6 - ln $PRG $SBIN/shutdown - chmod u+s $SBIN/shutdown - - ln -s $PRG $SBIN/adjkerntz - ln -s $PRG $SBIN/atacontrol - ln -s $PRG $SBIN/badsect ln -s $PRG $SBIN/bsdlabel ln -s $PRG $SBIN/disklabel ln -s $PRG $SBIN/camcontrol - ln -s $PRG $SBIN/ccdconfig ln -s $PRG $SBIN/comcontrol ln -s $PRG $SBIN/conscontrol ln -s $PRG $SBIN/devfs @@ -258,22 +260,18 @@ install_rootfs() ln -s $PRG $SBIN/dmesg ln -s $PRG $SBIN/dump ln -s $PRG $SBIN/rdump - ln -s $PRG $SBIN/dumpfs ln -s $PRG $SBIN/dumpon ln -s $PRG $SBIN/fdisk - ln -s $PRG $SBIN/ffsinfo ln -s $PRG $SBIN/fsck ln -s $PRG $SBIN/fsck_ffs ln -s $PRG $SBIN/fsck_ufs ln -s $PRG $SBIN/fsck_4.2bsd ln -s $PRG $SBIN/fsck_msdosfs - ln -s $PRG $SBIN/gbde - ln -s $PRG $SBIN/ggatec - ln -s $PRG $SBIN/ggated - ln -s $PRG $SBIN/ggatel + ln -s $PRG $SBIN/etherswitchcfg ln -s $PRG $SBIN/-geom ln -s $PRG $SBIN/glabel ln -s $PRG $SBIN/gpart + ln -s $PRG $SBIN/graid ln -s $PRG $SBIN/growfs ln -s $PRG $SBIN/hastctl ln -s $PRG $SBIN/hastd @@ -299,15 +297,15 @@ install_rootfs() ln -s $PRG $SBIN/mount_cd9660 ln -s $PRG $SBIN/mount_msdosfs ln -s $PRG $SBIN/mount_nfs - ln -s $PRG $SBIN/mount_ntfs +# ln -s $PRG $SBIN/mount_ntfs ln -s $PRG $SBIN/mount_nullfs ln -s $PRG $SBIN/mount_udf ln -s $PRG $SBIN/mount_unionfs - ln -s $PRG $SBIN/natd ln -s $PRG $SBIN/newfs ln -s $PRG $SBIN/newfs_msdos ln -s $PRG $SBIN/nfsiod ln -s $PRG $SBIN/nos-tun + ln -s $PRG $SBIN/nvmecontrol ln -s $PRG $SBIN/pfctl ln -s $PRG $SBIN/pflogd ln -s $PRG $SBIN/quotacheck @@ -320,9 +318,8 @@ install_rootfs() ln -s $PRG $SBIN/rrestore ln -s $PRG $SBIN/route ln -s $PRG $SBIN/rtsol + ln -s $PRG $SBIN/shutdown ln -s $PRG $SBIN/savecore - ln -s $PRG $SBIN/setkey - ln -s $PRG $SBIN/spppcontrol ln -s $PRG $SBIN/swapon ln -s $PRG $SBIN/swapoff ln -s $PRG $SBIN/swapctl @@ -332,10 +329,10 @@ install_rootfs() ln -s $PRG $SBIN/zfs ln -s $PRG $SBIN/zpool - ln $PRG $SBIN/traceroute - chmod u+s $SBIN/traceroute - ln $PRG $SBIN/traceroute6 - chmod u+s $SBIN/traceroute6 + ln -s $PRG $SBIN/ping + ln -s $PRG $SBIN/ping6 + ln -s $PRG $SBIN/traceroute + ln -s $PRG $SBIN/traceroute6 ln -s $PRG $SBIN/chown ln -s $PRG $SBIN/pwd_mkdb @@ -347,14 +344,11 @@ install_rootfs() ln -s $PRG $SBIN/wpa_cli ln -s $PRG $SBIN/wpa_passphrase ln -s $PRG $SBIN/wake - ln -s $PRG $SBIN/sshd ln -s $PRG $SBIN/watchdog ln -s $PRG $SBIN/watchdogd ln -s $PRG $SBIN/inetd ln -s $PRG $SBIN/wlandebug - ln -s $PRG $SBIN/tcpdump ln -s $PRG $SBIN/chroot - ln -s $PRG $SBIN/cron ln -s $PRG $SBIN/i2c ln -s $PRG $SBIN/iostat ln -s $PRG $SBIN/jail @@ -363,7 +357,6 @@ install_rootfs() ln -s $PRG $SBIN/ndp ln -s $PRG $SBIN/newsyslog ln -s $PRG $SBIN/nologin - ln -s $PRG $SBIN/ntpdate ln -s $PRG $SBIN/pstat ln -s $PRG $SBIN/rtadvctl ln -s $PRG $SBIN/rtadvd @@ -373,18 +366,20 @@ install_rootfs() ln -s $PRG $SBIN/swapinfo ln -s $PRG $SBIN/chgrp + ln -s $PRG $UBIN/login + ln -s $PRG $UBIN/passwd - ln $PRG $SBIN/getty + ln -s $PRG $LIBEXEC/getty + ln -s $PRG $LIBEXEC/tftpd - ln -s $PRG $SBIN/tftpd - ln -s $PRG $SBIN/sftp-server + strip -s $LNPRG chown -hR root:wheel $ROOTFS - chgrp kmem $BIN/netstat echo "+++ ELWIX clean CVS tags ..." CleanCVS $ETC CleanCVS $ETC/etc + echo } build_image() @@ -396,32 +391,32 @@ build_image() install_image() { echo "+++ Install ELWIX RootFS Image into kernel ..." - START=`strings -td $KERNEL | grep "MFS Filesystem" | cut -d ' ' -f 1 | head -1` - STOP=`strings -td $KERNEL | grep "MFS Filesystem" | cut -d ' ' -f 1 | tail -1` + START=`strings -td $KERNEL_ROOTFS | grep "MFS Filesystem" | cut -d ' ' -f 1 | head -1` + STOP=`strings -td $KERNEL_ROOTFS | grep "MFS Filesystem" | cut -d ' ' -f 1 | tail -1` STOP=$(($STOP + 1)) - head -c $START $KERNEL >$NEWKERN + head -c $START $KERNEL_ROOTFS >$NEWKERN cat $REL/$ROOTFS_IMG >>$NEWKERN - tail -c +$STOP $KERNEL >>$NEWKERN + tail -c +$STOP $KERNEL_ROOTFS >>$NEWKERN cd $REL - gzip -9 kernel + gzip -9 $KRNNAME cd - } ### main() if SnitVer ${WORLD}/elwix.ver; then clean_elwix - prepare_elwix - build_elwix + prepare_elwix || exit 1 + build_elwix || exit 1 - build_rootdir - install_rootfs + build_rootdir || exit 1 + install_rootfs || exit 1 - build_image - install_image + build_image || exit 1 + install_image || exit 1 else - echo "Skipped ELWIX RootFS build ..." + echo "$? Skipped ELWIX RootFS build ..." fi echo "+++ Complete build ELWIX RootFS"