pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/scripts When producing the list of directories cont...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b79a268c632f
branches:  trunk
changeset: 514964:b79a268c632f
user:      dmcmahill <dmcmahill%pkgsrc.org@localhost>
date:      Wed Jun 21 14:13:27 2006 +0000

description:
When producing the list of directories containing binary packages, do
some extra processing to ensure that we have a list of unique directories.
Otherwise we end up with two problems:

  - cache files get rebuilt all the time because they get built once for each
    path to the directory in question and since the path ends up in the cache,
    it is always declared out of date.

  - we end up with multiple links to the same binary package in the README.html
    files.

Committed during the freeze becuase this is a real bug which is encountered
daily.

diffstat:

 mk/scripts/binpkg-cache |  32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

diffs (84 lines):

diff -r 4c8617e9216f -r b79a268c632f mk/scripts/binpkg-cache
--- a/mk/scripts/binpkg-cache   Wed Jun 21 13:50:46 2006 +0000
+++ b/mk/scripts/binpkg-cache   Wed Jun 21 14:13:27 2006 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: binpkg-cache,v 1.9 2006/06/08 11:18:04 dmcmahill Exp $
+# $NetBSD: binpkg-cache,v 1.10 2006/06/21 14:13:27 dmcmahill Exp $
 #
 # Script for generating a cache file with information about
 # all binary packages contained in a directory.
@@ -67,6 +67,7 @@
        echo "${tmpd} already exists"
        exit 1
 fi
+all_dirs=${tmpd}/all_dirs
 
 prog=$0
 
@@ -132,6 +133,7 @@
 #
 
 process_binpkg_dir(){
+       rdir=`${GREP} "^${d} " ${all_dirs} | ${AWK} '{print $2}'`
        need_update=no
        if test -f ${d}/${cachefile} ; then
                stale_entries=`${FIND} ${d} -type f -name \*${PKG_SUFX} -newer ${d}/${cachefile} -print`
@@ -149,7 +151,7 @@
                # get the list of what pkgs belong in the cache
                rm -f ${tmpd}/pkg_list ${tmpd}/cache_pkg_list
                ${FIND} ${d}/ -name \*${PKG_SUFX} -print | \
-                       ${SED} -e "s;^${PACKAGES}/*;;g" -e 's;//;/;g' | \
+                       ${SED} -e "s;^${d}/*;${rdir}/;g" -e 's;//;/;g' | \
                        ${SORT} > ${tmpd}/pkg_list
 
                # and get the list of what is in the cache
@@ -161,6 +163,12 @@
                                echo "      No extra cache entries in ${d}/${cachefile}"
                        fi
                else
+                       if test "X${DEBUG}" = "Xyes" ; then
+                               echo "Package list:"
+                               cat  ${tmpd}/pkg_list
+                               echo "Cache list:"
+                               cat ${tmpd}/cache_pkg_list
+                       fi
                        echo "      Entries found in ${d}/${cachefile} but no packages found"
                        need_update=yes
                fi
@@ -197,7 +205,7 @@
        if test "X${need_update}" = "Xyes" ; then
                echo "pkgcache_version ${cacheversion}" > ${tmpd}/${cachefile}
                for f in ${d}/*${PKG_SUFX} ; do
-                       fn=`echo $f | ${SED} "s;^${PACKAGES}/*;;g"`
+                       fn=`grep "^${d} " ${all_dirs} | ${AWK} '{print $2}'`"/"`basename ${f}`
                        if test "X${DEBUG}" = "Xyes" ; then
                                echo "     Adding ${fn} (${f}) to the cache"
                        fi
@@ -339,7 +347,25 @@
 
 # put a trailing / after ${PACKAGES} in case ${PACKAGES} is 
 # a link.
+
+# pass 1, we find all directories under PACKAGES.  Note that this
+# may contain some directories more than once depending on what sort
+# of soft links may be in place
+rm -f ${all_dirs}.tmp
 for d in `${FIND} ${PACKAGES}/ -type d -follow -print` ; do
+       cname=`(cd ${d} && pwd -P)`
+       rname=`echo ${d} | ${SED} "s;^${PACKAGES}/*;;g"`
+       echo "${cname} ${rname}" >> ${all_dirs}.tmp
+done
+${SORT} -u -k1,1 ${all_dirs}.tmp > ${all_dirs}
+if test "X${DEBUG}" = "Xyes" ; then
+       echo "Full directory list:"
+       cat ${all_dirs}.tmp
+       echo "Unique directory list:"
+       cat ${all_dirs}
+fi
+
+for d in `${AWK} '{print $1}' ${all_dirs}` ; do
        if test "X${DEBUG}" = "Xyes" ; then
                echo "${prompt}Processing directory ${d}"
        fi



Home | Main Index | Thread Index | Old Index