Revisiting.
First I looked at apxs using perl debug mode:
Getting to the core: it looks like apxs is working fine:
It gets to where it calls instdso.sh and the second command (chmod) fails.
DB<1>
apxs::(/opt/httpd/sbin/apxs:525): &execute_cmds(@cmds);
DB<1> x @cmds
0 '/var/httpd/build/instdso.sh SH_LIBTOOL=\'/var/apr/build-1/libtool\'
libphp5.la /var/tmp/root/php-5.2.17.0/opt/httpd/libexec'
1 'chmod 755 /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.so'
/var/httpd/build/instdso.sh SH_LIBTOOL='/var/apr/build-1/libtool' libphp5.la
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec
rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.so
/var/apr/build-1/libtool --mode=install cp libphp5.la
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/
libtool: install: cp .libs/libphp5.a
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
libtool: install: cp .libs/libphp5.lai
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
libtool: install: warning: remember to run `libtool --finish
/data/prj/php/php-5.2.17/libs'
chmod 755 /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.so
chmod: /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.so: A file or
directory in the path name does not exist.
apxs:Error: Command failed with rc=65536
.
Debugged program terminated. Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info.
So, now to look deeper at instdso.sh
ksh -x /var/httpd/build/instdso.sh SH_LIBTOOL=/var/apr/build-1/libtool
libphp5.la /var/tmp/root/php-5.2.17.0/opt/httpd/libexec
+ test 3 != 3
+ + sed -e s/^SH_LIBTOOL=//
+ echo SH_LIBTOOL=/var/apr/build-1/libtool
SH_LIBTOOL=/var/apr/build-1/libtool
+ DSOARCHIVE=libphp5.la
+ + basename libphp5.la
DSOARCHIVE_BASENAME=libphp5.la
+ TARGETDIR=/var/tmp/root/php-5.2.17.0/opt/httpd/libexec
+ + sed -e s/\.la$//
+ echo libphp5.la
DSOBASE=libphp5
+ TARGET_NAME=libphp5.so
+ + uname -s
SYS=AIX
+ test AIX = AIX
+ CMD=rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.so
+ echo rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.so
rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.so
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.so
+ CMD=/var/apr/build-1/libtool --mode=install cp libphp5.la
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/
+ echo /var/apr/build-1/libtool --mode=install cp libphp5.la
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/
/var/apr/build-1/libtool --mode=install cp libphp5.la
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/
+ /var/apr/build-1/libtool --mode=install cp libphp5.la
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/
libtool: install: cp .libs/libphp5.a
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
libtool: install: cp .libs/libphp5.lai
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
libtool: install: warning: remember to run `libtool --finish
/data/prj/php/php-5.2.17/libs'
+ test AIX = OS/2
+ + sed -n /^dlname=/{s/.*='\([^']*\)'/\1/;p;}
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
DLNAME=libphp5.so
+ + sed -n /^library_names/{s/library_names='\([^']*\)'/\1/;p;}
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
LIBRARY_NAMES=libphp5.a libphp5.a
+ + sed -e s/ *libphp5.so//g
+ echo libphp5.a libphp5.a
LIBRARY_NAMES=libphp5.a libphp5.a
+ test -z libphp5.so
+ test -n libphp5.a libphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
+ test libphp5.so != libphp5.so
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/liblibphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/liblibphp5.so
+ exit 0
root@x093:[/data/prj/php/php-5.2.17]
Actually, looking at the source code, it all seems to be right - the key
lines are here:
DLNAME=`sed -n "/^dlname=/{s/.*='\([^']*\)'/\1/;p;}"
$TARGETDIR/$DSOARCHIVE_BASENAME`
LIBRARY_NAMES=`sed -n
"/^library_names/{s/library_names='\([^']*\)'/\1/;p;}"
$TARGETDIR/$DSOARCHIVE_BASENAME`
LIBRARY_NAMES=`echo $LIBRARY_NAMES | sed -e "s/ *$DLNAME//g"`
if test -z "$DLNAME"
then
echo "Warning! dlname not found in $TARGETDIR/$DSOARCHIVE_BASENAME."
echo "Assuming installing a .so rather than a libtool archive."
exit 0
fi
if test -n "$LIBRARY_NAMES"
then
for f in $LIBRARY_NAMES
do
rm -f $TARGETDIR/$f
done
fi
if test "$DLNAME" != "$TARGET_NAME"
then
mv $TARGETDIR/$DLNAME $TARGETDIR/$TARGET_NAME
fi
rm -f $TARGETDIR/$DSOARCHIVE_BASENAME
rm -f $TARGETDIR/$DSOBASE.a
rm -f $TARGETDIR/lib$DSOBASE.a
rm -f $TARGETDIR/lib$TARGET_NAME
exit 0
The problem is here:
CMD="$SH_LIBTOOL --mode=install cp $DSOARCHIVE $TARGETDIR/"
echo $CMD
$CMD || exit $?
At least, I am assuming this to be the problem - because I am assuming the
expectation is that $TARGET_NAME has been installed - unless DLNAME !=
TARGET_NAME - because in that case DLNAME gets moved.
Unfortunately, what has been installed is $LIBRARY_NAMES and that has
already been removed!
What has actually been installed - been staring at me for years is:
root@x093:[/data/prj/php/php-5.2.17]/var/apr/build-1/libtool --mode=install
cp libphp5.la /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/
libtool: install: cp .libs/libphp5.a
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
libtool: install: cp .libs/libphp5.lai
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
libtool: install: warning: remember to run `libtool --finish
/data/prj/php/php-5.2.17/libs'
root@x093:[/data/prj/php/php-5.2.17]ls -l
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/
total 46488
-rw-r--r-- 1 root system 23790199 Jun 20 15:58 libphp5.a
-rw-r--r-- 1 root system 1239 Jun 20 15:58 libphp5.la
The possible inputs are here:
root@x093:[/data/prj/php/php-5.2.17]ls -l .libs
total 92512
-rw-r--r-- 1 root system 23790199 Jun 19 18:14 libphp5.a
-rw-r--r-- 1 root system 127631 Jun 19 18:14 libphp5.exp
lrwxrwxrwx 1 root system 13 Jun 19 18:14 libphp5.la -> ../
libphp5.la
-rw-r--r-- 1 root system 1239 Jun 19 18:14 libphp5.lai
-rwxr-xr-x 1 root system 23433546 Jun 19 18:14 libphp5.so
So, now back to what happens:
As instdso.sh cleans up this is what it does:
+ /var/apr/build-1/libtool --mode=install cp libphp5.la
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/
libtool: install: cp .libs/libphp5.a
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
libtool: install: cp .libs/libphp5.lai
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
libtool: install: warning: remember to run `libtool --finish
/data/prj/php/php-5.2.17/libs'
+ test AIX = OS/2
+ + sed -n /^dlname=/{s/.*='\([^']*\)'/\1/;p;}
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
DLNAME=libphp5.so
## This DLNAME or TARGET_NAME is what the chmod command wants to act on
later
+ + sed -n /^library_names/{s/library_names='\([^']*\)'/\1/;p;}
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
## I assume this is correct
LIBRARY_NAMES=libphp5.a libphp5.a
+ + sed -e s/ *libphp5.so//g
+ echo libphp5.a libphp5.a
LIBRARY_NAMES=libphp5.a libphp5.a
+ test -z libphp5.so
# This is expected, continue
+ test -n libphp5.a libphp5.a
# And here we delete what was installed!!!
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
+ test libphp5.so != libphp5.so
# DLNAME == TARGET_NAME, so no move command
### none of these (except the first) exist
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/liblibphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/liblibphp5.so
# And now, everything is gone
+ exit 0
So, my quick hack is:
...
DLNAME=`sed -n "/^dlname=/{s/.*='\([^']*\)'/\1/;p;}"
$TARGETDIR/$DSOARCHIVE_BASENAME`
LIBRARY_NAMES=`sed -n
"/^library_names/{s/library_names='\([^']*\)'/\1/;p;}"
$TARGETDIR/$DSOARCHIVE_BASENAME`
LIBRARY_NAMES=`echo $LIBRARY_NAMES | sed -e "s/ *$DLNAME//g"`
if test -z "$DLNAME"
then
echo "Warning! dlname not found in $TARGETDIR/$DSOARCHIVE_BASENAME."
echo "Assuming installing a .so rather than a libtool archive."
exit 0
fi
## move block up to move DLNAME to TARGET_NAME before testing for existence
if test "$DLNAME" != "$TARGET_NAME"
then
mv $TARGETDIR/$DLNAME $TARGETDIR/$TARGET_NAME
fi
# if doesn't exist, then try copying from .libs directly - $CMD above
missed, sigh
if ! test -e $TARGETDIR/$TARGET_NAME
then
cp -p .libs/$TARGET_NAME $TARGETDIR/$TARGET_NAME
fi
if test -n "$LIBRARY_NAMES"
then
for f in $LIBRARY_NAMES
do
rm -f $TARGETDIR/$f
done
fi
rm -f $TARGETDIR/$DSOARCHIVE_BASENAME
rm -f $TARGETDIR/$DSOBASE.a
rm -f $TARGETDIR/lib$DSOBASE.a
rm -f $TARGETDIR/lib$TARGET_NAME
exit 0
And the result is:
libtool: install: cp .libs/libphp5.a
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
libtool: install: cp .libs/libphp5.lai
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
libtool: install: warning: remember to run `libtool --finish
/data/prj/php/php-5.2.17/libs'
+ test AIX = OS/2
+ + sed -n /^dlname=/{s/.*='\([^']*\)'/\1/;p;}
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
DLNAME=libphp5.so
+ + sed -n /^library_names/{s/library_names='\([^']*\)'/\1/;p;}
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
LIBRARY_NAMES=libphp5.a libphp5.a
+ + sed -e s/ *libphp5.so//g
+ echo libphp5.a libphp5.a
LIBRARY_NAMES=libphp5.a libphp5.a
+ test -z libphp5.so
+ test libphp5.so != libphp5.so
+ test -e /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.so
+ cp -p .libs/libphp5.so
/var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.so
+ test -n libphp5.a libphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.la
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/libphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/liblibphp5.a
+ rm -f /var/tmp/root/php-5.2.17.0/opt/httpd/libexec/liblibphp5.so
+ exit 0
Will submit a diff -u output later - need to reinstall the original - sigh,
forgot to copy before editing.
On Mon, May 5, 2014 at 8:17 AM, Michael Felt <[email protected]> wrote:
> I see I did not read far enough - as you found the reference to slibclean.
> In it's defense I expect the IBM install program is using slibclean during
> it's installation of files - or, the files are being moved to something
> like /usr/lpp/lpp.name/save (it has been a long long time since I have
> studied how the installp recover option works) and the remove is only
> actually performed after the new files have been put into position.
>
>
> On Mon, May 5, 2014 at 8:14 AM, Michael Felt <[email protected]> wrote:
>
>> Well, my patch is at the end, leaving the rm in place. However, I could
>> examine looking at using slibclean (shared library clean) - which is the
>> program to remove outstanding (loaded, but not active) shared library code.
>>
>> And - thinking through - if the remove is not done, and the .so file is
>> not copied - the old .so copy remains - but you "expect" it to be updated.
>> For these cases, rather than remove I would move the file to a dated pid
>> (mv $TARGET $TARGET.$today.$$) - and if all fails move it back, otherwise
>> remove (and slibclean again, for certainty). I have been quite perturbed in
>> the past when I was installing "live" and it failed. My previous installed
>> php was now broken.
>>
>> re: slibclean - the program has been around "forever" - at least since
>> since AIX 4.X (starting in 1994-1995). No idea if it has been tested before
>> for php and/or instdso.sh.
>>
>> However, to work, slibclean still needs the previous version to be
>> stopped. I assume that is the same as unlink() of a file - the inode is not
>> actually cleared until both the link count is 0 and there are no open
>> connections to the inode. That is, I do not expect that slibclean is
>> removing "open" routines - but it might.
>>
>> Finally, In my case, as I am "packaging" to a temp directory (installing
>> to $INSTALL_ROOT/*) this should never be an issue. The other issue I run
>> into is the -a argument - because when packaging (
>>
>>
>> On Sun, May 4, 2014 at 11:54 PM, Victor J. Orlikowski <
>> [email protected]> wrote:
>>
>>> On May 4, 2014, at 5:46 PM, Victor J. Orlikowski <
>>> [email protected]> wrote:
>>>
>>> My only comment to that would be: has AIX resolved the issue wherein it
>>> is required that the file backing a previously-loaded module has to be
>>> rm’d, in order to ensure that the in-memory copy is released?
>>>
>>>
>>> Responding to myself, after a quick consult with the Googlemonster:
>>> Seems you need to call a utility called slibclean, to remove the memory
>>> references to the shared object.
>>>
>>> And, sometimes, that still doesn’t work - so you have to rm it anyway. :/
>>>
>>> Anyhoo - it seems to me that the real problem is that we’re deleting the
>>> newly generated .so, rather than the *target* into which we’re trying to
>>> copy (which is what would be what has the in-memory references).
>>>
>>> Best,
>>> Victor
>>> --
>>> Victor J. Orlikowski <> [email protected]
>>>
>>>
>>
>