summaryrefslogtreecommitdiff
path: root/mk/scripts/mkreadme
diff options
context:
space:
mode:
authordmcmahill <dmcmahill>2005-05-17 21:46:59 +0000
committerdmcmahill <dmcmahill>2005-05-17 21:46:59 +0000
commit056c929b8debfddf632c149f12ae65e419ebe09a (patch)
tree0ab19d9d420b124621ec7a7e934636836fc90c76 /mk/scripts/mkreadme
parent25fb1bd6c84ba056c3fb88ff31d0df8cca95348f (diff)
downloadpkgsrc-056c929b8debfddf632c149f12ae65e419ebe09a.tar.gz
Rework the README.html generation code. Major changes are:
- completely redo the code which decides on the machine architecture, operating system, and operating system version for the binary packages. The old way just used to directory names to take a guess. The new way creates a cache file containing meta-data for all the binary packages in each "All" directory. This cache file is consulted when generating the lists of available binary packages. The meta-data is obtained with pkg_info so it should always be correct even if you do something silly like mix OS_VERSION or MACHINE_ARCH packages up in the same directory. Among the benefits are: works when PACKAGES is not $PKGSRC/packages, works with a more or less arbitrary subdirectory structure, works when there are subdirectories for multiple operating systems. This portion of the fix should address PR25390. The cache files are only updated when the contents of an "All" directory changes or if the cache file format changes. There is some room for improving the updating of the cache files, but its not too bad the way it is. - fix up some of the awk code so that generadme.awk works with Solaris nawk as well as NetBSD's nawk and gawk (for pre-2.0 systems). - remove some "if ! foo" shell constructs to increase portability. - be more consistent with what variables get passed to mkreadme from make and which ones are determined automatically. Mostly this meant moving stuff into mkreadme to make it easier to run it standalone.
Diffstat (limited to 'mk/scripts/mkreadme')
-rwxr-xr-xmk/scripts/mkreadme121
1 files changed, 45 insertions, 76 deletions
diff --git a/mk/scripts/mkreadme b/mk/scripts/mkreadme
index 231cdb36ee1..8eea9444dc3 100755
--- a/mk/scripts/mkreadme
+++ b/mk/scripts/mkreadme
@@ -1,9 +1,9 @@
#!/bin/sh
-# $NetBSD: mkreadme,v 1.4 2003/09/23 01:51:44 yyamano Exp $
+# $NetBSD: mkreadme,v 1.5 2005/05/17 21:46:59 dmcmahill Exp $
#
# Script for README.html generation
#
-# Copyright (c) 2002 The NetBSD Foundation, Inc.
+# Copyright (c) 2002, 2005 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
@@ -41,16 +41,27 @@
TMPDIR=${TMPDIR:-/tmp/mkreadme}
PKGSRCDIR=${PKGSRCDIR:-/usr/pkgsrc}
-BMAKE=${BMAKE:-make}
AWK=${AWK:-/usr/bin/awk}
-EXPR=${EXPR:-expr}
+
+opsys=`uname -s`
+case "$opsys" in
+ *BSD)
+ makeprog=make
+ ;;
+
+ *)
+ makeprog=bmake
+ ;;
+esac
+
+BMAKE=${BMAKE:-${makeprog}}
usage(){
echo "$prog - Generates README.html files for a pkgsrc tree"
echo "Usage: $prog [-c|--cdrom] [-C|--prune] [-d|--debug] [-f|--ftp] "
- echo " [-m|--multi-arch] [-p|--pkgsrc directory] "
+ echo " [-p|--pkgsrc directory] "
echo " [-P|--packages directory] [-r|--restart] "
- echo " [-s|--single-arch] [-S|--save-database]"
+ echo " [-S|--save-database]"
echo " "
echo " $prog -h|--help"
echo " "
@@ -69,10 +80,6 @@ usage(){
echo " "
echo " -h|--help Displays this help message"
echo " "
- echo " -m|--multi-arch Assumes a packages directory layout like:"
- echo " OS_VERSION/MACHINE_ARCH/ for example:"
- echo " 1.{5,6}/{alpha,i386,sparc,vax}"
- echo " "
echo " -p|--pkgsrc dir Specifies the pkgsrc directory. Defaults to"
echo " The value of the PKGSRCDIR environment variable"
echo " if set or /usr/pkgsrc otherwise."
@@ -83,9 +90,6 @@ usage(){
echo " from a previous run still exists and that the script"
echo " should use that instead of recreating the database."
echo " "
- echo " -s|--single-arch Assumes a single OS release and MACHINE_ARCH binary"
- echo " packages directory structure."
- 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."
@@ -114,6 +118,8 @@ prog=$0
#
######################################################################
+cmdline=$*
+
ftp_readme=no
restart=no
prune=no
@@ -157,12 +163,6 @@ do
exit 0
;;
- # assume a OS_RELEASE/MACHINE_ARCH/ layout for the binary pkgs
- -m|--multi-arch)
- multiarch=yes
- shift
- ;;
-
# Specify pkgsrc directory
-p|--pkgsrc)
PKGSRCDIR=$2
@@ -181,12 +181,6 @@ do
shift
;;
- # assume a single directory structure layout for the binary pkgs
- -s|--single-arch)
- multiarch=no
- shift
- ;;
-
# Save the database files
-S|--save-database)
save=yes
@@ -252,8 +246,9 @@ echo "Extracting configuration variables:"
echo " "
if [ -d ${PKGSRCDIR}/pkgtools/pkglint ]; then
cd ${PKGSRCDIR}/pkgtools/pkglint
-
- for v in DISTDIR PACKAGES PKGREPOSITORYSUBDIR PKG_SUFX MACHINE_ARCH PKG_URL OPSYS OS_VERSION FTP_PKG_URL_HOST FTP_PKG_URL_DIR CDROM_PKG_URL_HOST CDROM_PKG_URL_DIR
+ for v in AWK CDROM_PKG_URL_HOST CDROM_PKG_URL_DIR CMP DISTDIR ECHO EXPR \
+ FGREP FTP_PKG_URL_HOST FTP_PKG_URL_DIR GREP PACKAGES PKG_INFO PKG_SUFX \
+ SED SETENV SORT
do
val=`${BMAKE} show-var VARNAME=${v}`
if [ $? != 0 ]; then
@@ -261,15 +256,14 @@ if [ -d ${PKGSRCDIR}/pkgtools/pkglint ]; then
echo "Failed. This is a fatal error"
clean_and_exit
fi
- echo "$v=$val"
- eval ${v}=${val}
+ echo "----> ${v}=\"${val}\""
+ eval "${v}=\"${val}\""
done
else
echo "Error: ${PKGSRCDIR}/pkgtools/pkglint does not seem to exist"
exit 1
fi
-
######################################################################
#
# Decide on FTP vs CDROM README.html files
@@ -296,39 +290,6 @@ if [ ! -z "$PKGDIR" ]; then
echo "PACKAGES specified on command line to be $PKGDIR"
fi
-######################################################################
-#
-# Decide in binary package directory layout
-#
-######################################################################
-
-
-# If PACKAGES is set to the default (../../pkgsrc/packages), the current
-# ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory
-# structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed.
-#
-# This is the logic from bsd.pkg.mk, but I think I'd like to change it to
-# come from a command line switch
-
-if [ -z "$multiarch" -a -e ${PACKAGES} ]; then
- cd ${PACKAGES}
- case `pwd` in
- */pkgsrc/packages)
- multiarch=no
- ;;
-
- *)
- multiarch=yes
- ;;
- esac
-fi
-
-if [ "x$multiarch" = "xyes" ]; then
- echo "Will generate multi-release, multi-arch readme files"
-else
- echo "Will generate single-release, single-arch readme files"
-fi
-
######################################################################
#
@@ -339,6 +300,7 @@ fi
if [ "x$restart" = "xno" ] ; then
echo " "
echo "Extracting data. This could take a while"
+ echo "Started at: `date` "
echo " "
npkg=1
@@ -346,13 +308,13 @@ if [ "x$restart" = "xno" ] ; then
rm -fr $DATABASEFILE
cd ${PKGSRCDIR}
- list=`grep '^[[:space:]]*'SUBDIR */Makefile | sed 's,/Makefile.*=[[:space:]]*,/,'`
+ list=`${GREP} '^[ \t]*'SUBDIR */Makefile | ${GREP} -v regress/ | ${SED} 's,/Makefile.*=[[:space:]]*,/,'`
for pkgdir in $list
do
if [ ! -d $pkgdir ]; then
echo " "
echo "WARNING: the package directory $pkgdir is listed in" > /dev/stderr
- echo $pkgdir | sed 's;/.*;/Makefile;g' > /dev/stderr
+ echo $pkgdir | ${SED} 's;/.*;/Makefile;g' > /dev/stderr
echo "but the directory does not exist. Please fix this!" > /dev/stderr
else
cd $pkgdir
@@ -368,7 +330,7 @@ if [ "x$restart" = "xno" ] ; then
echo "$l" >> $DATABASEFILE
fi
fi
- echo -n "."
+ ${ECHO} -n "."
if [ `${EXPR} $npkg % 100 = 0` -eq 1 ]; then
echo " "
echo "$npkg"
@@ -376,6 +338,8 @@ if [ "x$restart" = "xno" ] ; then
npkg=`${EXPR} $npkg + 1`
cd $PKGSRCDIR
done
+ echo " "
+ echo "Finished extracting data for ${npkg} packages at: `date` "
else
echo " "
echo "Using existing database (are you sure you wanted the -r/--restart flag?)"
@@ -408,16 +372,18 @@ ${AWK} -f ${PKGSRCDIR}/mk/scripts/genreadme.awk \
builddependsfile=${TMPDIR}/pkgsrc.builddepends.debug \
debug=$debug \
dependsfile=${TMPDIR}/pkgsrc.depends.debug \
+ AWK=$AWK \
+ CMP=$CMP \
DISTDIR=$DISTDIR \
- MACHINE_ARCH=$MACHINE_ARCH \
- MULTIARCH=$multiarch \
- OPSYS=$OPSYS \
- OS_VERSION=$OS_VERSION \
+ GREP=$GREP \
PACKAGES=$PACKAGES \
+ PKG_INFO="$PKG_INFO" \
PKG_SUFX=$PKG_SUFX \
PKG_URL=$PKG_URL \
- PKGREPOSITORYSUBDIR=$PKGREPOSITORYSUBDIR \
PKGSRCDIR=$PKGSRCDIR \
+ SED=$SED \
+ SETENV=$SETENV \
+ SORT=$SORT \
TMPDIR=$TMPDIR \
${DATABASEFILE}
@@ -438,9 +404,9 @@ echo " "
cd ${PKGSRCDIR}
ipv6=${TMPDIR}/ipv6pkgs
ipv6_entries=${TMPDIR}/ipv6_entries
-grep -l '^BUILD_DEFS.*=.*USE_INET6' */*/Makefile | sed 's;Makefile;;g' > $ipv6
-fgrep -f $ipv6 README-all.html | sort -t/ +1 > $ipv6_entries
-sed \
+${GREP} -l '^BUILD_DEFS.*=.*USE_INET6' */*/Makefile | ${SED} 's;Makefile;;g' > $ipv6
+${FGREP} -f $ipv6 README-all.html | sort -t/ +1 > $ipv6_entries
+${SED} \
-e "/%%TRS%%/r${ipv6_entries}" \
-e '/%%TRS%%/d' \
templates/README.ipv6 > ${TMPDIR}/README-IPv6.html
@@ -448,10 +414,13 @@ if [ $? != 0 ]; then
echo "Error: README-IPv6.html generation failed (on sed script)"
clean_and_exit
fi
-if [ ! -f README-IPv6.html ] || ! cmp -s ${TMPDIR}/README-IPv6.html README-IPv6.html ; then
+
+if [ ! -f README-IPv6.html ]; then
mv -f ${TMPDIR}/README-IPv6.html README-IPv6.html
-else
+elif cmp -s ${TMPDIR}/README-IPv6.html README-IPv6.html ; then
echo "README-IPv6.html is unchanged (no changes were needed)"
+else
+ mv -f ${TMPDIR}/README-IPv6.html README-IPv6.html
fi
######################################################################