tazwok rev 450 4.3

tazwok: rework feature auto-recook of reverse depends
author Antoine Bodin <gokhlayeh@slitaz.org>
date Tue Mar 15 05:33:36 2011 +0100 (2011-03-15)
parents 04eb5fb6c9a3
children 5635a694843e
files TODO tazwok
line diff
     1.1 --- a/TODO	Tue Mar 15 03:52:02 2011 +0100
     1.2 +++ b/TODO	Tue Mar 15 05:33:36 2011 +0100
     1.3 @@ -31,7 +31,7 @@
     1.4  [ ] Allow to download safe-wok using rsync
     1.5  [ ] Take advantage of --rootconfig of new tazpkg (after tazpkg 4.3 release only)
     1.6  [*] Generate the safe-wok, and optionally a tarbalized one
     1.7 -[ ] Rework detection of broken shared libs dependencies
     1.8 +[รน] Rework detection of broken shared libs dependencies
     1.9  [ ] Check that packages are availbale before cooking
    1.10  	[*] Check that repositories exists into tazpkg conf
    1.11  	[*] Check that env is up to date, or upgrade, or propose upgrade if outside of chroot.
     2.1 --- a/tazwok	Tue Mar 15 03:52:02 2011 +0100
     2.2 +++ b/tazwok	Tue Mar 15 05:33:36 2011 +0100
     2.3 @@ -160,12 +160,14 @@
     2.4  		if [ "$ref_USE_ONLINE_PKG" ]; then
     2.5  			ref_dep_db=$LOCALSTATE_path/wok-depends.txt
     2.6  			ref_wan_db=$LOCALSTATE_path/wok-wanted.txt
     2.7 +			ref_lib_db=$LOCALSTATE_path/libraries.txt
     2.8  		else
     2.9  			ref_dep_db=$ref_PACKAGES_REPOSITORY/wok-depends.txt
    2.10  			ref_wan_db=$ref_PACKAGES_REPOSITORY/wok-wanted.txt
    2.11 +			ref_lib_db=$ref_PACKAGES_REPOSITORY/libraries.txt
    2.12  		fi
    2.13  
    2.14 -		for file in $ref_dep_db $ref_wan_db; do
    2.15 +		for file in $ref_dep_db $ref_wan_db $ref_lib_db; do
    2.16  			[ -f "$file" ] && continue
    2.17  			missing_file=t
    2.18  			echo "$file is missing." >&2
    2.19 @@ -209,7 +211,7 @@
    2.20  		check_dir $INCOMING_REPOSITORY
    2.21  		check_dir $LOCAL_REPOSITORY/log
    2.22  		for file in $dep_db $wan_db $cookorder $commit $cooklist \
    2.23 -			$broken $blocked $SOURCES_REPOSITORY/sources.list
    2.24 +			$broken $blocked $SOURCES_REPOSITORY/sources.list $lib_db
    2.25  		do
    2.26  			[ -f $file ] || touch $file
    2.27  		done
    2.28 @@ -230,6 +232,7 @@
    2.29  	LOG="$WOK/$PACKAGE/process.log"
    2.30  	dep_db=$INCOMING_REPOSITORY/wok-depends.txt
    2.31  	wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
    2.32 +	lib_db=$INCOMING_REPOSITORY/libraries.txt
    2.33  	cookorder=$PACKAGES_REPOSITORY/cookorder.txt
    2.34  	commit=$PACKAGES_REPOSITORY/commit
    2.35  	cooklist=$PACKAGES_REPOSITORY/cooklist
    2.36 @@ -1122,34 +1125,35 @@
    2.37  	done > files.list
    2.38  	
    2.39  	# Next, check if something has changed in lib files.
    2.40 -	if fgrep -q '.so' files.list; then
    2.41 -		for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
    2.42 -			$([ "$undigest" ] && echo $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
    2.43 -			echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
    2.44 -			prev_VERSION=$(get_pkg_version $rep)
    2.45 -			[ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
    2.46 +	# Plan to recook each packages which depends on libs
    2.47 +	# which doesn't exists anymore.
    2.48 +    libs=$(for file in $(find * -type f); do
    2.49 +	[ "$(dd if=$file bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ] || continue
    2.50 +		LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $PWD/$file
    2.51 +	done | { cut -f 1 -d ' ' | tr -d '\t' | sort -u | \
    2.52 +	sed -e 's/^linux-gate.so.*$/SLIB/' -e 's~^/lib/ld-.*$~SLIB~' \
    2.53 +		-e '/^statically$/d' | tr '\n' ' '; })
    2.54 +	libs=$(echo " $libs" | sed -r 's/( SLIB)+ / /g')
    2.55 +	old_libs=$(grep -m1 ^$PACKAGE$'\t' $lib_db | cut -f 2)
    2.56 +	if [ "$old_libs" ]; then
    2.57 +		report step "Looking if reverse depends needs to be refreshed"
    2.58 +		for i in $old_libs; do
    2.59 +			[ "${libs/ $i }" = "$libs" ] || continue
    2.60 +			fgrep " $i " $lib_db | cut -f 1
    2.61 +		done | sort -u | while read rdep; do
    2.62 +			[ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
    2.63 +			grep -q ^$rdep$ $blocked $cooklist && continue
    2.64 +			echo "Plan to recook $rdep"
    2.65 +			echo $rdep >> $cooklist
    2.66  		done
    2.67 -		if [ "$pkg_file" ]; then
    2.68 -			report step "Looking for major/minor updates in libraries"
    2.69 -			get_pkg_files $pkg_file
    2.70 -			cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
    2.71 -			fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
    2.72 -			while read lib; do
    2.73 -				fgrep -q "$lib" $pkg_files_dir/files.list && continue
    2.74 -				echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
    2.75 -				for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
    2.76 -					[ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
    2.77 -					grep -q ^$rdep$ $blocked $cooklist && continue
    2.78 -					echo $rdep >> $cooklist
    2.79 -				done
    2.80 -				regen_cooklist=yes
    2.81 -				break
    2.82 -			done
    2.83 -			rm -r $pkg_files_dir
    2.84 -			unset pkg_file
    2.85 -			report end-step		
    2.86 -   		fi
    2.87 -   	fi
    2.88 +		sed "/^$PACKAGE\t/d" -i $lib_db
    2.89 +		report end-step
    2.90 +	fi
    2.91 +	if [ "$libs" ]; then
    2.92 +		echo -e "$PACKAGE\t$libs" >> $lib_db
    2.93 +		sort -o $lib_db $lib_db
    2.94 +	fi
    2.95 +
    2.96  	if [ ! "$EXTRAVERSION" ]; then
    2.97  		case "$PACKAGE" in
    2.98  		linux*);;
    2.99 @@ -1383,7 +1387,7 @@
   2.100  
   2.101  erase_package_info_main()
   2.102  {
   2.103 -	for i in wanted.txt depends.txt; do
   2.104 +	for i in wanted.txt depends.txt libraries.txt; do
   2.105  		[ -f $i ] || continue
   2.106  		sed "/^$PACKAGE\t/d" -i $i
   2.107  	done
   2.108 @@ -1442,6 +1446,8 @@
   2.109  {
   2.110  	[ "$WANTED" ] && echo -e "$PACKAGE\t$WANTED" >> wanted.txt
   2.111  	echo -e "$PACKAGE\t "$DEPENDS" \t "$BUILD_DEPENDS" " >> package.txt
   2.112 +	libs=$(grep -m1 ^$PACKAGE$'\t' $lib_db | cut -f 2)
   2.113 +	[ "$libs" ] && echo "$libs" >> libraries.txt
   2.114  }
   2.115  
   2.116  source_receipt()
   2.117 @@ -1464,7 +1470,7 @@
   2.118  		report step "Sorting packages lists"
   2.119  		files_list="packages.list packages.desc packages.equiv"
   2.120  		[ "${pkg_repository##*/}" = packages ] && \
   2.121 -			files_list="$files_list wanted.txt depends.txt"
   2.122 +			files_list="$files_list wanted.txt depends.txt libraries.txt"
   2.123  		for file in $files_list; do
   2.124  			[ -f $file ] || continue
   2.125  			sort -o $file $file