File:  [ELWIX - Embedded LightWeight unIX -] / elwix / build_base.sh
Revision 1.4.2.5: download - view: text, annotated - select for diffs - revision graph
Thu Jun 15 23:09:44 2017 UTC (7 years, 4 months ago) by misho
Branches: elwix2_6
Diff to: branchpoint 1.4: preferred, unified
change /tmp

    1: #!/bin/sh
    2: #
    3: # ELWIX Build script for ELWIX raw BaseFS firmware
    4: #
    5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
    6: #    by Michael Pounov <misho@elwix.org>
    7: #
    8: # $Id: build_base.sh,v 1.4.2.5 2017/06/15 23:09:44 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 - BaseFS must build under root !?!"
   29: 	echo
   30: 	exit 1
   31: fi
   32: 
   33: clean_basefs()
   34: {
   35: 	echo "+++ Clean ELWIX BaseFS firmware ... $BASEFS"
   36: 	chflags -Rf noschg,nosunlink $BASEFS $BASE_FS
   37: 	rm -rf $BASEFS $BASE_FS ${REL}/${BASE_OS} ${REL}/kernel.gz
   38: }
   39: 
   40: build_basefs()
   41: {
   42: 	echo "+++ Build ELWIX BaseFS directory ... $BASEFS"
   43: 	mkdir -p $BASEFS
   44: 
   45: 	cd $BASEFS
   46: 
   47: 	install -d bin;
   48: 	install -d boot;
   49: 	install -d boot/defaults;
   50: 	install -d boot/firmware;
   51: 	install -d boot/kernel;
   52: 	install -d boot/modules;
   53: 	install -d boot/zfs;
   54: 	install -d dev;
   55: 	install -d elwix;
   56: 	install -d elwix/altroot;
   57: 	install -d elwix/altroot/var;
   58: 	install -d elwix/cf;
   59: 	case ${TARGET} in
   60: 		i386)
   61: 			ln -fs /dev/ada0g elwix/cf/map.cfg
   62: 			;;
   63: 		mips)
   64: 			ln -fs /dev/map/cfg elwix/cf/map.cfg
   65: 			;;
   66: 	esac
   67: 	install -d elwix/etc;
   68: 	install -d -o 883 -g 883 elwix/etc/mqtt;
   69: 	install -d elwix/exports;
   70: 	install -d elwix/home;
   71: 	install -d -m 0750 elwix/root;
   72: 	install -d -m 0750 elwix/root/.ssh;
   73: 	install -d elwix/tftpboot;
   74: 	install -d elwix/pkg;
   75: 	install -d elwix/local;
   76: 	ln -fs /elwix/etc etc;
   77: 	ln -fs /elwix/exports exports;
   78: 	ln -fs /elwix/home home;
   79: 	ln -fs /elwix/root root;
   80: 	ln -fs /elwix/tftpboot tftpboot;
   81: 	install -d mnt;
   82: 	install -d -m 0555 proc;
   83: 	install -d sbin;
   84: 	install -d tmp;
   85: 	install -d usr;
   86: 	install -d usr/bin;
   87: 	install -d usr/lib;
   88: 	ln -fs /usr/lib lib;
   89: 	install -d usr/lib/engines;
   90: 	install -d usr/lib/geom;
   91: 	case ${TARGET} in
   92: 		amd64)
   93: 			install -d usr/lib32;
   94: 			;;
   95: 		*)
   96: 			;;
   97: 	esac
   98: 	install -d usr/libdata;
   99: 	install -d usr/libexec;
  100: 	ln -fs /usr/libexec libexec;
  101: 	ln -fs /elwix/local usr/local;
  102: 	ln -fs /elwix/pkg usr/pkg;
  103: 	install -d usr/sbin;
  104: 	install -d usr/share;
  105: 	install -d usr/share/misc;
  106: 	install -d usr/share/skel;
  107: 	install -d usr/share/zoneinfo;
  108: 	install -d var;
  109: 
  110: 	chown -hR root:wheel .
  111: 	cd -
  112: }
  113: 
  114: install_basefs()
  115: {
  116: 	LIBS="${BASEFS}/usr/lib"
  117: 	LIBEXEC="${BASEFS}/usr/libexec"
  118: 	LIBDATA="${BASEFS}/usr/libdata"
  119: 	BIN="${BASEFS}/bin"
  120: 	UBIN="${BASEFS}/usr/bin"
  121: 	SBIN="${BASEFS}/sbin"
  122: 	USBIN="${BASEFS}/usr/sbin"
  123: 	SHARE="${BASEFS}/usr/share"
  124: 	SKEL="${SHARE}/skel"
  125: 	MISC="${SHARE}/misc"
  126: 
  127: 	echo "+++ Install ELWIX BaseFS software ... $BASEFS"
  128: 	if [ -r ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap ]; then
  129: 		install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap $MISC;
  130: 		install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/services $MISC;
  131: 	else
  132: 		install -v -m 644 ${BSDSRC}/etc/termcap.small $MISC/termcap;
  133: 		install -v -m 644 ${BSDSRC}/etc/services $MISC;
  134: 	fi
  135: 
  136: 	install -v ${CFGDIR}/root.skel/cshrc $SKEL/dot.cshrc;
  137: 	install -v ${CFGDIR}/root.skel/login $SKEL/dot.login;
  138: 	install -v ${CFGDIR}/root.skel/logout $SKEL/dot.logout;
  139: 	install -v ${CFGDIR}/root.skel/profile $SKEL/dot.profile;
  140: 	install -v ${CFGDIR}/root.skel/vimrc $SKEL/dot.vimrc;
  141: 
  142: 	find ${WORLD}/libexec -type f -name ld-elf.so\* -exec install {} $LIBEXEC \;
  143: 
  144: 	find ${WORLD}/lib -type f -name \*.so.\* ! -name \*.debug -exec install {} $LIBS \;
  145: 	find ${WORLD}/lib -type f -name libalias_\*.so -exec install {} $LIBS \;
  146: 	find ${WORLD}/lib/geom -type f -name \*.so -exec install {} $LIBS/geom \;
  147: 	find ${WORLD}/usr/lib -type f -name \*.so.\* ! -name \*.debug -exec install {} $LIBS \;
  148: 	find ${WORLD}/usr/lib/engines -type f -name \*.so -exec install {} $LIBS/engines \;
  149: 
  150: 	InstallList ${ELWIX_BASEFS} ${WORLD} ${BASEFS}
  151: 
  152: 	ln ${BIN}/tcsh ${UBIN}/tcsh
  153: 
  154: 	InstallDir ${WORLD}/usr/local/bin $UBIN
  155: 	InstallDir ${WORLD}/usr/local/sbin $USBIN
  156: 	InstallFiles \*.so\* ${WORLD}/usr/local/lib $LIBS
  157: 	InstallDir ${WORLD}/usr/local/libdata $LIBDATA
  158: 
  159: 	chown -R root:wheel $SBIN $BIN $USBIN $UBIN $LIBDATA $LIBEXEC $LIBS
  160: 
  161: 	echo "+++ Completed ELWIX BaseFS software ... $BASEFS"
  162: }
  163: 
  164: prepare_fs()
  165: {
  166: 	echo "+++ Prepare ELWIX fs ... $BASEFS --> $1"
  167: 	mkdir -p $1
  168: 
  169: 	if [ -d ${BASEFS} ]; then
  170: 		cd ${BASEFS}
  171: 		pax -rw -pe -X . $1
  172: 		cd -
  173: 	fi
  174: }
  175: 
  176: create_etc_fstab()
  177: {
  178: 	cat >$1/etc/fstab <<_EOF
  179: # Automatic generated fstab for ELWIX $2 at ${BUILD_DATE}
  180: #
  181: /dev/ufs/elwix		/	ufs	ro			0	1
  182: tmpfs			/tmp	tmpfs	rw			0	0
  183: md2			/var	mfs	rw,-s16m,-S,-n		0       0
  184: _EOF
  185: }
  186: 
  187: update_etc_cfexec()
  188: {
  189: 	echo "mount = \"/\"" >> $1/etc/cfexec.conf
  190: }
  191: 
  192: install_fs()
  193: {
  194: 	echo "+++ Install ELWIX BaseFS $1 in bundle OS install file ..."
  195: 	OSZ=""
  196: 
  197: 	install -v ${KERNEL} $1/boot/kernel;
  198: 	cd $1/boot/kernel;
  199: 	gzip -9 kernel;
  200: 	cp kernel.gz ${REL}
  201: 	cd -;
  202: 	echo "+++ Released native ELWIX kernel ... ${REL}/kernel.gz"
  203: 
  204: 	case "$2" in
  205: 		*)
  206: 			OSZ=${REL}/${BASE_OS}
  207: 			;;
  208: 	esac
  209: 
  210: 	cd $1
  211: 	tar -czvf $OSZ .
  212: 	echo "+++ Completed ELWIX BaseFS $1 --> $OSZ"
  213: }
  214: 
  215: ### main()
  216: clean_basefs
  217: build_basefs
  218: 
  219: install_basefs
  220: 
  221: # build fs
  222: prepare_fs ${BASE_FS}
  223: MakeFS_home ${BASE_FS}/elwix
  224: MakeFS_var ${BASE_FS}/elwix ${BASE_ETC}
  225: MakeFS_etc ${BASE_FS}/elwix ${BASE_ETC} base
  226: create_etc_fstab ${BASE_FS}/elwix base
  227: update_etc_cfexec ${BASE_FS}/elwix
  228: MakeFS_backup ${BASE_FS}/elwix
  229: MakeFS_boot ${BASE_FS}
  230: install_fs ${BASE_FS}
  231: 
  232: echo "+++ Complete build ELWIX BaseFS system"
  233: echo "ELWIX BaseFS finish version ${VERSION}, Good luck!"

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