Subject: pkg/33410: pkgsrc problem with posix awk
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <cheusov@tut.by>
List: pkgsrc-bugs
Date: 05/02/2006 10:55:00
>Number:         33410
>Category:       pkg
>Synopsis:       pkgsrc problem with posix awk
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 02 10:55:00 +0000 2006
>Originator:     Aleksey Cheusov
>Release:        NetBSD 3.0_STABLE
>Organization:
home
>Environment:
NetBSD chen.chizhovka.net 3.0_STABLE NetBSD 3.0_STABLE (GENERIC) #2: Sun Mar 12 12:49:58 GMT 2006  cheusov@chen:/usr/src/sys/arch/i386/compile/GENERIC i386
>Description:
Original problem is that I cannot build and install x11-links package
under Linux. While 'bmake install' I get the following log
Note that in the following log awk failed but exit status of bmake is
zero :(

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0 x11-links>bmake install
===> Checking for vulnerabilities in x11-links-0.30
===> Installing for x11-links-0.30
===> Becoming root@cheh to install x11-links.
/bin/su Password: 
/usr/bin/install -d -o root -g root -m 755 /usr/pkg/share/x11-links
cd /mnt/hdb4/ftp/pub/pkgsrc/pkgtools/x11-links/work/share/x11-links && /usr/pkg/bin/pax -rw . /usr/pkg/share/x11-links
awk: run time error: regular expression compile failed (Invalid content of \{\})
\${LOWER_VENDOR}
        FILENAME="-" FNR=1 NR=1
===> [Automatic manual page handling]
===> Registering installation for x11-links-0.30
0 x11-links>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Problem 1) exit status of awk is not checked by pkgsrc.
Problem 2) '(\${PKGBASE})' regexp is passed to awk.
           According to SUSv3 { and } symbols
           should be processed differently.

>How-To-Repeat:
/usr/bin/awk:
#!/bin/sh
gawk --posix "$@"

The try to build x11-links package
with X11_TYPE=native

>Fix:
Problem 2 is fixed with this patch:

Index: mk/plist/plist-subst.awk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/plist/plist-subst.awk,v
retrieving revision 1.2
diff -u -r1.2 plist-subst.awk
--- mk/plist/plist-subst.awk    22 Jan 2006 16:54:13 -0000      1.2
+++ mk/plist/plist-subst.awk    2 May 2006 10:49:28 -0000
@@ -49,7 +49,7 @@
                value = ENVIRON[vars[i]]
                var = vars[i]
                sub("^PLIST_", "", var)
-               regexp = "\\${" var "}"
+               regexp = "[$][{]" var "[}]"
                substitute[regexp] = value
        }
 }