|
|
|
|
@ -33,8 +33,8 @@ use vars qw/
|
|
|
|
|
$opt_R $opt_r $opt_f $opt_u $opt_U $opt_a $opt_A |
|
|
|
|
$opt_z $opt_Z $opt_P $opt_N $opt_E $opt_i $opt_D |
|
|
|
|
$opt_p $opt_q $opt_s $opt_S $opt_X $opt_M $opt_L |
|
|
|
|
$opt_W/; |
|
|
|
|
my $getopts = 'R:r:f:uUaAzZP:N:E:iD:p:qsSXMLW'; |
|
|
|
|
$opt_W $opt_K/; |
|
|
|
|
my $getopts = 'R:r:f:uUaAzZP:N:E:iD:p:qsSXMLWK'; |
|
|
|
|
getopts($getopts); |
|
|
|
|
|
|
|
|
|
########################################################################## |
|
|
|
|
@ -150,7 +150,7 @@ sub conditional ($$) {
|
|
|
|
|
|
|
|
|
|
########################################################################## |
|
|
|
|
|
|
|
|
|
my($RPM,$RPM_PRIV,$RPM_NPRIV,$CURL,$PROG); |
|
|
|
|
my($RPM,$CURL,$PROG); |
|
|
|
|
|
|
|
|
|
$RPM = $opt_R || $env{''}->{'R'} || '@l_prefix@/bin/rpm'; |
|
|
|
|
$RPM = (`which $RPM` =~ m{^(/.*)})[0]; |
|
|
|
|
@ -163,14 +163,26 @@ foreach my $env (sort { $a cmp $b } grep { $RPM =~ /^\Q$_\E/ } keys %env) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$RPM_PRIV = ($opt_P ? $opt_P." ".$RPM : $RPM); |
|
|
|
|
$RPM_NPRIV = ($opt_N ? $opt_N." ".$RPM : $RPM); |
|
|
|
|
$CURL = $RPM; |
|
|
|
|
$CURL =~ s/\/bin\/rpm$/\/lib\/openpkg\/curl/ |
|
|
|
|
or die "FATAL: cannot deduce curl path from $RPM\n"; |
|
|
|
|
|
|
|
|
|
($PROG) = $0 =~ /(?:.*\/)?(.*)/; |
|
|
|
|
|
|
|
|
|
sub cmd ($$) { |
|
|
|
|
my($w,$s) = @_; |
|
|
|
|
if (!defined $w) { |
|
|
|
|
return $s; |
|
|
|
|
} elsif ($w =~ /^-(.*)/) { |
|
|
|
|
return "$1 '$s'"; |
|
|
|
|
} else { |
|
|
|
|
return "$w $s"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
sub priv ($) { cmd($opt_P,$_[0]); } |
|
|
|
|
sub npriv ($) { cmd($opt_N,$_[0]); } |
|
|
|
|
sub run ($) { my($c) = cmd($opt_N,$_[0]); `$c` } |
|
|
|
|
|
|
|
|
|
sub version_cmp ($$) { |
|
|
|
|
my($a,$b) = @_; |
|
|
|
|
my(@a,@b,$c); |
|
|
|
|
@ -243,7 +255,7 @@ sub get_config ()
|
|
|
|
|
{ |
|
|
|
|
my($c,@q,@g); |
|
|
|
|
|
|
|
|
|
$c = `$RPM_NPRIV --eval '%{_rpmdir} %{_rpmfilename} %{_target_os} %{_target_cpu} %{_target_platform} %{_prefix}'`; |
|
|
|
|
$c = run("$RPM --eval '%{_rpmdir} %{_rpmfilename} %{_target_os} %{_target_cpu} %{_prefix}'"); |
|
|
|
|
chomp($c); |
|
|
|
|
(@q) = split(/\s+/,$c); |
|
|
|
|
|
|
|
|
|
@ -251,14 +263,14 @@ sub get_config ()
|
|
|
|
|
$q[1] =~ s/%{ARCH}/$q[3]/; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$c = `$RPM_NPRIV --showrc`; |
|
|
|
|
$c = run("$RPM --showrc"); |
|
|
|
|
@g = $c =~ /\%\{l_tool_locate\s+([^\s\}]+)/g; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
rpmdir => $q[0], |
|
|
|
|
template => $q[1], |
|
|
|
|
platform => $q[4], |
|
|
|
|
prefix => $q[5], |
|
|
|
|
platform => '', |
|
|
|
|
prefix => $q[4], |
|
|
|
|
optreg => '(?:'.join('|', map { "\Qwith_$_\E" } @g).')' |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
@ -266,16 +278,13 @@ sub get_config ()
|
|
|
|
|
sub get_release () { |
|
|
|
|
my($rel,$url); |
|
|
|
|
|
|
|
|
|
($rel) =`$RPM_NPRIV -qi openpkg` =~ /Version:\s*(\S+)/m; |
|
|
|
|
|
|
|
|
|
($rel) = run("$RPM -qi openpkg") =~ /Version:\s*(\S+)/m; |
|
|
|
|
if ($rel =~ /^\d+$/) { |
|
|
|
|
print "# $PROG current($rel)\n"; |
|
|
|
|
print "# using '$RPM_NPRIV' (build) and '$RPM_PRIV' (install)\n"; |
|
|
|
|
$url = "ftp://ftp.openpkg.org/current/"; |
|
|
|
|
} elsif ($rel =~ /^(\d+\.\d+)/) { |
|
|
|
|
$rel = $1; |
|
|
|
|
print "# $PROG release($rel)\n"; |
|
|
|
|
print "# using '$RPM_NPRIV' (build) and '$RPM_PRIV' (install)\n"; |
|
|
|
|
$url = "ftp://ftp.openpkg.org/release/$rel/"; |
|
|
|
|
} else { |
|
|
|
|
die "FATAL: don't know how to handle this release\n"; |
|
|
|
|
@ -416,7 +425,7 @@ sub depends2pkglist ($) {
|
|
|
|
|
# |
|
|
|
|
sub get_installed () { |
|
|
|
|
my(%map); |
|
|
|
|
my(@l) = `$RPM_NPRIV --provides -qa`; |
|
|
|
|
my(@l) = run("$RPM --provides -qa"); |
|
|
|
|
my($p); |
|
|
|
|
my($nam,$val,%options); |
|
|
|
|
|
|
|
|
|
@ -548,9 +557,9 @@ sub get_with ($$;$) {
|
|
|
|
|
$opt = $t->{OPTIONS}; |
|
|
|
|
} else { |
|
|
|
|
if (defined $fn) { |
|
|
|
|
@l = `$RPM_NPRIV -qi -p $fn`; |
|
|
|
|
@l = run("$RPM -qi -p $fn"); |
|
|
|
|
} else { |
|
|
|
|
@l = `$RPM_NPRIV -qi $t->{name}`; |
|
|
|
|
@l = run("$RPM -qi $t->{name}"); |
|
|
|
|
} |
|
|
|
|
$opt = parse_options(\@l); |
|
|
|
|
$t->{OPTIONS} = $opt if $env; |
|
|
|
|
@ -633,8 +642,14 @@ sub with_list ($$) {
|
|
|
|
|
return \@out; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub simple_text_parser ($$$$) { |
|
|
|
|
my($fh,$url,$with,$map) = @_; |
|
|
|
|
sub goodpf ($$) { |
|
|
|
|
my($l,$p) = @_; |
|
|
|
|
return 1 if $l eq ''; |
|
|
|
|
return $l =~ /(?:^|\s)\Q$p\E(?:\s|$)/; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub simple_text_parser ($$$$$) { |
|
|
|
|
my($fh,$url,$with,$map,$pfmatch) = @_; |
|
|
|
|
my(@include); |
|
|
|
|
|
|
|
|
|
my($section); |
|
|
|
|
@ -671,8 +686,12 @@ sub simple_text_parser ($$$$) {
|
|
|
|
|
@nosource = (); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!(defined $href) && /<Repository.*?href="([^"]*)"/) { |
|
|
|
|
push(@include, $1); |
|
|
|
|
if (!(defined $href) && |
|
|
|
|
/<Repository.*?href="([^"]*)"(?:\s*platform="([^"]*)")?/ |
|
|
|
|
) { |
|
|
|
|
if (goodpf($2,$pfmatch)) { |
|
|
|
|
push(@include, $1) |
|
|
|
|
} |
|
|
|
|
next; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -809,8 +828,8 @@ sub simple_text_parser ($$$$) {
|
|
|
|
|
return \@include; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub xml_parser ($$$$) { |
|
|
|
|
my($fh, $url, $with, $map) = @_; |
|
|
|
|
sub xml_parser ($$$$$) { |
|
|
|
|
my($fh, $url, $with, $map,$pfmatch) = @_; |
|
|
|
|
my(@include); |
|
|
|
|
|
|
|
|
|
my($xml,$desc,$sub); |
|
|
|
|
@ -885,7 +904,11 @@ sub xml_parser ($$$$) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($sub) { |
|
|
|
|
@include = map { $_->{href} } @$sub; |
|
|
|
|
@include = map { |
|
|
|
|
goodpf($_->{platform},$pfmatch) |
|
|
|
|
? ( $_->{href} ) |
|
|
|
|
: ( ) |
|
|
|
|
} @$sub; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return \@include; |
|
|
|
|
@ -929,8 +952,8 @@ sub open_index ($$) {
|
|
|
|
|
# fetch index from file or URL |
|
|
|
|
# recursively fetch sub-indexes |
|
|
|
|
# |
|
|
|
|
sub get_index ($$$$) { |
|
|
|
|
my($url,$fn,$with,$noxml) = @_; |
|
|
|
|
sub get_index ($$$$$) { |
|
|
|
|
my($url,$fn,$with,$noxml,$pfmatch) = @_; |
|
|
|
|
my(%map,$include); |
|
|
|
|
|
|
|
|
|
open_index($url,$fn); |
|
|
|
|
@ -943,9 +966,9 @@ sub get_index ($$$$) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($noxml) { |
|
|
|
|
$include = simple_text_parser(\*RFH, $url, $with, \%map); |
|
|
|
|
$include = simple_text_parser(\*RFH, $url, $with, \%map, $pfmatch); |
|
|
|
|
} else { |
|
|
|
|
$include = xml_parser(\*RFH, $url, $with, \%map); |
|
|
|
|
$include = xml_parser(\*RFH, $url, $with, \%map, $pfmatch); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
close(RFH) |
|
|
|
|
@ -958,7 +981,7 @@ sub get_index ($$$$) {
|
|
|
|
|
foreach (@$include) { |
|
|
|
|
my($submap); |
|
|
|
|
my($suburl,$subfn) = relurl($url,$fn,$_); |
|
|
|
|
$submap = get_index($suburl,$subfn,$with,$noxml); |
|
|
|
|
$submap = get_index($suburl,$subfn,$with,$noxml,$pfmatch); |
|
|
|
|
while (my($name,$vmap) = each %$submap) { |
|
|
|
|
while (my($vs,$recs) = each %$vmap) { |
|
|
|
|
push @{$map{$name}->{$vs}}, @$recs; |
|
|
|
|
@ -1522,7 +1545,7 @@ sub build_list ($$) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
%keep = map { $_ => 1 } @keeps; |
|
|
|
|
@bonly = grep { |
|
|
|
|
@bonly = reverse grep { |
|
|
|
|
!$keep{$_} && !$env->{installed}->{$_->{name}}->{vs($_)}; |
|
|
|
|
} @targets; |
|
|
|
|
|
|
|
|
|
@ -1628,7 +1651,7 @@ sub binary_target ($$) {
|
|
|
|
|
# |
|
|
|
|
sub find_proxy ($$) { |
|
|
|
|
my($t,$bpkg) = @_; |
|
|
|
|
my(@l) = `$RPM_NPRIV -ql $t->{name}`; |
|
|
|
|
my(@l) = run("$RPM -ql $t->{name}"); |
|
|
|
|
my($link) = (grep { $_ =~ /\/\.prefix-$t->{name}$/ } @l)[0]; |
|
|
|
|
return unless defined $link; |
|
|
|
|
chomp $link; |
|
|
|
|
@ -1727,13 +1750,15 @@ sub print_list1 ($$$@$) {
|
|
|
|
|
# |
|
|
|
|
# rpm doesn't support additional parameters to the |
|
|
|
|
# mkproxy script |
|
|
|
|
# $cmd1 = "$RPM_NPRIV$opt --makeproxy $ppkg -- -o $bpkg"; |
|
|
|
|
# $cmd1 = npriv("$RPM$opt --makeproxy $ppkg -- -o $bpkg"); |
|
|
|
|
# |
|
|
|
|
$cmd1 = "( cd $c->{rpmdir} && $RPM_NPRIV$opt --makeproxy $ppkg )"; |
|
|
|
|
$cmd1 = "( cd $c->{rpmdir} && ". |
|
|
|
|
npriv("$RPM$opt --makeproxy $ppkg"). |
|
|
|
|
" )"; |
|
|
|
|
} elsif (defined $_->{prefix}) { |
|
|
|
|
$cmd1 = "$CURL -q -s -o $bpkg $spkg"; |
|
|
|
|
$cmd1 = npriv("$CURL -q -s -o $bpkg $spkg"); |
|
|
|
|
} else { |
|
|
|
|
$cmd1 = "$RPM_NPRIV$opt --rebuild $spkg"; |
|
|
|
|
$cmd1 = npriv("$RPM$opt --rebuild $spkg"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1743,7 +1768,7 @@ sub print_list1 ($$$@$) {
|
|
|
|
|
# files |
|
|
|
|
# |
|
|
|
|
$opt = $_->{REBUILD} ? ' --force' : ''; |
|
|
|
|
$cmd2 = "$RPM_PRIV$opt -Uvh $bpkg"; |
|
|
|
|
$cmd2 = priv("$RPM$opt -Uvh $bpkg"); |
|
|
|
|
|
|
|
|
|
if ($ignore) { |
|
|
|
|
$cmd2 = "$cmd1 && \\\n$cmd2" if defined $cmd1; |
|
|
|
|
@ -1770,7 +1795,7 @@ sub print_list2 ($$) {
|
|
|
|
|
|
|
|
|
|
foreach (@$list) { |
|
|
|
|
$pkg = "$_->{name}-$_->{version}-$_->{release}"; |
|
|
|
|
print "$RPM_PRIV -e $pkg\n"; |
|
|
|
|
print priv("$RPM -e $pkg\n"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1910,7 +1935,8 @@ $repository = get_index(
|
|
|
|
|
$url.'00INDEX.rdf', |
|
|
|
|
$opt_f, |
|
|
|
|
($opt_W ? undef : \%with), |
|
|
|
|
$opt_X); |
|
|
|
|
$opt_X, |
|
|
|
|
$config->{platform}); |
|
|
|
|
|
|
|
|
|
$env = { |
|
|
|
|
config => $config, |
|
|
|
|
@ -1953,7 +1979,7 @@ if ($opt_L) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
print_list1($list,$config,$opt_a || $opt_u || $opt_U,\%with,$opt_i); |
|
|
|
|
print_list2($bonly,$config); |
|
|
|
|
print_list2($bonly,$config) unless $opt_K; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|