4 # Original Author: Tim Mooney (mooney@plains.NoDak.edu)
5 # Improvements by: Ken Estes <kestes@staff.mail.com>
7 # This file is distributed under the terms of the GNU General Public License
10 # vpkg-provides.sh is part of RPM, the Red Hat Package Manager.
12 # vpkg-provides.sh searches a list of directories (based on what OS
13 # it's being executed on) for shared libraries and interpreter files
14 # that have been installed by some packaging system other than RPM.
15 # It then generates a spec file that can be used to build a "virtual
16 # package" that provides all of these things without actually
17 # installing any files. The spec file in effect tells rpm what it
18 # needs to know about operating system files which are not under rpm
19 # control. This makes it much easier to use RPM on non-Linux systems.
21 # By default the script also generates a %verifyscript (with hard
22 # coded $shlib_dirs, $ignore_dirs values) which will check that the
23 # checksum of each file in the directories searched has not changed
24 # since the package was built.
26 # Comments: This script is a quick hack. A better solution is to use the
27 # vendor's package management commands to actually query what's installed, and
28 # build one or more spec files based on that. This is something
29 # I intend to write, probably in perl, but the need for something like this
30 # first effort was great, so I didn't want to wait until the better solution
33 # The complete specfile will be sent to stdout.
35 # you will need to create a spec_header for the virtual package. This
36 # header will provide such specfile information as:
47 # most of the command line arguments have defaults
49 usage="usage: $0 --spec_header '/path/to/os-base-header.spec' \n"
50 usage="$usage\t[--find_provides '/path/to/find-provides']\n"
51 usage="$usage\t[--shlib_dirs 'dirs:which:contain:shared:libs']\n"
52 usage="$usage\t[--ignore_dirs 'grep-E|pattern|of|paths|to|ignore']\n"
54 # these two should be unnessary as the regular dependency analysis
55 # should take care of interpreters as well as shared libraries.
57 usage="$usage\t[--interp_dirs 'dirs:which:contain:interpreters']\n"
58 usage="$usage\t[--interps 'files:to:assume:are:installed']\n"
59 usage="$usage\t[--no_verify]\n"
62 # this command may not be portable to all OS's, does something else
63 # work? can this be set in the case $osname statement?
70 # if some subdirectories of the system directories needs to be ignored
71 # (eg /usr/local is a subdirectory of /usr but should not be part of
72 # the virtual package) then call this script with ignore_dirs set to a
73 # valid grep -E pattern which discribes the directories to ignored.
75 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd
80 # The (OS independent) default values.
82 spec_header='/usr/lib/rpm/os-base-header.spec';
83 interps="sh:csh:ksh:dtksh:wish:tclsh:perl:awk:gawk:nawk:oawk"
84 find_provides='/usr/lib/rpm/find-provides';
86 # no file names begin with this character so it is a good default
93 if test $? -ne 0 || test X$osname = X ; then
94 echo "I can't determine what platform this is. Exiting"
100 # Set OS dependent defaults
104 shlib_dirs='/shlib:/usr/shlib:/usr/dt/lib:/usr/opt'
105 interp_dirs='/bin:/usr/bin:/sbin:/usr/dt/bin:/usr/bin/posix'
108 shlib_dirs='/usr/shlib:/usr/dt/lib:/opt'
109 shlib_dirs="$shlib_dirs:/usr/bms:/usr/obam:/usr/sam"
110 interp_dirs='/bin:/usr/bin:/sbin:/usr/dt/bin:/usr/bin/posix'
113 shlib_dirs='/usr/lib:/usr/ccs/lib:/usr/dt/lib:/usr/lpp:/usr/opt'
114 interp_dirs='/bin:/usr/bin:/sbin:/usr/dt/bin'
117 shlib_dirs='/etc/lib:/etc/vx:/opt:/usr/lib:/usr/ccs/lib:/usr/dt/lib'
118 shlib_dirs="$shlib_dirs:/usr/4lib:/usr/openwin/lib:/usr/snadm/lib"
119 shlib_dirs="$shlib_dirs:/usr/ucblib:/usr/xpg4/lib"
120 interp_dirs='/bin:/usr/bin:/sbin:/usr/dt/bin:/usr/xpg4/bin'
123 shlib_dirs='/lib:/usr/lib:/usr/lib32:/usr/lib64'
124 # Irix always makes me laugh...
125 shlib_dirs="$shlib_dirs:/usr/ToolTalk:/usr/xfsm:/usr/SpeedShop"
126 shlib_dirs="$shlib_dirs:/usr/sgitcl:/usr/SGImeeting:/usr/pcp/lib"
127 shlib_dirs="$shlib_dirs:/usr/Motif-2.1"
128 interp_dirs='/bin:/usr/bin:/sbin:/usr/sbin:/usr/dt/bin'
131 echo "I'm sorry. I haven't been configured yet to work on $osname."
132 echo "Please poke around your system and try figure out what directories"
133 echo "I should be searching for shared libraries. Once you have this"
134 echo "information, email it to rpm-list@redhat.com, so that your OS"
135 echo "will be supported by some future version of this script."
144 # allow the user to change defaults with the command line arguments.
151 # Break out if there are no more args
158 # Get the first arg, and shuffle
162 # Make all options have two hyphens
163 orig_option=$option # Save original for error messages
166 -*) option=-$option ;;
203 echo "$0: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
210 # consistancy checks on the arguments
212 if [ ! -f $spec_header ]; then
213 echo "You must pass me the full path to the partial spec file"
214 echo "as my first argument, since this file does not appear in the"
215 echo "default location of $default_spec_header"
223 if [ ! -f $find_provides ]; then
224 echo "You must pass me the full path to the find-provides script as my"
225 echo "second argument, since find-provides does not appear in the"
226 echo "default location of $default_find_provides"
235 provides_tmp=${TMPDIR:-/tmp}/provides.$$
236 if test -f $provides_tmp ; then
237 echo "$provides_tmp already exists. Exiting."
242 # iterate through all the directories in shlib_dirs, looking for shared
245 for d in `echo $shlib_dirs | sed -e 's/:/ /g'`
247 find $d -type f -print 2>/dev/null | grep -E -v \'$ignore_dirs\' | $find_provides >> $provides_tmp
250 sum_tmp=${TMPDIR:-/tmp}/sum.$$
251 if test -f $sum_tmp ; then
252 echo "$sum_tmp already exists. Exiting."
257 # iterate through all the directories in shlib_dirs, record the sum
259 for d in `echo $shlib_dirs | sed -e 's/:/ /g'`
261 find $d -type f -print 2>/dev/null | grep -E -v \'$ignore_dirs\' | $sum_cmd >> $sum_tmp
266 # output the initial part of the spec file
271 # output the 'Provides: ' part of the spec file
275 # Output the shared libraries
277 for f in `cat $provides_tmp | sort -u`
283 # Output the available shell interpreters
285 for d in `echo $interp_dirs | sed -e 's/:/ /g'`
287 for f in `echo $interps | sed -e 's/:/ /g'`
289 if test -f $d/$f ; then
290 echo "Provides: $d/$f"
294 } | sed -e 's/%/%%/g'
297 # Output the discription of the spec file
304 This is a virtual RPM package. It contains no actual files. It uses the
305 \`Provides' token from RPM 3.x and later to list many of the shared libraries
306 and interpreters that are part of the base operating system and associated
307 OS packages for $osname.
309 This virtual package was constructed based on the vendor/system software
310 installed on the '$osname' machine named '$hostname', as of the date
315 spec_header=$spec_header
316 ignore_dirs=$ignore_dirs
317 find_provides=$find_provides
318 shlib_dirs=$shlib_dirs
319 interp_dirs=$interp_dirs
325 # Output the build sections of the spec file
329 echo '# nothing to do'
331 echo '# nothing to do'
333 echo '# nothing to do'
335 echo '# nothing to do'
337 if [ -z "${no_verify}" ]; then
340 # Output the optional verify section of the spec file
347 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd
350 sum_current_tmp=\${TMPDIR:-/tmp}/rpm.sum.current.\$\$
351 if test -f \$sum_current_tmp ; then
352 echo "\$sum_current_tmp already exists. Exiting."
356 sum_package_tmp=\${TMPDIR:-/tmp}/rpm.sum.package.\$\$
357 if test -f \$sum_package_tmp ; then
358 echo "\$sum_package_tmp already exists. Exiting."
362 for d in `echo $shlib_dirs | sed -e 's/:/ /g'`
364 find \$d -type f -print 2>/dev/null | grep -E -v \'$ignore_dirs\' | $sum_cmd >> \$sum_current_tmp
367 cat >\$sum_package_tmp <<_EOF_
370 # the contents of the temporary file are hardcoded into the verify
371 # script so that the file can be reproduced at verification time.
373 cat $sum_tmp | sed -e 's/%/%%/g'
379 cmp \$sum_package_tmp \$sum_current_tmp
381 if [ \$? -ne 0 ]; then
382 echo"Differences found by: cmp \$sum_package_tmp \$sum_current_tmp"
388 # end optional verify section
392 # Output the files section of the spec file
396 echo '# no files in a virtual package'