tazwok rev 119

Add check-depends
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Mar 11 11:00:50 2009 +0000 (2009-03-11)
parents b3780d73c463
children 1803f2206ec5
files tazwok
line diff
     1.1 --- a/tazwok	Fri Feb 13 00:10:08 2009 +0100
     1.2 +++ b/tazwok	Wed Mar 11 11:00:50 2009 +0000
     1.3 @@ -93,6 +93,7 @@
     1.4    info           Get information about a package in the wok.
     1.5    check          Check every receipt for common errors.
     1.6    check-log      Check the process log file of a package.
     1.7 +  check-depends  Check every receipt for DEPENDS misses scanning ELF files
     1.8    search         Search for a package in the wok by pattern or name.
     1.9    compile        Configure and build a package using the receipt rules.
    1.10    genpkg         Generate a suitable package for Tazpkg with the rules.
    1.11 @@ -694,6 +695,76 @@
    1.12  			done
    1.13  		done
    1.14  		;;
    1.15 +	check-depends)
    1.16 +		# Check package depends
    1.17 +		echo ""
    1.18 +		echo -e "\033[1mCheck every receipt for DEPENDS misses scanning ELF files\033[0m
    1.19 +================================================================================"
    1.20 +		TMPDIR=/tmp/tazwok$$
    1.21 +		DEFAULT_DEPENDS="glibc-base gcc-lib-base"
    1.22 +
    1.23 +		# Build ALL_DEPENDS variable
    1.24 +		scan_dep()
    1.25 +		{
    1.26 +			local i
    1.27 +			ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
    1.28 +			for i in $DEPENDS ; do
    1.29 +				case " $ALL_DEPENDS " in
    1.30 +				*\ $i\ *) continue;;
    1.31 +				esac
    1.32 +				[ -d $WOK/$i ] || continue
    1.33 +				. $WOK/$i/receipt
    1.34 +				scan_dep
    1.35 +			done
    1.36 +		}
    1.37 +		
    1.38 +		# Check for ELF file
    1.39 +		is_elf()
    1.40 +		{
    1.41 +			[ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
    1.42 +				= "ELF" ]
    1.43 +		}
    1.44 +
    1.45 +		# Print shared library dependencies
    1.46 +		ldd()
    1.47 +		{
    1.48 +			LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1
    1.49 +		}
    1.50 +
    1.51 +		mkdir $TMPDIR
    1.52 +		cd $TMPDIR
    1.53 +		for i in /var/lib/tazpkg/files.list.lzma \
    1.54 +	 		/var/lib/tazpkg/undigest/*/files.list.lzma ; do
    1.55 +	 		[ -f $i ] && lzma d $i -so >> files.list
    1.56 +		done
    1.57 +		for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
    1.58 +			tazpkg extract $pkg > /dev/null 2>&1
    1.59 +			. */receipt
    1.60 +			ALL_DEPENDS="$DEFAULT_DEPENDS "
    1.61 +			scan_dep
    1.62 +			find */fs -type f | while read file ; do
    1.63 +				is_elf $file || continue
    1.64 +				case "$file" in
    1.65 +				*.o|*.ko|*.ko.gz) continue;;
    1.66 +				esac
    1.67 +				ldd $file | while read lib rem; do
    1.68 +					case "$lib" in
    1.69 +					linux-gate.so*|ld-*.so|*/ld-*.so)
    1.70 +						continue;;
    1.71 +					esac
    1.72 +					for dep in $(grep $lib files.list | cut -d: -f1); do
    1.73 +						case " $ALL_DEPENDS " in
    1.74 +						*\ $dep\ *) continue 2;;
    1.75 +						esac
    1.76 +					done
    1.77 +					echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
    1.78 +				done
    1.79 +			done
    1.80 +			rm -rf */
    1.81 +		done
    1.82 +		cd /tmp
    1.83 +		rm -rf $TMPDIR
    1.84 +		;;
    1.85  	check)
    1.86  		# Check wok consistancy
    1.87  		echo ""