# HG changeset patch # User Antoine Bodin # Date 1295912314 -3600 # Node ID 219330eece9fb85afe4b15c2124f9f0ac8f8bd72 # Parent 05010d8d951b1a99773109cc8f99cb6ed2b2e5c4 Replace grep by fgrep when possible to speed-up a little things diff -r 05010d8d951b -r 219330eece9f tazpkg --- a/tazpkg Tue Jan 25 00:24:26 2011 +0100 +++ b/tazpkg Tue Jan 25 00:38:34 2011 +0100 @@ -237,7 +237,7 @@ { for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \ $LOCALSTATE/undigest/*/packages.equiv | sed "s/^$1=//"); do - if echo $i | grep -q : ; then + if echo $i | fgrep -q : ; then # format 'alternative:newname' # if alternative is installed then substitute newname if [ -f $2$INSTALLED/${i%:*}/receipt ]; then @@ -264,7 +264,7 @@ for i in $(for rep in $priority; do grep -hs "^$1=" $rep/packages.equiv done | sed "s/^$1=//"); do - if echo $i | grep -q : ; then + if echo $i | fgrep -q : ; then # format 'alternative:newname' # if alternative is installed then substitute newname if [ -f $2$INSTALLED/${i%:*}/receipt ]; then @@ -336,7 +336,7 @@ { local extra [ "$1" = "Installed" ] && \ - extra=" - $(grep $PACKAGE-$VERSION $LOCALSTATE/installed.md5 | awk '{ print $1 }')" + extra=" - $(fgrep $PACKAGE-$VERSION $LOCALSTATE/installed.md5 | awk '{ print $1 }')" [ -e $LOG ] || touch $LOG DATE=`date +'%F %T'` [ -w $LOG ] && @@ -478,7 +478,7 @@ while read file; do grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue for i in $(cat $PACKAGE/modifiers 2> /dev/null ; - grep -sl $PACKAGE */modifiers | cut -d/ -f1 ); do + fgrep -sl $PACKAGE */modifiers | cut -d/ -f1 ); do grep -qs "^$(echo $file | grepesc)$" $i/files.list && continue 2 done echo $file @@ -486,7 +486,7 @@ fi # Remember modified packages { check=false - for i in $(grep -v '\[' $TMP_DIR/files.list); do + for i in $(fgrep -v [ $TMP_DIR/files.list); do [ -e "$ROOT$i" ] || continue [ -d "$ROOT$i" ] && continue echo "- $i" @@ -576,11 +576,11 @@ post_install $ROOT fi # Update-desktop-database if needed. - if [ "$(grep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | grep /usr/share/applications/)" ]; then + if [ "$(fgrep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | fgrep /usr/share/applications/)" ]; then updatedesktopdb=yes fi # Update-mime-database if needed. - if [ "$(grep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then + if [ "$(fgrep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then updatemimedb=yes fi cd $TOP_DIR @@ -957,7 +957,7 @@ *\ $i\ *) continue;; esac ALL_DEPS="$ALL_DEPS $i" - [ -n "$2" ] && echo "$2$i ($(grep -A 3 $i $LOCALSTATE/packages.txt \ + [ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $LOCALSTATE/packages.txt \ | tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))" [ -f $i/receipt ] || continue DEPENDS="" @@ -999,7 +999,7 @@ echo -n $spc | sed 's/=/ /g' echo -n $pkg echo -n ' (' - grep -A 3 $pkg $LOCALSTATE/packages.txt | tail -1 | \ + fgrep -A 3 $pkg $LOCALSTATE/packages.txt | tail -1 | \ sed 's/.*(\([^ ]*\).*/\1)/' done } @@ -1037,7 +1037,7 @@ continue;; esac find $TMP_DIR/$file/fs | grep -q /$lib$ && continue - for dep in $(grep $lib files.list | cut -d: -f1); do + for dep in $(fgrep $lib files.list | cut -d: -f1); do case " $DEFAULT_DEPENDS " in *\ $dep\ *) continue 2;; esac @@ -2121,7 +2121,7 @@ zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \ { cd fs; cpio -idm --quiet; } fi - if grep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then + if fgrep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then . $INSTALLED/$PACKAGE/receipt repack_cleanup fs fi @@ -2232,7 +2232,7 @@ suffix=$(head -1 mirror) suffix=packages${suffix#*/packages} for i in $(cat mirrors 2> /dev/null); do - grep -qs $i mirror || echo $i$suffix >> mirror + fgrep -qs $i mirror || echo $i$suffix >> mirror done if [ -f "packages.list.bak" ]; then diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff @@ -2266,7 +2266,7 @@ check_root cd $LOCALSTATE while read md5 file ; do - grep -qs "$md5 $file" packages.md5 && continue + fgrep -qs "$md5 $file" packages.md5 && continue for i in 1 2 3 4 5; do file=${file%-*} [ -d installed/$file ] || continue @@ -2330,8 +2330,8 @@ # we just check for equality. RELEASE="" if [ -f installed.md5 -a -f packages.md5 ]; then - current_md5=$(grep -s " $PACKAGE-$VERSION" installed.md5 | awk '{ print $1 }') - new_md5=$(grep -hs " $PACKAGE-$VERSION" packages.md5 undigest/*/packages.md5 | head -1 | awk '{ print $1 }') + current_md5=$(fgrep -s " $PACKAGE-$VERSION" installed.md5 | awk '{ print $1 }') + new_md5=$(fgrep -hs " $PACKAGE-$VERSION" packages.md5 undigest/*/packages.md5 | head -1 | awk '{ print $1 }') [ -n "$current_md5" ] && [ -n "$new_md5" ] && [ "$current_md5" != "$new_md5" ] && RELEASE=$(gettext "build") fi @@ -2584,7 +2584,7 @@ check_for_package_in_list echo "" if [ -f $PACKAGE.tazpkg ]; then - if [ "$(md5sum $PACKAGE.tazpkg)" != "$(grep " $PACKAGE.tazpkg$" /var/lib/tazpkg/packages.md5)" ]; then + if [ "$(md5sum $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" /var/lib/tazpkg/packages.md5)" ]; then rm -f $PACKAGE.tazpkg download $PACKAGE.tazpkg fi @@ -2628,11 +2628,11 @@ if [ -f "$PACKAGE.tazpkg" ]; then eval_gettext "\$PACKAGE already in the cache : \$CACHE_DIR"; echo # Check package download was finished - tail -c 2k $PACKAGE.tazpkg | grep -q 00000000TRAILER || { + tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || { eval_gettext "Continuing \$PACKAGE download"; echo download $PACKAGE.tazpkg } - if [ "$(md5sum $PACKAGE.tazpkg)" != "$(grep " $PACKAGE.tazpkg$" /var/lib/tazpkg/packages.md5)" ]; then + if [ "$(md5sum $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" /var/lib/tazpkg/packages.md5)" ]; then rm -f $PACKAGE.tazpkg download $PACKAGE.tazpkg fi