Sync with 4.0.4, splint clean.

CVS patchset: 5309
CVS date: 2002/02/09 22:39:29
This commit is contained in:
jbj 2002-02-09 22:39:29 +00:00
parent 1cf6127e81
commit d83891c743
16 changed files with 588 additions and 36 deletions

View File

@ -124,6 +124,7 @@
- generate index for fileid (aka Filemd5s) tag, query/verify by fileid.
- query/verify by install transaction id.
- rpm-4.0.4 release candidate.
- add cpanflute2, another perl.req fiddle.
4.0.2 -> 4.0.3:
- update per-interpreter dependency scripts, add sql/tcl (#20295).

View File

@ -193,12 +193,8 @@
#undef HAVE_LIBTHREAD
/* Name of package */
#if !defined(PACKAGE)
#undef PACKAGE
#endif
/* Version number of package */
#if !defined(VERSION)
#undef VERSION
#endif

View File

@ -2495,7 +2495,7 @@ static int generateDepends(Spec spec, Package pkg, TFI_t cpioList, int multiLib)
/* Expand rest of script arguments (if any) */
for (i = 1; i < 4; i++) {
if (dm->argv[i] == NULL)
break;
/*@innerbreak@*/ break;
/*@-nullderef@*/ /* FIX: double indirection. @*/
myargv[ac++] = rpmExpand(dm->argv[i], NULL);
/*@=nullderef@*/

View File

@ -2,7 +2,6 @@
SUBDIRS = manual ja pl ru sk
man_MANS = gendiff.1 rpm.8 rpmbuild.8 rpm2cpio.8
man_MANS = gendiff.1 RPM*Specfile.3pm rpm.8 rpmbuild.8 rpm2cpio.8
EXTRA_DIST = $(man_MANS)

161
doc/RPM::Specfile.3pm Normal file
View File

@ -0,0 +1,161 @@
.\" Automatically generated by Pod::Man version 1.15
.\" Thu Feb 7 12:18:29 2002
.\"
.\" Standard preamble:
.\" ======================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Ip \" List item
.br
.ie \\n(.$>=3 .ne \\$3
.el .ne 3
.IP "\\$1" \\$2
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used
.\" to do unbreakable dashes and therefore won't be available. \*(C` and
.\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr
.\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
.\" index entries marked with X<> in POD. Of course, you'll have to process
.\" the output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it
.\" makes way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
.bd B 3
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ======================================================================
.\"
.IX Title "RPM::Specfile 3"
.TH RPM::Specfile 3 "perl v5.6.1" "2002-02-02" "User Contributed Perl Documentation"
.UC
.SH "NAME"
\&\s-1RPM:\s0:Specfile \- Perl extension for creating \s-1RPM\s0 Specfiles
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use RPM::Specfile;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Simple module for creation of \s-1RPM\s0 Spec files
.Sh "\s-1EXPORT\s0"
.IX Subsection "EXPORT"
None by default.
.SH "AUTHOR"
.IX Header "AUTHOR"
Chip Turner <cturner@redhat.com>
.SH "SEE ALSO"
.IX Header "SEE ALSO"
the perl manpage.

View File

@ -882,8 +882,8 @@ static int checkDependentConflicts(rpmTransactionSet ts, const char * key)
}
struct badDeps_s {
/*@observer@*/ /*@null@*/ const char * pname;
/*@observer@*/ /*@null@*/ const char * qname;
/*@observer@*/ /*@owned@*/ /*@null@*/ const char * pname;
/*@observer@*/ /*@dependent@*/ /*@null@*/ const char * qname;
};
#ifdef DYING
@ -916,6 +916,7 @@ static struct badDeps_s {
{ NULL, NULL }
};
#else
/*@unchecked@*/ /*@only@*/ /*@null@*/
static struct badDeps_s * badDeps = NULL;
#endif
@ -932,11 +933,12 @@ static int ignoreDep(const transactionElement p,
{
struct badDeps_s * bdp;
static int _initialized = 0;
const char ** av = NULL;
int ac = 0;
/*@-globs -mods@*/
if (!_initialized) {
char * s = rpmExpand("%{?_dependency_whiteout}", NULL);
const char ** av = NULL;
int ac = 0;
int i;
if (s != NULL && *s != '\0'
@ -945,32 +947,38 @@ static int ignoreDep(const transactionElement p,
{
bdp = badDeps = xcalloc(ac+1, sizeof(*badDeps));
for (i = 0; i < ac; i++, bdp++) {
char * p, * q;
char * pname, * qname;
if (av[i] == NULL)
break;
p = xstrdup(av[i]);
if ((q = strchr(p, '>')) != NULL)
*q++ = '\0';
bdp->pname = p;
bdp->qname = q;
pname = xstrdup(av[i]);
if ((qname = strchr(pname, '>')) != NULL)
*qname++ = '\0';
bdp->pname = pname;
/*@-usereleased@*/
bdp->qname = qname;
/*@=usereleased@*/
rpmMessage(RPMMESS_DEBUG,
_("ignore package name relation(s) [%d]\t%s -> %s\n"),
i, bdp->pname, bdp->qname);
i, bdp->pname, (bdp->qname ? bdp->qname : "???"));
}
bdp->pname = bdp->qname = NULL;
bdp->pname = NULL;
bdp->qname = NULL;
}
av = _free(av);
s = _free(s);
_initialized++;
}
/*@=globs =mods@*/
/*@-compdef@*/
if (badDeps != NULL)
for (bdp = badDeps; bdp->pname != NULL && bdp->qname != NULL; bdp++) {
if (!strcmp(teGetN(p), bdp->pname) && !strcmp(teGetN(q), bdp->qname))
return 1;
}
return 0;
/*@=compdef@*/
}
/**

View File

@ -1407,7 +1407,7 @@ assert(psm->mi == NULL);
hi = headerFreeIterator(hi);
/*@=branchstate@*/
headerFree(oh, NULL);
oh = headerFree(oh, NULL);
uh = hfd(uh, uht);
} else
break; /* XXX shouldn't ever happen */
@ -1851,9 +1851,11 @@ assert(psm->mi == NULL);
{ const char * payload_compressor = NULL;
char * t;
/*@-branchstate@*/
if (!hge(fi->h, RPMTAG_PAYLOADCOMPRESSOR, NULL,
(void **) &payload_compressor, NULL))
payload_compressor = "gzip";
/*@=branchstate@*/
psm->rpmio_flags = t = xmalloc(sizeof("w9.gzdio"));
*t = '\0';
t = stpcpy(t, ((psm->goal == PSM_PKGSAVE) ? "w9" : "r"));
@ -1890,7 +1892,7 @@ fprintf(stderr, "*** PSM_RDB_LOAD: header #%u not found\n", fi->record);
default:
break;
}
/*@i@*/ }
/*@=branchstate@*/
/*@-nullstate@*/ /* FIX: psm->oh and psm->fi->h may be NULL. */

View File

@ -775,6 +775,7 @@ restart:
return 1;
}
md5[0] = '\0';
for (i = 0, t = md5, s = arg; i < 16; i++, t++, s += 2)
*t = (nibble(s[0]) << 4) | nibble(s[1]);

View File

@ -894,8 +894,8 @@ IDTX IDTXglob(rpmTransactionSet ts, const char * globstr, rpmTag tag)
/** @todo Transaction handling, more, needs work. */
int rpmRollback(rpmTransactionSet ts,
struct rpmInstallArguments_s * ia,
const char ** argv)
/*@unused@*/ struct rpmInstallArguments_s * ia,
const char ** argv)
{
#ifdef NOTYET
rpmdb db = NULL;
@ -915,7 +915,6 @@ int rpmRollback(rpmTransactionSet ts,
IDT ip;
int niids = 0;
int rc = 0;
int i;
if (argv != NULL && *argv != NULL) {
rc = -1;
@ -1051,12 +1050,14 @@ int rpmRollback(rpmTransactionSet ts,
goto exit;
/* Clean up after successful rollback. */
if (!rpmIsDebug())
for (i = 0; i < rtids->nidt; i++) {
IDT rrp = rtids->idt + i;
if (rrp->val.u32 != thistid)
continue;
(void) unlink(rrp->key);
if (!rpmIsDebug()) {
int i;
for (i = 0; i < rtids->nidt; i++) {
IDT rrp = rtids->idt + i;
if (rrp->val.u32 != thistid)
continue;
(void) unlink(rrp->key);
}
}
} while (1);

View File

@ -206,7 +206,8 @@ mkdir -p $RPM_BUILD_ROOT/var/lib/rpm
for dbi in \
Basenames Conflictname Dirnames Group Installtid Name Providename \
Provideversion Removetid Requirename Requireversion Triggername \
Packages __db.001 __db.002 __db.003 __db.004 __db.005 __db.006 __db.007 \
Sigmd5 Sha1header Filemd5s Packages \
__db.001 __db.002 __db.003 __db.004 __db.005 __db.006 __db.007 \
__db.008 __db.009
do
touch $RPM_BUILD_ROOT/var/lib/rpm/$dbi
@ -316,6 +317,7 @@ fi
%rpmdbattr /var/lib/rpm/Conflictname
%rpmdbattr /var/lib/rpm/__db.0*
%rpmdbattr /var/lib/rpm/Dirnames
%rpmdbattr /var/lib/rpm/Filemd5s
%rpmdbattr /var/lib/rpm/Group
%rpmdbattr /var/lib/rpm/Installtid
%rpmdbattr /var/lib/rpm/Name
@ -325,6 +327,8 @@ fi
%rpmdbattr /var/lib/rpm/Removetid
%rpmdbattr /var/lib/rpm/Requirename
%rpmdbattr /var/lib/rpm/Requireversion
%rpmdbattr /var/lib/rpm/Sigmd5
%rpmdbattr /var/lib/rpm/Sha1header
%rpmdbattr /var/lib/rpm/Triggername
%endif
@ -349,6 +353,7 @@ fi
%attr(0644, rpm, rpm) %{__prefix}/lib/rpm/macros
%rpmattr %{__prefix}/lib/rpm/mkinstalldirs
%rpmattr %{__prefix}/lib/rpm/rpm.*
%rpmattr %{__prefix}/lib/rpm/rpm2cpio.sh
%rpmattr %{__prefix}/lib/rpm/rpm[deiukqv]
%attr(0644, rpm, rpm) %{__prefix}/lib/rpm/rpmpopt*
%attr(0644, rpm, rpm) %{__prefix}/lib/rpm/rpmrc
@ -421,6 +426,7 @@ fi
%rpmattr %{__prefix}/lib/rpm/check-prereqs
%rpmattr %{__prefix}/lib/rpm/config.site
%rpmattr %{__prefix}/lib/rpm/cpanflute
%rpmattr %{__prefix}/lib/rpm/cpanflute2
%rpmattr %{__prefix}/lib/rpm/cross-build
%rpmattr %{__prefix}/lib/rpm/find-lang.sh
%rpmattr %{__prefix}/lib/rpm/find-prov.pl
@ -436,6 +442,7 @@ fi
%rpmattr %{__prefix}/lib/rpm/magic.prov
%rpmattr %{__prefix}/lib/rpm/magic.req
%rpmattr %{__prefix}/lib/rpm/perl.prov
%rpmattr %{__prefix}/lib/rpm/Specfile.pm
# XXX remove executable bit to disable autogenerated perl requires for now.
%rpmattr %{__prefix}/lib/rpm/perl.req
@ -444,6 +451,7 @@ fi
%rpmattr %{__prefix}/lib/rpm/rpm[bt]
%rpmattr %{__prefix}/lib/rpm/rpmdiff
%rpmattr %{__prefix}/lib/rpm/rpmdiff.cgi
%rpmattr %{__prefix}/lib/rpm/trpm
%rpmattr %{__prefix}/lib/rpm/u_pkg.sh
%rpmattr %{__prefix}/lib/rpm/vpkg-provides.sh
%rpmattr %{__prefix}/lib/rpm/vpkg-provides2.sh
@ -627,3 +635,13 @@ fi
- perl.req: don't mis-generate dependencies like perl(::path/to/foo.pl).
- permit args to be hidden within %%__find_{requires,provides}.
- a couple more perl.{prov,req} fiddles.
- macro for %files, always include %defattr(), redhat config only.
- fix: drop header region when writing repackaged legacy header.
- bail on %files macro.
- transaction rollbacks are functional.
- generate index for pkgid (aka Sigmd5) tag, query/verify by pkgid.
- generate index for hdrid (aka Sha1header) tag, query/verify by hdrid.
- generate index for fileid (aka Filemd5s) tag, query/verify by fileid.
- query/verify by install transaction id.
- rpm-4.0.4 release candidate.
- add cpanflute2, another perl.req fiddle.

View File

@ -426,6 +426,7 @@ fi
%rpmattr %{__prefix}/lib/rpm/check-prereqs
%rpmattr %{__prefix}/lib/rpm/config.site
%rpmattr %{__prefix}/lib/rpm/cpanflute
%rpmattr %{__prefix}/lib/rpm/cpanflute2
%rpmattr %{__prefix}/lib/rpm/cross-build
%rpmattr %{__prefix}/lib/rpm/find-lang.sh
%rpmattr %{__prefix}/lib/rpm/find-prov.pl
@ -441,6 +442,7 @@ fi
%rpmattr %{__prefix}/lib/rpm/magic.prov
%rpmattr %{__prefix}/lib/rpm/magic.req
%rpmattr %{__prefix}/lib/rpm/perl.prov
%rpmattr %{__prefix}/lib/rpm/Specfile.pm
# XXX remove executable bit to disable autogenerated perl requires for now.
%rpmattr %{__prefix}/lib/rpm/perl.req
@ -642,3 +644,4 @@ fi
- generate index for fileid (aka Filemd5s) tag, query/verify by fileid.
- query/verify by install transaction id.
- rpm-4.0.4 release candidate.
- add cpanflute2, another perl.req fiddle.

View File

@ -1085,7 +1085,7 @@ ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE;
argerror(_("no packages given for install"));
ia->transFlags |= RPMTRANS_FLAG_NOMD5;
ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE;
ec += rpmRollback(ts, ia, NULL);
/*@i@*/ ec += rpmRollback(ts, ia, NULL);
} else {
/*@-compdef@*/ /* FIX: ia->relocations[0].newPath undefined */
ec += rpmInstall(ts, (const char **)poptGetArgs(optCon),

View File

@ -6,7 +6,8 @@ EXTRA_DIST = \
brp-compress brp-redhat brp-strip brp-strip-comment-note \
brp-strip-shared \
brp-sparc64-linux check-prereqs convertrpmrc.sh cross-build \
find-lang.sh find-prov.pl find-req.pl cpanflute find-provides.perl \
find-lang.sh find-prov.pl find-req.pl \
cpanflute cpanflute2 Specfile.pm find-provides.perl \
find-requires.perl get_magic.pl getpo.sh http.req \
magic.prov magic.req perl.prov perl.req rpmdiff rpmdiff.cgi \
rpm.daily rpm.log rpm.xinetd rpm2cpio.sh \
@ -22,7 +23,8 @@ config_SCRIPTS = \
brp-compress brp-redhat brp-strip brp-strip-comment-note \
brp-strip-shared \
brp-sparc64-linux check-prereqs convertrpmrc.sh cross-build \
find-lang.sh find-prov.pl find-req.pl cpanflute find-provides.perl \
find-lang.sh find-prov.pl find-req.pl \
cpanflute cpanflute2 Specfile.pm find-provides.perl \
find-requires.perl get_magic.pl getpo.sh http.req \
magic.prov magic.req perl.prov perl.req rpmdiff rpmdiff.cgi \
rpm.daily rpm.log rpm.xinetd rpm2cpio.sh \

193
scripts/Specfile.pm Normal file
View File

@ -0,0 +1,193 @@
package RPM::Specfile;
use POSIX;
use strict;
use vars qw/$VERSION/;
$VERSION = '1.02';
sub new {
my $class = shift;
my $self = bless { }, $class;
return $self;
}
my @simple_accessors = qw/name version release epoch license group url description prep build clean install summary buildroot buildrequires file_param packager vendor distribution buildarch/;
foreach my $field (@simple_accessors) {
my $sub = q {
sub RPM::Specfile::[[field]] {
my $self = shift;
if (@_) {
my $value = shift;
$self->{__[[field]]__} = $value;
}
return $self->{__[[field]]__};
}
};
$sub =~ s/\[\[field\]\]/$field/g;
eval $sub;
if ($@) {
die $@;
}
}
my @array_accessors = qw/source patch changelog provide require file/;
foreach my $field (@array_accessors) {
my $sub = q {
sub RPM::Specfile::[[field]] {
my $self = shift;
$self->{__[[field]]__} ||= [ ];
if (@_) {
my $index = shift;
if (@_) {
my $value = shift;
$self->{__[[field]]__}->[$index] = $value;
}
return $self->{__[[field]]__}->[$index];
}
else {
return @{$self->{__[[field]]__}};
}
}
sub RPM::Specfile::push_[[field]] {
my $self = shift;
my $entry = shift;
$self->{__[[field]]__} ||= [ ];
push @{$self->{__[[field]]__}}, $entry;
}
sub RPM::Specfile::clear_[[field]] {
my $self = shift;
my $entry = shift;
$self->{__[[field]]__} = [ ];
}
};
$sub =~ s/\[\[field\]\]/$field/g;
eval $sub;
if ($@) {
die $@;
}
}
sub add_changelog_entry {
my $self = shift;
my $who = shift;
my $entry = shift;
my $output;
$output .= strftime("* %a %b %d %Y $who\n", localtime time);
$output .= "- $entry\n";
$self->push_changelog($output);
}
sub generate_specfile {
my $self = shift;
my $output;
my %defaults = ( buildroot => "%{_tmppath}/%{name}-root" );
$self->$_($self->$_() || $defaults{$_}) foreach keys %defaults;
my %proper_names = ( url => "URL", buildroot => "BuildRoot", "buildrequires" => "BuildRequires" );
foreach my $tag (qw/name version release epoch packager vendor distribution summary license group url buildroot buildrequires buildarch/) {
my $proper = $proper_names{$tag} || ucfirst $tag;
next unless defined $self->$tag();
$output .= "$proper: " . $self->$tag() . "\n";
}
my @reqs = $self->require;
for my $i (0 .. $#reqs) {
$output .= "Requires: $reqs[$i]\n";
}
my @sources = $self->source;
for my $i (0 .. $#sources) {
$output .= "Source$i: $sources[$i]\n";
}
my @patches = $self->patch;
for my $i (0 .. $#patches) {
$output .= "Patch$i: $patches[$i]\n";
}
$output .= "\n";
foreach my $sect (qw/description prep build clean install/) {
$output .= "%$sect\n";
$output .= $self->$sect() . "\n";
}
if ($self->file_param) {
$output .= "%files " . $self->file_param . "\n";
}
else {
$output .= "%files\n";
}
$output .= "$_\n" foreach $self->file;
$output .= "\n%changelog\n";
$output .= "$_\n" foreach $self->changelog;
return $output;
}
sub write_specfile {
my $self = shift;
my $dest = shift;
open FH, ">$dest"
or die "Can't open $dest: $!";
print FH $self->generate_specfile;
close FH;
}
1;
__END__
# Below is stub documentation for your module. You better edit it!
=head1 NAME
RPM::Specfile - Perl extension for creating RPM Specfiles
=head1 SYNOPSIS
use RPM::Specfile;
=head1 DESCRIPTION
Simple module for creation of RPM Spec files
=head2 EXPORT
None by default.
=head1 AUTHOR
Chip Turner <cturner@redhat.com>
=head1 SEE ALSO
L<perl>.
=cut

160
scripts/cpanflute2 Executable file
View File

@ -0,0 +1,160 @@
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use File::Basename;
use File::Copy;
use Archive::Tar;
use lib '/usr/lib/rpm';
use Specfile;
my %options;
GetOptions(\%options, "outdir=s", "tmpdir=s", "email=s", "name=s", "create", "test", "epoch=n", "version=s", "release=s", "perlver=s", "patch=s", "noarch=s") or die_usage();
my $fullname = shift;
die_usage() unless $fullname;
my $tarball = basename($fullname);
my $create = $options{create} || '';
my $email = $options{email} || (getpwuid($<))[0] . '@redhat.com';
my $outdir = $options{outdir} || './';
my $tmpdir = $options{tmpdir} || '/tmp';
my $noarch = $options{noarch};
$tarball =~ /^(.+)\-([^-]+)\.tar\.gz$/;
my $name = $options{name} || $1;
my $ver = $options{version} || $2;
die "Module name/version not parsable from $tarball" unless $name and $ver;
$name =~ s/::/-/g;
copy($fullname, $tmpdir)
or die "copy: $!";
$noarch = $options{noarch};
my $patchfile = '';
if ($options{patch}) {
copy($options{patch}, $tmpdir);
$patchfile = $options{patch};
}
my $spec = new RPM::Specfile;
my $perlver = "0:5.00503";
if ($options{perlver} and $options{perlver} eq '5.6.1') {
$perlver = "1:5.6.1";
}
# some basic spec fields
$spec->name("perl-$name");
$spec->version($ver);
$spec->release($options{release} || "8");
$spec->epoch($options{epoch});
$spec->summary("$name Perl module");
$spec->description($spec->summary);
$spec->group("Development/Libraries");
$spec->license("distributable");
$spec->buildrequires("perl >= $perlver");
$spec->packager($email);
$spec->add_changelog_entry($email, 'Specfile autogenerated');
$spec->buildarch('noarch') if $noarch;
# $spec->push_require(q|%(perl -MConfig -le 'if (defined $Config{useithreads}) { print "perl(:WITH_ITHREADS)" } else { print "perl(:WITHOUT_ITHREADS)" }')|);
# $spec->push_require(q|%(perl -MConfig -le 'if (defined $Config{usethreads}) { print "perl(:WITH_THREADS)" } else { print "perl(:WITHOUT_THREADS)" }')|);
# $spec->push_require(q|%(perl -MConfig -le 'if (defined $Config{uselargefiles}) { print "perl(:WITH_LARGEFILES)" } else { print "perl(:WITHOUT_LARGEFILES)" }')|);
$spec->push_source($tarball);
$spec->push_patch(basename($patchfile))
if $patchfile;
# make a URL that can actually possibly take you to the right place
my $url_name = $name;
$url_name =~ s/-/::/g;
$url_name =~ s/([^a-zA-Z0-9])/sprintf "%%%x", ord $1/ge;
$spec->url("http://search.cpan.org/search?mode=module&query=$url_name");
# now we get into the multiline tags. stolen mostly verbatim from
# cpanflute1
my $patch = '';
if ($patchfile) {
$patch = "%patch0 -p1\n";
}
$spec->prep("%setup -q -n $name-%{version} $create\n$patch");
$spec->file_param("-f $name-$ver-filelist");
$spec->push_file("%defattr(-,root,root)");
my $test_clause = '';
$test_clause = "make test" if $options{test};
$spec->build(<<EOB);
CFLAGS="\$RPM_OPT_FLAGS" perl Makefile.PL
make
$test_clause
EOB
$spec->clean('rm -rf $RPM_BUILD_ROOT');
my $inst = q{
rm -rf $RPM_BUILD_ROOT
eval `perl '-V:installarchlib'`
mkdir -p $RPM_BUILD_ROOT/$installarchlib
make PREFIX=$RPM_BUILD_ROOT/usr install
[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress
find $RPM_BUILD_ROOT/usr -type f -print | \
sed "s@^$RPM_BUILD_ROOT@@g" | \
grep -v perllocal.pod | \
grep -v "\.packlist" > $name-$ver-filelist
if [ "$(cat $name-$ver-filelist)X" = "X" ] ; then
echo "ERROR: EMPTY FILE LIST"
exit -1
fi
};
$inst =~ s/\$name/$name/g;
$inst =~ s/\$ver/$ver/g;
$spec->install($inst);
# write the spec file. create some macros.
$spec->write_specfile("$tmpdir/perl-$name.spec");
open FH, ">$tmpdir/macros"
or die "Can't create $tmpdir/macros: $!";
print FH qq{
%_topdir $tmpdir
%_builddir %{_topdir}
%_rpmdir %{_topdir}
%_sourcedir %{_topdir}
%_specdir %{_topdir}
%_srcrpmdir $outdir
};
close FH;
open FH, ">$tmpdir/rpmrc"
or die "Can't create $tmpdir/rpmrc: $!";
print FH qq{
include: /usr/lib/rpm/rpmrc
macrofiles: /usr/lib/rpm/macros:$tmpdir/macros
};
close FH;
# perform the build, die on error
my $retval = system "rpm --rcfile $tmpdir/rpmrc -bs --rmsource --rmspec --clean $tmpdir/perl-$name.spec";
$retval = $? >> 8;
if ($retval != 0) {
die "RPM building failed!\n";
}
unlink "$tmpdir/rpmrc", "$tmpdir/macros";

View File

@ -185,8 +185,15 @@ sub process_file {
# 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 ($module =~ /5.00/) {
print "perl >= 0:$module\n";
next;
}
else {
print "perl >= 1:$module\n";
next;
}
};
# ph files do not use the package name inside the file.