cookutils rev 426

cook: install build deps in cross environment root if we cross compiling
author Christophe Lincoln <pankso@slitaz.org>
date Sat May 19 23:42:58 2012 +0200 (2012-05-19)
parents 183ef2eaddc6
children 0f79cede3518
files cook
line diff
     1.1 --- a/cook	Sat May 19 23:40:17 2012 +0200
     1.2 +++ b/cook	Sat May 19 23:42:58 2012 +0200
     1.3 @@ -406,12 +406,12 @@
     1.4  	if [ -s "$CACHE/installed.cook.diff" ]; then
     1.5  		deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
     1.6  		nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
     1.7 -		gettext "Build dependencies to remove:"; echo " $nb"
     1.8 +		gettext "Build dependencies to remove:"; echo " $nb $root"
     1.9  		gettext "Removing:"
    1.10  		for dep in $deps
    1.11  		do
    1.12  			echo -n " $dep"
    1.13 -			echo 'y' | tazpkg remove $dep >/dev/null
    1.14 +			echo 'y' | tazpkg remove $dep --root=$root >/dev/null
    1.15  		done
    1.16  		echo -e "\n"
    1.17  		# Keep the last diff for debug and info.
    1.18 @@ -431,20 +431,26 @@
    1.19  			# CROSS_COMPILE is used by at least Busybox and the kernel to set
    1.20  			# the cross-tools prefix but first check if sysroot is used.
    1.21  			if [ "$SYSROOT" ]; then
    1.22 -				echo "cook: $ARCH sysroot: $SYSROOT"
    1.23 +				echo "$ARCH sysroot: $SYSROOT"
    1.24  			else
    1.25 -				echo "cook: adding /usr/cross/$ARCH/bin to PATH"
    1.26 +				echo "Adding /usr/cross/$ARCH/bin to PATH"
    1.27  				export PATH=$PATH:$CROSS_PREFIX/bin
    1.28  			fi
    1.29  			export CROSS_COMPILE=${HOST_SYSTEM}-
    1.30 -			echo "cook: using cross-tools: $CROSS_COMPILE"
    1.31 +			echo "Using cross-tools: $CROSS_COMPILE"
    1.32  			export CC=${HOST_SYSTEM}-gcc
    1.33  			export CXX=${HOST_SYSTEM}-g++
    1.34  			export AR=${HOST_SYSTEM}-ar
    1.35  			export AS=${HOST_SYSTEM}-as
    1.36  			export RANLIB=${HOST_SYSTEM}-ranlib
    1.37  			export LD=${HOST_SYSTEM}-ld
    1.38 -			export STRIP=${HOST_SYSTEM}-strip ;;
    1.39 +			export STRIP=${HOST_SYSTEM}-strip
    1.40 +			# Set root path when cross compiling. ARM tested but not x86_64
    1.41 +			# When cross compiling we must install build deps in CROSS_PREFIX
    1.42 +			# or SYSROOT when it will be support by cross (the final goal is
    1.43 +			# to use only the sysroot method).
    1.44 +			root=$CROSS_PREFIX
    1.45 +			arch=-${ARCH} ;;
    1.46  	esac
    1.47  
    1.48  	[ "$QA" ] && receipt_quality
    1.49 @@ -471,23 +477,24 @@
    1.50  	rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
    1.51  	touch $CACHE/installed.local $CACHE/installed.web
    1.52  	[ "$BUILD_DEPENDS" ] && gettext -e "Checking build dependencies...\n"
    1.53 +	[ "$root" ] && echo "Using packages DB: ${root}$DB"
    1.54  	for dep in $BUILD_DEPENDS
    1.55  	do
    1.56  		implicit=${dep%-dev}
    1.57  		for i in $dep $implicit
    1.58  		do
    1.59 -			if [ ! -f "$INSTALLED/$i/receipt" ]; then
    1.60 +			if [ ! -f "${root}$INSTALLED/$i/receipt" ]; then
    1.61  				# Try local package first. In some cases implicit doesn't exist, ex:
    1.62  				# libboost-dev exists but not libboost, so check if we got vers.
    1.63  				unset vers
    1.64  				vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
    1.65 -				if [ -f "$PKGS/$i-$vers.tazpkg" ]; then
    1.66 -					echo $i-$vers.tazpkg >> $CACHE/installed.local
    1.67 +				if [ -f "$PKGS/$i-${vers}${arch}.tazpkg" ]; then
    1.68 +					echo $i-${vers}${arch}.tazpkg >> $CACHE/installed.local
    1.69  				else
    1.70  					# Priority to package version in wok (maybe more up-to-date)
    1.71  					# than the mirrored one.
    1.72  					if [ "$vers" ]; then
    1.73 -						if fgrep -q $i-$vers $DB/packages.list; then
    1.74 +						if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
    1.75  							echo $i >> $CACHE/installed.web
    1.76  						else
    1.77  							# So package exists in wok but not available.
    1.78 @@ -496,7 +503,7 @@
    1.79  						fi
    1.80  					else
    1.81  						# Package is not in wok but may be in repo.
    1.82 -						if fgrep -q $i-$vers $DB/packages.list; then
    1.83 +						if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
    1.84  							echo $i >> $CACHE/installed.web
    1.85  						else
    1.86  							echo "ERROR: unknown dep $i" && exit 1
    1.87 @@ -508,7 +515,7 @@
    1.88  	done
    1.89  
    1.90  	# Get the list of installed packages
    1.91 -	cd $INSTALLED && ls -1 > $CACHE/installed.list
    1.92 +	cd ${root}$INSTALLED && ls -1 > $CACHE/installed.list
    1.93  
    1.94  	# Have we a missing build dep to cook ?
    1.95  	if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
    1.96 @@ -535,12 +542,7 @@
    1.97  		echo "ERROR: missing dep $nb" && exit 1
    1.98  	fi
    1.99  
   1.100 -	# Set root path when cross compiling. ARM tested but not x86_64
   1.101 -	case "$ARCH" in
   1.102 -		arm) root=$CROSS_PREFIX ;;
   1.103 -	esac
   1.104 -
   1.105 -	# Install local packages.
   1.106 +	# Install local packages: package-version${arch}
   1.107  	cd $PKGS
   1.108  	for i in $(uniq $CACHE/installed.local)
   1.109  	do
   1.110 @@ -557,7 +559,7 @@
   1.111  	done
   1.112  
   1.113  	# If a cook failed deps are removed.
   1.114 -	cd $INSTALLED && ls -1 > $CACHE/installed.cook && cd $CACHE
   1.115 +	cd ${root}$INSTALLED && ls -1 > $CACHE/installed.cook && cd $CACHE
   1.116  	[ ! -s "installed.cook.diff" ] && \
   1.117  		busybox diff installed.list installed.cook > installed.cook.diff
   1.118  	deps=$(cat installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
   1.119 @@ -958,10 +960,20 @@
   1.120  		if [ "$SYSROOT" ]; then
   1.121  			echo "Arch sysroot    : $SYSROOT"
   1.122  			CC=/usr/bin/${HOST_SYSTEM}-gcc
   1.123 +			root=$SYSROOT
   1.124  		else
   1.125 -			echo "Additional path : /usr/cross/$ARCH/bin"
   1.126 -			CC=/usr/cross/$ARCH/bin/${HOST_SYSTEM}-gcc
   1.127 +			echo "Additional path : $CROSS_PREFIX/bin"
   1.128 +			CC=$CROSS_PREFIX/bin/${HOST_SYSTEM}-gcc
   1.129 +			root=$CROSS_PREFIX
   1.130  		fi
   1.131 +		# Tell package manager wher to find package.
   1.132 +		echo "Packages DB     : ${root}$DB"
   1.133 +		cd ${root}$DB && rm -f *.bak
   1.134 +		for list in packages.list packages.desc packages.equiv packages.md5
   1.135 +		do
   1.136 +			rm -f $list && ln -s $SLITAZ/packages/$list $list
   1.137 +		done
   1.138 +		# Show GCC version or warn if not yet compiled.
   1.139  		if [ -x $CC ]; then
   1.140  			echo "Cross compiler  : ${HOST_SYSTEM}-gcc"
   1.141  		else