From 562b734c42ca3dc181f5f4cf4b9dff4a4e1265b0 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 8 Sep 2014 17:57:54 +0200 Subject: kill dead magic.* files --- Makefile.am | 2 - NEWS | 1 + magic.prov | 167 ------------------------------------------------------------ magic.req | 143 --------------------------------------------------- 4 files changed, 1 insertion(+), 312 deletions(-) delete mode 100755 magic.prov delete mode 100755 magic.req diff --git a/Makefile.am b/Makefile.am index c5231a2..a3766a8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,8 +32,6 @@ pkg_scripts = \ git-repository--after-tarball \ git-repository--apply-patch \ http.req \ - magic.prov \ - magic.req \ kmod.prov \ perlapi.prov \ perlapi.req \ diff --git a/NEWS b/NEWS index 1150e53..cb71478 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ - drop gstreamer/haskell/ruby/typelib deps generators we backported the needed .(attr|prov|req) files from FC/SuSe in other packages - drop most of the script-based dependency generation bits +- drop some long dead scripts - use internal dependency generator instead of "external generator" (like all other distros) which is way much faster :-) See: diff --git a/magic.prov b/magic.prov deleted file mode 100755 index ba3a45c..0000000 --- a/magic.prov +++ /dev/null @@ -1,167 +0,0 @@ -#!/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/magic.req b/magic.req deleted file mode 100755 index e325328..0000000 --- a/magic.req +++ /dev/null @@ -1,143 +0,0 @@ -#!/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 ; -} -- cgit v1.2.1