tazwok rev 410 4.3

Code optimization into scan() subfunctions & packages files generation
author Antoine Bodin <gokhlayeh@slitaz.org>
date Fri Mar 04 19:50:26 2011 +0100 (2011-03-04)
parents e1a89abb78b9
children 7b60ce65b63f
files TODO tazwok
line diff
     1.1 --- a/TODO	Fri Mar 04 18:40:31 2011 +0100
     1.2 +++ b/TODO	Fri Mar 04 19:50:26 2011 +0100
     1.3 @@ -2,34 +2,39 @@
     1.4  
     1.5  [ ] fix --undigest repository support
     1.6  	[*] Check if reference repository is local or on network
     1.7 -	[ ] Check that various scan() usage case are fine
     1.8 +	[ ] Check that various scan() usage case are fine (need help at beta time)
     1.9  		[ ] get build-depends
    1.10  		[ ] get reverse depends when a recook is needed (don't catch packages from reference repository!)
    1.11 +			> this one is not good yet
    1.12  		[ ] cooklist generation
    1.13  [ ] Fix md5um on-the-fly generation when using check-incoming)
    1.14  [*] Generate cooklist properly after cook-toolchain
    1.15  
    1.16  ==== Code optimizations ====
    1.17  
    1.18 -[ ] Removing check for $UNDIGEST in scan() subfunctions - define how theses functions should act before
    1.19 -[ ] Don't check for repository used into update_packages_db() & erase_packages_info(); define this before.
    1.20 +[*] Removing check for $UNDIGEST in scan() subfunctions - define how theses functions should act before
    1.21 +[*] Don't check for repository used into update_packages_db() & erase_packages_info(); define this before.
    1.22 +[ ] Don't plan regen_cookorder multiple times.
    1.23  [*] Don't mount all theses /home/slitaz/... directories when chrooting: one is enough!
    1.24  [ ] Move files related to cooking env from packages to packages-incoming (just before releasing the beta)
    1.25  [*] Use variables for most used files
    1.26  	[*] cook-order.txt; wok-wanted.txt/wok-depends.txt of reference repository
    1.27  	[*] cooklist, commit, broken, blocked
    1.28  [ ] Rename wok-wanted.txt/wok-depends.txt to simply depends.txt/wanted.txt
    1.29 +	[*] For main packages
    1.30 +	[ ] For packages-incoming (at beta release time)
    1.31  [x] L407: Use fgrep here are variable subsitution are not optimize for big strings.
    1.32  	> False, variable substitution is definitively better.
    1.33  
    1.34  ==== New features ====
    1.35  
    1.36 -[ ] Take advantage of --rootconfig of new tazpkg
    1.37 +[ ] Take advantage of --rootconfig of new tazpkg (after tazpkg 4.3 release only)
    1.38  [*] Generate the safe-wok, and optionally a tarbalized one
    1.39  [ ] Rework detection of broken shared libs dependencies
    1.40 -[ ] Check that packages are availble before cooking
    1.41 +[ ] Check that packages are availbale before cooking
    1.42  	[*] Check that repositories exists into tazpkg conf
    1.43  	[*] Check that env is up to date, or upgrade, or propose upgrade if outside of chroot.
    1.44  	[ ] Need to check priorities outside of chroot
    1.45  [*] Generate ID of the repository.
    1.46  [ ] Ensure ID is up-dated after cook operations to avoid false-changes detection.
    1.47 +[ ] Ensure smooth tazwok update by automatically update cook environnement according new stuff
    1.48 \ No newline at end of file
     2.1 --- a/tazwok	Fri Mar 04 18:40:31 2011 +0100
     2.2 +++ b/tazwok	Fri Mar 04 19:50:26 2011 +0100
     2.3 @@ -147,6 +147,7 @@
     2.4  
     2.5  	# In case undigest is used, we need to upgrade system.
     2.6  	if [ "$undigest" ]; then
     2.7 +		use_undigest_scan_core
     2.8  		ref_PACKAGES_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION/packages
     2.9  		if [ -f $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf ] && \
    2.10  		grep -q ^USE_ONLINE_PKG $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf; then
    2.11 @@ -1346,6 +1347,13 @@
    2.12  	# Needed in some case as tazwok define RECEIPT at configuration time
    2.13  	# in this particular case it can broke the script.
    2.14  	unset RECEIPT
    2.15 +
    2.16 +	# If $packages_repository is the main one, configure few functions
    2.17 +	# to act as they should, without having loop on them (speed-up)
    2.18 +	if [ "${pkg_repository##*/}" = packages ]; then
    2.19 +		erase_package_info_extracmd="erase_package_info_main"
    2.20 +		get_packages_info_extracmd="erase_packages_info_main"
    2.21 +	fi		
    2.22  }
    2.23  
    2.24  erase_package_info()
    2.25 @@ -1361,7 +1369,11 @@
    2.26  	sed "/^$PACKAGE:/d" -i files.list
    2.27  	sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
    2.28  	sed "/ $(basename $pkg)$/d" -i packages.md5
    2.29 -	[ "$pkg_repository" != "$PACKAGES_REPOSITORY" ] && return 0	
    2.30 +	$erase_package_info_extracmd
    2.31 +}
    2.32 +
    2.33 +erase_package_info_main()
    2.34 +{
    2.35  	for i in wanted.txt depends.txt; do
    2.36  		[ -f $i ] || continue
    2.37  		sed "/^$PACKAGE\t/d" -i $i
    2.38 @@ -1413,14 +1425,14 @@
    2.39  
    2.40  	cd $pkg_repository
    2.41  	echo $(basename ${pkg%.tazpkg}) >> packages.list
    2.42 -	[ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
    2.43 -	echo "$package_md5" >> packages.md5
    2.44 -	unset package_md5
    2.45 +	md5sum $(basename $pkg) >> packages.md5
    2.46 +	$get_packages_info_extracmd
    2.47 +}
    2.48  
    2.49 -	if [ "$pkg_repository" = "$PACKAGES_REPOSITORY" ]; then
    2.50 -		[ "$WANTED" ] && echo -e "$PACKAGE\t$WANTED" >> wanted.txt
    2.51 -		echo -e "$PACKAGE\t "$DEPENDS" \t "$BUILD_DEPENDS" " >> package.txt
    2.52 -	fi
    2.53 +get_packages_info_main()
    2.54 +{
    2.55 +	[ "$WANTED" ] && echo -e "$PACKAGE\t$WANTED" >> wanted.txt
    2.56 +	echo -e "$PACKAGE\t "$DEPENDS" \t "$BUILD_DEPENDS" " >> package.txt
    2.57  }
    2.58  
    2.59  source_receipt()
    2.60 @@ -1589,11 +1601,7 @@
    2.61  
    2.62  look_for_dep()
    2.63  {
    2.64 -	if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
    2.65 -		grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2
    2.66 -	else
    2.67 -		grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2
    2.68 -	fi
    2.69 +	grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2
    2.70  }
    2.71  
    2.72  look_for_bdep()
    2.73 @@ -1603,75 +1611,38 @@
    2.74  
    2.75  look_for_all()
    2.76  {
    2.77 -	if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
    2.78 -		grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2,3 | sed 's/ 	 / /'
    2.79 -	else
    2.80 -		grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ 	 / /'
    2.81 -	fi
    2.82 +	grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ 	 / /'
    2.83  }
    2.84  
    2.85  look_for_rdep()
    2.86  {
    2.87  	fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
    2.88 -	if [ "$undigest" ]; then
    2.89 -		for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1); do
    2.90 -			if [ ! -f "WOK$/$rdep/receipt" ]; then
    2.91 -				echo "$rdep"
    2.92 -			fi
    2.93 -		done
    2.94 -	fi
    2.95  }
    2.96  
    2.97  look_for_rbdep()
    2.98  {
    2.99  	fgrep ' '$PACKAGE' ' $dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
   2.100 -	if [ "$undigest" ]; then
   2.101 -		for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
   2.102 -			if [ ! -f "WOK$/$rdep/receipt" ]; then
   2.103 -				echo "$rdep"
   2.104 -			fi
   2.105 -		done
   2.106 -	fi
   2.107  }
   2.108  
   2.109  # Return WANTED if it exists.
   2.110  look_for_wanted()
   2.111  {
   2.112 -	if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
   2.113 -		grep -m1 ^$PACKAGE$'\t' $ref_wan_db | cut -f 2
   2.114 -	else
   2.115 -		grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
   2.116 -	fi
   2.117 +	grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
   2.118  }
   2.119  
   2.120  # Return packages which wants PACKAGE.
   2.121  look_for_rwanted()
   2.122  {
   2.123  	grep $'\t'$PACKAGE$ $wan_db | cut -f 1
   2.124 -	if [ "$undigest" ]; then
   2.125 -		for rwanted in $(grep $'\t' $ref_wan_db | cut -f 1); do
   2.126 -			if [ ! -f "$WOK/$rwanted/receipt" ]; then
   2.127 -				echo "$rwanted"
   2.128 -			fi
   2.129 -		done
   2.130 -	fi
   2.131  }
   2.132  
   2.133  look_for_dev()
   2.134  {
   2.135  	WANTED=$(look_for_wanted)
   2.136  	if [ "$WANTED" ]; then
   2.137 -		if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
   2.138 -			grep -q ^$WANTED-dev$'\t' $ref_dep_db && echo $WANTED-dev
   2.139 -		else
   2.140 -			[ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
   2.141 -		fi
   2.142 +		[ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
   2.143  	fi
   2.144 -	if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
   2.145 -			grep -q ^$PACKAGE-dev$'\t' $ref_dep_db && echo $PACKAGE-dev
   2.146 -	else
   2.147 -		[ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
   2.148 -	fi
   2.149 +	[ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
   2.150  }
   2.151  
   2.152  with_dev()
   2.153 @@ -1692,10 +1663,83 @@
   2.154  
   2.155  use_wanted()
   2.156  {
   2.157 -for input in $(cat); do
   2.158 -	{ grep ^$input$'\t' $wan_db || echo $input
   2.159 -	} | sed 's/.*\t//'
   2.160 -done
   2.161 +	for input in $(cat); do
   2.162 +		{ grep ^$input$'\t' $wan_db || echo $input
   2.163 +		} | sed 's/.*\t//'
   2.164 +	done
   2.165 +}
   2.166 +
   2.167 +# Define how theses functions should act when using --undigest.
   2.168 +use_undigest_scan_core()
   2.169 +{
   2.170 +	look_for_dep()
   2.171 +	{
   2.172 +		if [ -f "$WOK/$PACKAGE/receipt" ]; then
   2.173 +			grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2	
   2.174 +		else
   2.175 +			grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2
   2.176 +		fi
   2.177 +	}
   2.178 +
   2.179 +	look_for_all()
   2.180 +	{
   2.181 +		if [ -f "$WOK/$PACKAGE/receipt" ]; then
   2.182 +			grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ 	 / /'
   2.183 +		else
   2.184 +			grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2,3 | sed 's/ 	 / /'
   2.185 +		fi
   2.186 +	}
   2.187 +
   2.188 +	look_for_rdep()
   2.189 +	{
   2.190 +		fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
   2.191 +		for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1); do
   2.192 +			[ -f "WOK$/$rdep/receipt" ] || echo "$rdep"
   2.193 +		done
   2.194 +	}
   2.195 +
   2.196 +	look_for_rbdep()
   2.197 +	{
   2.198 +		fgrep ' '$PACKAGE' ' $dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
   2.199 +		for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
   2.200 +			[ -f "WOK$/$rdep/receipt" ] || echo "$rdep"
   2.201 +		done
   2.202 +	}
   2.203 +
   2.204 +	look_for_wanted()
   2.205 +	{
   2.206 +		if [ -f "$WOK/$PACKAGE/receipt" ]; then
   2.207 +			grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
   2.208 +		else
   2.209 +			grep -m1 ^$PACKAGE$'\t' $ref_wan_db | cut -f 2
   2.210 +		fi
   2.211 +	}
   2.212 +
   2.213 +	look_for_rwanted()
   2.214 +	{
   2.215 +		if [ -f "$WOK/$PACKAGE/receipt" ]; then
   2.216 +			grep $'\t'$PACKAGE$ $wan_db | cut -f 1
   2.217 +		else
   2.218 +			grep $'\t'$PACKAGE$ $ref_wan_db | cut -f 1
   2.219 +		fi
   2.220 +	}
   2.221 +
   2.222 +	look_for_dev()
   2.223 +	{
   2.224 +		WANTED=$(look_for_wanted)
   2.225 +		if [ "$WANTED" ]; then
   2.226 +			if [ -f "$WOK/$WANTED/receipt" ]; then
   2.227 +				[ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
   2.228 +			else
   2.229 +				grep -q ^$WANTED-dev$'\t' $ref_dep_db && echo $WANTED-dev
   2.230 +			fi
   2.231 +		fi
   2.232 +		if [ -f "$WOK/$PACKAGE/receipt" ]; then
   2.233 +			[ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
   2.234 +		else
   2.235 +			grep -q ^$PACKAGE-dev$'\t' $ref_dep_db && echo $PACKAGE-dev
   2.236 +		fi
   2.237 +	}
   2.238  }
   2.239  
   2.240  ########################################################################