Mantis - cswclassutils
Viewing Issue Advanced Details
4118 regular use minor always 2010-01-07 14:10 2010-03-31 22:06
skayser  
bonivart  
normal  
closed  
fixed  
none    
none  
0004118: Alternate root installation (via pkgadd -R): i.cswcpsampleconf throws chown/chmod errors
When one installs a package to an alternate root via -R, i.cswcpsampleconf will throw chown/chmod errors (see additional information). Looks like the following bit in i.cswcpsampleconf needs some tweaking of the "grep" invocation.

                echo Copying sample config to $confdest
                [ -x /usr/bin/pkgadm ] && /usr/bin/pkgadm sync > /dev/null 2>&1
                contents=`grep "^$dest" /var/sadm/install/contents`
                mode=`echo $contents | awk '{print $4}'`
                user=`echo $contents | awk '{print $5}'`
                group=`echo $contents | awk '{print $6}'`
                cp $dest $confdest
                chmod $mode $confdest
                chown $user:$group $confdest

The "grep" needs to be given a $dest with a potential $PKG_INSTALL_ROOT stripped while /var/sadm/install/contents needs to be prepended with $PKG_INSTALL_ROOT. Example which works in my case:

                file=`echo $dest | sed -e "s,$PKG_INSTALL_ROOT,,"`
                contents=`grep "^$file" $PKG_INSTALL_ROOT/var/sadm/install/contents`

Additionally i suppose, the call to pkgadm also needs to be prefixed with $PKG_INSTALL_ROOT (but that would need be cross-checked by someone who is familiar with pkgadm).

Another interesting thing I noticed is that the CAS invoked during an alternate-root installation are NOT the ones from the alternate root, but the ones from the system where the alternate root is mounted. Does this mean that our CAS are worthless for someone who does a Jumpstart installation and installs our packages during the phase where the installed system is still mounted at /a?
# pkgparam CSWcswclassutils VERSION
1.30,REV=2009.11.21

/a is a pre-populated root environment.

# pkgadd -R /a -d /var/opt/csw/pkgutil/packages/sudo.sparc.5.9.pkg CSWsudosh2

[ verifying class <none> ]
Copying sample config to /a/etc/opt/csw/sudosh.conf
usage: chmod [-fR] <absolute-mode> file ...
        chmod [-fR] <symbolic-mode-list> file ...
where <symbolic-mode-list> is a comma-separated list of
        [ugoa]{+|-|=}[rwxXlstugo]

[ verifying class <cswcpsampleconf> ]
## Executing postinstall script.
ADDED /opt/csw/bin/sudosh to /a/etc/shells.

Installation of <CSWsudosh2> was successful.
Issue History
2010-01-07 14:10 skayser New Issue
2010-01-07 17:40 bonivart Status new => assigned
2010-01-07 17:40 bonivart Assigned To => bonivart
2010-02-09 10:22 bonivart Note Added: 0007419
2010-02-11 13:55 bonivart Note Added: 0007421
2010-02-11 14:55 skayser Note Added: 0007422
2010-02-11 15:11 skayser Note Added: 0007423
2010-02-11 16:01 bonivart Note Added: 0007424
2010-03-31 22:06 bonivart Note Added: 0007785
2010-03-31 22:06 bonivart Status assigned => closed
2010-03-31 22:06 bonivart Resolution open => fixed

Notes
(0007419)
bonivart   
2010-02-09 10:22   
I have tried this in r8430, both for cpsampleconf and preserveconf. I will package 1.32 of cswclassutils so it can be tested.
(0007421)
bonivart   
2010-02-11 13:55   
Did you only try your fix with setting -R? Not without? Because it fails and I think it's the sed that is complaining about replacing nothing with nothing.

"First RE may not be null"

I will try a few more tricks. :-)
(0007422)
skayser   
2010-02-11 14:55   
You are right. Put

PKG_INSTALL_ROOT=${PKG_INSTALL_ROOT:-}

near the start of the script and it should be fine. We could also start thinking about a test suite for cswclassutils to make hacking on those scripts easier.
(0007423)
skayser   
2010-02-11 15:11   
Have to correct myself, the variable will be defined, but still be empty and sed unhappy. Didn't quite catch the context with sed.
(0007424)
bonivart   
2010-02-11 16:01   
I have fixed that part so it works without using -R now, could you please test 1.33 in testing *with* -R?
(0007785)
bonivart   
2010-03-31 22:06   
Released in 1.34.