# HG changeset patch # User Antoine Bodin # Date 1295918977 -3600 # Node ID 70e85df2121b3153b812ef64e11497d825d2aa67 # Parent 3736cce27b0a93f9139245511f14cf76b28c6731 Various code cleanup and improvement diff -r 3736cce27b0a -r 70e85df2121b tazwok --- a/tazwok Sun Jan 23 16:59:02 2011 +0100 +++ b/tazwok Tue Jan 25 02:29:37 2011 +0100 @@ -199,7 +199,7 @@ # genpkg_rules: it maybe need something inside. for i in $PACKAGE $(look_for_rwanted); do sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \ - grep -q \$src && tazwok_warning "Sources will not be removed \ + fgrep -q '$src' && tazwok_warning "Sources will not be removed \ because $i use \$src in his receipt." && return done @@ -275,7 +275,7 @@ rwanted=$(look_for_rwanted) for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \ - grep -v -e "Don't make the command fail" $(for i in $(look_for_rwanted); do echo " -e $i"; done)) + fgrep -v -e "Don't make the command fail" $(for i in $(look_for_rwanted); do echo " -e $i"; done)) do # Delay the removing of previous cook depends if they are needed @@ -357,7 +357,7 @@ for var in $@; do for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do [ -f $WOK/$pkg/receipt ] || continue - grep -q "$var=" $WOK/$pkg/receipt && return 1 + fgrep -q "$var=" $WOK/$pkg/receipt && return 1 done done @@ -463,7 +463,7 @@ tar xf - -C $tmp_src else case "$TARBALL" in - *zip|*xpi) ( cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL );; + *zip|*xpi) { cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL; };; *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;; *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;; *lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;; @@ -528,22 +528,15 @@ rm -f /tmp/config.site # Free some RAM by cleaning cache if option is enabled. - freeram=$(free | grep '^-/+ buffers' | tr -s ' ' | cut -f 4 -d ' ') - #if [ "$clean_cache" = yes ] && [ "$freeram" -lt 524288 ]; then - # sync; echo 3 > /proc/sys/vm/drop_caches - # freeram=$(free | grep ^Total | tr -s ' ' | cut -f 4 -d ' ') - #fi + freeram=$(free | fgrep '-/+ buffers' | tr -s ' ' | cut -f 4 -d ' ') # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free # RAM are available. - if [ "$CFLAGS" != "${CFLAGS/-pipe}" ] || \ - [ "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then - - if [ "$freeram" -lt 524288 ]; then - tazwok_warning "Disabling -pipe compile flag because only $freeramb of RAM are available." + if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \ + "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then + tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM are available." CFLAGS="${CFLAGS/-pipe}" CXXFLAGS="${CXXFLAGS/-pipe}" - fi fi unset freeram @@ -722,7 +715,7 @@ usr/local usr/sbin usr/share usr/src" for i in `ls -d * usr/* 2>/dev/null` do - if ! echo $FSH | grep -q $i; then + if ! echo $FSH | fgrep -q $i; then echo "Wrong path: /$i" >&2 error=1 fi @@ -846,7 +839,7 @@ report step "Creating the list of files" cd taz/$PACKAGE-$VERSION LAST_FILE="" - ( find fs -print; echo ) | while read file; do + { find fs -print; echo; } | while read file; do if [ "$LAST_FILE" ]; then case "$file" in $LAST_FILE/*) @@ -937,7 +930,7 @@ # Restore package tree in case we want to browse it. report step "Restoring original package tree" - ( zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma ) | cpio --quiet -id + { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id rm fs.cpio.* && cd .. # Log process. @@ -1005,7 +998,7 @@ packages_db_start unset RECEIPT report step "Reading datas from all packages" - for pkg in $(echo $pkg_repository/*.tazpkg | grep -v '\*'); do + for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do get_packages_info done report end-step @@ -1037,9 +1030,8 @@ # Look for removed/update packages. for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do - pkg=$(echo $pkg_repository/`grep ^$PACKAGE- packages.list | sed 1!d`*.tazpkg | grep -v '\*') - if [ ! "$pkg" ]; then - pkg=$(grep ^$PACKAGE- packages.list | sed 1!d).tazpkg + pkg="$(grep ^$PACKAGE- packages.list | sed 1!d).tazpkg" + if ! [ -f "$pkg" ]; then erase_package_info else echo $pkg >> $tmp/pkglist @@ -1051,8 +1043,8 @@ done # Look for new packages. - for pkg in $(echo $pkg_repository/*.tazpkg | grep -v '\*'); do - if ! grep -q ^$pkg$ $tmp/pkglist; then + for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do + if ! fgrep " ${pkg##*/}" $pkg_repository/packages.md5; then get_packages_info fi done @@ -1119,7 +1111,7 @@ # Packages.equiv is used by tazpkg install to check depends for i in $PROVIDE; do DEST="" - echo $i | grep -q : && DEST="${i#*:}:" + echo $i | fgrep -q : && DEST="${i#*:}:" if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv else @@ -1169,11 +1161,6 @@ # Dont log this because lzma always output error. lzma e files.list files.list.lzma rm files.list 2>/dev/null - if ! grep -q ^$pkg_repository$ $LOCALSTATE/mirror && \ - ! { [ -d $LOCALSTATE/undigest ] && \ - grep -q ^$pkg_repository$ $LOCALSTATE/undigest/*/mirror; }; then - tazpkg add-undigest $(basename `echo $pkg_repository | sed 's~/packages~~'`) $pkg_repository - fi } ######################################################################## @@ -1235,7 +1222,7 @@ while [ -s "$tmp/db" ]; do status=start for pkg in $(cut -f 1 $tmp/db); do - if ! grep -q ' '$pkg' ' $tmp/db; then + if ! fgrep -q ' '$pkg' ' $tmp/db; then echo $pkg >> $tmp/cookorder sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db status=proceed @@ -1323,9 +1310,9 @@ look_for_rdep() { - grep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1 + fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1 if [ "$undigest" ]; then - for rdep in $(grep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do + for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do if [ ! -f "WOK$/$rdep/receipt" ]; then echo "$rdep" fi @@ -1335,11 +1322,11 @@ look_for_rbdep() { - grep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \ - cut -f 1,3 | grep ' '$PACKAGE' ' | cut -f 1 + fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \ + cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1 if [ "$undigest" ]; then - for rdep in $(grep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \ - | cut -f 1,3 | grep ' '$PACKAGE' ' | cut -f 1); do + for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \ + | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do if [ ! -f "WOK$/$rdep/receipt" ]; then echo "$rdep" fi @@ -1502,7 +1489,7 @@ rm $PACKAGES_REPOSITORY/commit 2>/dev/null # If there's a packages-incoming repository we need to check it too. - for RECEIPT in $(echo $WOK/*/receipt | grep -v '\*'); do + for RECEIPT in $(echo $WOK/*/receipt | fgrep -v '*'); do source_receipt # We use md5 of cooking stuff in the packaged receipt to check @@ -1533,7 +1520,7 @@ # If md5sum check if ok, check for new files in # cooking stuff. for file in receipt description.txt $( [ -d stuff ] && find stuff); do - if [ -f $file ] && ! grep -q ' '$file$ md5; then + if [ -f $file ] && ! fgrep -q " $file" md5; then set_commited fi done @@ -1550,7 +1537,7 @@ echo "Commit: $PACKAGE ($VERSION)" gen_cookmd5 } - taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | grep -v '\*') + taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*') if [ -f $WOK/$PACKAGE/md5 ]; then cd $WOK/$PACKAGE check_for_commit_using_md5sum @@ -1558,8 +1545,8 @@ cd $taz_dir check_for_commit_using_md5sum else - pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*') - [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*') + pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*') + [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*') if [ "$pkg" ]; then get_pkg_files $pkg check_for_commit_using_md5sum @@ -1652,38 +1639,6 @@ report end-step } - - -#remove_old_packages() -#{ - #report step "Removing old packages" - #echo -n "" >> $tmp/oldpkg - #if [ -f $INCOMING_REPOSITORY/packages.txt ]; then - - #&& incoming=y - #for RECEIPT in $(echo $WOK/*/receipt | grep -v '\*'); do - #source_receipt - ## First look for package in packages-incoming. - #if [ "$incoming" ]; then - #pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*') - #fi - #if [ "$pkg" ]; then - #echo $pkg >> $tmp/oldpkg - ## The package in PACKAGES_REPOSITORY, even if old, should not be removed yet. - #echo $PACKAGES_REPOSITORY/$(grep ^$PACKAGE- $PACKAGES_REPOSITORY/packages.list 2>/dev/null)*.tazpkg >> $tmp/oldpkg - #else - #echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg >> $tmp/oldpkg - #fi - #done - #for pkg in $(echo $PACKAGES_REPOSITORY/*.tazpkg | grep -v '\*') \ - #$(echo $INCOMING_REPOSITORY/*.tazpkg | grep -v '\*'); do - #grep -q ^$pkg$ $tmp/oldpkg && continue - #echo "Removing $pkg" - ##rm $pkg - #done - #rm $tmp/oldpkg -#} - check_for_incoming() { [ -s $INCOMING_REPOSITORY/packages.txt ] || return @@ -1970,7 +1925,7 @@ whoprovide() { local i; - for i in $(grep -l PROVIDE $WOK/*/receipt); do + for i in $(fgrep -l PROVIDE $WOK/*/receipt); do . $i case " $PROVIDE " in *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));; @@ -2101,11 +2056,11 @@ statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;; esac - for dep in $(grep $lib files.list | cut -d: -f1); do + for dep in $(fgrep $lib files.list | cut -d: -f1); do case " $ALL_DEPENDS " in *\ $dep\ *) continue 2;; esac - for vdep in $(grep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do + for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do case " $ALL_DEPENDS " in *\ $vdep\ *) continue 3;; esac @@ -2144,7 +2099,7 @@ BASEVERSION=$(. $WANTED/receipt ; echo $VERSION) if [ "$VERSION" = "$WANTED" ]; then # BASEVERSION is computed in receipt - grep -q '_pkg=' $pkg/receipt && + fgrep -q '_pkg=' $pkg/receipt && BASEVERSION=$VERSION fi if [ "$VERSION" != "$BASEVERSION" ]; then @@ -2303,7 +2258,7 @@ echo "" echo -e "\033[1mSearch result for :\033[0m $2" echo "================================================================================" - list=`ls -1 $WOK | grep $2` + list=`ls -1 $WOK | fgrep $2` for pkg in $list do . $WOK/$pkg/receipt @@ -2476,7 +2431,7 @@ cd $PACKAGES_REPOSITORY for pkg in $(echo *.tazpkg); do package_md5=$(md5sum $pkg) - [ "$PACKAGE_md5" = "$(grep ' '$pkg$ packages.md5)" ] && continue + [ "$package_md5" = "$(fgrep " $pkg" packages.md5)" ] && continue erase_package_info get_packages_info done @@ -2596,7 +2551,7 @@ hgup) # Pull and update a Hg wok. get_tazwok_config - if ls -l $WOK/.hg/hgrc | grep -q "root"; then + if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then check_root fi cd $WOK @@ -2611,7 +2566,7 @@ for pkg in $WOK/* do . $pkg/receipt - if ! grep -q "$MAINTAINER" /tmp/slitaz-maintainers; then + if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then echo "$MAINTAINER" >> /tmp/slitaz-maintainers echo "$MAINTAINER" fi @@ -2634,7 +2589,7 @@ for pkg in $WOK/* do . $pkg/receipt - if echo "$MAINTAINER" | grep -q "$2"; then + if echo "$MAINTAINER" | fgrep -q "$2"; then echo "$PACKAGE" packages=$(($PACKAGEs+1)) fi