[netfilter-cvslog] r6577 - trunk/patch-o-matic-ng

kaber at netfilter.org kaber at netfilter.org
Thu Apr 6 11:24:22 CEST 2006


Author: kaber at netfilter.org
Date: 2006-04-06 11:24:21 +0200 (Thu, 06 Apr 2006)
New Revision: 6577

Added:
   trunk/patch-o-matic-ng/sources.list
Modified:
   trunk/patch-o-matic-ng/runme
Log:
Add apt-get like patch fetching mechanism. Someone who likes perl feel
free to clean this up :)


Modified: trunk/patch-o-matic-ng/runme
===================================================================
--- trunk/patch-o-matic-ng/runme	2006-04-03 18:13:04 UTC (rev 6576)
+++ trunk/patch-o-matic-ng/runme	2006-04-06 09:24:21 UTC (rev 6577)
@@ -88,6 +88,7 @@
 my @opt_exclude;
 my $opt_path;
 my $opt_iptpath;
+my $opt_download;
 
 my $result = GetOptions("batch" => \$opt_batch,
 			"verbose" => \$opt_verbose,
@@ -97,12 +98,80 @@
 			"exclude=s" => \@opt_exclude,
 			"help" => \$opt_help,
 			"man" => \$opt_man,
+			"download" => \$opt_download,
 			"kernel-path=s" => \$opt_path,
 			"iptables-path=s" => \$opt_iptpath) or pod2usage(2);
 
 pod2usage(-verbose=>2, -exitval=>0) if $opt_man;
 pod2usage(-verbose=>1, -exitval=>0) if $opt_help;
 
+if ($opt_download) {
+	open(SOURCES, "<sources.list") || die "could not open sources.list";
+	while (my $source = <SOURCES>) {
+		chomp($source);
+		if ($source =~ m/^\s*#/ || $source =~ m/^\s+$/) {
+			next;
+		}
+		if (!open(INDEX, "curl -s $source/index |")) {
+			print STDERR "could not get $source/index\n";
+		}
+		while (my $patch = <INDEX>) {
+			chomp($patch);
+			if ($patch =~ m/^\s*#/ || $patch =~ m/^\s+$/) {
+				next;
+			}
+			if ($patch =~ m/[^a-zA-Z0-9\-]/) {
+				print STDERR "$source: bad patch name $patch, ignored\n";
+				next;
+			}
+			# only allow overwriting of external patches
+			if (-f "$POMNG_ROOT_DIR/$patch/info") {
+				if (!open(INFO, "<$POMNG_ROOT_DIR/$patch/info")) {
+					print STDERR "could not open $POMNG_ROOT_DIR/$patch/info\n";
+					next;
+				}
+				my $external = 0;
+				while (<INFO>) {
+					if( /^Repository:\s+external/ ) {
+						$external = 1;
+					}
+				}
+				close(INFO);
+				if (!$external) {
+					print STDERR "$POMNG_ROOT_DIR/$patch exists and is not external\n";
+					next;
+				}
+			}
+
+			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";
+			}
+
+			# check for "Repository: external"
+			if (!open(INFO, "<$POMNG_ROOT_DIR/$patch/info")) {
+				print STDERR "could not open $POMNG_ROOT_DIR/$patch/info\n";
+				system("rm -rf $POMNG_ROOT_DIR/$patch");
+				next;
+			}
+			my $external = 0;
+			while (<INFO>) {
+				if( /^Repository:\s+external/ ) {
+					$external = 1;
+				}
+			}
+			close(INFO);
+			if (!$external) {
+				print STDERR "patch is not marked external\n";
+				system("rm -rf $POMNG_ROOT_DIR/$patch");
+				next;
+			}
+			print "Successfully downloaded external patch $patch\n";
+		}
+		close(INDEX);
+	}
+	close(SOURCES);
+}
+
 my %paths;
 my @paths = (
 	{ 'project'	=> 'linux',
@@ -198,7 +267,7 @@
 if ($opt_repository eq 'magic') {
 	push(@repositories, $opt_repository);
 } else {
-	foreach my $rep (qw(updates submitted pending base extra obsolete)) {
+	foreach my $rep (qw(updates submitted pending base extra external obsolete)) {
 		push(@repositories, $rep);
 		last if $opt_repository eq $rep;
 	}

Added: trunk/patch-o-matic-ng/sources.list
===================================================================
--- trunk/patch-o-matic-ng/sources.list	2006-04-03 18:13:04 UTC (rev 6576)
+++ trunk/patch-o-matic-ng/sources.list	2006-04-06 09:24:21 UTC (rev 6577)
@@ -0,0 +1,2 @@
+# Add the URLs for external patchlets here
+# 




More information about the netfilter-cvslog mailing list