tazwok rev 195

Various code cleanup and improvement
author Antoine Bodin <gokhlayeh@slitaz.org>
date Tue Jan 25 02:29:37 2011 +0100 (2011-01-25)
parents 3736cce27b0a
children eabdb6079aec
files tazwok
line diff
     1.1 --- a/tazwok	Sun Jan 23 16:59:02 2011 +0100
     1.2 +++ b/tazwok	Tue Jan 25 02:29:37 2011 +0100
     1.3 @@ -199,7 +199,7 @@
     1.4  	# genpkg_rules: it maybe need something inside.
     1.5  	for i in $PACKAGE $(look_for_rwanted); do
     1.6  		sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \
     1.7 -			grep -q \$src && tazwok_warning "Sources will not be removed \
     1.8 +			fgrep -q '$src' && tazwok_warning "Sources will not be removed \
     1.9  because $i use \$src in his receipt." && return
    1.10  	done
    1.11  	
    1.12 @@ -275,7 +275,7 @@
    1.13  	rwanted=$(look_for_rwanted)
    1.14  
    1.15  	for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
    1.16 -		grep -v -e "Don't make the command fail" $(for i in $(look_for_rwanted); do echo " -e $i"; done))
    1.17 +		fgrep -v -e "Don't make the command fail" $(for i in $(look_for_rwanted); do echo " -e $i"; done))
    1.18  	do
    1.19  
    1.20  		# Delay the removing of previous cook depends if they are needed
    1.21 @@ -357,7 +357,7 @@
    1.22  	for var in $@; do
    1.23  		for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
    1.24  			[ -f $WOK/$pkg/receipt ] || continue
    1.25 -			grep -q "$var=" $WOK/$pkg/receipt && return 1
    1.26 +			fgrep -q "$var=" $WOK/$pkg/receipt && return 1
    1.27  		done
    1.28  	done
    1.29  	
    1.30 @@ -463,7 +463,7 @@
    1.31  						tar xf - -C $tmp_src
    1.32  				else
    1.33  					case "$TARBALL" in
    1.34 -						*zip|*xpi) ( cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL );;
    1.35 +						*zip|*xpi) { cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL; };;
    1.36  						*bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
    1.37  						*tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
    1.38  						*lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
    1.39 @@ -528,22 +528,15 @@
    1.40  		rm -f /tmp/config.site
    1.41  
    1.42  		# Free some RAM by cleaning cache if option is enabled.
    1.43 -		freeram=$(free | grep '^-/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
    1.44 -		#if [ "$clean_cache" = yes ] && [ "$freeram" -lt 524288 ]; then
    1.45 -		#	sync; echo 3 > /proc/sys/vm/drop_caches
    1.46 -		#	freeram=$(free | grep ^Total | tr -s ' ' | cut -f 4 -d ' ')
    1.47 -		#fi
    1.48 +		freeram=$(free | fgrep '-/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
    1.49  
    1.50  		# Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
    1.51  		# RAM are available.
    1.52 -		if [ "$CFLAGS" != "${CFLAGS/-pipe}" ] || \
    1.53 -			[ "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
    1.54 -
    1.55 -			if [ "$freeram" -lt 524288 ]; then
    1.56 -				tazwok_warning "Disabling -pipe compile flag because only $freeramb of RAM are available."
    1.57 +		if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
    1.58 +			"$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
    1.59 +				tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM are available."
    1.60  				CFLAGS="${CFLAGS/-pipe}"
    1.61  				CXXFLAGS="${CXXFLAGS/-pipe}"
    1.62 -			fi
    1.63  		fi
    1.64  		unset freeram
    1.65  
    1.66 @@ -722,7 +715,7 @@
    1.67  usr/local usr/sbin usr/share usr/src"
    1.68  	for i in `ls -d * usr/* 2>/dev/null`
    1.69  	do
    1.70 -		if ! echo $FSH | grep -q $i; then
    1.71 +		if ! echo $FSH | fgrep -q $i; then
    1.72  			echo "Wrong path: /$i" >&2
    1.73  			error=1
    1.74  		fi
    1.75 @@ -846,7 +839,7 @@
    1.76  	report step "Creating the list of files"
    1.77  	cd taz/$PACKAGE-$VERSION
    1.78    	LAST_FILE=""
    1.79 -  	( find fs -print; echo ) | while read file; do
    1.80 +  	{ find fs -print; echo; } | while read file; do
    1.81  		if [ "$LAST_FILE" ]; then
    1.82  			case "$file" in
    1.83  			$LAST_FILE/*)
    1.84 @@ -937,7 +930,7 @@
    1.85  	
    1.86  	# Restore package tree in case we want to browse it.
    1.87  	report step "Restoring original package tree"
    1.88 -	( zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma ) | cpio --quiet -id
    1.89 +	{ zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
    1.90  	rm fs.cpio.* && cd ..
    1.91  	
    1.92  	# Log process.
    1.93 @@ -1005,7 +998,7 @@
    1.94  	packages_db_start
    1.95  	unset RECEIPT
    1.96  	report step "Reading datas from all packages"
    1.97 -	for pkg in $(echo $pkg_repository/*.tazpkg | grep -v '\*'); do
    1.98 +	for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
    1.99  		get_packages_info
   1.100  	done
   1.101  	report end-step
   1.102 @@ -1037,9 +1030,8 @@
   1.103  	
   1.104  	# Look for removed/update packages.
   1.105  	for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
   1.106 -		pkg=$(echo $pkg_repository/`grep ^$PACKAGE- packages.list | sed 1!d`*.tazpkg | grep -v '\*')
   1.107 -		if [ ! "$pkg" ]; then
   1.108 -			pkg=$(grep ^$PACKAGE- packages.list | sed 1!d).tazpkg
   1.109 +		pkg="$(grep ^$PACKAGE- packages.list | sed 1!d).tazpkg"
   1.110 +		if ! [ -f "$pkg" ]; then
   1.111  			erase_package_info
   1.112  		else
   1.113  			echo $pkg >> $tmp/pkglist
   1.114 @@ -1051,8 +1043,8 @@
   1.115  	done
   1.116  	
   1.117  	# Look for new packages.
   1.118 -	for pkg in $(echo $pkg_repository/*.tazpkg | grep -v '\*'); do
   1.119 -		if ! grep -q ^$pkg$ $tmp/pkglist; then
   1.120 +	for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
   1.121 +		if ! fgrep "  ${pkg##*/}" $pkg_repository/packages.md5; then
   1.122  			get_packages_info
   1.123  		fi
   1.124  	done
   1.125 @@ -1119,7 +1111,7 @@
   1.126  	# Packages.equiv is used by tazpkg install to check depends
   1.127  	for i in $PROVIDE; do
   1.128  		DEST=""
   1.129 -		echo $i | grep -q : && DEST="${i#*:}:"
   1.130 +		echo $i | fgrep -q : && DEST="${i#*:}:"
   1.131  		if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
   1.132  			sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
   1.133  		else
   1.134 @@ -1169,11 +1161,6 @@
   1.135  	# Dont log this because lzma always output error.
   1.136  	lzma e files.list files.list.lzma
   1.137  	rm files.list 2>/dev/null
   1.138 -	if ! grep -q ^$pkg_repository$ $LOCALSTATE/mirror && \
   1.139 -		! { [ -d $LOCALSTATE/undigest ] && \
   1.140 -		grep -q ^$pkg_repository$ $LOCALSTATE/undigest/*/mirror; }; then
   1.141 -		tazpkg add-undigest $(basename `echo $pkg_repository | sed 's~/packages~~'`) $pkg_repository
   1.142 -	fi
   1.143  }
   1.144  
   1.145  ########################################################################
   1.146 @@ -1235,7 +1222,7 @@
   1.147  	while [ -s "$tmp/db" ]; do
   1.148  		status=start
   1.149  		for pkg in $(cut -f 1 $tmp/db); do
   1.150 -			 if ! grep -q ' '$pkg' ' $tmp/db; then
   1.151 +			 if ! fgrep -q ' '$pkg' ' $tmp/db; then
   1.152  				echo $pkg >> $tmp/cookorder
   1.153  				sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
   1.154  				status=proceed
   1.155 @@ -1323,9 +1310,9 @@
   1.156  
   1.157  look_for_rdep()
   1.158  {
   1.159 -	grep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
   1.160 +	fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
   1.161  	if [ "$undigest" ]; then
   1.162 -		for rdep in $(grep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do
   1.163 +		for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do
   1.164  			if [ ! -f "WOK$/$rdep/receipt" ]; then
   1.165  				echo "$rdep"
   1.166  			fi
   1.167 @@ -1335,11 +1322,11 @@
   1.168  
   1.169  look_for_rbdep()
   1.170  {
   1.171 -	grep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
   1.172 -		cut -f 1,3 | grep ' '$PACKAGE' ' | cut -f 1
   1.173 +	fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
   1.174 +		cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
   1.175  	if [ "$undigest" ]; then
   1.176 -		for rdep in $(grep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
   1.177 -			| cut -f 1,3 | grep ' '$PACKAGE' ' | cut -f 1); do
   1.178 +		for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
   1.179 +			| cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
   1.180  			if [ ! -f "WOK$/$rdep/receipt" ]; then
   1.181  				echo "$rdep"
   1.182  			fi
   1.183 @@ -1502,7 +1489,7 @@
   1.184  	rm $PACKAGES_REPOSITORY/commit 2>/dev/null
   1.185  	
   1.186  	# If there's a packages-incoming repository we need to check it too.
   1.187 -	for RECEIPT in $(echo $WOK/*/receipt | grep -v '\*'); do
   1.188 +	for RECEIPT in $(echo $WOK/*/receipt | fgrep -v '*'); do
   1.189  		source_receipt
   1.190  	
   1.191  		# We use md5 of cooking stuff in the packaged receipt to check
   1.192 @@ -1533,7 +1520,7 @@
   1.193  					# If md5sum check if ok, check for new files in
   1.194  					# cooking stuff.
   1.195  					for file in receipt description.txt $( [ -d stuff ] && find stuff); do
   1.196 -						if [ -f $file ] && ! grep -q ' '$file$ md5; then
   1.197 +						if [ -f $file ] && ! fgrep -q "  $file" md5; then
   1.198  							set_commited
   1.199  						fi
   1.200  					done
   1.201 @@ -1550,7 +1537,7 @@
   1.202  			echo "Commit: $PACKAGE ($VERSION)"
   1.203  			gen_cookmd5
   1.204  		}
   1.205 -		taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | grep -v '\*')
   1.206 +		taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
   1.207  		if [ -f $WOK/$PACKAGE/md5 ]; then
   1.208  			cd $WOK/$PACKAGE
   1.209  			check_for_commit_using_md5sum
   1.210 @@ -1558,8 +1545,8 @@
   1.211  			cd $taz_dir
   1.212  			check_for_commit_using_md5sum
   1.213  		else
   1.214 -			pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*')
   1.215 -			[ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*')
   1.216 +			pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
   1.217 +			[ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
   1.218  			if [ "$pkg" ]; then
   1.219  				get_pkg_files $pkg
   1.220  				check_for_commit_using_md5sum
   1.221 @@ -1652,38 +1639,6 @@
   1.222  	report end-step
   1.223  }
   1.224  
   1.225 -
   1.226 -
   1.227 -#remove_old_packages()
   1.228 -#{
   1.229 -	#report step "Removing old packages"
   1.230 -	#echo -n "" >> $tmp/oldpkg
   1.231 -	#if [ -f $INCOMING_REPOSITORY/packages.txt ]; then
   1.232 -		
   1.233 -	 #&& incoming=y
   1.234 -	#for RECEIPT in $(echo $WOK/*/receipt | grep -v '\*'); do
   1.235 -		#source_receipt
   1.236 -		## First look for package in packages-incoming.
   1.237 -		#if [ "$incoming" ]; then
   1.238 -			#pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*')
   1.239 -		#fi
   1.240 -		#if [ "$pkg" ]; then
   1.241 -			#echo $pkg >> $tmp/oldpkg
   1.242 -			## The package in PACKAGES_REPOSITORY, even if old, should not be removed yet.
   1.243 -			#echo $PACKAGES_REPOSITORY/$(grep ^$PACKAGE- $PACKAGES_REPOSITORY/packages.list 2>/dev/null)*.tazpkg >> $tmp/oldpkg
   1.244 -		#else
   1.245 -			#echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg >> $tmp/oldpkg
   1.246 -		#fi
   1.247 -	#done
   1.248 -	#for pkg in $(echo $PACKAGES_REPOSITORY/*.tazpkg | grep -v '\*') \
   1.249 -		#$(echo $INCOMING_REPOSITORY/*.tazpkg | grep -v '\*'); do
   1.250 -		#grep -q ^$pkg$ $tmp/oldpkg && continue
   1.251 -		#echo "Removing $pkg"
   1.252 -		##rm $pkg
   1.253 -	#done
   1.254 -	#rm $tmp/oldpkg
   1.255 -#}
   1.256 -
   1.257  check_for_incoming()
   1.258  {
   1.259  	[ -s $INCOMING_REPOSITORY/packages.txt ] || return
   1.260 @@ -1970,7 +1925,7 @@
   1.261  whoprovide()
   1.262  {
   1.263  	local i;
   1.264 -	for i in $(grep -l PROVIDE $WOK/*/receipt); do
   1.265 +	for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
   1.266  		. $i
   1.267  		case " $PROVIDE " in
   1.268  		*\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
   1.269 @@ -2101,11 +2056,11 @@
   1.270  					statically|linux-gate.so*|ld-*.so|*/ld-*.so)
   1.271  						continue;;
   1.272  					esac
   1.273 -					for dep in $(grep $lib files.list | cut -d: -f1); do
   1.274 +					for dep in $(fgrep $lib files.list | cut -d: -f1); do
   1.275  						case " $ALL_DEPENDS " in
   1.276  						*\ $dep\ *) continue 2;;
   1.277  						esac
   1.278 -						for vdep in $(grep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
   1.279 +						for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
   1.280  							case " $ALL_DEPENDS " in
   1.281  							*\ $vdep\ *) continue 3;;
   1.282  							esac
   1.283 @@ -2144,7 +2099,7 @@
   1.284  					BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
   1.285  					if [ "$VERSION" = "$WANTED" ]; then
   1.286  						# BASEVERSION is computed in receipt
   1.287 -						grep -q '_pkg=' $pkg/receipt &&
   1.288 +						fgrep -q '_pkg=' $pkg/receipt &&
   1.289  						BASEVERSION=$VERSION
   1.290  					fi
   1.291  					if [ "$VERSION" != "$BASEVERSION" ]; then
   1.292 @@ -2303,7 +2258,7 @@
   1.293  		echo ""
   1.294  		echo -e "\033[1mSearch result for :\033[0m $2"
   1.295  		echo "================================================================================"
   1.296 -		list=`ls -1 $WOK | grep $2`
   1.297 +		list=`ls -1 $WOK | fgrep $2`
   1.298  		for pkg in $list
   1.299  		do
   1.300  			. $WOK/$pkg/receipt
   1.301 @@ -2476,7 +2431,7 @@
   1.302  		cd $PACKAGES_REPOSITORY
   1.303  		for pkg in $(echo *.tazpkg); do
   1.304  			package_md5=$(md5sum $pkg)
   1.305 -			[ "$PACKAGE_md5" = "$(grep ' '$pkg$ packages.md5)" ] && continue
   1.306 +			[ "$package_md5" = "$(fgrep "  $pkg" packages.md5)" ] && continue
   1.307  			erase_package_info
   1.308  			get_packages_info
   1.309  		done
   1.310 @@ -2596,7 +2551,7 @@
   1.311  	hgup)
   1.312  		# Pull and update a Hg wok.
   1.313  		get_tazwok_config
   1.314 -		if ls -l $WOK/.hg/hgrc | grep -q "root"; then
   1.315 +		if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
   1.316  			check_root
   1.317  		fi
   1.318  		cd $WOK
   1.319 @@ -2611,7 +2566,7 @@
   1.320  		for pkg in $WOK/*
   1.321  		do
   1.322  			. $pkg/receipt
   1.323 -			if ! grep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
   1.324 +			if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
   1.325  				echo "$MAINTAINER" >> /tmp/slitaz-maintainers
   1.326  				echo "$MAINTAINER"
   1.327  			fi
   1.328 @@ -2634,7 +2589,7 @@
   1.329  		for pkg in $WOK/*
   1.330  		do
   1.331  			. $pkg/receipt
   1.332 -			if echo "$MAINTAINER" | grep -q "$2"; then
   1.333 +			if echo "$MAINTAINER" | fgrep -q "$2"; then
   1.334  				echo "$PACKAGE"
   1.335  				packages=$(($PACKAGEs+1))
   1.336  			fi