[netfilter-cvslog] r6717 - trunk/patch-o-matic-ng
gandalf at netfilter.org
gandalf at netfilter.org
Fri Dec 29 00:45:20 CET 2006
Author: gandalf at netfilter.org
Date: 2006-12-29 00:45:19 +0100 (Fri, 29 Dec 2006)
New Revision: 6717
Modified:
trunk/patch-o-matic-ng/runme
Log:
Patch from Jonas Berlin <xkr47 at outerspace.dyndns.org>:
Fixed help text bugs, improved --download description and added a list of
suites.
Added support for multiple download clients (curl and wget) to --download code,
previously only curl supported. Also now the error messages lists what software
was attempted if none of them worked out.
Added verbose messages to --download operations (enabled through --verbose).
Modified: trunk/patch-o-matic-ng/runme
===================================================================
--- trunk/patch-o-matic-ng/runme 2006-12-23 15:41:38 UTC (rev 6716)
+++ trunk/patch-o-matic-ng/runme 2006-12-28 23:45:19 UTC (rev 6717)
@@ -106,18 +106,59 @@
pod2usage(-verbose=>1, -exitval=>0) if $opt_help;
if ($opt_download) {
+ # a list of commands that can download content referred to by
+ # urls and print them and _only_ them on stdout and return
+ # error code on failure
+ my @download_commands_stdout = ("curl -s -L", "wget -q -O -");
+ my @download_commands_file = ("curl -s -L -o ", "wget -q -O ");
+ # this is updated once the command to use has been determined
+ my $download_command_idx = -1;
+
open(SOURCES, "<sources.list") || die "could not open sources.list";
while (my $source = <SOURCES>) {
chomp($source);
- if ($source =~ m/^\s*#/ || $source =~ m/^\s+$/) {
+ if ($source =~ m/^\s*\#/ || $source =~ m/^\s*$/) {
next;
}
- if (!open(INDEX, "curl -s $source/index |")) {
- print STDERR "could not get $source/index\n";
+ print "Attempting to download $source/index\n" if ($opt_verbose);
+ my $success = 0; # true if program was launched
+ my $ret = 0; # return code
+
+ # if download command undecided, try one at a time until we successfully execute one
+ if ($download_command_idx == -1) {
+ for ($download_command_idx = 0; $download_command_idx <= $#download_commands_file; ++$download_command_idx) {
+ my $ret = system($download_commands_file[$download_command_idx]." /tmp/pom-runme-index $source/index");
+ if($ret != -1) {
+ # command worked
+ $success = 1;
+ last;
+ }
+ }
+ } else {
+ $ret = system($download_commands_file[$download_command_idx]." /tmp/pom-runme-index $source/index");
+ if($ret != -1) {
+ $success = 1;
+ }
}
+ # none of the commands worked or the command stopped working
+ if(!$success) {
+ print STDERR "Failed to execute ".join(" or ", map { s/ .*//; $_ } @download_commands_file)." to download files. Please install one of them.\n";
+ exit(1);
+ }
+ # if process returned nonzero value, skip
+ if($ret & 0xFF00) {
+ print STDERR "Failed to get $source/index, skipping..\n";
+ next;
+ }
+
+ # read the downloaded index file
+ if(!open(INDEX, '<', "/tmp/pom-runme-index")) {
+ print STDERR "Failed to read temporary file /tmp/pom-runme-index: $? - aborting!\n";
+ exit(1);
+ }
while (my $patch = <INDEX>) {
chomp($patch);
- if ($patch =~ m/^\s*#/ || $patch =~ m/^\s+$/) {
+ if ($patch =~ m/^\s*\#/ || $patch =~ m/^\s*$/) {
next;
}
if ($patch =~ m/[^a-zA-Z0-9\-]/) {
@@ -143,8 +184,14 @@
}
}
- if (system("curl -s $source/$patch.tar.gz | tar xz -C $POMNG_ROOT_DIR $patch 2>/dev/null")) {
- print STDERR "could not get $source/$patch.tar.gz\n";
+ print "Attempting to download $source/$patch.tar.gz\n" if ($opt_verbose);
+ if (system($download_commands_stdout[$download_command_idx]." $source/$patch.tar.gz | tar xz -C $POMNG_ROOT_DIR $patch 2>/dev/null")) {
+ # some packages are not gzipped even if extension suggests so.. so try without before complaining
+ if (system($download_commands_stdout[$download_command_idx]." $source/$patch.tar.gz | tar x -C $POMNG_ROOT_DIR $patch 2>/dev/null")) {
+ print STDERR "could not get $source/$patch.tar.gz\n";
+ system("rm -rf $POMNG_ROOT_DIR/$patch");
+ next;
+ }
}
# check for "Repository: external"
@@ -397,7 +444,7 @@
=head1 SYNOPSIS
-./runme [--batch] [--reverse] [--exclude suite/patch-dir ] suite|suite/patch-dir
+./runme [options] suite|suite/patch-dir
=head1 OPTIONS
@@ -405,7 +452,11 @@
=item B<--download>
-download patches from external repositories.
+some patches are stored at external locations and are not available by
+default. To add these to the selection of patchlets, add the
+--download switch to the command line and they will be available in
+the "external" suite. You need curl or wget installed for this to
+work.
=item B<--batch>
@@ -436,11 +487,11 @@
print the whole manpage
-=item B<--kernel-path>
+=item B<--kernel-path> path
specify the kernel source path
-=item B<--iptables-path>
+=item B<--iptables-path> path
specify the iptables source path
@@ -452,6 +503,8 @@
=head1 DESCRIPTION
-B<runme> is the main executable of the patch-o-matic system
+B<runme> is the main executable of the patch-o-matic system.
+Available suites: updates submitted pending base extra external obsolete
+
=cut
More information about the netfilter-cvslog
mailing list