Subject: pkg/22246: Fix mk/bulk/tflat for some awks
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <jonathan@perkin.org.uk>
List: netbsd-bugs
Date: 07/24/2003 16:37:36
>Number:         22246
>Category:       pkg
>Synopsis:       Fix mk/bulk/tflat for some awks
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 24 16:38:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Jonathan Perkin
>Release:        N/A
>Organization:
British Broadcasting Corporation
>Environment:
SunOS build0 5.8 Generic_108528-15 sun4u sparc SUNW,UltraSPARC-IIi-cEngineNetBSD munkeh.intra.nut 1.6U NetBSD 1.6U (GENERIC) #6: Thu Jul 17 10:54:45 BST 2003  root@munkeh.intra.nut:/usr/obj/sys/arch/sparc64/compile/GENERIC sparc64
>Description:
This is probably a "feature" of nawk, but the following behaviour
occurs both with SunOS /usr/bin/nawk (/usr/xpkg4/bin/awk) and the
current nawk in NetBSD 1.6U:

-% uname -rs
SunOS 5.8
-% cat test.awk
BEGIN { if (ARGV[1] == "-u") print "foo" }
-% nawk -f test.awk -u
nawk: unknown option -u ignored
-% nawk 'BEGIN { if (ARGV[1] == "-u") print "foo" }' -u
foo

munkeh# pwd
/usr/src/dist/nawk
munkeh# ./a.out -f test.awk -u
./a.out: unknown option -u ignored
munkeh# ./a.out 'BEGIN { if (ARGV[1] == "-u") print "foo" }' -u
foo

There may be other awks out there which exihibit the same behaviour,
and so there's a simple patch needed to get bulk builds working on
those systems (well, not "working", but I have more patches to get
to that stage coming...)

An additional patch could be to try and get this working with other
awks which try to interpret any options as filenames by saving ARGV[x]
then deleting it, but I don't have any awks installed which seem to
trip up on that.  SunOS /usr/bin/awk is just too badly broken :-)
>How-To-Repeat:
--<jonp@build1>-</home/jonp/src/pkgsrc>--
-% sh mk/bulk/build
Bulk build started: Thu Jul 24 15:07:11 BST 2003
[...]
/usr/bin/nawk -f /home/jonp/src/pkgsrc/mk/bulk/tflat -u /home/jonp/src/pkgsrc/.d
ependstree.build1 > /home/jonp/src/pkgsrc/.supports.build1
/usr/bin/nawk: unknown option -u ignored
*** Error code 1

Stop.
bmake: stopped in /home/jonp/src/pkgsrc
mk/bulk/build: Cache creation failed.  Aborting build.
>Fix:
http://www.perkin.org.uk/projects/netbsd/tflat.patch

Index: bsd.bulk-pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bulk/bsd.bulk-pkg.mk,v
retrieving revision 1.45
diff -u -r1.45 bsd.bulk-pkg.mk
--- bsd.bulk-pkg.mk     2003/07/11 23:54:32     1.45
+++ bsd.bulk-pkg.mk     2003/07/24 15:23:37
@@ -126,8 +126,8 @@
        @${ECHO_MSG} "BULK> Sorting build order."
        tsort ${DEPENDSTREEFILE} > ${ORDERFILE}
        @${ECHO_MSG} "BULK> Generating up and down dependency files."
-       ${AWK} -f ${_PKGSRCDIR}/mk/bulk/tflat -u ${DEPENDSTREEFILE} > ${SUPPORTSFILE}
-       ${AWK} -f ${_PKGSRCDIR}/mk/bulk/tflat -d ${DEPENDSTREEFILE} > ${DEPENDSFILE}
+       ${AWK} -f ${_PKGSRCDIR}/mk/bulk/tflat up ${DEPENDSTREEFILE} > ${SUPPORTSFILE}
+       ${AWK} -f ${_PKGSRCDIR}/mk/bulk/tflat down ${DEPENDSTREEFILE} > ${DEPENDSFILE}
        @${ECHO_MSG} "BULK> Generating package name <=> package directory cross reference file"
        @${ECHO_MSG} "      (this may take a while)."
        cd ${_PKGSRCDIR} && ${SH} mk/bulk/printindex ${BROKENFILE} > ${INDEXFILE}
Index: tflat
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bulk/tflat,v
retrieving revision 1.9
diff -u -r1.9 tflat
--- tflat       2003/07/11 23:54:33     1.9
+++ tflat       2003/07/24 15:23:37
@@ -42,11 +42,11 @@
                exit(1);
        }
 
-       if ( ARGV[1] == "-u" ) {
+       if ( ARGV[1] == "up" ) {
                up=1;
        }
        else{
-               if ( ARGV[1] == "-d" ) { up=0; }
+               if ( ARGV[1] == "down" ) { up=0; }
                else{
                        printf("tflat: unknown option  \"%s\"\n",ARGV[1]);
                        usage();
@@ -177,10 +177,10 @@
        printf("         packages which depend upon a given package or alternatively\n");
        printf("         all packages which are depend upon by a given package.\n");
        printf("\n");
-       printf("Usage:\ttflat -u|-d depfile\n");
+       printf("Usage:\ttflat up|down depfile\n");
        printf("\n");
-       printf("Options:\t-d\tgo down the depends tree (ie \"foo depends on:\")\n");
-       printf("        \t-u\tgo up the depends tree (ie \"foo is depended on by:\")\n");
+       printf("Options:\tdown\tgo down the depends tree (ie \"foo depends on:\")\n");
+       printf("        \tup\tgo up the depends tree (ie \"foo is depended on by:\")\n");
        printf("\n");
        printf("Input file format is in the form\n");
        printf("foo     bar\n");
@@ -194,8 +194,8 @@
        printf("The typical use is:\n");
        printf("cd /usr/pkgsrc\n");
        printf("./mk/bulk/printdepends > .depends\n");
-       printf("./mk/bulk/tflat -u .depends > .supports\n");
-       printf("./mk/bulk/tflat -d .depends > .requires\n");
+       printf("./mk/bulk/tflat up .depends > .supports\n");
+       printf("./mk/bulk/tflat down .depends > .requires\n");
        printf("\n");
 
 }
>Release-Note:
>Audit-Trail:
>Unformatted: