cookutils diff cook @ rev 598

Apply common stylesheet for docs; light reformatting of html code; add experimental (unfinished) '--cdeps' option to cook.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat May 04 18:02:53 2013 +0000 (2013-05-04)
parents f3eb8e8e9d2e
children cc087b6b3690
line diff
     1.1 --- a/cook	Fri Apr 05 13:48:40 2013 +0200
     1.2 +++ b/cook	Sat May 04 18:02:53 2013 +0000
     1.3 @@ -50,6 +50,7 @@
     1.4    --getsrc|-gs       Cook : $(_ "get the package source tarball.")
     1.5    --block|-b         Cook : $(_ "block a package so cook will skip it.")
     1.6    --unblock|-ub      Cook : $(_ "unblock a blocked package.")
     1.7 +  --cdeps            Cook : $(_ "check dependencies of cooked package.")
     1.8    --pack             Cook : $(_ "repack an already built package.")
     1.9    --interactive|-x   New  : $(_ "create a receipt interactively.")
    1.10    --wok              Setup: $(_ "clone the cooking wok from Hg repo.")
    1.11 @@ -948,6 +949,69 @@
    1.12  	fi
    1.13  }
    1.14  
    1.15 +# Search file in mirrored packages
    1.16 +search_file_mirror()
    1.17 +{
    1.18 +	busybox unlzma -c $DB/files.list.lzma | grep $1\$ | cut -d: -f1 | sort -u
    1.19 +}
    1.20 +
    1.21 +# Search file in local wok packages
    1.22 +search_file_local()
    1.23 +{
    1.24 +	# existing packages have precedence over the package/taz folder
    1.25 +	srch=$1
    1.26 +	{ for package in $(find $PKGS -name '*.tazpkg'); do
    1.27 +		if [ ! "x$(busybox cpio --to-stdout --quiet -i files.list < $package | grep /$srch\$)" == "x" ]; then
    1.28 +			busybox cpio -i receipt < $package | fgrep PACKAGE | cut -d\" -f2
    1.29 +		fi
    1.30 +	done } | sort -u
    1.31 +}
    1.32 +
    1.33 +# Ask in multiple choice
    1.34 +ask_multiple()
    1.35 +{
    1.36 +	local multiples first my_choice
    1.37 +	multiples="$1"
    1.38 +	first=$(echo "$multiples" | head -n1)
    1.39 +	newline; _ "Multiple choice:\n$multiples\n"
    1.40 +	_ "Select one [$first]: "; read my_choice
    1.41 +	[ "x$my_choice" == "x" ] && my_choice="$first"
    1.42 +	found=$my_choice
    1.43 +}
    1.44 +
    1.45 +# Search file in local cache (fast), local wok packages, mirrored packages
    1.46 +search_file()
    1.47 +{
    1.48 +	local srch cache missing
    1.49 +	srch=$1
    1.50 +	cache=/var/cache/ldsearch.cache
    1.51 +	missing=/var/cache/missing.file
    1.52 +	touch $cache $missing
    1.53 +	found=$(grep $srch $cache | cut -d'	' -f2)
    1.54 +	if [ "x$found" == "x" ]; then
    1.55 +		found=$(search_file_local $srch)
    1.56 +		if [ "x$found" != "x" ]; then
    1.57 +			if [ $(echo "$found" | wc -l) -gt 1 ]; then
    1.58 +				ask_multiple "$found"
    1.59 +			fi
    1.60 +			echo "$srch	$found" >> $cache
    1.61 +		else
    1.62 +			found=$(search_file_mirror $srch)
    1.63 +			if [ "x$found" != "x" ]; then
    1.64 +				if [ $(echo "$found" | wc -l) -gt 1 ]; then
    1.65 +					ask_multiple "$found"
    1.66 +				fi
    1.67 +				echo "$srch	$found" >> $cache
    1.68 +			else
    1.69 +				echo "$srch" >> $missing
    1.70 +			fi
    1.71 +		fi
    1.72 +	fi
    1.73 +}
    1.74 +
    1.75 +
    1.76 +
    1.77 +
    1.78  #
    1.79  # Commands
    1.80  #
    1.81 @@ -1377,6 +1441,30 @@
    1.82  					_ "Need to build \$pkg." && exit 0
    1.83  				fi
    1.84  				exit 0 ;;
    1.85 +			--cdeps)
    1.86 +				[ ! -d $WOK/$pkg/taz ] && _ "Need to build \$pkg." && exit 0
    1.87 +				_ "Checking depends"; separator
    1.88 +				lddlist=/tmp/lddlist; touch $lddlist
    1.89 +				missing=/var/cache/missing.file
    1.90 +				# find all deps using ldd
    1.91 +				for exe in $(find $WOK/$pkg/taz -type f -perm +111); do
    1.92 +					[ "x$(dd if=$exe bs=4 count=1 2>/dev/null)" == "xELF" ] &&
    1.93 +						ldd $exe | sed 's|	||' | cut -d' ' -f1 >> $lddlist
    1.94 +				done
    1.95 +				# remove exe/so duplicates
    1.96 +				sort -u $lddlist > $lddlist.sorted
    1.97 +				# search packages
    1.98 +				for exefile in $(cat $lddlist.sorted); do
    1.99 +					search_file $exefile
   1.100 +					echo $found >> $lddlist.pkgs
   1.101 +					echo -n "."
   1.102 +				done
   1.103 +				echo
   1.104 +				# remove packages duplicates
   1.105 +				sort -u $lddlist.pkgs > $lddlist.final
   1.106 +				sort -u $missing > $missing.final
   1.107 +				rm -f $lddlist $lddlist.sorted $lddlist.pkgs $missing
   1.108 +				exit 0 ;;
   1.109  		esac
   1.110  
   1.111  		# Check if wanted is built now so we have separate log files.