wok rev 6111

tazbb: add check-receipt
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Sep 04 13:54:44 2010 +0200 (2010-09-04)
parents 6cc3281e3803
children ae97a9aa5f66
files tazbb/stuff/tazbb
line diff
     1.1 --- a/tazbb/stuff/tazbb	Sat Sep 04 13:06:54 2010 +0200
     1.2 +++ b/tazbb/stuff/tazbb	Sat Sep 04 13:54:44 2010 +0200
     1.3 @@ -396,7 +396,7 @@
     1.4  	WANTED=""
     1.5  	echo "(cooking <a href=\"log.php?package=$(escape $pkg)$LOG_SUFFIX\">$pkg</a>)" > $DB_DIR/running
     1.6  	tazwok clean $pkg
     1.7 -	script -c "echo 'install' | tazwok cook $pkg" $LOG_DIR/$pkg.log
     1.8 +	script -c "tazbb check-receipt $pkg && echo 'install' | tazwok cook $pkg" $LOG_DIR/$pkg.log
     1.9  	# Install new package (important for new shared libs). Note
    1.10  	# that tests are done separatly with 'test_packages' and should
    1.11  	# be done by tazwok.
    1.12 @@ -501,6 +501,100 @@
    1.13  	done
    1.14  }
    1.15  
    1.16 +# Check for misc variables
    1.17 +check_variables()
    1.18 +{
    1.19 +	PACKAGE=""
    1.20 +	VERSION=""
    1.21 +	EXTRAVERSION=""
    1.22 +	CATEGORY=""
    1.23 +	SHORT_DESC=""
    1.24 +	MAINTAINER=""
    1.25 +	WEB_SITE=""
    1.26 +	PACKED_SIZE=""
    1.27 +	UNPACKED_SIZE=""
    1.28 +	. $BUILD_WOK/$1/receipt
    1.29 +	if [ "$PACKAGE" != "$1" ]; then
    1.30 +		echo "The PACKAGE variable should be $1"
    1.31 +		return 1
    1.32 +	fi
    1.33 +	if [ -z "$VERSION" ]; then
    1.34 +		echo "No VERSION in $1"
    1.35 +		return 1
    1.36 +	fi
    1.37 +	if [ -z "$SHORT_DESC" ]; then
    1.38 +		echo "No SHORT_DESC in $1"
    1.39 +		return 1
    1.40 +	fi
    1.41 +	case "$MAINTAINER" in
    1.42 +	'')	echo "No MAINTAINER in $1"
    1.43 +		return 1 ;;
    1.44 +	*\<*|*\>*)
    1.45 +		echo "Invalid MAINTAINER in $1"
    1.46 +		return 1 ;;
    1.47 +	*@*)	;;
    1.48 +	*)	echo "No email address for MAINTAINER in $1"
    1.49 +		return 1 ;;
    1.50 +	esac
    1.51 +	if [ -z "$WEB_SITE" ]; then
    1.52 +		echo "No WEB_SITE in $1"
    1.53 +		return 1
    1.54 +	fi
    1.55 +	if [ -n "$EXTRAVERSION" ]; then
    1.56 +		echo "Hardcoded EXTRAVERSION in $1"
    1.57 +		return 1
    1.58 +	fi
    1.59 +	if [ -n "$PACKED_SIZE" ]; then
    1.60 +		echo "Hardcoded PACKED_SIZE in $1"
    1.61 +		return 1
    1.62 +	fi
    1.63 +	if [ -n "$UNPACKED_SIZE" ]; then
    1.64 +		echo "Hardcoded UNPACKED_SIZE in $1"
    1.65 +		return 1
    1.66 +	fi
    1.67 +	case " base-system x-window utilities network graphics multimedia \
    1.68 +               office development system-tools security games misc meta \
    1.69 +               non-free " in
    1.70 +	*\ $CATEGORY\ *);;
    1.71 +	*) 	echo "Invalid CATEGORY in $1 : $CATEGORY"
    1.72 +		return 1;
    1.73 +	esac
    1.74 +	return 0
    1.75 +}
    1.76 +
    1.77 +# Check for WANTED version
    1.78 +check_wanted_version()
    1.79 +{
    1.80 +	WANTED=""
    1.81 +	. $BUILD_WOK/$1/receipt
    1.82 +	if [ -n $WANTED ]; then
    1.83 +		expected=$VERSION
    1.84 +		VERSION=
    1.85 +		. $BUILD_WOK/$WANTED/receipt
    1.86 +		if [ "$VERSION" != "$expected" ]; then
    1.87 +			return 1
    1.88 +		fi
    1.89 +	fi
    1.90 +	return 0
    1.91 +}
    1.92 +
    1.93 +# Check for loop in BUILD_DEPENDS/WANTED
    1.94 +check_build_depends()
    1.95 +{
    1.96 +	local i
    1.97 +	BUILD_DEPENDS=""
    1.98 +	WANTED=""
    1.99 +	. $BUILD_WOK/$1/receipt
   1.100 +	for i in $BUILD_DEPENDS $WANTED ; do
   1.101 +		case " $2 " in
   1.102 +		*\ $i\ *)	echo "Loop in BUILD_DEPENDS/WANTED chain $2 $i"
   1.103 +				return 1 ;;
   1.104 +		*)		check_build_depends $i "$2 $1" || return 1 ;;
   1.105 +		esac
   1.106 +	done
   1.107 +	return 0
   1.108 +}
   1.109 +
   1.110  # Build depends_to_skip list with packages to remove from depends_to_add list
   1.111  # These packages are already present in depends_to_add trees
   1.112  scan_depends_to_skip()
   1.113 @@ -808,6 +902,7 @@
   1.114  	cd - > /dev/null
   1.115  }
   1.116  
   1.117 +return_status=0
   1.118  case "$1" in
   1.119  	list-pkgs)
   1.120  		# List last cooked packages.
   1.121 @@ -921,6 +1016,11 @@
   1.122  		echo -n "Cleaning: $LOG_DIR... "
   1.123  		rm -rf $LOG_DIR/*
   1.124  		echo "$logs log removed" ;;
   1.125 +	check-receipt)
   1.126 +		check_variables $2 &&
   1.127 +		check_wanted_version $2 &&
   1.128 +		check_build_depends $2 ""
   1.129 +		return_status=$? ;;
   1.130  	check-depends)
   1.131  		case "$2" in
   1.132  		wok)
   1.133 @@ -957,4 +1057,4 @@
   1.134  echo "" > $DB_DIR/running
   1.135  rm -f $LOCK_FILE /tmp/files.list.tazbb$$
   1.136  
   1.137 -exit 0
   1.138 +exit $return_status