wok rev 4174

tazbb: sort cook list
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Sep 22 21:25:03 2009 +0200 (2009-09-22)
parents 9a3c3f52c282
children 5a780c98c23b
files tazbb/stuff/tazbb
line diff
     1.1 --- a/tazbb/stuff/tazbb	Tue Sep 22 21:22:57 2009 +0200
     1.2 +++ b/tazbb/stuff/tazbb	Tue Sep 22 21:25:03 2009 +0200
     1.3 @@ -247,31 +247,74 @@
     1.4  	packages_summary
     1.5  }
     1.6  
     1.7 +# Cook one package
     1.8 +cook_package()
     1.9 +{
    1.10 +	EXTRAVERSION=""
    1.11 +	DEPENDS=""
    1.12 +	BUILD_DEPENDS=""
    1.13 +	SOURCE=""
    1.14 +	WANTED=""
    1.15 +	echo "(cooking <a href=\"log.php?package=$(escape $pkg)\">$pkg</a>)" > $DB_DIR/running
    1.16 +	tazwok clean $pkg
    1.17 +	script -c "echo 'install' | tazwok cook $pkg" $LOG_DIR/$pkg.log
    1.18 +	# Install new package (important for new shared libs). Note
    1.19 +	# that tests are done separatly with 'test_packages' and should
    1.20 +	# be done by tazwok.
    1.21 +	if [ -f $BUILD_WOK/$pkg/taz/*/receipt ]; then
    1.22 +		. $BUILD_WOK/$pkg/taz/*/receipt
    1.23 +		echo "(installing $PACKAGE-${VERSION}$EXTRAVERSION.tazpkg)" \
    1.24 +			> $DB_DIR/running
    1.25 +		yes | tazpkg install \
    1.26 +			$PACKAGES_REPOSITORY/$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg \
    1.27 +			--forced
    1.28 +		return 0
    1.29 +	fi
    1.30 +	return 1
    1.31 +}
    1.32 +
    1.33 +# Sort list according WANTED and BUILD_DEPENDS
    1.34 +sort_cook_list()
    1.35 +{
    1.36 +	sort | while read pkg; do
    1.37 +		echo -n "$pkg"
    1.38 +		WANTED=""
    1.39 +		BUILD_DEPENDS=""
    1.40 +		. $BUILD_WOK/$pkg/receipt
    1.41 +		for i in $WANTED $BUILD_DEPENDS ; do
    1.42 +			if [ ! -f $BUILD_WOK/$i/taz/*/receipt ]; then
    1.43 +				echo -n " $i"
    1.44 +			fi
    1.45 +		done
    1.46 +		echo ""
    1.47 +	done | awk '{
    1.48 +		if ($2 == "") print;
    1.49 +		else {
    1.50 +			depcnt[$1] = NF - 1;
    1.51 +			unres = unres " " $1;
    1.52 +			for (i = 2; i <= NF; i++) {
    1.53 +				revdepcnt[$i]++;
    1.54 +				revdep[$i] = revdep[$i] " " $1;
    1.55 +			}
    1.56 +		}
    1.57 +		if (revdepcnt[$1] > 0)
    1.58 +			for (i = split(revdep[$1], pkg, " "); i > 0; i--)
    1.59 +				if (--depcnt[pkg[i]] == 0) print pkg[i];
    1.60 +	}
    1.61 +	END {
    1.62 +		for (i = split(unres, pkg, " "); i > 0; i--)
    1.63 +			if (depcnt[pkg[i]] > 0) print pkg[i];
    1.64 +	}
    1.65 +'
    1.66 +}
    1.67 +
    1.68  # Here we cook all packages found in the cooklist.
    1.69  cook_install()
    1.70  {
    1.71  	echo "" > $DB_DIR/unbuilt
    1.72 -	for pkg in `cat $DB_DIR/cooklist | sort`
    1.73 +	for pkg in `cat $DB_DIR/cooklist | sort_cook_list`
    1.74  	do
    1.75 -		EXTRAVERSION=""
    1.76 -		DEPENDS=""
    1.77 -		BUILD_DEPENDS=""
    1.78 -		SOURCE=""
    1.79 -		WANTED=""
    1.80 -		echo "(cooking <a href=\"log.php?package=$(escape $pkg)\">$pkg</a>)" > $DB_DIR/running
    1.81 -		tazwok clean $pkg
    1.82 -		script -c "echo 'install' | tazwok cook $pkg" $LOG_DIR/$pkg.log
    1.83 -		# Install new package (important for new shared libs). Note
    1.84 -		# that tests are done separatly with 'test_packages' and should
    1.85 -		# be done by tazwok.
    1.86 -		if [ -f $BUILD_WOK/$pkg/taz/*/receipt ]; then
    1.87 -			. $BUILD_WOK/$pkg/taz/*/receipt
    1.88 -			echo "(installing $PACKAGE-${VERSION}$EXTRAVERSION.tazpkg)" \
    1.89 -				> $DB_DIR/running
    1.90 -			yes | tazpkg install \
    1.91 -				$PACKAGES_REPOSITORY/$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg \
    1.92 -				--forced
    1.93 -		else
    1.94 +		if ! cook_package $pkg; then
    1.95  			# Link to build log.
    1.96  			echo "<a href=\"log.php?package=$(escape $pkg)\">$pkg</a>" >> \
    1.97  				$DB_DIR/unbuilt
    1.98 @@ -434,17 +477,7 @@
    1.99  		fi
   1.100  		pkg=$2
   1.101  		echo "Starting to cook and install: $pkg"
   1.102 -		echo "(cooking <a href=\"log.php?package=$(escape $pkg)\">$pkg</a>)" > $DB_DIR/running
   1.103 -		tazwok clean $pkg
   1.104 -		script -c "echo 'install' | tazwok cook $pkg" $LOG_DIR/$pkg.log
   1.105 -		if [ -f $BUILD_WOK/$pkg/taz/*/receipt ]; then
   1.106 -			. $BUILD_WOK/$pkg/taz/*/receipt
   1.107 -			echo "(installing $PACKAGE-${VERSION}$EXTRAVERSION.tazpkg)" \
   1.108 -				> $DB_DIR/running
   1.109 -			yes | tazpkg install \
   1.110 -				$PACKAGES_REPOSITORY/$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg \
   1.111 -				--forced
   1.112 -		else
   1.113 +		if ! cook_package $pkg; then
   1.114  			echo "Unable to install: $pkg"
   1.115  		fi ;;
   1.116  	cook-all)