add scripts for autogenerating CPAN dependencies.

CVS patchset: 3560
CVS date: 2000/02/15 22:17:43
This commit is contained in:
jbj 2000-02-15 22:17:43 +00:00
parent 0433f06173
commit 9358ab55e9
7 changed files with 238 additions and 4 deletions

View File

@ -52,6 +52,7 @@
- {Free,Open}BSD find-{provides,requires} (suzukis@file.phys.tohoku.ac.jp).
- new rpm-build package to isolate rpm dependencies on perl/bash2.
- always remove duplicate identical package entries on --rebuilddb.
- add scripts for autogenerating CPAN dependencies.
3.0.2 -> 3.0.3
- add --eval to find result of macro expansion.

View File

@ -2,7 +2,7 @@ Summary: The Red Hat package management system.
Name: rpm
%define version 3.0.4
Version: %{version}
Release: 0.39
Release: 0.40
Group: System Environment/Base
Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-3.0.x/rpm-%{version}.tar.gz
Copyright: GPL
@ -171,9 +171,12 @@ fi
%lang(pl) /usr/man/pl/man[18]/*.[18]*
%lang(ru) /usr/man/ru/man[18]/*.[18]*
%files -n build
%files build
%defattr(-,root,root)
/usr/lib/rpm/check-prereqs
/usr/lib/rpm/cpanflute
/usr/lib/rpm/find-provides.perl
/usr/lib/rpm/find-requires.perl
/usr/lib/rpm/get_magic.pl
/usr/lib/rpm/http.req
/usr/lib/rpm/magic.prov
@ -217,6 +220,7 @@ fi
* Tue Feb 15 2000 Jeff Johnson <jbj@redhat.com>
- new rpm-build package to isolate rpm dependencies on perl/bash2.
- always remove duplicate identical package entries on --rebuilddb.
- add scripts for autogenerating CPAN dependencies.
* Wed Feb 9 2000 Jeff Johnson <jbj@redhat.com>
- brp-compress deals with hard links correctly.

View File

@ -5,6 +5,7 @@ AUTOMAKE_OPTIONS = 1.4 foreign
EXTRA_DIST = \
brp-compress brp-strip brp-strip-comment-note \
check-prereqs convertrpmrc.sh find-lang.sh find-prov.pl find-req.pl \
cpanflute find-provides.perl find-requires.perl \
freshen.sh get_magic.pl getpo.sh http.req magic.prov magic.req \
perl.prov perl.req rpmdiff rpmdiff.cgi u_pkg.sh \
vpkg-provides.sh vpkg-provides2.sh
@ -17,6 +18,7 @@ configdir = ${prefix}/lib/rpm
config_SCRIPTS = \
brp-compress brp-strip brp-strip-comment-note \
check-prereqs convertrpmrc.sh find-lang.sh find-prov.pl find-req.pl \
cpanflute find-provides.perl find-requires.perl \
freshen.sh get_magic.pl getpo.sh http.req magic.prov magic.req \
perl.prov perl.req rpmdiff rpmdiff.cgi u_pkg.sh \
vpkg-provides.sh vpkg-provides2.sh

View File

@ -153,13 +153,13 @@ varprefix = @varprefix@
AUTOMAKE_OPTIONS = 1.4 foreign
EXTRA_DIST = brp-compress brp-strip brp-strip-comment-note check-prereqs 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 rpmdiff.cgi u_pkg.sh vpkg-provides.sh vpkg-provides2.sh
EXTRA_DIST = brp-compress brp-strip brp-strip-comment-note check-prereqs convertrpmrc.sh find-lang.sh find-prov.pl find-req.pl cpanflute find-provides.perl find-requires.perl freshen.sh get_magic.pl getpo.sh http.req magic.prov magic.req perl.prov perl.req rpmdiff rpmdiff.cgi u_pkg.sh vpkg-provides.sh vpkg-provides2.sh
installprefix = $(DESTDIR)
configdir = ${prefix}/lib/rpm
config_SCRIPTS = brp-compress brp-strip brp-strip-comment-note check-prereqs 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 rpmdiff.cgi u_pkg.sh vpkg-provides.sh vpkg-provides2.sh
config_SCRIPTS = brp-compress brp-strip brp-strip-comment-note check-prereqs convertrpmrc.sh find-lang.sh find-prov.pl find-req.pl cpanflute find-provides.perl find-requires.perl freshen.sh get_magic.pl getpo.sh http.req magic.prov magic.req perl.prov perl.req rpmdiff rpmdiff.cgi u_pkg.sh vpkg-provides.sh vpkg-provides2.sh
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h

167
scripts/cpanflute Executable file
View File

@ -0,0 +1,167 @@
#!/usr/bin/perl
# need this for hostname()
use File::Basename;
use Sys::Hostname;
use Getopt::Long;
use strict;
my $MainDir = '/tmp/cpan';
# set default options, then get options
my %options=();
$options{'email'}=(getpwuid($<))[0] . "\@" . hostname();
GetOptions(\%options, "email=s", "n=s", "create") || exit 1;
my $InputFile = $ARGV[0];
my $create = '';
if ($options{'create'}) {
$create = '-c';
}
my $tarball = basename($InputFile);
$tarball =~ /(\S+)\-(\S+)\.tar\.gz/;
my $clm_name=$1;
my $clm_version=$2;
my $class = dirname($InputFile);
$class =~ s/^\.\/[0-9][0-9]_//;
if ($class ne '.') {
$class = "($class)";
} else {
$class = "";
}
# Change ::'s to -'s
$clm_name =~ s/::/-/g;
my $clm_changelog = get_changelog();
# complain if either parameter is missing
($clm_name eq "") && die "Module name not specified\n";
($clm_version eq "") && die "Module version not specified\n";
# Create and Open file to create SPEC files.
mkdir($MainDir, 0755);
system("cp $InputFile $MainDir");
my $filename = $clm_name . '.spec';
open (FILE, "> $MainDir/$filename");
# Print the spec file. Lots of substitutions here.
print FILE "Summary: $clm_name module for perl $class
Name: perl-$clm_name
Version: $clm_version
Release: 2
Copyright: distributable
Group: Applications/CPAN
Source0: $clm_name-$clm_version.tar.gz
Url: http://www.cpan.org
BuildRoot: /var/tmp/perl-$clm_name-buildroot/
BuildRequires: perl >= 5.00503
Requires: perl >= 5.00503
%description
$clm_name module for perl
# Provide perl-specific find-{provides,requires}.
%define __find_provides /usr/lib/rpm/find-provides.perl
%define __find_requires /usr/lib/rpm/find-requires.perl
%prep
%setup -q -n $clm_name-%{version} $create
%build
CFLAGS=\"\$RPM_OPT_FLAGS\" perl Makefile.PL
make
%clean
rm -rf \$RPM_BUILD_ROOT
%install
rm -rf \$RPM_BUILD_ROOT
eval `perl '-V:installarchlib'`
mkdir -p \$RPM_BUILD_ROOT/\$installarchlib
make PREFIX=\$RPM_BUILD_ROOT/usr install
find \$RPM_BUILD_ROOT/usr -type f -print | \
sed \"s\@^\$RPM_BUILD_ROOT\@\@g\" | \
grep -v perllocal.pod | \
grep -v \"\\.packlist\" > $clm_name-$clm_version-filelist
if [ \"\$(cat $clm_name-$clm_version-filelist)X\" = \"X\" ] ; then
echo \"ERROR: EMPTY FILE LIST\"
exit -1
fi
%files -f $clm_name-$clm_version-filelist
%defattr(-,root,root)
%changelog
* $clm_changelog
- Spec file was autogenerated.
";
close(FILE);
# Now build the rpm
create_rcfiles();
open (LOG, "> $MainDir/LogFile");
build_rpm();
close LOG;
sub cleanup {
unlink "$MainDir/$filename";
unlink "$MainDir/$tarball";
}
sub build_rpm {
my $retval;
# First, make sure it unpacks cleanely
system("rpm --rcfile $MainDir/rpmrc -bp $MainDir/$filename");
$retval = $? >> 8;
if ($retval != 0) {
print "RPM test unpacking failed!\n";
print LOG "PREP failed: $filename\n";
return;
}
system("rpm --rcfile $MainDir/rpmrc -bs --rmsource --rmspec --clean $MainDir/$filename");
$retval = $? >> 8;
if ($retval != 0) {
print "RPM building failed!\n";
print LOG "SOURCE failed: $filename\n";
return;
}
cleanup();
}
sub create_rcfiles {
open(MACROS, "> $MainDir/macros");
print MACROS qq{
%_topdir $MainDir
%_builddir %{_topdir}/junk
%_rpmdir %{_topdir}
%_sourcedir %{_topdir}
%_specdir %{_topdir}
%_srcrpmdir %{_topdir}/temp
};
close(MACROS);
open(RPMRC, "> $MainDir/rpmrc");
print RPMRC qq{
include: /usr/lib/rpm/rpmrc
macrofiles: /usr/lib/rpm/macros:$MainDir/macros
};
close(RPMRC);
}
sub get_changelog {
# generate the changelog entry from available system info
return ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")[(localtime)[6]] . " " .
("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[(localtime)[4]] . " " .
(localtime)[3] . " " . (1900+(localtime)[5]) . " " .
(getpwuid($<))[6] . " <" . $options{'email'} . ">";
}

10
scripts/find-provides.perl Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
filelist=`sed "s/['\"]/\\\&/g"`
{ echo $filelist | tr [:blank:] \\n | /usr/lib/rpm/find-provides
#
# Generate perl module dependencies, if any.
[ -x /usr/lib/rpm/perl.prov ] && \
echo $filelist | tr [:blank:] \\n | /usr/lib/rpm/perl.prov
} | sort -u

50
scripts/find-requires.perl Executable file
View File

@ -0,0 +1,50 @@
#!/bin/sh
# note this works for both a.out and ELF executables
# it also auto-generates requirment lines for shell scripts
ulimit -c 0
filelist=`sed "s/['\"]/\\\&/g"`
exelist=`echo $filelist | xargs -r file | fgrep executable | cut -d: -f1 `
scriptlist=`echo $filelist | xargs -r file | egrep ":.* (commands|script) " | cut -d: -f1 `
liblist=`echo $filelist | xargs -r file | grep "shared object" | cut -d : -f1 `
for f in $exelist; do
if [ -x $f ]; then
ldd $f | awk '/=>/ { print $1 }'
fi
done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | grep -v '4[um]lib.so' | sort -u
for f in $liblist; do
ldd $f | awk '/=>/ { print $1 }'
done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | grep -v '4[um]lib.so' | sort -u
perllist=
for f in $scriptlist; do
[ -x $f ] || continue
interp=`head -1 $f | sed -e 's/^\#\![ ]*//' | cut -d" " -f1 `
case $interp in
*/perl) perllist="$perllist $f" ;;
esac
echo $interp
done | sort -u
for f in $liblist $exelist ; do
objdump -p $f | awk '
BEGIN { START=0; LIBNAME=""; }
/Version References:/ { START=1; }
/required from/ && (START==1) {
sub(/:/, "", $3);
LIBNAME=$3;
}
(START==1) && (LIBNAME!="") && ($4!="") { print LIBNAME "(" $4 ")"; }
/^$/ { START=0; }
'
done | sort -u
#
# Generate perl module dependencies, if any.
set -x
[ -x /usr/lib/rpm/perl.req -a -n "$perllist" ] && \
echo $perllist | tr [:blank:] \\n | /usr/lib/rpm/perl.req | sort -u