summaryrefslogtreecommitdiff
path: root/scripts/vpkg-provides.sh
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1999-10-20 16:46:54 +0000
committerjbj <devnull@localhost>1999-10-20 16:46:54 +0000
commitb38f7bc532b038cfc0aac13ba8a7ff15c6c6b923 (patch)
tree786b9f67dbbb76548c40c8f311b1014b78d85853 /scripts/vpkg-provides.sh
parent925c8130d5e4b8399e45e79b6253df5f8a8de760 (diff)
downloadrpm-b38f7bc532b038cfc0aac13ba8a7ff15c6c6b923.tar.gz
rpm-b38f7bc532b038cfc0aac13ba8a7ff15c6c6b923.tar.bz2
rpm-b38f7bc532b038cfc0aac13ba8a7ff15c6c6b923.zip
Dependency code from Ken Estes.
CVS patchset: 3384 CVS date: 1999/10/20 16:46:54
Diffstat (limited to 'scripts/vpkg-provides.sh')
-rwxr-xr-xscripts/vpkg-provides.sh275
1 files changed, 212 insertions, 63 deletions
diff --git a/scripts/vpkg-provides.sh b/scripts/vpkg-provides.sh
index df4746791..88130420c 100755
--- a/scripts/vpkg-provides.sh
+++ b/scripts/vpkg-provides.sh
@@ -1,12 +1,15 @@
+
+
#!/bin/sh
#
# Original Author: Tim Mooney (mooney@plains.NoDak.edu)
+# Improvements by: Ken Estes <kestes@staff.mail.com>
#
# This file is distributed under the terms of the GNU General Public License
#
-# non-linux-provides is part of RPM, the Red Hat Package Manager.
-# non-linux-provides searches a list of directories (based on what OS it's
+# vpkg-provides.sh is part of RPM, the Red Hat Package Manager.
+# vpkg-provides.sh searches a list of directories (based on what OS it's
# being executed on) for shared libraries and interpreters that have been
# installed by some packaging system other than RPM. It then generates a
# spec file that can be used to build a "virtual package" that provides all
@@ -20,15 +23,55 @@
# first effort was great, so I didn't want to wait until the better solution
# was done.
+# you will need to create a spec_header for the virtual package. This
+# header will provide such specfile information as:
+#
+# Summary:
+# Name:
+# Version:
+# Release:
+# Copyright:
+# Group:
+# Source:
+
+
+usage= "usage: $0 [--spec_header '/path/to/os-base-header.spec'] \n"
+usage= "$usage\t[--find_provides '/path/to/find-provides']\n"
+usage= "$usage\t[--shlib_dirs 'dirs:which:contain:shared:libs']\n"
+usage= "$usage\t[--ignore_dirs 'egrep|pattern|of|paths|to|ignore']\n"
+
+# these two should be unnessary as the regular dependency analysis
+# should take care of interpreters as well as shared libraries.
+
+usage= "$usage\t[--interp_dirs 'dirs:which:contain:interpreters']\n"
+usage= "$usage\t[--interps 'files:to:assume:are:installed']\n"
+
+
+# this command may not be portable to all OS's, does something else
+# work? can this be set in the case $osname statement?
+
+sum_cmd="xargs cksum"
+
+date=`date`
+hostname=`uname -n`
+
+# if some subdirectories of the system directories needs to be ignored
+# (eg /usr/local is a subdirectory of /usr but should not be part of
+# the virtual package) then call this script with IGNORE_DIRS set to a
+# vaild egrep pattern which discribes the directories to ignored.
+
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd
export PATH
+
#
-# The default directories to use if they're not specified as
-# arguments 1 and 2, respectively.
+# The (OS independent) default values.
#
-default_spec_header='/usr/local/lib/rpm/os-base-header.spec';
-default_find_provides='/usr/local/lib/rpm/find-provides';
+spec_header='/usr/local/lib/rpm/os-base-header.spec';
+interps="sh:csh:ksh:dtksh:wish:tclsh:perl:awk:gawk:nawk:oawk"
+find_provides='/usr/local/lib/rpm/find-provides';
+ignore_dirs="."
+
osname=`uname -s`
if test $? -ne 0 || test X$osname = X ; then
@@ -36,73 +79,29 @@ if test $? -ne 0 || test X$osname = X ; then
exit 1
fi
-if test X$1 = X ; then
- if test -f $default_spec_header ; then
- spec_header=$default_spec_header
- else
- echo "You must pass me the full path to the partial spec file"
- echo "as my first argument, since this file does not appear in the"
- echo "default location of $default_spec_header"
- echo
- echo "usage: $0 [ /path/to/spec-header ] [ /path/to/find-provides ]"
- echo
- exit 9
- fi
-else
- spec_header=$1
- if test ! -f $spec_header ; then
- echo "$spec_header does not exist or is not what I was expecting."
- exit 10
- fi
-fi
-
-if test X$2 = X ; then
- if test -f $default_find_provides ; then
- find_provides=$default_find_provides
- else
- echo "You must pass me the full path to the find-provides script as my"
- echo "second argument, since find-provides does not appear in the"
- echo "default location of $default_find_provides"
- echo
- echo "usage: $0 [ /path/to/spec-header ] [ /path/to/find-provides ]"
- echo
- exit 9
- fi
-else
- find_provides=$2
- if test ! -f $find_provides ; then
- echo "$find_provides does not exist or is not what I was expecting."
- exit 10
- fi
-fi
#
-# Set what directories we search for shared libraries and what interpreters
-# we look for, based on what OS we're on.
+# Set OS dependent defaults
#
case $osname in
OSF1)
shlib_dirs='/shlib:/usr/shlib:/usr/dt/lib:/usr/opt'
interp_dirs='/bin:/usr/bin:/sbin:/usr/dt/bin:/usr/bin/posix'
- interps="sh:csh:ksh:dtksh:wish:tclsh:perl:awk:gawk:nawk:oawk"
;;
HP-UX)
shlib_dirs='/usr/shlib:/usr/dt/lib:/opt'
shlib_dirs="$shlib_dirs:/usr/bms:/usr/obam:/usr/sam"
interp_dirs='/bin:/usr/bin:/sbin:/usr/dt/bin:/usr/bin/posix'
- interps="sh:csh:ksh:dtksh:wish:tclsh:perl:awk:gawk:nawk:oawk"
;;
AIX)
shlib_dirs='/usr/lib:/usr/ccs/lib:/usr/dt/lib:/usr/lpp:/usr/opt'
interp_dirs='/bin:/usr/bin:/sbin:/usr/dt/bin'
- interps="bsh:sh:csh:ksh:dtksh:wish:tclsh:perl:awk:gawk:nawk:oawk"
;;
SunOS)
shlib_dirs='/etc/lib:/etc/vx:/opt:/usr/lib:/usr/ccs/lib:/usr/dt/lib'
shlib_dirs="$shlib_dirs:/usr/4lib:/usr/openwin/lib:/usr/snadm/lib"
shlib_dirs="$shlib_dirs:/usr/ucblib:/usr/xpg4/lib"
interp_dirs='/bin:/usr/bin:/sbin:/usr/dt/bin:/usr/xpg4/bin'
- interps="bsh:sh:csh:ksh:dtksh:wish:tclsh:perl:awk:gawk:nawk:oawk"
;;
IRIX|IRIX64)
shlib_dirs='/lib:/usr/lib:/usr/lib32:/usr/lib64'
@@ -111,7 +110,6 @@ case $osname in
shlib_dirs="$shlib_dirs:/usr/sgitcl:/usr/SGImeeting:/usr/pcp/lib"
shlib_dirs="$shlib_dirs:/usr/Motif-2.1"
interp_dirs='/bin:/usr/bin:/sbin:/usr/sbin:/usr/dt/bin'
- interps="sh:csh:tcsh:ksh:dtksh:wish:tclsh:perl:perl5:awk:gawk:nawk:oawk"
;;
*)
echo "I'm sorry. I haven't been configured yet to work on $osname."
@@ -126,9 +124,96 @@ case $osname in
;;
esac
-tmp_file=/tmp/shlibs.$$
-if test -f $tmp_file ; then
- echo "$tmp_file already exists. Exiting."
+
+# allow the user to change defaults with the command line arguments.
+
+# Loop over all args
+
+while :
+do
+
+# Break out if there are no more args
+ case $# in
+ 0)
+ break
+ ;;
+ esac
+
+# Get the first arg, and shuffle
+ option=$1
+ shift
+
+# Make all options have two hyphens
+ orig_option=$option # Save original for error messages
+ case $option in
+ --*) ;;
+ -*) option=-$option ;;
+ esac
+
+
+ case $option in
+ --spec_header)
+ spec_header=$1
+ shift
+ ;;
+ --ignore_dirs)
+ ignore_dirs=$1
+ shift
+ ;;
+ --find_provides)
+ find_provides=$1
+ shift
+ ;;
+ --shlib_dirs)
+ shlib_dirs=$1
+ shift
+ ;;
+ --interp_dirs)
+ interp_dirs=$1
+ shift
+ ;;
+ --interps)
+ interps=$1
+ shift
+ ;;
+ --help)
+ echo $usage
+ exit 0
+ ;;
+ *)
+ echo "$0: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
+ exit 1
+ ;;
+
+
+# consistancy checks on the arguments
+
+if [ ! -f $spec_header ]; then
+ echo "You must pass me the full path to the partial spec file"
+ echo "as my first argument, since this file does not appear in the"
+ echo "default location of $default_spec_header"
+ echo
+ echo $usage
+ echo
+ exit 9
+fi
+
+
+if [ ! -f $find_provides ]; then
+ echo "You must pass me the full path to the find-provides script as my"
+ echo "second argument, since find-provides does not appear in the"
+ echo "default location of $default_find_provides"
+ echo
+ echo $usage
+ echo
+ exit 9
+fi
+
+
+
+provides_tmp=/tmp/provides.$$
+if test -f $provides_tmp ; then
+ echo "$provides_tmp already exists. Exiting."
exit 11
fi
@@ -138,16 +223,25 @@ fi
#
for d in `echo $shlib_dirs | sed -e 's/:/ /g'`
do
- find $d -type f -print 2>/dev/null | $find_provides >> $tmp_file
+ find $d -type f -print 2>/dev/null | egrep -v \'$IGNORE_DIRS\' | $find_provides >> $provides_tmp
done
-provides=/tmp/provides.$$
-if test -f $provides ; then
- echo "$provides already exists. Exiting."
+sum_tmp=/tmp/sum.$$
+if test -f $sum_tmp ; then
+ echo "$sum_tmp already exists. Exiting."
exit 11
fi
#
+# iterate through all the directories in shlib_dirs, record the sum
+#
+for d in `echo $shlib_dirs | sed -e 's/:/ /g'`
+do
+ find $d -type f -print 2>/dev/null | egrep -v \'$IGNORE_DIRS\' | $sum_cmd >> $sum_tmp
+done
+
+
+#
# output the initial part of the spec file
#
cat $spec_header
@@ -155,7 +249,7 @@ cat $spec_header
#
# Output the shared libraries
#
-for f in `cat $tmp_file | sort -u`
+for f in `cat $provides_tmp | sort -u`
do
echo "Provides: $f"
done
@@ -174,10 +268,8 @@ do
done
#
-# Finish off the spec file we're spitting out.
+# Output the discription of the spec file
#
-date=`date`
-hostname=`uname -n`
cat <<_EIEIO_
@@ -194,6 +286,9 @@ $date.
_EIEIO_
+#
+# Output the build sections of the spec file
+#
echo '%prep'
echo '# nothing to do'
echo '%build'
@@ -202,4 +297,58 @@ echo '%install'
echo '# nothing to do'
echo '%clean'
echo '# nothing to do'
+
+#
+# Output the verify section of the spec file
+#
+
+cat <<_EIEIO_
+
+%verifyscript
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd
+export PATH
+
+sum_current_tmp=/tmp/rpm.sum.current.\$\$
+if test -f \$sum_current_tmp ; then
+ echo "\$sum_current_tmp already exists. Exiting."
+ exit 11
+fi
+
+sum_package_tmp=/tmp/rpm.sum.package.\$\$
+if test -f \$sum_package_tmp ; then
+ echo "\$sum_package_tmp already exists. Exiting."
+ exit 11
+fi
+
+for d in `echo $shlib_dirs | sed -e 's/:/ /g'`
+do
+ find \$d -type f -print 2>/dev/null | egrep -v \'$IGNORE_DIRS\' | $sum_cmd >> \$sum_current_tmp
+done
+
+cat >\$sum_package_tmp <<_EOF_
+_EIEIO_
+
+# the contents of the temporary file are hardcoded into the verify
+# script so that the file can be reproduced at verification time.
+
+cat $sum_tmp
+
+cat <<_EIEIO_
+_EOF_
+
+
+cmp \$sum_package_tmp \$sum_current_tmp
+
+if [ $? -ne 0 ]; then
+ echo"Differences found by: cmp \$sum_package_tmp \$sum_current_tmp"
+ exit \$?
+fi
+
+_EIEIO_
+
+#
+# Output the files section of the spec file
+#
+
echo '%files'