File:  [ELWIX - Embedded LightWeight unIX -] / elwix / build_fs.sh
Revision 1.11.2.4: download - view: text, annotated - select for diffs - revision graph
Mon Jun 19 21:12:57 2017 UTC (6 years, 11 months ago) by misho
Branches: elwix2_6
Diff to: branchpoint 1.11: preferred, unified
almost finish rootfs images

    1: #!/bin/sh
    2: #
    3: # ELWIX Build script for ELWIX CompactFlash image
    4: #
    5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
    6: #    by Michael Pounov <misho@elwix.org>
    7: #
    8: # $Id: build_fs.sh,v 1.11.2.4 2017/06/19 21:12:57 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 - FS must build under root !?!"
   29: 	echo
   30: 	exit 1
   31: fi
   32: 
   33: clean_fsdir()
   34: {
   35: 	echo "+++ Clean ELWIX FS ... $1"
   36: 	chflags -Rf nosunlink $1
   37: 	rm -rf $1 $2
   38: }
   39: 
   40: build_fsdir()
   41: {
   42: 	#
   43: 	# Structure of ELWIX CF Drive mount on /elwix
   44: 	#
   45: 	echo "+++ Build ELWIX FS directory ... $1"
   46: 	mkdir -p $1
   47: 
   48: 	cd $1
   49: # boot
   50: 	install -d boot;
   51: # cf
   52: 	install -d cf;
   53: 	case ${TARGET} in
   54: 		i386)
   55: 			ln -fs /dev/ada0g cf/map.cfg
   56: 			;;
   57: 		mips)
   58: 			ln -fs /dev/map/cfg cf/map.cfg
   59: 			;;
   60: 	esac
   61: # etc
   62: 	install -d etc;
   63: # exports
   64: 	install -d exports;
   65: # home
   66: 	install -d home;
   67: # local
   68: 	install -d local;
   69: # root
   70: 	install -d -m 0750 root;
   71: # pkg
   72: 	install -d pkg;
   73: # tftpboot
   74: 	install -d tftpboot;
   75: 
   76: 	chown -hR root:wheel .
   77: 	cd -
   78: }
   79: 
   80: create_etc_fstab()
   81: {
   82: 	cat >$1/etc/fstab <<_EOF
   83: # Automatic generated fstab for ELWIX $2 at ${BUILD_DATE}
   84: #
   85: /dev/ufs/elwix		/elwix	ufs	ro			0	1
   86: _EOF
   87: }
   88: 
   89: update_etc_cfexec()
   90: {
   91: 	echo "mount = \"/elwix\"" >> $1/etc/cfexec.conf
   92: }
   93: 
   94: install_fsdir()
   95: {
   96: 	echo "+++ Install ELWIX RootFS $1 in bundle OS install file ..."
   97: 	OSZ=""
   98: 
   99: 	install -v ${REL}/${ROOTFS_KERN} $1/boot/kernel/kernel.gz
  100: 
  101: 	case "$2" in
  102: 		[Ee][Xx][Tt])
  103: 			install -d $1/usr
  104: 			cd $1/usr
  105: 			pax -r -z -pe -f ${REL}/${ROMFS_IMG}
  106: 			cd -
  107: 
  108: 			install -d $1/pkg
  109: 			cd $1/pkg
  110: 			pax -r -z -pe -f ${REL}/${ROMFS_IMG2}
  111: 			cd -
  112: 
  113: 			OSZ=${REL}/${OS_EXT}
  114: 			;;
  115: 		*)
  116: 			install -v ${REL}/${ROMFS_IMG} \
  117: 				$1/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH}
  118: 			ln $1/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} \
  119: 				$1/altroot/${ROMFS_IMG}
  120: 			ln -s /elwix/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} \
  121: 				$1/${ROMFS_IMG}
  122: 
  123: 			install -v ${REL}/${ROMFS_IMG2} \
  124: 				$1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH}
  125: 			ln $1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \
  126: 				$1/altroot/${ROMFS_IMG2}
  127: 			ln -s /elwix/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \
  128: 				$1/${ROMFS_IMG2}
  129: 
  130: 			OSZ=${REL}/${OS}
  131: 			;;
  132: 	esac
  133: 
  134: 	cd $1
  135: 	tar -czvf $OSZ .
  136: 
  137: 	echo "+++ Completed ELWIX RootFS $1 --> $OSZ"
  138: }
  139: 
  140: ### main()
  141: if [ ! -r ${REL}/${ROOTFS_KERN} -o ! -r ${REL}/${ROMFS_IMG} ]; then
  142: 	echo
  143: 	echo "Error:: not found kernel or firmware elwix files ..."
  144: 	echo
  145: 	echo " For fix this issue, please re-run build_rootfs.sh or build_romfs.sh"
  146: 	echo
  147: 	exit 1
  148: fi
  149: 
  150: clean_fsdir ${FS} ${REL}/${OS} || exit 1
  151: clean_fsdir ${FS_EXT} ${REL}/${OS_EXT} || exit 1
  152: 
  153: build_fsdir ${FS} || exit 1
  154: build_fsdir ${FS_EXT} || exit 1
  155: 
  156: MakeFS_home ${FS} || exit 1
  157: MakeFS_home ${FS_EXT} || exit 1
  158: 
  159: MakeFS_var ${FS} ${FS_ETC} || exit 1
  160: MakeFS_var ${FS_EXT} ${FS_EXT_ETC} || exit 1
  161: 
  162: MakeFS_etc ${FS} ${FS_ETC} || exit 1
  163: MakeFS_etc ${FS_EXT} ${FS_EXT_ETC} ext || exit 1
  164: 
  165: create_etc_fstab ${FS} || exit 1
  166: create_etc_fstab ${FS_EXT} ext || exit 1
  167: 
  168: update_etc_cfexec ${FS} || exit 1
  169: update_etc_cfexec ${FS_EXT} ext || exit 1
  170: 
  171: MakeFS_boot ${FS} || exit 1
  172: MakeFS_boot ${FS_EXT} || exit 1
  173: 
  174: install_fsdir ${FS} || exit 1
  175: install_fsdir ${FS_EXT} ext || exit 1
  176: 
  177: echo "+++ Complete build ELWIX RootFS system"
  178: echo "ELWIX RootFS finish version ${VERSION}, Good luck!"

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