Subject: strange problem when installing xpkgwedge: install script issue; shell bug?
To: None <tech-pkg@netbsd.org>
From: Georg Schwarz <georg.schwarz@freenet.de>
List: tech-pkg
Date: 04/15/2006 23:32:30
When installing xpkgwedge on IRIX 5.3 I encounter the following error  
message (seems to be non-fatal):

+INSTALL: bad option(s)

I traced it back to the following line (/bin/ksh -x prefix added by me):

ksh -x /usr/people/schwarz/pkgsrc/pkgtools/xpkgwedge/work/.pkgdb/ 
INSTALL xpkgwedge-1.15 PRE-INSTALL

which yields:

...
+ PKG_INSTALLATION_TYPE=overwrite
+ _PKG_CONFIG=yes
+ /usr/people/schwarz/pkgsrc/pkgtools/xpkgwedge/work/.pkgdb/+INSTALL  
xpkgwedge-1.15 UNPACK
+INSTALL: bad option(s)
+ /usr/local/bin/test ! -x ./+USERGROUP
....


the respective code looks like this:

...
case ${STAGE} in
PRE-INSTALL)
         #
         # Unpack the helper scriptlets.
         #
         ${SELF} ${PKGNAME} UNPACK
         #
         # Require that necessary users and groups exist or else fail  
the
         # installation of the package.
         #
         ${TEST} ! -x ./+USERGROUP ||
                 { ./+USERGROUP ADD ${PKG_METADATA_DIR}
                   if ./+USERGROUP CHECK-ADD ${PKG_METADATA_DIR}; then
...

Now the funny this is if I do

  cp /usr/people/schwarz/pkgsrc/pkgtools/xpkgwedge/work/.pkgdb/ 
+INSTALL /usr/people/schwarz/pkgsrc/pkgtools/xpkgwedge/work/.pkgdb/ 
XXXinstallXXX

and then call
ksh -x /usr/people/schwarz/pkgsrc/pkgtools/xpkgwedge/work/.pkgdb/ 
XXXinstallXXX xpkgwedge-1.15 PRE-INSTALL

the problem does not show up. Could that be an obscure shell bug? The  
issue does not show up either when using /bin/sh instead of /bin/ksh.

I traced it down to the following:

lorenz 193% cd /var/tmp
lorenz 194% cat > ./+INSTALL
#!/bin/ksh
SELF="$0"
echo $SELF
$SELF
lorenz 195% chmod a+x ./+INSTALL
lorenz 196% ./+INSTALL | head -3
./+INSTALL
./+INSTALL
./+INSTALL
lorenz 197% `pwd`/+INSTALL | head -3
/var/tmp/+INSTALL
+INSTALL: bad option(s)

further investigations yielded:

lorenz 198% mv ./+INSTALL ./+INSTALL1
lorenz 199% `pwd`/+INSTALL1 | head -3
/var/tmp/+INSTALL1
+INSTALL1: bad option(s)
lorenz 200% mv ./+INSTALL1 ./+IN
lorenz 201% `pwd`/+IN | head -3
/var/tmp/+IN
+IN: bad option(s)
lorenz 202% mv ./+IN ./+qq
lorenz 203% `pwd`/+qq | head -3
/var/tmp/+qq
+qq: bad option(s)
lorenz 204% mv ./+qq ./qq
lorenz 205% `pwd`/qq | head -3
/var/tmp/qq
qq
qq


looks like although $0 is the full path for the first invocation it  
no longer is for any consecutive.

On my imac it works as expected:

imac:/var/tmp schwarz$ `pwd`/qq |head -3
/var/tmp/qq
/var/tmp/qq
/var/tmp/qq

and so it does on IRIX 6.5.
So looks like this is a bug in the old ksh of IRIX 5.3. Maybe other  
OSes are also affected?
Unfortunately pkgsrc/mk/install/install makes use of such recursive  
constructions.

-- 
Georg Schwarz    http://home.pages.de/~schwarz/
georg.schwarz@freenet.de  +49 178 8545053