From 8c43c87b270294274d5af2675cefc5dbfc0a484d Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Wed, 25 Jan 2006 14:26:05 +0000 Subject: Allow to install specfiles via urpmi (like source rpms) --- urpm.pm | 20 ++++++++++++++------ urpmi | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/urpm.pm b/urpm.pm index 3c1d53af..46fda003 100644 --- a/urpm.pm +++ b/urpm.pm @@ -2081,10 +2081,10 @@ sub register_rpms { #- depslist and provides environment. $start = @{$urpm->{depslist}}; foreach (@files) { - /\.rpm$/ or $error = 1, $urpm->{error}(N("invalid rpm file name [%s]", $_)), next; + /\.(?:rpm|spec)$/ or $error = 1, $urpm->{error}(N("invalid rpm file name [%s]", $_)), next; #- allow url to be given. - if (my ($basename) = m|^[^:]*:/.*/([^/]*\.rpm)$|) { + if (my ($basename) = m{^[^:]*:/.*/([^/]*\.(?:rpm|spec))\z}) { unlink "$urpm->{cachedir}/partial/$basename"; eval { $urpm->{log}(N("retrieving rpm file [%s] ...", $_)); @@ -2108,10 +2108,18 @@ sub register_rpms { -r $_ or $error = 1, $urpm->{error}(N("unable to access rpm file [%s]", $_)), next; } - ($id, undef) = $urpm->parse_rpm($_); - my $pkg = defined $id && $urpm->{depslist}[$id]; - $pkg or $urpm->{error}(N("unable to register rpm file")), next; - $urpm->{source}{$id} = $_; + if (/\.spec$/) { + my $pkg = URPM::spec2srcheader($_) + or $error = 1, $urpm->{error}(N("unable to parse spec file %s [%s]", $_, $!)), next; + $id = @{$urpm->{depslist}}; + $urpm->{depslist}[$id] = $pkg; + $urpm->{source}{$id} = $_; + } else { + ($id, undef) = $urpm->parse_rpm($_); + my $pkg = defined $id && $urpm->{depslist}[$id]; + $pkg or $error = 1, $urpm->{error}(N("unable to register rpm file")), next; + $urpm->{source}{$id} = $_; + } } $error and $urpm->{fatal}(2, N("error registering local packages")); defined $id && $start <= $id and @requested{($start .. $id)} = (1) x ($id-$start+1); diff --git a/urpmi b/urpmi index ebb10ccf..fb846e30 100755 --- a/urpmi +++ b/urpmi @@ -174,8 +174,8 @@ urpm::args::parse_cmdline(urpm => $urpm); # Process the rest of the arguments while (defined($_ = shift @ARGV)) { - if (/\.rpm$/) { - if (/\.src\.rpm$/) { + if (/\.(?:rpm|spec)$/) { + if (/\.(?:src\.rpm|spec)$/) { push @src_files, $_; } else { push @files, untaint($_); -- cgit v1.2.1