OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Michael van Elst
Root: /e/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-re Date: 20-Nov-2002 16:43:29
Branch: HEAD Handle: 2002112015432900
Modified files:
openpkg-re openpkg-build
Log:
with options moved to -D parameter. Syntax -Dwith_bla or -Dwith_bla=yes.
targets are now taken from all ARGV, no more quoting necessary.
-E option forbids _upgrades_ of existing targets (but still allows
new installs,... this will change).
-i option removes "|| exit 1" clauses from build script for best effort
builds. Failed builds will still skip installation for that package.
Output is now tagged with ++OPENPKG-BUILD++<pid> BEGIN/END.
Summary:
Revision Changes Path
1.34 +59 -31 openpkg-re/openpkg-build
____________________________________________________________________________
Index: openpkg-re/openpkg-build
============================================================
$ cvs diff -u -r1.33 -r1.34 openpkg-build
--- openpkg-re/openpkg-build 19 Nov 2002 22:47:24 -0000 1.33
+++ openpkg-re/openpkg-build 20 Nov 2002 15:43:29 -0000 1.34
@@ -30,26 +30,39 @@
$|=1; # autoflush
use strict;
+use vars qw/$opt_R $opt_r $opt_f $opt_u $opt_U $opt_a $opt_A $opt_z $opt_P $opt_N
$opt_E $opt_i $opt_D/;
##########################################################################
sub getopts ($) {
my($opts) = @_;
- my(%opts) = map { /(\w)/; $1 => $_ } $opts =~ /(\w:|\w)/g;
- my(@argv,$optarg);
+ my(%optf) = map { /(\w)/; $1 => $_ } $opts =~ /(\w:|\w)/g;
+ my(%opts,@argv,$optarg);
foreach (@ARGV) {
if (@argv) {
push @argv, $_;
} elsif (defined $optarg) {
- eval "\$opt_$optarg = \"".quotemeta($_)."\";";
+ if (exists $opts{$optarg}) {
+ $opts{$optarg} .= " $_";
+ } else {
+ $opts{$optarg} = $_;
+ }
$optarg = undef;
- } elsif (/^-(\w)/) {
- if (exists $opts{$1}) {
- if (length($opts{$1}) > 1) {
- $optarg = $1;
+ } elsif (/^-(\w)(.*)/) {
+ if (exists $optf{$1}) {
+ if (length($optf{$1}) > 1) {
+ if (defined $2) {
+ if (exists $opts{$1}) {
+ $opts{$1} .= " $2";
+ } else {
+ $opts{$1} = $2;
+ }
+ } else {
+ $optarg = $1;
+ }
} else {
- eval "\$opt_$1 = 1;";
+ $opts{$1} = 1;
}
} else {
warn "warning: unknown option $_\n";
@@ -62,32 +75,31 @@
warn "warning: option $optarg requires an argument\n";
}
+ foreach (keys %opts) {
+ eval '$opt_'.$_.' = "'.quotemeta($opts{$_}).'";';
+ }
+
@ARGV = @argv;
}
-use vars qw/$opt_R $opt_r $opt_f $opt_u $opt_U $opt_a $opt_A $opt_z $opt_P $opt_N/;
-
-my(%env) = ( '' => { opt => {}, argv => [] } );
+my(%env) = ( '' => { } );
if (open(FH, "< $ENV{'HOME'}/.openpkg-build.rc")) {
my($env) = $env{''};
while (<FH>) {
if (/^\s*\[([^\]]*)\]/) {
- $env{$1} = { opt => {}, argv => [] } unless $env{$1};
+ $env{$1} = { } unless $env{$1};
$env = $env{$1};
} elsif (my($opt,$val) = /^\-([RfruUaAzPN])\s*(.*?)\s*$/) {
$val = 1 unless defined $val;
- $env->{opt}->{$opt} = $val;
- } else {
- chomp;
- push @{$env->{arg}}, split(/\s+/, $_);
+ $env->{$opt} = $val;
}
}
close(FH);
}
-getopts('R:r:f:uUaAzP:N:');
-die "usage: $0 [-R rpm] [-r repository] [-f index.rdf] [-uUz] [-P priv-cmd] [-N
non-priv-cmd] ( [-aA] | pattern ) [with..]\n"
- unless $ARGV[0] =~ /\S/ || $opt_a || $opt_A;
+getopts('R:r:f:uUaAzP:N:E:iD:');
+die "usage: $0 [-R rpm] [-r repository] [-f index.rdf] [-uUzEi] [-P priv-cmd] [-N
non-priv-cmd] [-Dwith ...] [-Ename ...] ( [-aA] | patternlist )\n"
+ unless $#ARGV >= 0 || ($#ARGV == -1 && ($opt_a || $opt_A));
##########################################################################
@@ -125,7 +137,7 @@
##########################################################################
-my($RPM,$RPM_PRIV,$RPM_NPRIV,$PROG,@WITH);
+my($RPM,$RPM_PRIV,$RPM_NPRIV,$PROG);
$RPM = $opt_R || $env{''}->{opt}->{'R'} || 'rpm';
$RPM = (`which $RPM` =~ m{^(/.*)})[0];
@@ -133,10 +145,9 @@
# augment command line parameters
foreach my $env (sort { $a cmp $b } grep { $RPM =~ /^\Q$_\E/ } keys %env) {
- while (my($opt,$val) = each %{$env{$env}->{opt}}) {
+ while (my($opt,$val) = each %{$env{$env}}) {
eval "\$opt_$opt = '$val' unless defined \$opt_$opt;";
}
- push @WITH, @{$env{$env}->{argv}};
}
$RPM_PRIV = ($opt_P ? $opt_P." ".$RPM : $RPM);
@@ -742,7 +753,10 @@
# see if a target is already installed and requires a rebuild
#
if ($env->{installed}->{$target->{name}}) {
- if ($target->{REBUILD}) {
+ if (exists $env->{exclude}->{$target->{name}}) {
+ print "# excluding $target->{name} (no upgrade allowed)\n";
+ return;
+ } elsif ($target->{REBUILD}) {
print "# rebuilding $target->{name} (dependency)\n";
} elsif ($env->{zero}) {
print "# rebuilding $target->{name} (zero)\n";
@@ -951,13 +965,16 @@
return $with;
}
-sub print_list1 ($$$$@) {
- my($list,$c,$url,$uncond,$with) = @_;
+sub print_list1 ($$$$@$) {
+ my($list,$c,$url,$uncond,$with,$ignore) = @_;
my($spkg,$bpkg);
my($opt);
+ my($cmd1, $cmd2, $mark);
$url .= '/' unless $url =~ m{/$}s;
+ $mark = "++".uc($PROG)."++".$$;
+
foreach (@$list) {
$spkg = $_->{href};
$bpkg = target2rpm($_, $c);
@@ -970,11 +987,12 @@
# OR dependency check found that installed package is not suitable
# OR existing binary package doesn't satisfy wanted options
#
+ $cmd1 = undef;
if ($uncond || !-f $bpkg || $_->{REBUILD} ||
!target_suitable(binary_target($_, $bpkg),$with)) {
$opt = make_defines($_->{OPTIONS}, $with);
- print "$RPM_NPRIV$opt --rebuild $url$spkg || exit 1\n";
+ $cmd1 = "$RPM_NPRIV$opt --rebuild $url$spkg";
}
#
@@ -983,7 +1001,15 @@
# files
#
$opt = $_->{REBUILD} ? ' --force' : '';
- print "$RPM_PRIV$opt -Uvh $bpkg\n";
+ $cmd2 = "$RPM_PRIV$opt -Uvh $bpkg";
+
+ if ($ignore) {
+ $cmd2 = "$cmd1 && $cmd2" if defined $cmd1;
+ } else {
+ $cmd2 = "( $cmd1 && $cmd2 )" if defined $cmd1;
+ $cmd2 = "$cmd2 || exit 1";
+ }
+ print "echo $mark BEGIN $spkg\n$cmd2\necho $mark END $spkg\n";
}
}
@@ -1000,12 +1026,12 @@
#######################################################################
my($config,$url,$repository,$installed,$list,$bonly);
-my($pattern,%with);
+my($pattern,%with,%exclude);
if ($opt_a) {
$pattern = undef;
} else {
- $pattern = shift @ARGV;
+ $pattern = join(' ', @ARGV);
}
if ($opt_A) {
@@ -1016,7 +1042,8 @@
/([^\s=]+)(?:\=(\S+))?/
? ($1 => (defined $2 ? $2 : 'yes'))
: ()
- } ( @ARGV, @WITH );
+ } split(/\s+/, $opt_D);
+%exclude = map { $_ => 1 } split(/\s+/, $opt_E);
$config = get_config();
@@ -1036,12 +1063,13 @@
built => {},
revdep => undef,
with => \%with,
+ exclude => \%exclude,
upgrade => ($opt_a || $opt_U),
zero => $opt_z
});
die "FATAL: cannot find package\n" unless defined $list;
-print_list1($list,$config,$url,$opt_a || $opt_u || $opt_U,\%with);
+print_list1($list,$config,$url,$opt_a || $opt_u || $opt_U,\%with,$opt_i);
print_list2($bonly,$config);
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List [EMAIL PROTECTED]