CPAN-RPM
view release on metacpan or search on metacpan
push @dirserr, $_ unless -d && -w;
}
if (@dirserr) {
print "RPM user environment - Your account does not have\n";
print "permissions to the requisite RPM directory structure.\n";
print "Try 'cpan2rpm --mk-rpm-dirs=~/rpm' to setup your\n";
print "environment for non-root package building.\n";
print "Failing dirs: ", join(" ", @dirserr), "\n";
exit(1);
}
}
# --- init routines -----------------------------------------------------------
#
# creates user directories for RPM
#
sub mk_rpm_dirs {
local $_ = "$ENV{HOME}/.rpmmacros";
my $topdir = `echo -n $info{"mk-rpm-dirs"}`;
my $txt = <<EOF;
%_topdir $topdir
%_smp_mflags -j3
%__arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
%debug_package %{nil}
EOF
if (!-e) {
writefile($_, $txt);
}
elsif (-r) {
my $s = readfile();
writefile($_, $txt, ">>")
unless $s =~ /topdir/is;
}
my @subdirs = qw|
BUILD SOURCES SPECS SRPMS
RPMS RPMS/i386 RPMS/i686 RPMS/noarch
|;
push @subdirs, "RPMS/$info{buildarch}" if $info{buildarch};
for (map "$topdir/$_", "", @subdirs) {
next if -e;
mkdir($_, 0755) || die "Cannot make $_: $!";
}
print "RPM user environment set up. Your system should be ";
print "ready for packaging!\n";
}
#
# sets up an account for signing packages
#
sub sign_setup {
my $msg = "Incorrectly formatted argument. ";
$msg .= "Do not pass a module name with this option!\nStopped";
die $msg unless $info{"sign-setup"} =~ /(^(gpg|pgp):)|^\s*$/i;
my $mac = "$ENV{HOME}/.rpmmacros"; local $_ = $mac;
die "Cannot read use macros file" unless -r;
readfile();
die "Package signing already set up.\n"
. "Please edit macros file manually at $mac\n"
. "Stopped"
if /%_signature/i;
# make sure gpg's there
my $gpg = getrpm_macdef("_gpg");
$gpg = inpath("gpg") unless -e $gpg;
$gpg = inpath("pgp") unless -e $gpg;
die "Neither GPG nor PGP found in PATH. Stopped"
unless -e $gpg;
die "$gpg is not executable! Stopped" unless -x $gpg;
my $gpg_path = getrpm_macdef("_gpg_path");
$gpg_path = "$ENV{HOME}/.gnupg" if $gpg_path eq '%{_gpg_path}';
my ($type, $usr) = split ":", $info{"sign-setup"};
$type ||= "gpg";
my $key = gpgkey();
$msg = "No keypairs available on your keyring! Run:\n";
$msg .= "\n\t# gpg --gen-key\n";
$msg .= "\nStopped";
die $msg unless $key;
$usr ||= $key;
my @gpg = (
"%_signature $type",
"%_gpgbin $gpg",
"%_gpg_path $gpg_path",
"%_gpg_name $usr",
);
writefile($mac, join($/, "", @gpg, ""), ">>");
print "Package signing macros set up.\nPlease review $mac\n";
}
# --- miscellany --------------------------------------------------------------
sub gpgkey {
for (qx|gpg --list-keys --with-colons 2> /dev/null|) {
return $1 if /^pub:\w+:\d+:\w+:([A-Z0-9]+):/;
}
}
sub optagg {
my $info = shift || die "optagg: no info!";
my $nm = shift || $_;
my @opt; push @opt, split /,/ for @{$info->{$nm}};
my $ret = "";
$ret .= sprintf("%-*s %s\n", $SPECCOL, "$nm:", $_) for @opt;
$ret;
}
# returns 404 for 4.0.4 and 420 for 4.2
sub getrpm_ver {
chomp(local $_ = qx/rpm --version/);
$_ = (split)[2];
s/\.//g; $_ *= 10 if $_ < 100;
$_;
}
sub getrpm_macdef($) {
my $key = shift;
chomp(local $_ = qx/rpm --eval \%{$key}/);
s/^\s+//; s/\s*\n+/ /gs; s/\s+$//;
$_;
}
sub inpath($) {
my $cmd = shift;
-x "$_/$cmd" && return "$_/$cmd" for split /:/, $ENV{PATH};
}
sub mksec {
my $info = shift;
my $nm = shift;
my $ret = qq|$/%$nm|;
$ret .= "$/$info->{prologue}{$nm}" if $info->{prologue}{$nm};
$ret .= "$/$_" for @_;
$ret .= "$/$info->{epilogue}{$nm}" if $info->{epilogue}{$nm};
$ret;
}
sub chkupgrade {
return if defined $info{"no-upgrade-chk"};
return if !$VERSION;
print "Upgrade check\n";
eval {
alarm(5);
$SIG{ALRM} = sub {
die "Network too slow, check elapsed...\n";
};
local $_ = http_get("$LATEST_MOD/CPAN::RPM");
$info{latestversionavailable} = $1 if /"version"\s*:\s*"?([\d\.\_\-]+)"?/;
};
alarm(0);
if ($info{latestversionavailable} and $info{latestversionavailable} gt $VERSION) {
local $\ = $/;
Specify a temporary working directory instead of utilizing File::Temp.
=item B<--req-scan-all>
By default, the I<rpm-build> requirements script scans all files in a tarball for requirements information. As this may on occasion generate requirements on the produced rpm that belong only to sample programs or other files not critical to the modu...
=item B<--no-clean>
By default, the system passes I<--clean> to F<rpmbuild>, thus removing the unpacked sources from the BUILD directory. This option suppresses that functionality.
=item B<--shadow-pure>
Forces installation under F<installarchlib> even if the module is pure perl. This is significant because it is first in the @INC search for module determination. This will not do any good for modules with XS code or those that are already installed...
User may be required to use --force (see below) in conjuction with this option to build a fresh rpm before attempting to --install again.
=item B<--force>
By default the script will do as little work as possible i.e. if it has already previously retrieved a module from CPAN, it will not retrieve it again. If it has already generated a spec file it will not generate it again. This option allows the pa...
=item B<--no-fixin>
This option allows suppression of the fixin step when generating a package and avoids breaking certain test script e.g. MIME::Base64
=item B<--no-sign>
Suppresses package signatures. By default, cpan2rpm will sign the packages it generates IF the the RPM macros file has been configured to use signatures - this option prevents this behaviour. See also the I<--sign-setup> option below.
=item B<--install | -i>
Install the RPM after building it. If non-root user, you must have "sudo rpm" privileges to use this option.
=back
=head2 Miscellaneous options
The options below perform functions not closely related to the quotidien process of building a package.
=over
=item B<--fetch=C<string-value>>
One of B<cpanplus>, B<cpan>, B<web>, or B<reg>, this parameter specifies which method to use when retrieving a module from CPAN. Web retrievals are by parsing the CPAN website and may be faster though more error prone. To use either the CPAN or CPA...
If your environment requires the use of a proxy, simply set the environment variable as indicated below in (bash format):
F<export HTTP_PROXY=http://user:password@host.org:8080>
=item B<--modules, -f =C<string-value>>
Lists of modules to be processed can be stored in a file. Pass this parameter the name of your file. The file should contain the name of each module in a single line and the modules can be specified in any of their many forms (e.g. url, path to tar...
=item B<--mk-rpm-dirs=C<string-value>>
This option allows the non-root user to easily set up his account for building packages. The option requires a directory path where the RPMS, SPECS, etc. subdirectories will be created. These directories will contain the spec files, binaries and th...
Additionally, the script will create architecture directories F<i386>, F<i686> and F<noarch> and allows the user to pass B<--buildarch> to also create a directory for that architecture.
=item B<--sign-setup=[C<type:user>]>
This option sets up your RPM macros file to support the signing of packages. The option may be passed a value consisting of the signature type to use (currently only B<gpg> and B<pgp> are valid but consult the RPM man pages), a colon, and the user n...
B<Note:> unless you know what you're doing, do not pass any arguments to this option! Also, make sure not to pass a module name as an argument.
To further tailor your macros file please refer to the I<GPG SIGNATURES> section of the RPM man page.
=item B<--upgrade>
Whenever a new version of this program becomes available, an automatic notification will be issued to the user of this fact. The user may then choose to upgrade via this option. The option takes no parameters.
=item B<--no-upgrade-chk|-U>
During version checks, the script will time out within 5 seconds if the F<arix.com> server is unavailable (when working offline or if the server is down). Should the 5 seconds become annoying, users may pass this option to skip the version check.
=item B<--debug[=n]>
This option produces debugging output. An optional integer increases the level of verbosity for this output. If no integer is given, 1 is assumed.
=item B<--help, -h>
Displays a terse syntax message.
=item B<-V>
This option displays the version number of cpan2rpm itself.
=item B<-D>
This option runs cpan2rpm in the Perl debugger. Useful for anyone willing to dig on my behalf.
=back
=head1 CONFIGURATION FILE
In addition to reading options from the command line, cpan2rpm will slurp the configuration file F<~/.cpan2rpm>, if it exists. Please note that for this functionality to work, the module F<Getopt::ArgvFile> must be installed. If the config file exi...
Additionally, please note that if no config file exists in the $HOME directory, one may be passed explicitly on the command line as shown in the example below:
# cpan2rpm @options-file -V
Note that options from command line will override options from config file.
The configuration file should contain options in same format as they would be used in command line. Place one option per line.
Example:
--packager="John Doe <john.doe@example.com>"
--url="http://example.com/johndoe/perlmodules/"
=head1 REQUIREMENTS
This script requires that RPM be installed. Both the B<rpm> and B<rpm-build>
packages must be installed on the local machine. Please see the RPM documentation (man rpm) for further information.
Additionally, the B<Perl> package will be needed :) and the CPAN module
(which is bundled with the Perl distribution) will need to be configured. To configure CPAN (CPAN.pm or CPAN/MyConfig.pm) use the following:
perl -MCPAN -e shell
For further information please refer to the CPAN manpage.
( run in 1.355 second using v1.01-cache-2.11-cpan-e1769b4cff6 )