pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/36298 (improvements for pkgtools/pkg_chk)



The following reply was made to PR pkg/36298; it has been noted by GNATS.

From: Aleksey Cheusov <cheusov%tut.by@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: abs%NetBSD.org@localhost, pkg-manager%netbsd.org@localhost, 
pkgsrc-bugs%netbsd.org@localhost,
        gnats-admin%netbsd.org@localhost, wiz%netbsd.org@localhost
Subject: Re: pkg/36298 (improvements for pkgtools/pkg_chk)
Date: Wed, 20 Jun 2007 21:10:41 +0300

 --=-=-=
 
 > Synopsis: improvements for pkgtools/pkg_chk
 
 New patch is in attachment.
 
 Cache format is changed to that of pkg_summary.gz.
 External tool (wip/pkg_update_summary)
 discussed in pkgsrc-users@ (Subject: pkg_summary)
 is used for keeping pkg_summary.gz up-to-date
 
 
 --=-=-=
 Content-Type: text/x-patch
 Content-Disposition: attachment; filename=pkg_chk_summary.diff
 Content-Description: patch for using/updating pkg_summary.gz
 
 ? pkg_chk-1.85.diff
 ? pkg_chk_summary.diff
 Index: Makefile
 ===================================================================
 RCS file: /cvsroot/pkgsrc/pkgtools/pkg_chk/Makefile,v
 retrieving revision 1.54
 diff -u -r1.54 Makefile
 --- Makefile   19 Jun 2007 16:08:47 -0000      1.54
 +++ Makefile   20 Jun 2007 18:00:37 -0000
 @@ -12,6 +12,8 @@
  
  PKG_INSTALLATION_TYPES=       overwrite pkgviews
  
 +DEPENDS+=     pkg_update_summary-[0-9]*:../../wip/pkg_update_summary
 +
  WRKSRC=               ${WRKDIR}
  EXTRACT_ONLY= # empty
  USE_LANGUAGES=        # empty
 Index: files/pkg_chk.sh
 ===================================================================
 RCS file: /cvsroot/pkgsrc/pkgtools/pkg_chk/files/pkg_chk.sh,v
 retrieving revision 1.49
 diff -u -r1.49 pkg_chk.sh
 --- files/pkg_chk.sh   19 Jun 2007 13:45:50 -0000      1.49
 +++ files/pkg_chk.sh   20 Jun 2007 18:00:37 -0000
 @@ -176,18 +176,27 @@
        extract_make_vars Makefile \
                AWK GREP GZIP_CMD ID PACKAGES PKGCHK_CONF PKGCHK_NOTAGS \
                PKGCHK_TAGS PKGCHK_UPDATE_CONF PKG_ADD PKG_DBDIR PKG_DELETE \
 -              PKG_INFO PKG_SUFX SED SORT SU_CMD TSORT
 +              PKG_INFO PKG_SUFX SED SORT SU_CMD TSORT PKG_BIN_CACHE
        if [ -z "$PACKAGES" ];then
            PACKAGES=$PKGSRCDIR/packages
        fi
      elif [ $MAKECONF != /dev/null ] ; then
        extract_make_vars $MAKECONF PACKAGES PKGCHK_CONF PKGCHK_UPDATE_CONF \
 -                      PKGCHK_TAGS PKGCHK_NOTAGS PKG_SUFX
 +                      PKGCHK_TAGS PKGCHK_NOTAGS PKG_SUFX PKG_BIN_CACHE
        if [ -z "$PACKAGES" ] ; then
            PACKAGES=`pwd`
        fi
      fi
  
 +    # compress and uncompress commands
 +    if echo "$PKG_BIN_CACHE" | $GREP '[.]gz$' > /dev/null; then
 +      COMPRESS="$GZIP_CMD -c"
 +      DECOMPRESS="$GZIP_CMD -dc"
 +    else
 +      COMPRESS='cat'
 +      DECOMPRESS='cat'
 +    fi
 +
      # .tgz/.tbz to regexp
      PKG_SUFX_RE=`echo $PKG_SUFX | sed 's/[.]/[.]/'`
  
 @@ -680,6 +689,9 @@
  fi
  
  MY_TMPDIR=`mktemp -d ${TMPDIR-/tmp}/${0##*/}.XXXXXX`
 +if [ -z "$MY_TMPDIR" ]; then
 +    exit 1
 +fi
  MY_TMPFILE=$MY_TMPDIR/tmp
  
  # Hide PKG_PATH to avoid breakage in 'make' calls
 @@ -726,7 +738,7 @@
  fi
  
  if [ -n "$opt_L" ] ; then
 -    rm -f $opt_L
 +    printf '' > $opt_L
  fi
  
  basedir=$(pwd)
 @@ -741,6 +753,40 @@
      PACKAGES="$PACKAGES/All"
  fi
  
 +list_bin_pkgs (){
 +    ls -t $PACKAGES | grep "$PKG_SUFX_RE"'$' |
 +    awk "{print \"$PACKAGES/\" \$0}"
 +}
 +
 +bin_pkg_info_is_up_to_date (){
 +    if test -f "$PKG_BIN_CACHE" && \
 +      test "$PKG_BIN_CACHE" -nt "$PACKAGES"
 +    then
 +      return 0
 +    else
 +      return 1
 +    fi
 +}
 +
 +get_bin_pkg_info (){
 +    if test -z "$PKG_BIN_CACHE"; then
 +      list_bin_pkgs | xargs ${PKG_INFO} -X
 +    elif bin_pkg_info_is_up_to_date; then
 +      $DECOMPRESS "$PKG_BIN_CACHE"
 +    else
 +      pkg_update_summary "$PKG_BIN_CACHE" "$PACKAGES" \
 +          "$DECOMPRESS" "$COMPRESS"
 +
 +      $DECOMPRESS "$PKG_BIN_CACHE"
 +    fi
 +}
 +
 +bin_pkg_info2pkgdb (){
 +    ${SED} -n -e 's|^PKGPATH=||p' \
 +            -e 's|^PKGNAME=||p' |
 +    ${AWK} '{getline name; printf "%s:%s ", name, $0}'
 +}
 +
  if [ "`${ID} -u`" = 0 ] ; then
      SU_CMD=
  fi
 @@ -775,13 +821,7 @@
        *)
            if [ -d "$PACKAGES" ] ; then
                msg_progress Scan $PACKAGES
 -              cd $PACKAGES
 -              for f in `ls -t | grep "$PKG_SUFX_RE"'$'` ; do # Sort by time 
to pick up newest first
 -                  PKGDIR=`${PKG_INFO} -. -B $PACKAGES/$f|${AWK} -F= 
'$1=="PKGPATH"{print $2}'`
 -                  PKGNAME=`echo $f | ${SED} "s/$PKG_SUFX"'$//'`
 -                  PKGDB="${PKGDB} $PKGDIR:$PKGNAME"
 -              done
 -              PKGSRCDIR=NONE
 +              PKGDB=$(get_bin_pkg_info | bin_pkg_info2pkgdb)
            fi;;
      esac
  fi
 
 --=-=-=
 
 
 -- 
 Best regards, Aleksey Cheusov.
 
 --=-=-=--
 



Home | Main Index | Thread Index | Old Index