pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc Allow the binpkg-cache script to also generate pkg_sum...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/4ffcdf6301c0
branches:  trunk
changeset: 516803:4ffcdf6301c0
user:      dmcmahill <dmcmahill%pkgsrc.org@localhost>
date:      Fri Jul 28 02:41:07 2006 +0000

description:
Allow the binpkg-cache script to also generate pkg_summary.gz files
if requested.  Suggested by Joerg Sonnenberger.

diffstat:

 mk/scripts/binpkg-cache         |  43 +++++++++++++++++++++++++++++++++++++---
 mk/scripts/genreadme.awk        |  33 +++++++++++++++++++------------
 mk/scripts/mkreadme             |  18 +++++++++++++++-
 pkgtools/prereq-readme/Makefile |   3 +-
 4 files changed, 77 insertions(+), 20 deletions(-)

diffs (266 lines):

diff -r a71c5c69cc92 -r 4ffcdf6301c0 mk/scripts/binpkg-cache
--- a/mk/scripts/binpkg-cache   Fri Jul 28 01:52:00 2006 +0000
+++ b/mk/scripts/binpkg-cache   Fri Jul 28 02:41:07 2006 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: binpkg-cache,v 1.10 2006/06/21 14:13:27 dmcmahill Exp $
+# $NetBSD: binpkg-cache,v 1.11 2006/07/28 02:41:07 dmcmahill Exp $
 #
 # Script for generating a cache file with information about
 # all binary packages contained in a directory.
@@ -47,6 +47,7 @@
 CMP=${CMP:-cmp}
 FIND=${FIND:-find}
 GREP=${GREP:-grep}
+GZIP_CMD=${GZIP_CMD:-gzip}
 PKG_INFO=${PKG_INFO:-pkg_info}
 PKG_SUFX=${PKG_SUFX:-.tgz}
 SED=${SED:-sed}
@@ -54,6 +55,7 @@
 STAT=${STAT:-stat}
 
 cachefile=.pkgcache
+summaryfile=pkg_summary
 cacheversion=20050428
 
 prompt="----> "
@@ -197,6 +199,15 @@
                fi
        fi
 
+       if test "${build_summary}" = "yes" -a ! -f ${d}/${summaryfile}.gz ; then 
+               echo "${tab}Summary file ${d}/${summaryfile}.gz is missing and will be created."
+               need_update=yes
+       fi
+       if test "${build_summary}" = "yes" -a ${d}/${summaryfile}.gz -ot ${d}/${cachefile} ; then
+               echo "${tab}Summary file ${d}/${summaryfile}.gz is out of date and will be regnerated."
+               need_update=yes
+       fi
+
        # FIX_ME
        # We should use stale_entries in a way where we only update the 
        # cache file entries corresponding to these if we're rebuilding
@@ -204,6 +215,7 @@
        # 
        if test "X${need_update}" = "Xyes" ; then
                echo "pkgcache_version ${cacheversion}" > ${tmpd}/${cachefile}
+               echo "" > ${tmpd}/${summaryfile}
                for f in ${d}/*${PKG_SUFX} ; do
                        fn=`grep "^${d} " ${all_dirs} | ${AWK} '{print $2}'`"/"`basename ${f}`
                        if test "X${DEBUG}" = "Xyes" ; then
@@ -215,10 +227,14 @@
                        #eval $(${STAT} -s ${f} 2>/dev/null)
                        echo "pkgcache_begin ${fn}" >> ${tmpd}/${cachefile}
                        #echo "pkgcache_mtime=${st_mtime}" >> ${tmpd}/${cachefile}
-                       if test "X${DEBUG}" = "Xyes" ; then
-                               echo "${PKG_INFO} -q -B ${f}"
+
+                       if test "X${DEBUG}" = "Xyes" ; then echo "${PKG_INFO} -q -B ${f}" ; fi
+                       ${PKG_INFO} -q -B ${f} >> ${tmpd}/${cachefile}
+
+                       if test "${build_summary}" = "yes" ; then
+                               if test "X${DEBUG}" = "Xyes" ; then echo "${PKG_INFO} -X ${f}" ; fi
+                               ${PKG_INFO} -X ${f} >> ${tmpd}/${summaryfile}
                        fi
-                       ${PKG_INFO} -q -B ${f} >> ${tmpd}/${cachefile}
                        echo "pkgcache_end ${fn}" >> ${tmpd}/${cachefile}
                done
                mv -f ${tmpd}/${cachefile} ${d}/${cachefile}
@@ -230,6 +246,18 @@
                        echo "********** WARNING **********"
                        return
                fi
+               
+               if test "${build_summary}" = "yes" ; then
+                       cat ${tmpd}/${summaryfile} | ${GZIP_CMD} > ${d}/${summaryfile}.gz
+                       if test $? -ne 0 ; then
+                               echo "********** WARNING **********"
+                               echo "${GZIP_CMD} of ${tmpd}/${summaryfile} to ${d}/${summaryfile}.gz failed!"
+                               echo "Perhaps you do not have write permissions to ${d}?"
+                               echo "********** WARNING **********"
+                               return
+                       fi
+               fi
+
        fi
 
        # if we got here, then this directory should have a good cache file in
@@ -280,6 +308,7 @@
 DEBUG=no
 verbose=no
 force=no
+build_summary=no
 
 while
        test -n "$1"
@@ -310,6 +339,12 @@
                        shift 2
                        ;;
 
+               # Build the pkg_summary.gz files
+               -s|--summary)
+                       build_summary=yes
+                       shift
+                       ;;
+
                # Version
                -V|--version)
                        ${AWK} '/^#[ \t]*\$NetBSD/ {gsub(/,v/,"",$3);printf("%s:  Version %s, %s\n",$3,$4,$5); exit 0;}' $prog
diff -r a71c5c69cc92 -r 4ffcdf6301c0 mk/scripts/genreadme.awk
--- a/mk/scripts/genreadme.awk  Fri Jul 28 01:52:00 2006 +0000
+++ b/mk/scripts/genreadme.awk  Fri Jul 28 02:41:07 2006 +0000
@@ -1,5 +1,5 @@
 #!/usr/bin/awk -f
-# $NetBSD: genreadme.awk,v 1.22 2006/04/15 15:00:24 salo Exp $
+# $NetBSD: genreadme.awk,v 1.23 2006/07/28 02:41:07 dmcmahill Exp $
 #
 # Copyright (c) 2002, 2003, 2005, 2006 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -201,8 +201,8 @@
        if ( builddependsfile == "" ) builddependsfile = "/dev/stdout";
 
        printf("Making sure binary package cache file is up to date...\n");
-       cmd = sprintf("%s AWK=%s CMP=%s FIND=%s GREP=%s PKG_INFO=\"%s\" PKG_SUFX=%s SED=%s SORT=%s %s/mk/scripts/binpkg-cache --packages %s",
-               SETENV, AWK, CMP, FIND, GREP, PKG_INFO, PKG_SUFX, SED, SORT, PKGSRCDIR, PACKAGES);
+       cmd = sprintf("%s AWK=%s CMP=%s FIND=%s GREP=%s GZIP_CMD=\"%s\" PKG_INFO=\"%s\" PKG_SUFX=%s SED=%s SORT=%s %s/mk/scripts/binpkg-cache %s --packages %s",
+               SETENV, AWK, CMP, FIND, GREP, GZIP_CMD, PKG_INFO, PKG_SUFX, SED, SORT, PKGSRCDIR, summary, PACKAGES);
        if (debug) printf("\nExecute:  %s\n",cmd);
        rc = system(cmd);
 
@@ -376,17 +376,17 @@
                                         toppkg, pkgbase);
                                }
                                while(i in vulpkg) {
-                                       nm = vulpkg[i];
-                                       gsub(/&/, "\\\\\\&amp;", nm);
-                                       gsub(/</, "\\\\\\&lt;", nm);
-                                       gsub(/>/, "\\\\\\&gt;", nm);
-                                       url = vulref[i];
-                                       gsub(/&/, "\\\\\\&", url);
-                                       printurl = vulref[i];
-                                       gsub(/&/, "\\\\\\&amp;", printurl);
-                                       gsub(/</, "\\\\\\&lt;", printurl);
-                                       gsub(/>/, "\\\\\\&gt;", printurl);
                                        if (vulpkg[i] ~ "^" pkgbase"[-<>=]+[0-9]") {
+                                               nm = vulpkg[i];
+                                               gsub(/&/, "\\\\\\&amp;", nm);
+                                               gsub(/</, "\\\\\\&lt;", nm);
+                                               gsub(/>/, "\\\\\\&gt;", nm);
+                                               url = vulref[i];
+                                               gsub(/&/, "\\\\\\&", url);
+                                               printurl = vulref[i];
+                                               gsub(/&/, "\\\\\\&amp;", printurl);
+                                               gsub(/</, "\\\\\\&lt;", printurl);
+                                               gsub(/>/, "\\\\\\&gt;", printurl);
                                                vul =  sprintf("%s<LI><STRONG>%s has a <a href=\"%s\">%s</a> vulnerability</STRONG></LI>\n",
                                                          vul, nm, url, vultype[i]);
                                        }
@@ -719,10 +719,17 @@
 # an awk regular expression.
 #
 function glob2reg(reg){
+
+       # escape some characters which are special in regular expressions
         gsub(/\./, "\\\.", reg);
         gsub(/\+/, "\\\+", reg);
+
+       # and reformat some others
         gsub(/\*/, ".*", reg);
         gsub(/\?/, ".?", reg);
+
+       # finally, expand {a,b,c} type patterns
+
         return(reg);
 }
 
diff -r a71c5c69cc92 -r 4ffcdf6301c0 mk/scripts/mkreadme
--- a/mk/scripts/mkreadme       Fri Jul 28 01:52:00 2006 +0000
+++ b/mk/scripts/mkreadme       Fri Jul 28 02:41:07 2006 +0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: mkreadme,v 1.10 2006/05/29 02:41:26 dmcmahill Exp $
+# $NetBSD: mkreadme,v 1.11 2006/07/28 02:41:07 dmcmahill Exp $
 #
 # Script for README.html generation
 #
@@ -61,6 +61,7 @@
     echo "Usage:      $prog [-c|--cdrom] [-C|--prune] [-d|--debug] [-f|--ftp] "
     echo "                  [-p|--pkgsrc directory] "
     echo "                  [-P|--packages directory] [-r|--restart] "
+    echo "                  [-s|--summary]"
     echo "                  [-S|--save-database]"
     echo " "
     echo "            $prog -h|--help"
@@ -90,6 +91,9 @@
     echo "                      from a previous run still exists and that the script"
     echo "                      should use that instead of recreating the database."
     echo " "
+    echo "  -s|--summary        Generate pkg_summary.gz files for the binary packages"
+    echo "                      directories while processing them."
+    echo " "
     echo "  -S|--save-database  Does not delete the database file after the run."
     echo "                      This is useful for debugging or re-running this script"
     echo "                      with the -r option."
@@ -126,6 +130,8 @@
 DEBUG=no
 save=no
 
+summary=""
+
 while
     test -n "$1"
 do
@@ -181,6 +187,12 @@
        shift
        ;;
 
+    # Generate the pkg_summary.gz files
+    -s|--summary)
+       summary="--summary"
+       shift
+       ;;
+
     # Save the database files
     -S|--save-database)
        save=yes
@@ -247,7 +259,7 @@
 if [ -d ${PKGSRCDIR}/pkgtools/prereq-readme ]; then
     cd ${PKGSRCDIR}/pkgtools/prereq-readme
     eval "`${BMAKE} show-tools`"
-    for v in AWK CMP ECHO EXPR FGREP FIND GREP SED SETENV SORT 
+    for v in AWK CMP ECHO EXPR FGREP FIND GREP GZIP_CMD SED SETENV SORT 
     do
        eval "echo '---->'  ${v}=\"\${${v}}\""
     done
@@ -397,11 +409,13 @@
     builddependsfile=${TMPDIR}/pkgsrc.builddepends.debug \
     debug=$debug \
     dependsfile=${TMPDIR}/pkgsrc.depends.debug \
+    summary=${summary} \
     AWK=$AWK \
     CMP=$CMP \
     DISTDIR=$DISTDIR \
     FIND=$FIND \
     GREP=$GREP \
+    GZIP_CMD="$GZIP_CMD" \
     PACKAGES=$PACKAGES \
     PKG_INFO="$PKG_INFO" \
     PKG_SUFX=$PKG_SUFX \
diff -r a71c5c69cc92 -r 4ffcdf6301c0 pkgtools/prereq-readme/Makefile
--- a/pkgtools/prereq-readme/Makefile   Fri Jul 28 01:52:00 2006 +0000
+++ b/pkgtools/prereq-readme/Makefile   Fri Jul 28 02:41:07 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2005/09/28 20:52:25 rillig Exp $
+# $NetBSD: Makefile,v 1.5 2006/07/28 02:41:07 dmcmahill Exp $
 #
 
 DISTNAME=      prereq-readme-20050521
@@ -25,6 +25,7 @@
 USE_TOOLS+=    fgrep
 USE_TOOLS+=    find
 USE_TOOLS+=    grep
+USE_TOOLS+=    gzip
 USE_TOOLS+=    sed
 USE_TOOLS+=    setenv
 USE_TOOLS+=    sort



Home | Main Index | Thread Index | Old Index