File:  [ELWIX - Embedded LightWeight unIX -] / elwix / build_fs.sh
Revision 1.12: download - view: text, annotated - select for diffs - revision graph
Thu Mar 11 13:59:50 2021 UTC (3 years, 2 months ago) by misho
Branches: MAIN
CVS tags: elwix2_8, elwix2_7, HEAD, ELWIX2_7, ELWIX2_6
ver 2.6

    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.12 2021/03/11 13:59:50 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: # etc
   54: 	install -d etc;
   55: # exports
   56: 	install -d exports;
   57: # home
   58: 	install -d home;
   59: # local
   60: 	install -d local;
   61: 	install -d local/lib;
   62: # root
   63: 	install -d -m 0750 root;
   64: # pkg
   65: 	install -d pkg;
   66: # tftpboot
   67: 	install -d tftpboot;
   68: 
   69: 	chown -hR root:wheel .
   70: 	cd -
   71: }
   72: 
   73: create_etc_fstab()
   74: {
   75: 	cat >$1/etc/fstab <<_EOF
   76: # Automatic generated fstab for ELWIX $2 at ${BUILD_DATE}
   77: #
   78: _EOF
   79: }
   80: 
   81: update_etc_cfexec()
   82: {
   83: 	echo "mount = \"/elwix\"" >> $1/etc/cfexec.conf
   84: }
   85: 
   86: install_fsdir()
   87: {
   88: 	echo "+++ Install ELWIX RootFS $1 in bundle OS install file ..."
   89: 	OSZ=""
   90: 
   91: 	install -v ${REL}/${ROOTFS_KERN} $1/boot/kernel/kernel.gz
   92: 
   93: 	case "$2" in
   94: 		[Ee][Xx][Tt])
   95: 			install -d $1/usr
   96: 			cd $1/usr
   97: 			pax -r -z -pe -f ${REL}/${ROMFS_IMG}
   98: 			cd -
   99: 
  100: 			install -d $1/pkg
  101: 			cd $1/pkg
  102: 			pax -r -z -pe -f ${REL}/${ROMFS_IMG2}
  103: 			cd -
  104: 
  105: 			OSZ=${REL}/${OS_EXT}
  106: 			;;
  107: 		*)
  108: 			install -v ${REL}/${ROMFS_IMG} \
  109: 				$1/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH}
  110: 			ln $1/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} \
  111: 				$1/altroot/${ROMFS_IMG}
  112: 			ln -s /elwix/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} \
  113: 				$1/${ROMFS_IMG}
  114: 
  115: 			install -v ${REL}/${ROMFS_IMG2} \
  116: 				$1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH}
  117: 			ln $1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \
  118: 				$1/altroot/${ROMFS_IMG2}
  119: 			ln -s /elwix/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \
  120: 				$1/${ROMFS_IMG2}
  121: 
  122: 			OSZ=${REL}/${OS}
  123: 			;;
  124: 	esac
  125: 
  126: 	cd $1
  127: 	tar -czvf $OSZ .
  128: 
  129: 	echo "+++ Completed ELWIX RootFS $1 --> $OSZ"
  130: }
  131: 
  132: ### main()
  133: if [ ! -r ${REL}/${ROOTFS_KERN} -o ! -r ${REL}/${ROMFS_IMG} ]; then
  134: 	echo
  135: 	echo "Error:: not found kernel or firmware elwix files ..."
  136: 	echo
  137: 	echo " For fix this issue, please re-run build_rootfs.sh or build_romfs.sh"
  138: 	echo
  139: 	exit 1
  140: fi
  141: 
  142: clean_fsdir ${FS} ${REL}/${OS} || exit 1
  143: clean_fsdir ${FS_EXT} ${REL}/${OS_EXT} || exit 1
  144: 
  145: build_fsdir ${FS} || exit 1
  146: build_fsdir ${FS_EXT} || exit 1
  147: 
  148: MakeFS_home ${FS} || exit 1
  149: MakeFS_home ${FS_EXT} || exit 1
  150: 
  151: MakeFS_var ${FS} ${FS_ETC} || exit 1
  152: MakeFS_var ${FS_EXT} ${FS_EXT_ETC} || exit 1
  153: 
  154: MakeFS_etc ${FS} ${FS_ETC} rootfs || exit 1
  155: MakeFS_etc ${FS_EXT} ${FS_EXT_ETC} rootfsext || exit 1
  156: 
  157: create_etc_fstab ${FS} || exit 1
  158: create_etc_fstab ${FS_EXT} ext || exit 1
  159: 
  160: update_etc_cfexec ${FS} || exit 1
  161: update_etc_cfexec ${FS_EXT} ext || exit 1
  162: 
  163: MakeFS_boot ${FS} || exit 1
  164: MakeFS_boot ${FS_EXT} || exit 1
  165: 
  166: install_fsdir ${FS} || exit 1
  167: install_fsdir ${FS_EXT} ext || exit 1
  168: 
  169: echo "+++ Complete build ELWIX RootFS system"
  170: echo "ELWIX RootFS finish version ${VERSION}, Good luck!"

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