From b780f5a8d636073d67dbcdfa3f8795f878b55218 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 31 Aug 2007 11:15:16 +0300 Subject: [PATCH] Nuke more unused scripts... - http.req doesn't have anything to do with rpm really - find-prov, -req.pl and get_magic.pl are not used anyway --- scripts/find-prov.pl | 223 --------------------------------------------------- scripts/find-req.pl | 211 ------------------------------------------------ scripts/get_magic.pl | 115 -------------------------- scripts/http.req | 165 ------------------------------------- 4 files changed, 714 deletions(-) delete mode 100755 scripts/find-prov.pl delete mode 100755 scripts/find-req.pl delete mode 100755 scripts/get_magic.pl delete mode 100755 scripts/http.req diff --git a/scripts/find-prov.pl b/scripts/find-prov.pl deleted file mode 100755 index f430c50..0000000 --- a/scripts/find-prov.pl +++ /dev/null @@ -1,223 +0,0 @@ -#!/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 deleted file mode 100755 index 6bf23a1..0000000 --- a/scripts/find-req.pl +++ /dev/null @@ -1,211 +0,0 @@ -#!/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 deleted file mode 100755 index eda5dd5..0000000 --- a/scripts/get_magic.pl +++ /dev/null @@ -1,115 +0,0 @@ -#!/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 deleted file mode 100755 index 5d04d0c..0000000 --- a/scripts/http.req +++ /dev/null @@ -1,165 +0,0 @@ -#!/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. - -# These references create dependencies: - -#
-# -# -# -# -# -# adWidget.writeAd(out, "login.html", "expired"); -# -# response.sendRedirect("http://"+request.getServerName()+"/mailcom/login.jhtml"); - - -# Notice how we look for strings WITH the proper ending. This is -# because the java sometimes has really strange double quoting -# conventions. Look at how splitting out the strings in this -# fragment would get you the wrong text. - -# - -# 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 '../' and I can not figure out where the document root -# is for the webserver this would just kill the dependnecy tracking -# mechanism. - - - -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 tags. - - my (@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; - - # 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 '../' and I can not figure out where the document root - # is for the webserver this would just kill the dependnecy tracking - # mechanism. - - - # Notice how we look for strings WITH the proper ending. This is - # because the java sometimes has really strange double quoting - # conventions. Look at how splitting out the strings in this - # fragment would get you the wrong text. - - # - - while ( m{\"([^\"]+$DEPS_PAT)\"}g ) { - my $string = $1; - chomp $string; - if ( $string !~ m!http://! ) { - $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!\s*([^<]+)\s*