File:  [ELWIX - Embedded LightWeight unIX -] / elwix / build_rootfs.sh
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Mon Jan 28 01:47:34 2013 UTC (11 years, 4 months ago) by misho
Branches: MAIN
CVS tags: elwix1_8, HEAD
ELWIX 1.7

    1: #!/bin/sh
    2: #
    3: # ELWIX build script for rootfs firmware
    4: #
    5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
    6: #    by Michael Pounov <misho@elwix.org>
    7: #
    8: # $Id: build_rootfs.sh,v 1.4 2013/01/28 01:47:34 misho Exp $
    9: #
   10: 
   11: [ -r ./config/rc.elwix ] && . ./config/rc.elwix
   12: if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then
   13: 	echo
   14: 	echo "ELWIX project is not configured !?!"
   15: 	echo
   16: 	exit 1
   17: fi
   18: 
   19: if [ ! -d ${BSDSRC} ]; then
   20: 	echo
   21: 	echo "ELWIX project is not configured - missing BSD sources !?!"
   22: 	echo
   23: 	exit 1
   24: fi
   25: 
   26: if [ "${USER}" != "root" ]; then
   27: 	echo
   28: 	echo "ELWIX project is not configured - RootFS must build under root !?!"
   29: 	echo
   30: 	exit 1
   31: fi
   32: 
   33: NEWKERN="${REL}/kernel"
   34: 
   35: clean_elwix()
   36: {
   37: 	echo "+++ Clean elwix binary from ELWIX World ..."
   38: 	rm -rf $BSDOBJ/elwix
   39: 
   40: 	echo "+++ Clean ELWIX RootFS firmware ..."
   41: 	rm -rf $MKDIR
   42: 	mkdir $MKDIR
   43: 
   44: 	echo "+++ Clean RootFS directory ..."
   45: 	chflags -R noschg $ROOTFS
   46: 	rm -rf $ROOTFS
   47: 	mkdir $ROOTFS
   48: 
   49: 	echo "+++ Clean Release directory ..."
   50: 	rm -rf $REL/$ROOTFS_IMG ${NEWKERN}*
   51: }
   52: 
   53: prepare_elwix()
   54: {
   55: 	echo "+++ Prepair ELWIX RootFS firmware ..."
   56: 	cd $MKDIR
   57: 	cat >$MKH <<_EOF
   58: # Auto-generated Makefile include for crungegen
   59: # !!! Dont edit by hand !!!
   60: #
   61: 
   62: LIBS += -L${WORLD}/lib -L${WORLD}/usr/lib
   63: _EOF
   64: 	cat >$ROOTFS_CONF <<_EOF
   65: srcdirs ${BSDSRC}/tools/tools ${BSDSRC}/tools/tools/ath
   66: srcdirs ${BSDSRC}/release/picobsd/tinyware
   67: srcdirs ${BSDSRC}/bin ${BSDSRC}/sbin ${BSDSRC}/libexec ${BSDSRC}/cddl/sbin ${BSDSRC}/sbin/ggate
   68: srcdirs ${BSDSRC}/usr.bin ${BSDSRC}/usr.sbin ${BSDSRC}/usr.sbin/wpa
   69: srcdirs ${BSDSRC}/secure/usr.bin ${BSDSRC}/secure/usr.sbin ${BSDSRC}/secure/libexec
   70: 
   71: buildopts -DNO_PAM -DNO_KERBEROS WITHOUT_PAM_SUPPORT=yes WITHOUT_KERBEROS_SUPPORT=yes WITHOUT_KERBEROS=yes
   72: buildopts TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} MAKEOBJDIRPREFIX=${BSDOBJ}/elwix
   73: _EOF
   74: 	cat $CFGDIR/$ROOTFS_CONF >>$ROOTFS_CONF
   75: 
   76: 	. ${CENV}
   77: 	install -d ${BSDOBJ}/elwix
   78: 	crunchgen -f -o -p ${BSDOBJ}/elwix -h $MKDIR/$MKH -m $MKF -c elwix.c -e elwix $ROOTFS_CONF
   79: 	cd -
   80: }
   81: 
   82: build_elwix()
   83: {
   84: 	echo "+++ Build ELWIX RootFS firmware ..."
   85: 	cd $MKDIR
   86: 	. ${CENV}
   87: 	MAKEOBJDIRPREFIX=${BSDOBJ}/elwix
   88: 	make -f $MKF clean
   89: 	make -f $MKF
   90: 	if [ $? -ne 0 ]; then
   91: 		exit 1
   92: 	fi
   93: 	cd -
   94: }
   95: 
   96: build_rootdir()
   97: {
   98: 	echo "+++ Build RootFS directory ..."
   99: 	cd $ROOTFS
  100: 
  101: 	install -d bin;
  102: 	install -d dev;
  103: 	install -d elwix;
  104: 	install -d elwix/etc;
  105: 	install -d libexec;
  106: 	install -d mnt;
  107: 	install -d -m 0555 proc;
  108: 	install -d sbin;
  109: 	install -d -m 1777 tmp;
  110: 	install -d usr;
  111: 	install -d usr/bin;
  112: 	install -d usr/lib;
  113: 	install -d usr/libexec;
  114: 	install -d usr/sbin;
  115: 	install -d var;
  116: 	install -d var/sys;
  117: 
  118: 	ln -fs /usr/lib lib;
  119: 
  120: 	ln -fs /elwix/etc etc;
  121: 	ln -fs /elwix/exports exports;
  122: 	ln -fs /elwix/home home;
  123: 	ln -fs /elwix/root root;
  124: 	ln -fs /elwix/tftpboot tftpboot;
  125: 
  126: 	cd -
  127: }
  128: 
  129: install_rootfs()
  130: {
  131: 	BIN="${ROOTFS}/bin"
  132: 	SBIN="${ROOTFS}/sbin"
  133: 	UBIN="${ROOTFS}/usr/bin"
  134: 	LIBEXEC="${ROOTFS}/usr/libexec"
  135: 	ETC="${ROOTFS}/elwix/etc"
  136: 
  137: 	PRG="/sbin/elwix"
  138: 	LNPRG="${SBIN}/elwix"
  139: 
  140: 	echo "+++ Install ELWIX into RootFS directory ..."
  141: 	install $MKDIR/elwix $SBIN
  142: 
  143: 	InstallList ${ELWIX_ROOTFS} ${WORLD} ${ROOTFS}
  144: 
  145: 	InstallDir ${ROOTFS_ETC} $ETC
  146: 
  147: #	ln -s /usr/sbin/nologin $SBIN
  148: 
  149: 	ln -s $PRG $BIN/test
  150: 	ln -s $PRG $BIN/\[
  151: 	ln -s $PRG $BIN/cat
  152: 	ln -s $PRG $BIN/chflags
  153: 	ln -s $PRG $BIN/chio
  154: 	ln -s $PRG $BIN/chmod
  155: 	ln -s $PRG $BIN/cp
  156: 	ln -s $PRG $BIN/date
  157: 	ln -s $PRG $BIN/dd
  158: 	ln -s $PRG $BIN/df
  159: 	ln -s $PRG $BIN/domainname
  160: 	ln -s $PRG $BIN/echo
  161: 	ln -s $PRG $BIN/expr
  162: 	ln -s $PRG $BIN/hostname
  163: 	ln -s $PRG $BIN/kenv
  164: 	ln -s $PRG $BIN/kill
  165: 	ln -s $PRG $BIN/ln
  166: 	ln -s $PRG $BIN/link
  167: 	ln -s $PRG $BIN/ls
  168: 	ln -s $PRG $BIN/mkdir
  169: 	ln -s $PRG $BIN/mv
  170: 	ln -s $PRG $BIN/pax
  171: 	ln -s $PRG $BIN/pkill
  172: 	ln -s $PRG $BIN/pgrep
  173: 	ln -s $PRG $BIN/sh
  174: 	ln -s $PRG $BIN/-sh
  175: 	ln -s $PRG $BIN/ps
  176: 	ln -s $PRG $BIN/pwait
  177: 	ln -s $PRG $BIN/pwd
  178: 	ln -s $PRG $BIN/realpath
  179: 	ln -s $PRG $BIN/rm
  180: 	ln -s $PRG $BIN/unlink
  181: 	ln -s $PRG $BIN/rmdir
  182: 	ln -s $PRG $BIN/sleep
  183: 	ln -s $PRG $BIN/stty
  184: 	ln -s $PRG $BIN/sync
  185: 	ln -s $PRG $BIN/uuidgen
  186: 
  187: 	ln -s $PRG $BIN/true
  188: 	ln -s $PRG $BIN/false
  189: 	ln -s $PRG $BIN/basename
  190: 	ln -s $PRG $BIN/tail
  191: 	ln -s $PRG $BIN/nc
  192: 	ln -s $PRG $BIN/w
  193: 	ln -s $PRG $BIN/head
  194: 	ln -s $PRG $BIN/uname
  195: 	ln -s $PRG $BIN/tset
  196: 	ln -s $PRG $BIN/vmstat
  197: 	ln -s $PRG $BIN/systat
  198: 	ln -s $PRG $BIN/tput
  199: 	ln -s $PRG $BIN/grep
  200: 	ln -s $PRG $BIN/awk
  201: 	ln -s $PRG $BIN/less
  202: 	ln -s $PRG $BIN/gzip
  203: 	ln -s $PRG $BIN/cap_mkdb
  204: 	ln -s $PRG $BIN/sed
  205: 	ln -s $PRG $BIN/vi
  206: 	ln -s $PRG $BIN/du
  207: 	ln -s $PRG $BIN/getopt
  208: 	ln -s $PRG $BIN/logger
  209: 	ln -s $PRG $BIN/nice
  210: 	ln -s $PRG $BIN/nohup
  211: 	ln -s $PRG $BIN/seq
  212: 	ln -s $PRG $BIN/sockstat
  213: 	ln -s $PRG $BIN/stat
  214: 	ln -s $PRG $BIN/tee
  215: 	ln -s $PRG $BIN/tftp
  216: 	ln -s $PRG $BIN/touch
  217: 	ln -s $PRG $BIN/wc
  218: 	ln -s $PRG $BIN/xargs
  219: 	ln -s $PRG $BIN/printenv
  220: 	ln -s $PRG $BIN/egrep
  221: 	ln -s $PRG $BIN/fgrep
  222: 	ln -s $PRG $BIN/tar
  223: 	ln -s $PRG $BIN/cpio
  224: 	ln -s $PRG $BIN/nawk
  225: 	ln -s $PRG $BIN/gunzip
  226: 	ln -s $PRG $BIN/gzcat
  227: 	ln -s $PRG $BIN/zcat
  228: 	ln -s $PRG $BIN/more
  229: 	ln -s $PRG $BIN/reset
  230: 	ln -s $PRG $BIN/readlink
  231: 	ln -s $PRG $BIN/uptime
  232: 	ln -s $PRG $BIN/bzip2
  233: 	ln -s $PRG $BIN/bunzip2
  234: 	ln -s $PRG $BIN/bzcat
  235: 
  236: 	ln -s $PRG $SBIN/bsdlabel
  237: 	ln -s $PRG $SBIN/disklabel
  238: 	ln -s $PRG $SBIN/camcontrol
  239: 	ln -s $PRG $SBIN/comcontrol
  240: 	ln -s $PRG $SBIN/conscontrol
  241: 	ln -s $PRG $SBIN/devfs
  242: 	ln -s $PRG $SBIN/dhclient
  243: 	ln -s $PRG $SBIN/dmesg
  244: 	ln -s $PRG $SBIN/dump
  245: 	ln -s $PRG $SBIN/rdump
  246: 	ln -s $PRG $SBIN/dumpon
  247: 	ln -s $PRG $SBIN/fdisk
  248: 	ln -s $PRG $SBIN/fsck
  249: 	ln -s $PRG $SBIN/fsck_ffs
  250: 	ln -s $PRG $SBIN/fsck_ufs
  251: 	ln -s $PRG $SBIN/fsck_4.2bsd
  252: 	ln -s $PRG $SBIN/fsck_msdosfs
  253: 	ln -s $PRG $SBIN/etherswitchcfg
  254: 	ln -s $PRG $SBIN/-geom
  255: 	ln -s $PRG $SBIN/glabel
  256: 	ln -s $PRG $SBIN/gpart
  257: 	ln -s $PRG $SBIN/graid
  258: 	ln -s $PRG $SBIN/growfs
  259: 	ln -s $PRG $SBIN/hastctl
  260: 	ln -s $PRG $SBIN/hastd
  261: 	ln -s $PRG $SBIN/ifconfig
  262: 	ln -s $PRG $SBIN/init
  263: 	ln -s $PRG $SBIN/ipfw
  264: 	ln -s $PRG $SBIN/iscontrol
  265: 	ln -s $PRG $SBIN/kldconfig
  266: 	ln -s $PRG $SBIN/kldload
  267: 	ln -s $PRG $SBIN/kldstat
  268: 	ln -s $PRG $SBIN/kldunload
  269: 	ln -s $PRG $SBIN/ldconfig
  270: 	ln -s $PRG $SBIN/md5
  271: 	ln -s $PRG $SBIN/sha1
  272: 	ln -s $PRG $SBIN/sha256
  273: 	ln -s $PRG $SBIN/rmd160
  274: 	ln -s $PRG $SBIN/mdconfig
  275: 	ln -s $PRG $SBIN/mdmfs
  276: 	ln -s $PRG $SBIN/mount_mfs
  277: 	ln -s $PRG $SBIN/mknod
  278: 	ln -s $PRG $SBIN/mksnap_ffs
  279: 	ln -s $PRG $SBIN/mount
  280: 	ln -s $PRG $SBIN/mount_cd9660
  281: 	ln -s $PRG $SBIN/mount_msdosfs
  282: 	ln -s $PRG $SBIN/mount_nfs
  283: #	ln -s $PRG $SBIN/mount_ntfs
  284: 	ln -s $PRG $SBIN/mount_nullfs
  285: 	ln -s $PRG $SBIN/mount_udf
  286: 	ln -s $PRG $SBIN/mount_unionfs
  287: 	ln -s $PRG $SBIN/newfs
  288: 	ln -s $PRG $SBIN/newfs_msdos
  289: 	ln -s $PRG $SBIN/nfsiod
  290: 	ln -s $PRG $SBIN/nos-tun
  291: 	ln -s $PRG $SBIN/nvmecontrol
  292: 	ln -s $PRG $SBIN/pfctl
  293: 	ln -s $PRG $SBIN/pflogd
  294: 	ln -s $PRG $SBIN/quotacheck
  295: 	ln -s $PRG $SBIN/reboot
  296: 	ln -s $PRG $SBIN/halt
  297: 	ln -s $PRG $SBIN/fastboot
  298: 	ln -s $PRG $SBIN/fasthalt
  299: 	ln -s $PRG $SBIN/recoverdisk
  300: 	ln -s $PRG $SBIN/restore
  301: 	ln -s $PRG $SBIN/rrestore
  302: 	ln -s $PRG $SBIN/route
  303: 	ln -s $PRG $SBIN/rtsol
  304: 	ln -s $PRG $SBIN/shutdown
  305: 	ln -s $PRG $SBIN/savecore
  306: 	ln -s $PRG $SBIN/swapon
  307: 	ln -s $PRG $SBIN/swapoff
  308: 	ln -s $PRG $SBIN/swapctl
  309: 	ln -s $PRG $SBIN/sysctl
  310: 	ln -s $PRG $SBIN/tunefs
  311: 	ln -s $PRG $SBIN/umount
  312: 	ln -s $PRG $SBIN/zfs
  313: 	ln -s $PRG $SBIN/zpool
  314: 
  315: 	ln -s $PRG $SBIN/ping
  316: 	ln -s $PRG $SBIN/ping6
  317: 	ln -s $PRG $SBIN/traceroute
  318: 	ln -s $PRG $SBIN/traceroute6
  319: 
  320: 	ln -s $PRG $SBIN/chown
  321: 	ln -s $PRG $SBIN/pwd_mkdb
  322: 	ln -s $PRG $SBIN/arp
  323: 	ln -s $PRG $SBIN/gpioctl
  324: 	ln -s $PRG $SBIN/hostapd
  325: 	ln -s $PRG $SBIN/hostapd_cli
  326: 	ln -s $PRG $SBIN/wpa_supplicant
  327: 	ln -s $PRG $SBIN/wpa_cli
  328: 	ln -s $PRG $SBIN/wpa_passphrase
  329: 	ln -s $PRG $SBIN/wake
  330: 	ln -s $PRG $SBIN/watchdog
  331: 	ln -s $PRG $SBIN/watchdogd
  332: 	ln -s $PRG $SBIN/inetd
  333: 	ln -s $PRG $SBIN/wlandebug
  334: 	ln -s $PRG $SBIN/chroot
  335: 	ln -s $PRG $SBIN/i2c
  336: 	ln -s $PRG $SBIN/iostat
  337: 	ln -s $PRG $SBIN/jail
  338: 	ln -s $PRG $SBIN/jexec
  339: 	ln -s $PRG $SBIN/jls
  340: 	ln -s $PRG $SBIN/ndp
  341: 	ln -s $PRG $SBIN/newsyslog
  342: 	ln -s $PRG $SBIN/nologin
  343: 	ln -s $PRG $SBIN/pstat
  344: 	ln -s $PRG $SBIN/rtadvctl
  345: 	ln -s $PRG $SBIN/rtadvd
  346: 	ln -s $PRG $SBIN/rtsold
  347: 	ln -s $PRG $SBIN/syslogd
  348: 	ln -s $PRG $SBIN/setfib
  349: 	ln -s $PRG $SBIN/swapinfo
  350: 	ln -s $PRG $SBIN/chgrp
  351: 
  352: 	ln -s $PRG $UBIN/login
  353: 	ln -s $PRG $UBIN/passwd
  354: 
  355: 	ln -s $PRG $LIBEXEC/getty
  356: 	ln -s $PRG $LIBEXEC/tftpd
  357: 
  358: 	strip -s $LNPRG
  359: 
  360: 	chown -hR root:wheel $ROOTFS
  361: 
  362: 	echo "+++ ELWIX clean CVS tags ..."
  363: 	CleanCVS $ETC
  364: 	CleanCVS $ETC/etc
  365: }
  366: 
  367: build_image()
  368: {
  369: 	echo "+++ Build ELWIX RootFS image ..."
  370: 	makefs -s ${ROOTFS_SIZE} -o minfree=0 $REL/$ROOTFS_IMG $ROOTFS
  371: }
  372: 
  373: install_image()
  374: {
  375: 	echo "+++ Install ELWIX RootFS Image into kernel ..."
  376: 	START=`strings -td $KERNEL | grep "MFS Filesystem" | cut -d ' ' -f 1 | head -1`
  377: 	STOP=`strings -td $KERNEL | grep "MFS Filesystem" | cut -d ' ' -f 1 | tail -1`
  378: 	STOP=$(($STOP + 1))
  379: 
  380: 	head -c $START $KERNEL >$NEWKERN
  381: 	cat $REL/$ROOTFS_IMG >>$NEWKERN
  382: 	tail -c +$STOP $KERNEL >>$NEWKERN
  383: 
  384: 	cd $REL
  385: 	gzip -9 kernel
  386: 	cd -
  387: }
  388: 
  389: ### main()
  390: if SnitVer ${WORLD}/elwix.ver; then
  391: 	clean_elwix
  392: 	prepare_elwix
  393: 	build_elwix
  394: 
  395: 	build_rootdir
  396: 	install_rootfs
  397: 
  398: 	build_image
  399: 	install_image
  400: else
  401: 	echo "Skipped ELWIX RootFS build ..."
  402: fi
  403: 
  404: echo "+++ Complete build ELWIX RootFS"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>