File:  [ELWIX - Embedded LightWeight unIX -] / elwix / build_rootfs.sh
Revision 1.2.4.3: download - view: text, annotated - select for diffs - revision graph
Thu Feb 9 01:36:21 2012 UTC (12 years, 4 months ago) by misho
Branches: elwix1_6
Diff to: branchpoint 1.2: preferred, unified
changed getty to new location

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

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