OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Thomas Lotterer
Root: /v/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-tools Date: 20-Feb-2007 23:24:42
Branch: HEAD Handle: 2007022022244200
Modified files:
openpkg-tools/cmd build.pl
Log:
make "openpkg build" use "openpkg curl" for downloading indices,
sources and binaries; add -k option to keep downloaded packages after
use
Summary:
Revision Changes Path
1.41 +48 -20 openpkg-tools/cmd/build.pl
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-tools/cmd/build.pl
============================================================================
$ cvs diff -u -r1.40 -r1.41 build.pl
--- openpkg-tools/cmd/build.pl 1 Jan 2007 17:45:10 -0000 1.40
+++ openpkg-tools/cmd/build.pl 20 Feb 2007 22:24:42 -0000 1.41
@@ -34,7 +34,8 @@
$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_H, $opt_i,
$opt_D, $opt_p, $opt_q, $opt_s, $opt_S, $opt_X, $opt_M,
- $opt_L, $opt_W, $opt_K, $opt_e, $opt_b, $opt_B, $opt_g
+ $opt_L, $opt_W, $opt_K, $opt_e, $opt_b, $opt_B, $opt_g,
+ $opt_k
);
# global context variables
@@ -46,7 +47,7 @@
##
# parse command line options
-my $getopts = 'hR:r:f:uUaAzZP:N:E:H:iD:p:qsSXMLWKebBg';
+my $getopts = 'hR:r:f:uUaAzZP:N:E:H:iD:p:qsSXMLWKebBgk';
getopts($getopts);
# parse configuration script options
@@ -93,6 +94,7 @@
" -L generate list of packages in repository
depending on target\n" .
" -W include dependencies as if all build options are
enabled\n" .
" -K keep temporarily installed packages\n" .
+ " -k keep temporarily downloaded packages\n" .
" -e rebuild exact version of a package from
repository\n" .
" -b build-time check existing binaries for
dependencies only\n" .
" -B build-time check existing binaries for
dependencies and target\n" .
@@ -378,9 +380,10 @@
$bzip2 =~ s/\/bin\/openpkg rpm$/\/lib\/openpkg\/bzip2/;
my $curl = $rpm;
$curl =~ s/\/bin\/openpkg rpm$/\/lib\/openpkg\/curl/;
+ $curl = "$l_prefix/bin/openpkg curl" if (system("$l_prefix/bin/openpkg
curl file://$l_prefix/etc/openpkg/platform >/dev/null 2>&1") == 0);
# expand RPM macros holding information
- my $c = run("$rpm --eval '%{_rpmdir} %{_rpmfilename} %{_target_os}
%{_target_cpu}'");
+ my $c = run("$rpm --eval '%{_rpmdir} %{_rpmfilename} %{_target_os}
%{_target_cpu} %{_srcrpmdir}'");
# parse and post-process information
chomp($c);
@@ -400,6 +403,7 @@
bzip2 => $bzip2,
curl => $curl,
rpmdir => $q[0],
+ srcrpmdir=> $q[4],
template => $q[1],
platform => '',
prefix => $l_prefix,
@@ -2399,6 +2403,12 @@
}
}
+# compute path to source RPM from rpm config and target data
+sub target2srcrpm ($$) {
+ my ($target, $c) = @_;
+ return
$c->{srcrpmdir}.'/'.$target->{name}.'-'.$target->{version}.'-'.$target->{release}.'.src.rpm';
+}
+
# compute path to binary RPM from rpm config and target data
sub target2rpm ($$) {
my ($target, $c) = @_;
@@ -2472,6 +2482,13 @@
return (glob("$prefix/RPM/PKG/$bpkg"))[0];
}
+# indent text to form a block
+sub indent ($) {
+ my ($txt) = @_;
+ $txt =~ s/^/ /gm;
+ return $txt;
+}
+
# print commands from package build list
# c -> configuration to derive paths from
# uncond -> always do the --rebuild
@@ -2484,9 +2501,12 @@
my ($pkg, $spkg, $bpkg, $ppkg);
my ($opt);
my ($cmd1, $cmd2, $mark);
+ my ($cmd3, $srcpkg);
$mark = '::::';
+ my $err;
+ if ($ignore) { $err = "|| true" } else { $err = "|| exit \$?" };
foreach (@$list) {
$pkg = $_->{name};
$spkg = $_->{href};
@@ -2494,6 +2514,8 @@
die "openpkg:build:FATAL: internal error, ",vsn($_)," without
source URL\n";
}
$bpkg = target2rpm($_, $c);
+ $srcpkg = target2srcrpm($_, $c);
+ $cmd3 = '';
# rebuild binary package IF
# 'unconditional' option
@@ -2524,36 +2546,37 @@
npriv($config->{"mkp"} . " $ppkg").
" )";
} elsif (defined $_->{prefix}) {
- $cmd1 = npriv($config->{"curl"} . " -s -o $bpkg $spkg");
+ $cmd1 = '';
+ $cmd1 .= npriv($config->{"curl"} . " -# -o $bpkg $spkg
$err\n");
+ $cmd3 = npriv("rm -f $bpkg >/dev/null 2>&1 $err\n") unless
($opt_k);
} else {
- $cmd1 = npriv($config->{"rpm"} . "$opt --rebuild $spkg");
+ $cmd1 = '';
+ $cmd1 .= "if test ! -f $srcpkg; then\n";
+ $cmd1 .= indent(npriv($config->{"curl"} . " -# -o $srcpkg
$spkg $err\n"));
+ $cmd1 .= "fi\n";
+ $cmd1 .= npriv($config->{"rpm"} . "$opt --rebuild $srcpkg
$err\n");
+ $cmd1 .= npriv("rm -f $srcpkg >/dev/null 2>&1 $err\n")
unless ($opt_k);
}
}
# wrap build command with build-time check for existing
# binary target
if (defined($cmd1) && ($allbin || ($usebin && !$_->{GOAL}))) {
- $cmd1 = "if test ! -f $bpkg ; then $cmd1 ; fi";
+ $cmd1 = "if test ! -f $bpkg; then\n".indent($cmd1)."fi\n";
}
# if package exist force rpm to copy over new files
# better than erasing everything and losing configuration
# files
$opt = ($_->{REBUILD} || ($allbin || ($usebin && !$_->{GOAL}))) ? '
--force' : '';
- $cmd2 = priv($config->{"rpm"} . "$opt -Uvh $bpkg");
+ $cmd2 = '';
+ $cmd2 .= priv($config->{"rpm"} . "$opt -Uvh $bpkg $err\n");
if ($allbin || ($usebin && !$_->{GOAL})) {
- $cmd2 = "if test \".`".$config->{"rpm"}." -q --qf '\%{SIGMD5}'
$pkg`\" != \".`".$config->{"rpm"}." -qp --qf '\%{SIGMD5}' $bpkg`\"; then $cmd2;
fi";
- }
- if ($ignore) {
- $cmd2 = "$cmd1 && \\\n$cmd2" if defined $cmd1;
- } else {
- if (defined $cmd1) {
- $cmd2 = "$cmd1 || exit \$?\n$cmd2 || exit \$?"
- } else {
- $cmd2 = "$cmd2 || exit \$?";
- }
+ $cmd2 = "if test \".`".$config->{"rpm"}." -q --qf '\%{SIGMD5}'
$pkg`\" != \".`".$config->{"rpm"}." -qp --qf '\%{SIGMD5}' $bpkg`\";
then\n".indent($cmd2)."fi\n";
}
- print "echo $mark $spkg $mark\n$cmd2\necho $mark $spkg = \$?
$mark\n";
+ $cmd2 = $cmd1.$cmd2 if ($cmd1);
+ $cmd2 = $cmd2.$cmd3 if ($cmd3);
+ print "echo $mark $spkg $mark\n".$cmd2."echo $mark $spkg = \$?
$mark\n";
}
}
@@ -2600,6 +2623,7 @@
[B<-W>]
[B<-X>]
[B<-K>]
+[B<-k>]
[B<-e>]
[B<-b>]
[B<-B>]
@@ -2688,8 +2712,7 @@
=item B<-i>
-The generated script will ignore errors. However, if a build
-phase fails the install phase is still skipped.
+The generated script will ignore run-time errors.
=item B<-q>
@@ -2782,6 +2805,11 @@
Keep packages that were installed temporarily during the build process.
Without this option those packages are removed.
+=item B<-k>
+
+Keep packages that were downloaded temporarily for installation or building.
+Without this option those packages are removed.
+
=item B<-e>
Rebuild exact version of a package from repository even when you have
@@ .
______________________________________________________________________
OpenPKG http://openpkg.org
CVS Repository Commit List [email protected]