Hi all,
I need to create a rpm to install a couple of init scripts. I have my
spec file working and my services start correctly.
My problem is that some paths depend on env vars.
Motivation: The link target is an executable whose name seems to be too
long to be a service. I cannot change this name. When starting the
service the OS truncates the name causing failure. To correct this, I
create a link with a shorter name.
Problem details: The path to the link varies on different installation
machines. It may be determined by an env var. When I create the rpm
using the spec file, the env vars get substituted then. I need them to
be substituted when the rpm is installed.
Is there a way to accomplish this?
Thanks,
-d
My spec file:
#
# Spec file for HDS services RPM
#
Summary: HDS applications installed as services.
Name: hds_services
Version: 0.1
Release: 1
License: Scientific Solutions, Inc.
Group: System Environment/Daemons
Source: hds_services_0.1.tar.gz
URL: http://scisol.com
Distribution: HDS Linux
Vendor: Scientific Solutions, Inc.
Packager: David Ohlemacher <dohlemacher@scisol.com>
%description
blah blah...
%prep
HDS_SERV_TAR_FILE=hds_services_0.1.tar.gz
rm -rf $RPM_BUILD_DIR/hdsServices/
tar xvfz $RPM_SOURCE_DIR/$HDS_SERV_TAR_FILE
%build
# There is nothing to build.
%install
topDir=hdsServices
cp -f $RPM_BUILD_DIR/$topDir/init.d/* /etc/rc.d/init.d
cp -f $RPM_BUILD_DIR/$topDir/ld.so.conf.d/* /etc/ld.so.conf.d
echo "installing TENA scripts in $TENA_HOME/$TENA_VERSION" >&2
cp -f $RPM_BUILD_DIR/$topDir/tenaScripts/run_nns.sh
$TENA_HOME/$TENA_VERSION/scripts
cp -f $RPM_BUILD_DIR/$topDir/tenaScripts/run_em.sh
$TENA_HOME/$TENA_VERSION/scripts
chmod 744 /etc/rc.d/init.d/hdsNetNameServ
chmod 744 /etc/rc.d/init.d/hdsExecManServ
chmod 644 $TENA_HOME/$TENA_VERSION/scripts/run_nns.sh
chmod 644 $TENA_HOME/$TENA_VERSION/scripts/run_em.sh
# Configure dynamic linker run time bindings
ldconfig
# The initscripts fail with excessively long app names (truncated). We
create short links to allow them to work.
ln -f -s
$TENA_HOME/$TENA_VERSION/bin/$TENA_PLATFORM/networkNamingService
$TENA_HOME/$TENA_VERSION/bin/$TENA_PLATFORM/hds_nns
ln -f -s $TENA_HOME/$TENA_VERSION/bin/$TENA_PLATFORM/executionManager
$TENA_HOME/$TENA_VERSION/bin/$TENA_PLATFORM/hds_em
# Configure the services to start at the desired runlevel(s).
chkconfig --level 3 hdsNetNameServ on
chkconfig --level 3 hdsExecManServ on
%files
%config %attr(644, root, root) /etc/rc.d/init.d/hdsServiceConfiguration
%attr(744, root, root) /etc/rc.d/init.d/hdsExecManServ
%attr(744, root, root) /etc/rc.d/init.d/hdsNetNameServ
%attr(744, root, root) /etc/ld.so.conf.d/hds.conf
%attr(644, ops, ops) /home/ops/TENA/5.2.1/scripts/run_nns.sh
%attr(644, ops, ops) /home/ops/TENA/5.2.1/scripts/run_em.sh
%post
ldconfig
# The initscripts fail with excessively long app names (truncated). We
create links to allow them to work.
ln -f -s
$TENA_HOME/$TENA_VERSION/bin/$TENA_PLATFORM/networkNamingService
$TENA_HOME/$TENA_VERSION/bin/$TENA_PLATFORM/hds_nns
ln -f -s $TENA_HOME/$TENA_VERSION/bin/$TENA_PLATFORM/executionManager
$TENA_HOME/$TENA_VERSION/bin/$TENA_PLATFORM/hds_em
# Configure the services to start at the desired runlevel(s).
chkconfig --level 3 hdsNetNameServ on
chkconfig --level 3 hdsExecManServ on
%preun
if [ "$1" = "0" ] ; then # last uninstall
/sbin/service hdsNetNameServ stop
/sbin/service hdsNetNameServ stop
/sbin/chkconfig --del hdsNetNameServ
/sbin/chkconfig --del hdsExecManServ
fi
%verifyscript
# The script sends info and error messages to stdout, and error messages
only to stderr. Normally RPM will only display stderr from a
verification script; the output sent to stdout is only displayed when
the verification is run in verbose mode.
p=/etc/rc.d/init.d/
for n in hdsServiceConfiguration hdsExecManServ hdsNetNameServ; do
echo -n "Looking for $n in $p... "
if ! ls $p | grep "^${n}\$" > /dev/null; then
echo "missing"
echo " ${n} missing from $p" >&2
else
echo "found"
fi
done
p=/etc/ld.so.conf.d/
for n in hds.conf; do
echo -n "Looking for $n in $p... "
if ! ls $p | grep "^${n}\$" > /dev/null; then
echo "missing"
echo " ${n} missing from $p" >&2
else
echo "found"
fi
done
p=$TENA_HOME/$TENA_VERSION/scripts/
for n in run_nns.sh run_em.sh; do
echo -n "Looking for $n in $p... "
if ! ls $p | grep "^${n}\$" > /dev/null; then
echo "missing"
echo " ${n} missing from $p" >&2
else
echo "found"
fi
done
p=$TENA_HOME/$TENA_VERSION/bin/$TENA_PLATFORM/
for n in hds_nns hds_em; do
echo -n "Looking for $n in $p... "
if ! ls $p | grep "^${n}\$" > /dev/null; then
echo "missing"
echo " ${n} missing from $p" >&2
else
echo "found"
fi
done
--
That which is common to the greatest number has the least care bestowed
upon it.
Aristotle
Received on Wed Dec 12 15:52:29 2007