summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.am10
-rwxr-xr-xscripts/find-prov.pl223
-rwxr-xr-xscripts/find-req.pl211
-rwxr-xr-xscripts/get_magic.pl115
-rwxr-xr-xscripts/http.req126
-rwxr-xr-xscripts/magic.prov167
-rwxr-xr-xscripts/magic.req143
-rwxr-xr-xscripts/perl.prov34
-rwxr-xr-xscripts/perl.req43
-rwxr-xr-xscripts/u_pkg.sh74
-rwxr-xr-xscripts/vpkg-provides2.sh115
11 files changed, 1237 insertions, 24 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 98004564a..d5b320acc 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -3,8 +3,9 @@
AUTOMAKE_OPTIONS = 1.4 foreign
EXTRA_DIST = \
- convertrpmrc.sh find-lang.sh freshen.sh getpo.sh \
- perl.prov perl.req vpkg-provides.sh
+ convertrpmrc.sh find-lang.sh find-prov.pl find-req.pl \
+ freshen.sh get_magic.pl getpo.sh http.req magic.prov magic.req \
+ perl.prov perl.req rpmdiff u_pkg.sh vpkg-provides.sh vpkg-provides2.sh
installprefix = $(DESTDIR)
@@ -12,6 +13,7 @@ all:
configdir = ${prefix}/lib/rpm
config_SCRIPTS = \
- convertrpmrc.sh find-lang.sh freshen.sh getpo.sh \
- perl.prov perl.req vpkg-provides.sh
+ convertrpmrc.sh find-lang.sh find-prov.pl find-req.pl \
+ freshen.sh get_magic.pl getpo.sh http.req magic.prov magic.req \
+ perl.prov perl.req rpmdiff u_pkg.sh vpkg-provides.sh vpkg-provides2.sh
diff --git a/scripts/find-prov.pl b/scripts/find-prov.pl
new file mode 100755
index 000000000..f430c50fb
--- /dev/null
+++ b/scripts/find-prov.pl
@@ -0,0 +1,223 @@
+#!/bin/sh
+
+# This script reads filenames from STDIN and outputs any relevant provides
+# information that needs to be included in the package.
+
+PATH=/usr/bin:/usr/ccs/bin:/usr/sbin:/sbin:/usr/local/bin;
+export PATH;
+
+javadeps_args='--provides --rpmformat --keywords --starprov'
+
+
+IGNORE_DEPS="@"
+BUILDROOT="/"
+
+
+
+# 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
+ --buildroot)
+ BUILDROOT=$1
+ shift
+ ;;
+ --ignore_deps)
+ IGNORE_DEPS=$1
+ shift
+ ;;
+ --help)
+ echo $usage
+ exit 0
+ ;;
+ *)
+ echo "$0: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
+ exit 1
+ ;;
+ esac
+done
+
+
+
+
+
+
+
+for file in `cat -`
+do
+
+# this section is for processing based on the interpreter specified in
+# the '#!' line.
+
+case `get_magic $file` in
+
+bash)
+ print_deps --identifier executable $file
+ print_deps --identifier executable --basename $file
+;;
+
+sh)
+ print_deps --identifier executable $file
+ print_deps --identifier executable --basename $file
+;;
+
+perl)
+ perl.prov $file;
+;;
+
+wish)
+ print_deps --identifier tcl $file
+ print_deps --identifier tcl --basename $file
+;;
+
+
+esac
+
+
+# this section is for processing based on filename matching. It is
+# crude but needed as many library types have no easily identifiable
+# '#!' line
+
+case $file in
+
+# We can not count on finding a SONAME in third party Libraries though
+# they tend to include softlinks with the correct SONMAE name. We
+# must assume anything with a *\.so* and is of type 'dynamic lib' is a
+# library. This scriptlet works because 'file' follows soft links.
+
+
+*lib*.so*)
+ /usr/ucb/file -L $file 2>/dev/null | \
+ grep "ELF.*dynamic lib" | cut -d: -f1 | \
+ xargs -n 1 basename | print_deps --identifier so;
+
+ # keep this for backward compatibility till we have converted
+ # everything.
+
+ /usr/ucb/file -L $file 2>/dev/null | \
+ grep "ELF.*dynamic lib" | cut -d: -f1 | \
+ xargs -n 1 basename;
+;;
+
+# Java jar files are just a special kind of zip files.
+# Sun OS 5.5.1 does not understand zip archives, it calls them 'data'
+# Sun OS 5.6 has this line in /etc/magic
+# 0 string PK\003\004 ZIP archive
+
+*.jar)
+
+ unzip -p $file |\
+ javadeps $javadeps_args -;
+
+;;
+
+# there are enough jar files out there with zip extensions that we
+# need to have a separate entry
+
+*.zip)
+
+ unzip -p $file |\
+ javadeps $javadeps_args -;
+
+;;
+
+# Java Class files
+# Sun OS 5.6 has this line in /etc/magic
+# 0 string \312\376\272\276 java class file
+
+*.class)
+
+ javadeps $javadeps_args $file;
+
+;;
+
+
+
+# Perl libraries are hard to detect. Use file endings.
+
+*.pl)
+
+ perl.prov $file;
+
+ # pl files are often required using the .pl extension
+ # so provide that name as well
+
+ print_deps --identifier perl --basename $file
+;;
+
+*.pm)
+
+ perl.prov $file;
+;;
+
+*.ph)
+
+ # ph files do not use the package name inside the file.
+ # perlmodlib documentation says:
+
+ # the .ph files made by h2ph will probably end up as
+ # extension modules made by h2xs.
+
+ # so do not expend much effort on these.
+
+ print_deps --identifier perl --basename $file
+
+;;
+
+# tcl libraries are hard to detect. Use file endings.
+
+*.tcl)
+
+ print_deps --identifier tcl $file
+ print_deps --identifier tcl --basename $file
+;;
+
+
+
+*)
+
+ # Dependencies for html documenets are a bit ill defined. Lets try
+ # using file endings like the browsers do.
+ # precise globbing is hard so I use egrep instead of the case statement.
+
+hfile=`basename $file | egrep '\.((cgi)|(ps)|(pdf)|(png)|(jpg)|(gif)|(tiff)|(tif)|(xbm)|(html)|(htm)|(shtml)|(jhtml))$'`;
+
+ if [ "${hfile}" != "" ]
+ then
+ print_deps --identifier http --basename $file
+ fi
+
+ # all files are candidates for being an executable. Let the
+ # magic.prov script figure out what should be considered
+ # execuables.
+
+ magic.prov --buildroot=$BUILDROOT $file
+
+;;
+
+
+esac
+
+done | sort -u | egrep -v \'$IGNORE_DEPS\'
+
diff --git a/scripts/find-req.pl b/scripts/find-req.pl
new file mode 100755
index 000000000..6bf23a1fd
--- /dev/null
+++ b/scripts/find-req.pl
@@ -0,0 +1,211 @@
+#!/bin/sh
+
+# This script reads filenames from STDIN and outputs any relevant provides
+# information that needs to be included in the package.
+
+PATH=/usr/bin:/usr/ccs/bin:/usr/sbin:/sbin:/usr/local/bin;
+export PATH;
+
+javadeps_args='--requires --rpmformat --keywords'
+
+ulimit -c 0;
+
+
+
+
+
+IGNORE_DEPS="@"
+BUILDROOT="/"
+
+
+
+# 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
+ --buildroot)
+ BUILDROOT=$1
+ shift
+ ;;
+ --ignore_deps)
+ IGNORE_DEPS=$1
+ shift
+ ;;
+ --help)
+ echo $usage
+ exit 0
+ ;;
+ *)
+ echo "$0: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
+ exit 1
+ ;;
+ esac
+done
+
+
+for file in `cat -`
+do
+
+# this section is for processing based on the interpreter specified in
+# the '#!' line.
+
+case `get_magic $file` in
+
+bash)
+ /usr/local/lib/rpm/bash --rpm-requires $file;
+;;
+
+sh)
+ /usr/local/lib/rpm/bash --rpm-requires $file;
+;;
+
+perl)
+ perl.req $file;
+;;
+
+wish)
+ tcl.req $file;
+;;
+
+python)
+ python.req $file;
+;;
+
+esac
+
+
+# this section is for processing based on filename matching. It is
+# crude but needed as many library types have no easily identifiable
+# '#!' line
+
+case $file in
+
+# Shared libraries can depend on other shared libraries.
+
+*lib*.so*)
+
+ ldd $file 2>/dev/null | awk '/\=\>/ { print $1 }' \
+ | print_deps --identifier so;
+
+ # keep this for backward compatibility till we have converted
+ # everything.
+
+ ldd $file 2>/dev/null | awk '/\=\>/ { print $1 }';
+
+;;
+
+# Java jar files are just a special kind of zip files.
+# Sun OS 5.5.1 does not understand zip archives, it calls them 'data'
+# Sun OS 5.6 has this line in /etc/magic
+# 0 string PK\003\004 ZIP archive
+
+*.jar)
+
+ unzip -p $file |\
+ javadeps $javadeps_args -;
+
+;;
+
+# there are enough jar files out there with zip extensions that we
+# need to have a separate entry
+
+*.zip)
+
+ unzip -p $file |\
+ javadeps $javadeps_args -;
+
+;;
+
+# Java Class files
+# Sun OS 5.6 has this line in /etc/magic
+# 0 string \312\376\272\276 java class file
+
+*.class)
+
+ javadeps $javadeps_args $file;
+
+;;
+
+
+# Perl libraries are hard to detect. Need to also Look for #!*perl
+
+*.pl)
+
+ perl.req $file;
+
+;;
+
+*.pm)
+
+ perl.req $file;
+
+;;
+
+
+
+# tcl libraries are hard to detect. Need to also Look for #!*wish #!*tclsh
+
+*.tcl)
+
+ tcl.req $file;
+
+;;
+
+# python libraries are hard to detect. Need to also Look for #!*python
+
+*.py)
+
+ python.req $file;
+
+;;
+
+# Binary executables can have any filename so let file tell us which
+# ones are binary filenames. Assume that users do not name ELF binary
+# files with names like runme.java
+
+# Dependencies for html documenets are a bit ill defined. Lets try
+# extracting the basename of all strings within "'s
+# precise globbing is hard so I use egrep instead of the case statement.
+
+*)
+
+ /usr/ucb/file -L $file 2>/dev/null | grep executable | cut -d: -f1 |\
+ xargs ldd 2>/dev/null | awk '/\=\>/ { print $1 }' | xargs -n 1 basename;
+
+ echo $file | egrep '\.((cgi)|(ps)|(pdf)|(png)|(jpg)|(gif)|(tiff)|(tif)|(xbm)|(html)|(htm)|(shtml)|(jhtml))$' | xargs cat | httprequires
+
+
+ # All files are candidates for being an executable. Let the
+ # magic.req script figure out what should be considered
+ # execuables.
+
+ magic.req $file
+
+;;
+
+
+esac
+
+done | sort -u | egrep -v \'$IGNORE_DEPS\'
+
diff --git a/scripts/get_magic.pl b/scripts/get_magic.pl
new file mode 100755
index 000000000..eda5dd535
--- /dev/null
+++ b/scripts/get_magic.pl
@@ -0,0 +1,115 @@
+#!/usr/bin/perl
+
+# Given a filename on the command line or on stdin this script returns
+# the (single) interpreter that is required to run the executable. We
+# need this information to pick the best dependency parser for this
+# file.
+
+# Usually this is extracted from the #! line of the file
+# but we also handle the various 'exec' tricks that people use to
+# start the interpreter via an intermediate shell.
+
+
+# These have all been seen on our system or are "recommended" in
+# various man pages.
+
+# Examples:
+
+# #!/bin/sh
+# # the next line restarts using wish \
+# exec wish "$0" "$@"
+
+
+# #!/bin/sh -- # -*- perl -*- -p
+# eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
+# if $running_under_some_shell;
+
+
+# #!/bin/sh -- # -*- perl -*- -p
+# eval '(exit $?0)' && eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
+
+
+# #!/bin/sh -- # -*- perl -*- -p
+# & eval 'exec /usr/bin/perl -wS $0 $argv:q'
+# if $running_under_some_shell;
+
+
+# #! /usr/bin/env python
+
+
+use File::Basename;
+
+if ("@ARGV") {
+ foreach (@ARGV) {
+ process_file($_);
+ }
+} else {
+
+ # notice we are passed a list of filenames NOT as common in unix the
+ # contents of the file.
+
+ foreach (<>) {
+ process_file($_);
+ }
+}
+
+foreach $prog (sort keys %require) {
+
+ $prog=basename($prog);
+
+ # ignore variable interpolation and any program whose name is made
+ # up only of non word characters ('<', '&&', etc).
+
+ ( ( $prog != /\$/ ) || ( $prog =~ /^\W+$/ ) ) &&
+ next;
+
+ print "exectuable($prog)\n";
+
+}
+
+exit 0;
+
+
+sub process_file {
+
+ my ($file) = @_;
+ chomp $file;
+
+ my ($version, $magic) = ();
+
+ (-f $file) || return ;
+
+ open(FILE, "<$file")||
+ die("$0: Could not open file: '$file' : $!\n");
+
+ my $rc = sysread(FILE,$line,1000);
+
+ $rc =~ s/\#.*\n//g;
+
+ # Ignore all parameter substitution.
+ # I have no hope of parsing something like:
+ # exec ${SHELL:-/bin/sh}
+
+ $rc =~ s/\$\{.*\}//g;
+ $rc =~ s/echo\s+.*[\n;]//g;
+
+ if ( ($rc > 1) && ($line =~ m/^\#\!\s*/) ) {
+
+ if ($line =~ m/\b(exec|env)\s+([\'\"\`\\]+)?([^ \t\n\r]+)/) {
+ $require{$3} = 1;
+ last;
+ }
+
+ # strip off extra lines and any arguments
+ if ($line =~ m/^\#\!\s*([^ \t\n\r]+)/) {
+ $require{$1} = 1;
+ last;
+ }
+
+ }
+
+ close(FILE) ||
+ die("$0: Could not close file: '$file' : $!\n");
+
+ return ;
+}
diff --git a/scripts/http.req b/scripts/http.req
new file mode 100755
index 000000000..617958893
--- /dev/null
+++ b/scripts/http.req
@@ -0,0 +1,126 @@
+#!/usr/bin/perl
+
+# This file can find requirements of html and jhtml files (cgi, gif,
+# java dependencies). It is a bit of a hack but it turns out to work
+# well. We track only dependencies between Relative URLs, absolute
+# URL's are assumed to be extenernal to the RPM system. We do not
+# parse the HTML but look through the set of strings (text surrounded
+# by quotes) for something which looks like a reference. This avoids
+# writing a full HTML parsers and tends to work really well. In this
+# manner we can track dependencies for: href, src, action and other
+# HTML tags which have not been invented yet.
+
+
+# The reference:
+#
+# href="http://www.perl.org/images/arrow.gif"
+#
+# does not create a dependency but the reference
+#
+# href="images/arrow.gif"
+#
+# will create a dependency.
+
+# Additionally this program will find the requirements for sun jhtml
+# (html with embedded java) since jhtml is deprecated so is this part
+# of the code.
+
+
+use File::Basename;
+
+# this is the pattern of extensions to call requirements
+
+$DEPS_PAT = '\.((cgi)|(ps)|(pdf)|(png)|(jpg)|(gif)|(tiff)|(tif)|(xbm)|(html)|(htm)|(shtml)|(jhtml))$'; #'
+
+if ("@ARGV") {
+ foreach (@ARGV) {
+ process_file($_);
+ }
+} else {
+
+ # notice we are passed a list of filenames NOT as common in unix the
+ # contents of the file.
+
+ foreach (<>) {
+ process_file($_);
+ }
+}
+
+
+
+foreach $key (sort keys %seen) {
+ print "$key\n";
+}
+
+
+sub process_file {
+
+ my ($file) = @_;
+ chomp $file;
+
+ open(FILE, "<$file")||
+ die("$0: Could not open file: '$file' : $!\n");
+
+ # we have to suck in the whole file at once because too many people
+ # split lines around <java></java> tags.
+
+ my (@file) = <FILE>;
+
+ $_= "@file";
+
+ # ignore line based comments ( careful although it has two slashes
+ # 'http://www.yahoo.com' is not a comment! )
+
+ s!^\s*//.*$!!mg;
+ s!//\s.*$!!mg;
+ s!\s//.*$!!mg;
+
+ # ignore multi-line comments
+ # (use non greedy operators)
+
+ s!/\*.*?\*/!!g;
+ s/<!--.*?-->//g;
+
+ # html references other html documents inside strings. Ignore non
+ # relative references since these dependencies can not be met. (ie,
+ # no package you install will ever provide 'http://www.yahoo.com').
+ # I use basename since I have seen too many http references which
+ # begin with '../' this would just kill the dependnecy tracking
+ # mechanism.
+
+ while ( m{\"([^\"]+)\"}g ) {
+ my $string = $1;
+ chomp $string;
+ if ( ( $string !~ m!http://! ) &&
+ ( $string =~ m!$DEPS_PAT! ) ) {
+ $string = basename($string);
+ $string =~ s!\s+!!g;
+ $seen{"http(${string})"} = 1;
+ }
+ }
+
+ {
+
+ # This section is only for use with (Sun) jhtml dependencies, and
+ # since jhtml is deprecated so is this code.
+
+ # java imports in jhtml (may have stars for leaf class)
+ # these may span several lines
+
+ while ( m!<java type=((import)|(extends))>\s*([^<]+)\s*<!g ) {
+ my $java_list = $4;
+ $java_list =~ s/;/ /g;
+ $java_list =~ s/\n+/ /g;
+ $java_list =~ s/\s+/ /g;
+ foreach $java_class ( split(/\s+/, $java_list) ) {
+ $seen{"java(${java_class})"} = 1;
+ }
+ }
+
+ }
+
+ close(FILE, "<$file")||
+ die("$0: Could not close file: '$file' : $!\n");
+
+ return ;
+}
diff --git a/scripts/magic.prov b/scripts/magic.prov
new file mode 100755
index 000000000..ba3a45c85
--- /dev/null
+++ b/scripts/magic.prov
@@ -0,0 +1,167 @@
+#!/usr/bin/perl
+
+use File::Basename;
+use Getopt::Long;
+
+# this dependency analysis program is the only one which need to know
+# the RPM buildroot to do its work.
+
+# Figuring out what files are really executables via magic numbers is
+# hard. Not only is every '#!' an executable of some type (with a
+# potentially infinite supply of interpreters) but there are thousands
+# of valid binary magic numbers for old OS's and old CPU types.
+
+# Permissions do not always help discriminate binaries from the rest
+# of the files, on Solaris the shared libraries are marked as
+# 'executable'.
+
+# -rwxr-xr-x 1 bin bin 1013248 Jul 1 1998 /lib/libc.so.1
+
+# I would like to let the 'file' command take care of the magic
+# numbers for us. Alas! under linux file prints different kind of
+# messages for each interpreter, there is no common word 'script' to
+# look for.
+
+# ' perl commands text'
+# ' Bourne shell script text'
+# ' a /usr/bin/wish -f script text'
+
+# WORSE on solaris there are entries which say:
+
+# ' current ar archive, not a dynamic executable or shared object'
+
+# how do I grep for 'executable' when people put a 'not executable' in
+# there? I trim off everything after the first comma (if there is
+# one) and if the result has the string 'executable' in it then it may
+# be one.
+
+
+# so we must also do some magic number processing ourselves, and be
+# satisfied with 'good enough'.
+
+# I look for files which have atleast one of the executable bits set
+# and are either labled 'executable' by the file command (see above
+# restriction) OR have a '#!' as their first two characters.
+
+
+$is_mode_executable=oct(111);
+
+# set a known path
+
+$ENV{'PATH'}= (
+ ':/usr/bin'.
+ ':/bin'.
+ '');
+
+# taint perl requires we clean up these bad environmental variables.
+
+delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
+
+$BUILDROOT = '';
+%option_linkage = (
+ "buildroot" => \$BUILDROOT,
+ );
+
+if( !GetOptions (\%option_linkage, "buildroot=s") ) {
+ die("Illegal options in \@ARGV: '@ARGV'\n");
+
+}
+
+if ($BUILDROOT == '/') {
+ $BUILDROOT = '';
+}
+
+if ("@ARGV") {
+ foreach (@ARGV) {
+ process_file($_);
+ }
+} else {
+
+ # notice we are passed a list of filenames NOT as common in unix the
+ # contents of the file.
+
+ foreach (<>) {
+ process_file($_);
+ }
+}
+
+
+foreach $module (sort keys %provides) {
+ print "executable($module)\n";
+}
+
+exit 0;
+
+
+
+
+sub is_file_script {
+
+ my ($file) = @_;
+ chomp $file;
+
+ my $out = 0;
+ open(FILE, "<$file")||
+ die("$0: Could not open file: '$file' : $!\n");
+
+ my $rc = sysread(FILE,$line,2);
+
+ if ( ($rc > 1) && ($line =~ m/^\#\!/) ) {
+ $out = 1;
+ }
+
+ close(FILE) ||
+ die("$0: Could not close file: '$file' : $!\n");
+
+ return $out;
+}
+
+
+
+sub is_file_binary_executable {
+ my ($file) = @_;
+
+ $file_out=`file $file`;
+ # trim off any extra descriptions.
+ $file_out =~ s/\,.*$//;
+
+ my $out = 0;
+ if ($file_out =~ m/executable/ ) {
+ $out = 1;
+ }
+ return $out;
+}
+
+
+sub process_file {
+ my ($file) = @_;
+ chomp $file;
+
+ my $prov_name = $file;
+ $prov_name =~ s!^$BUILDROOT!!;
+
+ # If its a link find the file it points to. Dead links do not
+ # provide anything.
+
+ while (-l $file) {
+ my $newfile = readlink($file);
+ if ($newfile !~ m!^/!) {
+ $newfile = dirname($file).'/'.$newfile;
+ } else {
+ $newfile = $BUILDROOT.$newfile;
+ }
+ $file = $newfile;
+ }
+
+ (-f $file) || return ;
+ ( (stat($file))[2] & $is_mode_executable ) || return ;
+
+ is_file_script($file) ||
+ is_file_binary_executable($file) ||
+ return ;
+
+ $provides{$prov_name}=1;
+ $provides{basename($prov_name)}=1;
+
+ return ;
+}
diff --git a/scripts/magic.req b/scripts/magic.req
new file mode 100755
index 000000000..e32532881
--- /dev/null
+++ b/scripts/magic.req
@@ -0,0 +1,143 @@
+#!/usr/bin/perl
+
+# Given a list of filenames on the command line or on stdin this
+# script returns the interpreter that is required to run the
+# filenames. Usually this is extracted from the #! line of the file
+# but we also handle the various 'exec' tricks that people use to
+# start the interpreter via an intermediate shell.
+
+# Also we want to convert:
+# /usr/local/bin/perl5.00404
+# /usr/local/bin/tclsh8.0
+# into dependencies with RPM version numbers.
+
+
+
+
+
+# These have all been seen on our system or are "recommended" in
+# various man pages.
+
+# Examples:
+
+# #!/bin/sh
+# # the next line restarts using wish \
+# exec wish "$0" "$@"
+
+
+# #!/bin/sh -- # -*- perl -*- -p
+# eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
+# if $running_under_some_shell;
+
+
+# #!/bin/sh -- # -*- perl -*- -p
+# eval '(exit $?0)' && eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
+
+
+# #!/bin/sh -- # -*- perl -*- -p
+# & eval 'exec /usr/bin/perl -wS $0 $argv:q'
+# if $running_under_some_shell;
+
+
+# #! /usr/bin/env python
+
+
+use File::Basename;
+
+if ("@ARGV") {
+ foreach (@ARGV) {
+ process_file($_);
+ }
+} else {
+
+ # notice we are passed a list of filenames NOT as common in unix the
+ # contents of the file.
+
+ foreach (<>) {
+ process_file($_);
+ }
+}
+
+
+foreach $prog (sort keys %require) {
+
+
+ # ignore variable interpolation and any program whose name is made
+ # up only of non word characters ('<', '&&', etc).
+
+ ( ( $prog != /\$/ ) || ( $prog =~ /^\W+$/ ) ) &&
+ next;
+
+ # filenames of the form './miniperl' will be reported in canonical
+ # manner 'miniperl'
+
+ $prog =~ s!^\./!!;
+
+ if ( $prog !~ /\$/ ) {
+ print "exectuable($prog)\n";
+ }
+
+ $prog=basename($prog);
+
+ if ( $prog !~ /\$/ ) {
+ print "exectuable($prog)\n";
+
+ # get the correct version dependencies for magic numbers like:
+ # /usr/local/bin/perl5.00404
+ # /usr/local/bin/tclsh8.0
+ # these are always PACKAGE versions since typical executables do not
+ # have versions
+
+ my $version = "";
+ if ($module =~ s/([.0-9]+)$//) {
+ $version = "$1";
+ print "$prog>=$version\n";
+ }
+
+ }
+
+}
+
+exit 0;
+
+
+sub process_file {
+
+ my ($file) = @_;
+ chomp $file;
+
+ my ($version, $magic) = ();
+
+ (-f $file) || return ;
+
+ open(FILE, "<$file")||
+ die("$0: Could not open file: '$file' : $!\n");
+
+ my $rc = sysread(FILE,$line,1000);
+
+ $rc =~ s/\#.*\n//g;
+
+ # Ignore all parameter substitution.
+ # I have no hope of parsing something like:
+ # exec ${SHELL:-/bin/sh}
+ $rc =~ s/\$\{.*\}//g;
+ $rc =~ s/echo\s+.*[\n;]//g;
+
+ if ( ($rc > 1) && ($line =~ m/^\#\!\s*/) ) {
+
+ if ($line =~ m/\b(exec|env)\s+([\'\"\`\\]+)?([^ \t\n\r]+)/) {
+ $require{$3} = 1;
+ }
+
+ # strip off extra lines and any arguments
+ if ($line =~ m/^\#\!\s*([^ \t\n\r]+)/) {
+ $require{$1} = 1;
+ }
+
+ }
+
+ close(FILE) ||
+ die("$0: Could not close file: '$file' : $!\n");
+
+ return ;
+}
diff --git a/scripts/perl.prov b/scripts/perl.prov
index c2aa4f456..6643f6a6e 100755
--- a/scripts/perl.prov
+++ b/scripts/perl.prov
@@ -31,11 +31,6 @@ foreach $module (sort keys %require) {
print "perl($module)\n";
} else {
print "perl($module)=$require{$module}\n";
-
- # we need to print it without the version number until the
- # requires syntax accepts version numbers correctly.
-
- print "perl($module)\n";
}
}
@@ -49,14 +44,18 @@ sub process_file {
chomp $file;
open(FILE, "<$file")||
- die("Could not open file: '$file' : $!\n");
+ die("$0: Could not open file: '$file' : $!\n");
my ($package, $version) = ();
while (<FILE>) {
# skip the documentation
- if ( (m/^=(head1|head2|pod)/) .. (m/^=(cut)/) ) {
+ if ( (m/^=(head1|head2|pod|item)/) .. (m/^=(cut)/) ) {
+ next;
+ }
+
+ if ( (m/^=(over)/) .. (m/^=(back)/) ) {
next;
}
@@ -81,14 +80,14 @@ sub process_file {
# here are examples of VERSION lines from the perl distribution
- #FindBin.pm:$VERSION = $VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/);
- #ExtUtils/Install.pm:$VERSION = substr q$Revision: 1.1 $, 10;
- #CGI/Apache.pm:$VERSION = (qw$Revision: 1.1 $)[1];
+ #FindBin.pm:$VERSION = $VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/);
+ #ExtUtils/Install.pm:$VERSION = substr q$Revision: 1.2 $, 10;
+ #CGI/Apache.pm:$VERSION = (qw$Revision: 1.2 $)[1];
#DynaLoader.pm:$VERSION = $VERSION = "1.03"; # avoid typo warning
if (
($package) &&
- (m/^\s*\$VERSION\s+=\s+/)
+ (m/^\s*\$VERSION\s*=\s+/)
) {
# first see if the version string contains the string
@@ -106,7 +105,20 @@ sub process_file {
$require{$package}=$version;
}
+ # Each keyword can appear multiple times. Don't
+ # bother with datastructures to store these strings,
+ # if we need to print it print it now.
+
+ if ( m/^\s*\$RPM_Provides\s*=\s*["'](.*)['"]/i) {
+ foreach $_ (spit(/\s+/, $1)) {
+ print "$_\n";
+ }
+ }
+
}
+ close(FILE)||
+ die("$0: Could not close file: '$file' : $!\n");
+
return ;
}
diff --git a/scripts/perl.req b/scripts/perl.req
index d19afbcdb..bec4705c2 100755
--- a/scripts/perl.req
+++ b/scripts/perl.req
@@ -29,13 +29,7 @@ foreach $module (sort keys %require) {
if (length($require{$module}) == 0) {
print "perl($module)\n";
} else {
-
print "perl($module)>=$require{$module}\n";
-
- # we need to print it without the version number until the
- # requires syntax accepts version numbers correctly.
-
- print "perl($module)\n";
}
}
@@ -49,20 +43,34 @@ sub process_file {
chomp $file;
open(FILE, "<$file")||
- die("Could not open file: '$file' : $!\n");
+ die("$0: Could not open file: '$file' : $!\n");
while (<FILE>) {
# skip the documentation
- if ( (m/^=(head1|head2|pod)/) .. (m/^=(cut)/) ) {
+ if ( (m/^=(head1|head2|pod|item)/) .. (m/^=(cut)/) ) {
next;
}
+ if ( (m/^=(over)/) .. (m/^=(back)/) ) {
+ next;
+ }
+
# skip the data section
if (m/^__(DATA|END)__$/) {
last;
}
+ # Each keyword can appear multiple times. Don't
+ # bother with datastructures to store these strings,
+ # if we need to print it print it now.
+
+ if ( m/^\s*\$RPM_Requires\s*=\s*["'](.*)['"]/i) {
+ foreach $_ (spit(/\s+/, $1)) {
+ print "$_\n";
+ }
+ }
+
if (
# ouch could be in a eval, perhaps we do not want these since we catch
@@ -83,6 +91,19 @@ sub process_file {
) {
my ($module, $version) = ($2,$3);
+ # trim off trailing parenthesis if any. Sometimes people pass
+ # the module an empty list.
+
+ $module =~ s/\(\s*\)$//;
+
+ if ( $module =~ m/^[0-9._]+$/ ) {
+ # if module is a number then both require and use interpret that
+ # to mean that a particular version of perl is specified
+
+ print "perl>$module\n";
+ next;
+ };
+
# if there is some interpolation of variables just skip this
# dependency, we do not want
# do "$ENV{LOGDIR}/$rcfile";
@@ -116,5 +137,9 @@ sub process_file {
}
}
-
+
+ close(FILE)||
+ die("$0: Could not close file: '$file' : $!\n");
+
+ return ;
}
diff --git a/scripts/u_pkg.sh b/scripts/u_pkg.sh
new file mode 100755
index 000000000..86ff951bf
--- /dev/null
+++ b/scripts/u_pkg.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+# a universal interface to Unix OS package managment systems
+
+PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd:$PATH"
+export PATH
+
+
+
+osname=`uname -s`
+if test $? -ne 0 || test X$osname = X ; then
+ echo "I can't determine what platform this is. Exiting"
+ exit 1
+fi
+
+
+#
+# Set OS dependent defaults
+#
+case $osname in
+ Linux)
+ check_all_packages='rpm -Va'
+ list_all_packages='rpm -qa'
+ list_all_files='rpm -qla'
+ list_all_files_in_package='rpm -ql $1'
+ full_package_name='rpm -q $1'
+ query_file='rpm -qf $1'
+ ;;
+ SunOS)
+ check_all_packages='/usr/sbin/pkgchk -n'
+ list_all_files='/usr/sbin/pkgchk -l | /bin/egrep Pathname | /bin/awk "{print \$2}" '
+ list_all_files_in_package='/usr/sbin/pkgchk -l $1 | /bin/egrep Pathname | /bin/awk "{print \$2}" '
+ list_all_packages='/usr/bin/pkginfo -x | /bin/sed -e "/^[a-zA-Z]/ { N; /^\\n\$/d; s/ .*$//; }" '
+ package_version='/usr/bin/pkginfo -x $1 | egrep -v "^[a-zA-Z]" | sed -e "s/(.*)//; s/\ \ *//" '
+ query_file='/usr/sbin/pkgchk -l -p $1 | /bin/egrep -v "^[a-zA-Z]" | xargs /usr/bin/pkginfo -x | /bin/sed -e "/^[a-zA-Z]/ { N; /^\\n\$/d; s/\ .*\\n.*//; }" '
+ ;;
+ OSF1)
+ ;;
+ HP-UX)
+ ;;
+ AIX)
+ ;;
+ IRIX|IRIX64)
+ ;;
+ *)
+ echo "I haven't been configured yet to work on $osname."
+ echo "email it to rpm-list@redhat.com, so that your OS"
+ echo "will be supported by some future version of this script."
+ echo ""
+ echo "Thanks!"
+ echo
+ exit 2
+ ;;
+esac
+
+
+
+option=$1
+shift
+
+# I would like to have the second $ actually interpolate so I could
+# drop the second eval. Anyone know how to do this?
+
+if [ $option = 'print_cmd' ]; then
+ option=$1
+ shift
+ eval echo $"$option"
+ exit 0
+fi
+
+eval eval $"$option"
+
+
+
diff --git a/scripts/vpkg-provides2.sh b/scripts/vpkg-provides2.sh
new file mode 100755
index 000000000..d08a86caa
--- /dev/null
+++ b/scripts/vpkg-provides2.sh
@@ -0,0 +1,115 @@
+#!/bin/sh
+
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd
+export PATH
+
+IGNORE_DIRS='@'
+
+date=`date`
+hostname=`uname -n`
+osname=`uname -s`
+
+# programs we run
+
+#find_provides=/usr/local/lib/rpm/find-provides
+#find_requires=/usr/local/lib/rpm/find-requires
+find_provides=/devel/kestes/vendorc/tools/solaris.prov
+find_requires=/devel/kestes/vendorc/tools/solaris.req
+u_pkg=/devel/kestes/vendorc/rpm/scripts/u-pkg.sh
+
+# where we write output
+spec_filedir=/tmp
+provides_tmp=/tmp/provides.$$
+requires_tmp=/tmp/requires.$$
+
+
+for pkg in `$u_pkg list_all_packages`
+do
+
+# find OS pkg information
+
+spec_filename=$spec_filedir/$pkg
+
+veryify_cmd=`$u_pkg print_cmd package_version $pkg | sed -e "s/\\$1/$pkg/" `
+
+pkg_version=`$u_pkg package_version $pkg `
+
+
+# find all the dependencies
+
+$u_pkg list_all_files_in_package $pkg | egrep -v \'$IGNORE_DIRS\' | \
+ $find_provides | sed -e 's/^/Provides: /' > $provides_tmp
+
+$u_pkg list_all_files_in_package $pkg | egrep -v \'$IGNORE_DIRS\' | \
+ $find_requires | sed -e 's/^/Requires: /' > $requires_tmp
+
+# create the spec file
+
+rm -f $spec_filename
+
+echo >> $spec_filename
+
+cat $provides_tmp | sort -u >> $spec_filename
+
+echo >> $spec_filename
+
+cat $requires_tmp | sort -u >> $spec_filename
+
+echo >> $spec_filename
+
+
+# Output the rest of the spec file. It is a template stored in this
+# here file.
+
+
+cat >> $spec_filename <<_EIEIO_
+Name: vpkg-$pkg
+Version: $pkg_version
+
+%description
+This is a virtual RPM package. It contains no actual files. It uses the
+\`Provides' token from RPM 3.x and later to list many of the shared libraries
+and interpreters that are part of the base operating system and associated
+subsets for $osname.
+
+This virtual package was constructed based on the vendor/system software
+installed on the $osname machine named $hostname, as of the date
+$date. It is intended to supply dependency
+information about the OS package: $pkg, version: $pkg_version,
+
+
+%prep
+# nothing to do
+
+%build
+# nothing to do
+
+%install
+# nothing to do
+
+%clean
+# nothing to do
+
+
+%verifyscript
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd:/usr/local/bin
+export PATH
+
+expected_version='$pkg_version'
+current_version=\`$veryify_cmd\`
+
+if [ \$expected_version -ne \$current_version ]; then
+ echo "RPM virtual package does not match OS pkg: $pkg" >&2
+ echo "installed packge version: \$current_verion" >&2
+ echo "expected package version: \$expected_version" >&2
+ exit 9
+fi
+
+%files
+
+_EIEIO_
+
+done
+