tazpkg rev 409 4.2

Replace grep by fgrep when possible to speed-up a little things
author Antoine Bodin <gokhlayeh@slitaz.org>
date Tue Jan 25 00:38:34 2011 +0100 (2011-01-25)
parents 05010d8d951b
children 9af577b905a7
files tazpkg
line diff
     1.1 --- a/tazpkg	Tue Jan 25 00:24:26 2011 +0100
     1.2 +++ b/tazpkg	Tue Jan 25 00:38:34 2011 +0100
     1.3 @@ -237,7 +237,7 @@
     1.4  {
     1.5  	for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \
     1.6  		   $LOCALSTATE/undigest/*/packages.equiv | sed "s/^$1=//"); do
     1.7 -		if echo $i | grep -q : ; then
     1.8 +		if echo $i | fgrep -q : ; then
     1.9  			# format 'alternative:newname'
    1.10  			# if alternative is installed then substitute newname
    1.11  			if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
    1.12 @@ -264,7 +264,7 @@
    1.13  	for i in $(for rep in $priority; do 
    1.14  		grep -hs "^$1=" $rep/packages.equiv
    1.15  		done | sed "s/^$1=//"); do
    1.16 -		if echo $i | grep -q : ; then
    1.17 +		if echo $i | fgrep -q : ; then
    1.18  			# format 'alternative:newname'
    1.19  			# if alternative is installed then substitute newname
    1.20  			if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
    1.21 @@ -336,7 +336,7 @@
    1.22  {
    1.23  	local extra
    1.24  	[ "$1" = "Installed" ] && \
    1.25 -	extra=" - $(grep $PACKAGE-$VERSION $LOCALSTATE/installed.md5 | awk '{ print $1 }')"
    1.26 +	extra=" - $(fgrep $PACKAGE-$VERSION $LOCALSTATE/installed.md5 | awk '{ print $1 }')"
    1.27  	[ -e $LOG ] || touch $LOG
    1.28  	DATE=`date +'%F %T'`
    1.29  	[ -w $LOG ] &&
    1.30 @@ -478,7 +478,7 @@
    1.31  		while read file; do
    1.32  			grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue
    1.33  			for i in $(cat $PACKAGE/modifiers 2> /dev/null ;
    1.34 -			    grep -sl $PACKAGE */modifiers | cut -d/ -f1 ); do
    1.35 +			    fgrep -sl $PACKAGE */modifiers | cut -d/ -f1 ); do
    1.36  				grep -qs "^$(echo $file | grepesc)$" $i/files.list && continue 2
    1.37  			done
    1.38  			echo $file
    1.39 @@ -486,7 +486,7 @@
    1.40  	fi
    1.41  	# Remember modified packages
    1.42  	{ check=false
    1.43 -	  for i in $(grep -v '\[' $TMP_DIR/files.list); do
    1.44 +	  for i in $(fgrep -v [ $TMP_DIR/files.list); do
    1.45  		[ -e "$ROOT$i" ] || continue
    1.46  		[ -d "$ROOT$i" ] && continue
    1.47  		echo "- $i"
    1.48 @@ -576,11 +576,11 @@
    1.49  		post_install $ROOT
    1.50  	fi
    1.51   	# Update-desktop-database if needed.
    1.52 -	if [ "$(grep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | grep /usr/share/applications/)" ]; then
    1.53 +	if [ "$(fgrep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | fgrep /usr/share/applications/)" ]; then
    1.54  		updatedesktopdb=yes
    1.55  	fi
    1.56  	# Update-mime-database if needed.
    1.57 -	if [ "$(grep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
    1.58 +	if [ "$(fgrep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
    1.59  		updatemimedb=yes
    1.60  	fi
    1.61  	cd $TOP_DIR
    1.62 @@ -957,7 +957,7 @@
    1.63  	*\ $i\ *) continue;;
    1.64  	esac
    1.65  	ALL_DEPS="$ALL_DEPS $i"
    1.66 -	[ -n "$2" ] && echo "$2$i ($(grep -A 3 $i $LOCALSTATE/packages.txt \
    1.67 +	[ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $LOCALSTATE/packages.txt \
    1.68  				     | tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))"
    1.69  	[ -f $i/receipt ] || continue
    1.70  	DEPENDS=""
    1.71 @@ -999,7 +999,7 @@
    1.72  	echo -n $spc | sed 's/=/ /g'
    1.73  	echo -n $pkg
    1.74  	echo -n ' ('
    1.75 -	grep -A 3 $pkg $LOCALSTATE/packages.txt  | tail -1 | \
    1.76 +	fgrep -A 3 $pkg $LOCALSTATE/packages.txt  | tail -1 | \
    1.77  				    sed 's/.*(\([^ ]*\).*/\1)/'
    1.78  done
    1.79  }
    1.80 @@ -1037,7 +1037,7 @@
    1.81  				continue;;
    1.82  			esac
    1.83  			find $TMP_DIR/$file/fs | grep -q /$lib$ && continue
    1.84 -			for dep in $(grep $lib files.list | cut -d: -f1); do
    1.85 +			for dep in $(fgrep $lib files.list | cut -d: -f1); do
    1.86  				case " $DEFAULT_DEPENDS " in
    1.87  				*\ $dep\ *) continue 2;;
    1.88  				esac
    1.89 @@ -2121,7 +2121,7 @@
    1.90  			zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \
    1.91  				{ cd fs; cpio -idm --quiet; }
    1.92  		fi
    1.93 -		if grep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
    1.94 +		if fgrep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
    1.95  			. $INSTALLED/$PACKAGE/receipt
    1.96  			repack_cleanup fs
    1.97  		fi
    1.98 @@ -2232,7 +2232,7 @@
    1.99  			suffix=$(head -1 mirror)
   1.100  			suffix=packages${suffix#*/packages}
   1.101  			for i in $(cat mirrors 2> /dev/null); do
   1.102 -				grep -qs $i mirror || echo $i$suffix >> mirror
   1.103 +				fgrep -qs $i mirror || echo $i$suffix >> mirror
   1.104  			done
   1.105  			if [ -f "packages.list.bak" ]; then
   1.106  				diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
   1.107 @@ -2266,7 +2266,7 @@
   1.108  		check_root
   1.109  		cd $LOCALSTATE
   1.110  		while read md5 file ; do
   1.111 -			grep -qs "$md5  $file" packages.md5 && continue
   1.112 +			fgrep -qs "$md5  $file" packages.md5 && continue
   1.113  			for i in 1 2 3 4 5; do
   1.114  				file=${file%-*}
   1.115  				[ -d installed/$file ] || continue
   1.116 @@ -2330,8 +2330,8 @@
   1.117  					# we just check for equality.
   1.118  					RELEASE=""
   1.119  					if [ -f installed.md5 -a -f packages.md5 ]; then
   1.120 -						current_md5=$(grep -s "  $PACKAGE-$VERSION" installed.md5 | awk '{ print $1 }')
   1.121 -						new_md5=$(grep -hs "  $PACKAGE-$VERSION" packages.md5 undigest/*/packages.md5 | head -1 | awk '{ print $1 }')
   1.122 +						current_md5=$(fgrep -s "  $PACKAGE-$VERSION" installed.md5 | awk '{ print $1 }')
   1.123 +						new_md5=$(fgrep -hs "  $PACKAGE-$VERSION" packages.md5 undigest/*/packages.md5 | head -1 | awk '{ print $1 }')
   1.124  						[ -n "$current_md5" ] && [ -n "$new_md5" ] &&
   1.125  						[ "$current_md5" != "$new_md5" ] && RELEASE=$(gettext "build")
   1.126  					fi
   1.127 @@ -2584,7 +2584,7 @@
   1.128  		check_for_package_in_list
   1.129  		echo ""
   1.130  		if [ -f $PACKAGE.tazpkg ]; then
   1.131 -			if [ "$(md5sum $PACKAGE.tazpkg)" != "$(grep "  $PACKAGE.tazpkg$" /var/lib/tazpkg/packages.md5)" ]; then
   1.132 +			if [ "$(md5sum $PACKAGE.tazpkg)" != "$(fgrep "  $PACKAGE.tazpkg" /var/lib/tazpkg/packages.md5)" ]; then
   1.133  				rm -f $PACKAGE.tazpkg
   1.134  				download $PACKAGE.tazpkg
   1.135  			fi
   1.136 @@ -2628,11 +2628,11 @@
   1.137  		if [ -f "$PACKAGE.tazpkg" ]; then
   1.138  			eval_gettext "\$PACKAGE already in the cache : \$CACHE_DIR"; echo
   1.139  			# Check package download was finished
   1.140 -			tail -c 2k $PACKAGE.tazpkg | grep -q 00000000TRAILER || {
   1.141 +			tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
   1.142  				eval_gettext "Continuing \$PACKAGE download"; echo
   1.143  				download $PACKAGE.tazpkg
   1.144  			}
   1.145 -			if [ "$(md5sum $PACKAGE.tazpkg)" != "$(grep "  $PACKAGE.tazpkg$" /var/lib/tazpkg/packages.md5)" ]; then
   1.146 +			if [ "$(md5sum $PACKAGE.tazpkg)" != "$(fgrep "  $PACKAGE.tazpkg" /var/lib/tazpkg/packages.md5)" ]; then
   1.147  				rm -f $PACKAGE.tazpkg
   1.148  				download $PACKAGE.tazpkg
   1.149  			fi