Browse Source

fix temp pkgs, optionally keep temp pkgs, support for su command, skip sub-index by platform, no longer uses defaults for platform name

master
Michael van Elst 23 years ago committed by Ralf S. Engelschall
parent
commit
e481268d94
  1. 102
      openpkg-tool/openpkg-build.pl
  2. 9
      openpkg-tool/openpkg-index.pl
  3. 4
      openpkg-tool/openpkg-tool.spec
  4. 25
      openpkg-tool/openpkg.pod

102
openpkg-tool/openpkg-build.pl

@ -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;
}
}

9
openpkg-tool/openpkg-index.pl

@ -683,6 +683,10 @@ sub rpm2data ($$) {
my($q,$pipe,%a);
my($t,$v);
unless (defined $platform) {
die "FATAL: indexing binary package '$fn' requires -p option\n";
}
$q = <<EOFEOF;
Name %{Name}
Version %{Version}
@ -753,7 +757,9 @@ EOFEOF
if ($a{'SigMD5'} eq '(unknown type)') {
delete $a{'SigMD5'};
}
$a{'Platform'} = "$a{'Arch'}-$platform-$a{'Os'}";
if (defined $platform) {
$a{'Platform'} = $platform;
}
$a{'PreReq'} =~ s/^rpmlib\(.*$//mg;
$a{'Description'} = [ $a{'Description'} ];
@ -924,7 +930,6 @@ if ($opt_C) {
}
$opt_r = 'OpenPKG-CURRENT/Source/' unless defined $opt_r;
$opt_p = 'unknown' unless defined $opt_p;
if (defined $opt_o) {
$tmpo = $opt_o . '.tmp';

4
openpkg-tool/openpkg-tool.spec

@ -32,8 +32,8 @@ Packager: The OpenPKG Project
Distribution: OpenPKG [PLUS]
Group: Bootstrapping
License: GPL
Version: 20030116
Release: 20030116
Version: 20030121
Release: 20030121
# list of sources
Source0: openpkg.sh

25
openpkg-tool/openpkg.pod

@ -63,6 +63,7 @@ B<build>
[B<-L>]
[B<-W>]
[B<-X>]
[B<-K>]
[B<-P> I<priv-cmd>]
[B<-N> I<non-priv-cmd>]
[B<-p> I<platform>]
@ -97,12 +98,9 @@ The name of the resource stored in the index. The default is
=item B<-p> I<platform>
B<openpkg index> adds a platform attribute for binary RPMs. The
attribute is built as I<%{arch}>C<->I<platform>C<->I<%{os}> where
I<%{arch}> and I<%{os}> are taken from the RPM header and I<platform> is
the value of the B<-p> option. The default value is "C<unknown>". This
must be used to distinguish between platforms that support the same
Architecture and OS name like various Linux distributions.
B<openpkg index> adds a platform attribute for binary RPMs. This
must be unique to correctly identify a specific architecture, OS
and build environment.
=item B<-C> I<cache.db>
@ -275,20 +273,29 @@ results!>
Ignore an installed XML parser module but use the internal
simple text parser instead.
=item B<-K>
Keep packages that were installed temporarily during the build process.
=item B<-P> I<priv-cmd>
Command prefix to use for install commands that require elevated
privileges. The most common tool for this is sudo(8).
privileges. The most common tool for this is sudo(8). If I<priv-cmd>
starts with a dash it will be run without the dash and the command
line it should execute is passed as a single quoted string.
=item B<-N> I<non-priv-cmd>
Command prefix to use for install commands that do not require elevated
privileges. The most common tool for this is sudo(8).
privileges. The most common tool for this is sudo(8). If I<priv-cmd>
starts with a dash it will be run without the dash and the command
line it should execute is passed as a single quoted string.
=item B<-p> I<platform>
The platform string that is matched against the index for binary
packages. Default is to use the I<%{_target_platform}> variable.
packages. Default is an empty string so that no binary packages
are matched.
=item B<-D>I<var>=I<val>

Loading…
Cancel
Save