File:  [ELWIX - Embedded LightWeight unIX -] / elwix / config / rc.subr
Revision 1.6: download - view: text, annotated - select for diffs - revision graph
Tue May 7 20:46:48 2013 UTC (11 years ago) by misho
Branches: MAIN
CVS tags: elwix1_9_mips, elwix1_9, HEAD, ELWIX1_8
elwix 1.8

#
# ELWIX project build helper subroutines
#
# (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
#    by Michael Pounov <misho@elwix.org>
#
# $Id: rc.subr,v 1.6 2013/05/07 20:46:48 misho Exp $
#

### Dont edit this file !!!

CheckVer()
{
	[ -z "$1" -o ! -r "$1" ] && return 1

	cat $1 | awk '($1 == "ELWIX") { split($3, arr, ":"); printf("%s", arr[2]); }'
	return 0
}

SnitVer()
{
	install -d ${TOPDIR}

	V=$(CheckVer $1)

	if [ $? -ne 0 ]; then
# file not found
		return 1
	elif [ X"$V" != X"${VERSION}" ]; then
# different ELWIX version
		return 2
	fi

# already present file with same version
	return 0
}

# $1 = ELWIX install list config
# $2 = From World dir
# $3 = To Dest dir
InstallList()
{
	local TMPFILE=$(mktemp -q /tmp/instlist.XXXXXX)
	if [ $? -ne 0 ]; then
		echo "Error:: Can't create temp file, exiting..."
		exit 1
	fi

	sed -nE -e 's/^ *([^ #]+) */\1/p' < $1 | tr ':' '\n' >$TMPFILE
	cd $2
	for i in $(cat $TMPFILE); do
		if [ -x $i ]; then
			echo "Strip '$i'"
			strip -s $i
		fi
	done
	cd -
	tar -C $2 -cvf - -T $TMPFILE | tar -C $3 -x -f -
	rm -f $TMPFILE
}

# $1 = From dir
# $2 = To dir
InstallDir()
{
	cd $1
	pax -rw -pe -X . $2
	cd -
}

# $* = Program arguments for install tool
InstallProg()
{
	install -c $*
}

# $1 = file_pattern
# $2 = From dir
# $3 = To dir
InstallFiles()
{
	if [ -d "$2" ]; then
		cd $2
		find . -type f -name "$1" | 
			tar -cvf - -T - | tar -C $3 -xf -
		cd -
	fi
}

# $1 = Directory for clean
CleanCVS()
{
	find $1 -type d -name CVS -exec rm -rf {} \; >/dev/null 2>&1
	find $1 -type f -name .#\* -exec rm -f {} \; >/dev/null 2>&1
}

# $1 = file_pattern
# $2 = From dir
StripFiles()
{
	if [ -d "$2" ]; then
		local TMPFILE=$(mktemp -q /tmp/instlist.XXXXXX)
		if [ $? -ne 0 ]; then
			echo "Error:: Can't create temp file, exiting..."
			exit 1
		fi

		cd $2
		find . -type f -name "$1" >$TMPFILE
		for i in $(cat $TMPFILE); do
			if [ -x $i ]; then
				echo "Strip '$i'"
				strip -s $i
			fi
		done
		cd -
		rm -f $TMPFILE
	fi
}

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