File:  [ELWIX - Embedded LightWeight unIX -] / elwix / build_romfs.sh
Revision 1.11: download - view: text, annotated - select for diffs - revision graph
Fri Jul 16 18:35:50 2021 UTC (3 years, 4 months ago) by misho
Branches: MAIN
CVS tags: elwix2_8, HEAD, ELWIX2_7
ver 2.7

#!/bin/sh
#
# ELWIX Build script for ELWIX userland RomFS firmware
#
# (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
#    by Michael Pounov <misho@elwix.org>
#
# $Id: build_romfs.sh,v 1.11 2021/07/16 18:35:50 misho Exp $
#

[ -r ./config/rc.elwix ] && . ./config/rc.elwix
if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then
	echo
	echo "ELWIX project is not configured !?!"
	echo
	exit 1
fi

if [ ! -d ${BSDSRC} ]; then
	echo
	echo "ELWIX project is not configured - missing BSD sources !?!"
	echo
	exit 1
fi

if [ "${USER}" != "root" ]; then
	echo
	echo "ELWIX project is not configured - RomFS must build under root !?!"
	echo
	exit 1
fi

clean_romfs()
{
	echo "+++ Clean ELWIX RomFS firmware ... $ROMFS"
	chflags -Rf noschg $ROMFS
	rm -rf $ROMFS

	echo "+++ Clean ELWIX RomFS image ..."
	rm -f $REL/$ROMFS_IMG
}

build_romfs()
{
	echo "+++ Build ELWIX RomFS directory ... $ROMFS_USR"
	mkdir -p $ROMFS_USR

	cd $ROMFS_USR

	install -d bin;
	install -d sbin;
	install -d lib;
	install -d lib/geom;
	install -d libdata;
	install -d libexec;
	install -d share;
	install -d share/keys;
	install -d share/misc;
	install -d share/skel;
	install -d share/zoneinfo;

	ln -s /elwix/local local;
	ln -s /elwix/pkg pkg;

	# special patch to ensuring properly working of passwd!!!
	ln -s /sbin/pwd_mkdb sbin;
	# special patch to ensuring properly working of atrun!!!
	ln -s /usr/pkg/sbin/mini_sendmail sbin/sendmail;

	chown -hR root:wheel .
	cd -
}

install_romfs()
{
	LIBS="${ROMFS_USR}/lib"
	LIBEXEC="${ROMFS_USR}/libexec"
	LIBDATA="${ROMFS_USR}/libdata"
	BIN="${ROMFS_USR}/bin"
	SBIN="${ROMFS_USR}/sbin"
	SHARE="${ROMFS_USR}/share"
	SKEL="${SHARE}/skel"
	MISC="${SHARE}/misc"

	echo "+++ Install ELWIX RomFS software ... $ROMFS_USR"
	if [ -r files/etc/termcap ]; then
		install -v -m 644 files/etc/termcap $MISC;
		install -v -m 644 files/etc/services $MISC;
	else
		install -v -m 644 ${BSDSRC}/etc/termcap.small $MISC/termcap;
		install -v -m 644 ${BSDSRC}/etc/services $MISC;
	fi

	install -v ${CFGDIR}/root.skel/cshrc $SKEL/dot.cshrc;
	install -v ${CFGDIR}/root.skel/login $SKEL/dot.login;
	install -v ${CFGDIR}/root.skel/logout $SKEL/dot.logout;
	install -v ${CFGDIR}/root.skel/profile $SKEL/dot.profile;
	install -v ${CFGDIR}/root.skel/vimrc $SKEL/dot.vimrc;

	find ${WORLD}/lib -type f -name \*.so.\* ! -name \*.debug -exec install {} $LIBS \;
	find ${WORLD}/lib -type f -name libalias_\*.so -exec install {} $LIBS \;
	find ${WORLD}/lib/geom -type f -name \*.so -exec install {} $LIBS/geom \;
	find ${WORLD}/usr/lib -type f -name \*.so.\* ! -name \*.debug -exec install {} $LIBS \;
	find ${WORLD}/usr/lib/engines -type f -name \*.so -exec install {} $LIBS/engines \;

	InstallList ${ELWIX_ROMFS} ${WORLD} ${ROMFS}

	InstallDir ${WORLD}/usr/local/bin $BIN
	InstallDir ${WORLD}/usr/local/sbin $SBIN
	InstallDir ${WORLD}/usr/local/lib $LIBS
	InstallDir ${WORLD}/usr/local/libdata $LIBDATA

	chown -R root:wheel $SBIN $BIN $LIBDATA $LIBEXEC $LIBS
	echo "+++ Completed ELWIX RomFS software ... $ROMFS_USR"
}

build_image()
{
	echo "+++ Build ELWIX Firmware system image ... $ROMFS_USR --> ${REL}/${ROMFS_IMG}"

	cd ${ROMFS_USR}
	pax -w -z -v -f${REL}/${ROMFS_IMG} .
	cd -

# Stop using uzip fs
#	makefs -ominfree=0,bsize=8192,fsize=1024,optimization=space -s${ROMFS_SIZE} \
#		${REL}/${ROMFS_IMG} ${ROMFS_USR}

#	MDDEV=$(mdconfig -a -t vnode -f ${REL}/${ROMFS_IMG});
#	tunefs -L elwixFirmware /dev/$MDDEV;
#	mdconfig -d -u $MDDEV;

#	mkuzip -s 8192 -o ${REL}/${ROMFS_IMG}.uzip ${REL}/${ROMFS_IMG};
#	mv ${REL}/${ROMFS_IMG}.uzip ${REL}/${ROMFS_IMG}

	echo "+++ Completed ELWIX Firmware system image ... $ROMFS_USR --> ${REL}/${ROMFS_IMG}"
}

### main()
clean_romfs || exit 1
build_romfs || exit 1

install_romfs || exit 1
build_image || exit 1

echo "+++ Complete build ELWIX RomFS"

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