We have had a longstanding puzzle as to why, when a whole-machine image
that includes pcp is constructed in a chroot, pcp is chkconfig off when
the image comes to be used. Turns out to be due to `which` not being
available in the rpm post-install ops in the chroot.
Investigation suggests that using `which` from bash can be unsafe even
when its available, so the best solution seems to be to use `type` instead
in these cases. Here I simply say, use `type` if `sh -c 'type -p sh'`
succeeds (I think this makes sense for linux/bash); otherwise use which
There are other uses of `which` elsewhere that can be switched over to
also use $PCP_SH_WHICH should it ever turn out that there are any real
systems that dont install `which`, or if there are problems caused
by `which` using a different PATH to that used by bash. The current
priority was just to catch those uses that occur during install.
===========================================================================
pcp/build/rpm/pcp.spec.in
===========================================================================
--- a/pcp/build/rpm/pcp.spec.in 2008-03-10 22:34:37.000000000 -0700
+++ b/pcp/build/rpm/pcp.spec.in 2008-03-10 21:34:18.488557356 -0700
@@ -12,6 +12,7 @@
%if %sgi_chroot_build
Source: @package_name@-@package_version@.tar.bz2
BuildRequires: gcc-c++ libstdc++-devel
+
#
# Try not building 32bit libs for x86_64 & see who screams
#%ifarch x86_64
@@ -135,9 +136,11 @@
$PCP_RC_DIR/pmie stop >/dev/null 2>&1
[ -x $PCP_RC_DIR/pmproxy ] && PCP_RC_DIR/pmproxy stop >/dev/null 2>&1
rm -f $PCP_VAR_DIR/pmns/.NeedRebuild
+ else
+ PCP_SH_WHICH=type
fi
- if which chkconfig >/dev/null 2>&1
+ if $PCP_SH_WHICH chkconfig >/dev/null 2>&1
then
chkconfig --del pcp >/dev/null 2>&1
chkconfig --del pmie >/dev/null 2>&1
@@ -191,7 +194,7 @@
#
# the chkconfig thing
#
- if which chkconfig >/dev/null 2>&1
+ if $PCP_SH_WHICH chkconfig >/dev/null 2>&1
then
chkconfig --add pcp >/dev/null 2>&1
chkconfig --add pmie >/dev/null 2>&1
===========================================================================
pcp/build/rpm/pro.spec.in
===========================================================================
--- a/pcp/build/rpm/pro.spec.in 2008-03-10 22:34:37.000000000 -0700
+++ b/pcp/build/rpm/pro.spec.in 2008-03-10 21:42:35.882225055 -0700
@@ -182,8 +182,11 @@
if [ -f /etc/pcp.env ] ; then
. /etc/pcp.env
$PCP_RC_DIR/pmclusterd stop >/dev/null 2>&1
+ else
+ PCP_SH_WHICH=type
fi
- if which chkconfig >/dev/null 2>&1
+
+ if $PCP_SH_WHICH chkconfig >/dev/null 2>&1
then
chkconfig --del pmclusterd >/dev/null 2>&1
else
@@ -249,7 +252,7 @@
#
# the chkconfig thing
#
-if which chkconfig >/dev/null 2>&1
+if $PCP_SH_WHICH chkconfig >/dev/null 2>&1
then
chkconfig --add pmclusterd >/dev/null 2>&1
fi
===========================================================================
pcp/configure.in
===========================================================================
--- a/pcp/configure.in 2008-03-10 22:34:37.000000000 -0700
+++ b/pcp/configure.in 2008-03-10 21:12:41.294952824 -0700
@@ -507,6 +507,13 @@
fi
AC_SUBST(grep)
+which=which
+if sh -c 'type -p sh' >/dev/null 2>&1
+then
+ which=type
+fi
+AC_SUBST(which)
+
dnl checks for /proc pseudo file system and /proc/pinfo
AC_MSG_CHECKING([for /proc ])
if test -d /proc
===========================================================================
pcp/src/include/pcp.conf.in
===========================================================================
--- a/pcp/src/include/pcp.conf.in 2008-03-10 22:34:37.000000000 -0700
+++ b/pcp/src/include/pcp.conf.in 2008-03-10 21:20:23.070618643 -0700
@@ -130,6 +130,9 @@
PCP_PS_HAVE_BSD=@pcp_ps_have_bsd@
PCP_PS_ALL_FLAGS=@pcp_ps_all_flags@
+# which
+PCP_SH_WHICH=@which@
+
# host os
PCP_PLATFORM=@target_os@
===========================================================================
pcp/src/pmcd/rc-proc.sh
===========================================================================
--- a/pcp/src/pmcd/rc-proc.sh 2008-03-10 22:34:37.000000000 -0700
+++ b/pcp/src/pmcd/rc-proc.sh 2008-03-10 21:23:04.924294871 -0700
@@ -30,11 +30,11 @@
[ -f $PCP_RC_DIR/$1 ] && _have_flag=true
- if which runlevel >/dev/null 2>&1
+ if $PCP_SH_WHICH runlevel >/dev/null 2>&1
then
if [ "$PCP_PLATFORM" = solaris -o "$PCP_PLATFORM" = darwin ]
then
- if which runlevel | grep "no runlevel" >/dev/null
+ if $PCP_SH_WHICH runlevel | grep "no runlevel" >/dev/null
then
:
else
@@ -45,11 +45,11 @@
fi
fi
- if which chkconfig >/dev/null 2>&1
+ if $PCP_SH_WHICH chkconfig >/dev/null 2>&1
then
if [ "$PCP_PLATFORM" = solaris -o "$PCP_PLATFORM" = darwin ]
then
- if which chkconfig | grep "no chkconfig" >/dev/null
+ if $PCP_SH_WHICH chkconfig | grep "no chkconfig" >/dev/null
then
:
else
@@ -247,7 +247,7 @@
echo " To enable $_flag, run the following as root:"
if $_have_chkconfig
then
- _cmd=`which chkconfig`
+ _cmd=`$PCP_SH_WHICH chkconfig`
echo " # $_cmd $_flag on"
else
if [ -f /etc/debian_version ]; then
Dr.Michael("Kimba")Newton kimbrr@xxxxxxx
|