]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
Add support for external tarballs
authorJan Engelhardt <jengelh@computergmbh.de>
Sat, 16 Feb 2008 15:10:40 +0000 (16:10 +0100)
committerJan Engelhardt <jengelh@computergmbh.de>
Sat, 16 Feb 2008 15:10:40 +0000 (16:10 +0100)
Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de>
.gitignore
README
sources [new file with mode: 0644]
xa-download-more [new file with mode: 0755]

index 9d09822189b0063548181686593fde646fd99744..7d7f35ae8d84f7856a1e6c65aea3822ad1f853a8 100644 (file)
@@ -12,6 +12,8 @@ Makefile
 Makefile.in
 Module.symvers
 
+/downloads
+
 /aclocal.m4
 /autom4te*.cache
 /compile
diff --git a/README b/README
index ca1a097f591179c6d451b8bf340dcaee9436dcc0..e111d4221951cfd259f9ec33f27b2798399f2145 100644 (file)
--- a/README
+++ b/README
@@ -8,3 +8,32 @@ package.
 Xtables-addons is different from patch-o-matic in that you do not have
 to patch or recompile either kernel or Xtables(iptables). But please
 see the INSTALL file for the minimum requirements of this package.
+
+
+External extensions
+===================
+
+The program "xa-download-more" can be used to download more extensions
+from 3rd parties into the source tree. The URLs are listed in the
+"sources" file. If the "sources" file contains an entry like
+
+       http://foobar.org/xa/
+
+xa-download-more will inspect http://foobar.org/xa/xa-index.txt for files
+to download. That file may contain
+
+       foobar.tar.bz2
+
+and xa-download-more will then retrieve and unpack
+http://foobar.org/xa/foobar.tar.bz2.
+
+Files that should be contained in the tarball are an mconfig and Kbuild
+files to control building the extension, libxt_foobar.c for the userspace
+extension and xt_foobar.c for the kernel extension.
+
+       mconfig.foobar
+       extensions/Kbuild.foobar
+       extensions/libxt_foobar.c
+       extensions/libxt_foobar.man
+       extensions/xt_foobar.c
+       extensions/xt_foobar.h
diff --git a/sources b/sources
new file mode 100644 (file)
index 0000000..c66d5a1
--- /dev/null
+++ b/sources
@@ -0,0 +1,3 @@
+#
+# Source URLs for external patchlets
+#
diff --git a/xa-download-more b/xa-download-more
new file mode 100755 (executable)
index 0000000..34aa589
--- /dev/null
@@ -0,0 +1,83 @@
+#!/usr/bin/perl -w
+
+use HTTP::Request;
+use LWP::UserAgent;
+use strict;
+
+&main(\@ARGV);
+
+sub main ($)
+{
+       local *FH;
+
+       if (!-d "downloads") {
+               if (!mkdir("downloads")) {
+                       die "Could not create downloads/ directory";
+               }
+       }
+
+       open(FH, "<sources");
+       while (defined($_ = <FH>)) {
+               chomp $_;
+               $_ =~ s/#.*//gs;
+               $_ =~ s/^\s+|\s+$//gs;
+               if (length($_) == 0) {
+                       next;
+               }
+               &process_index($_);
+       }
+
+       close FH;
+}
+
+sub process_index ($)
+{
+       my $top = shift @_;
+       my($agent, $res, $url);
+       local *FH;
+
+       $agent = LWP::UserAgent->new();
+       $agent->env_proxy();
+
+       $url = &slash_remove("$top/xa-index.txt");
+       print "  GET     $url\n";
+       $res = $agent->get($url);
+       if (!$res->is_success()) {
+               print STDERR "  `->     ", $res->status_line(), "\n";
+               return;
+       }
+
+       foreach my $ext (split(/\s+/, $res->content())) {
+               my($ex_url, $ex_res);
+
+               $ex_url = &slash_remove("$top/$ext");
+               print "  GET     $ex_url\n";
+
+               $ex_res = $agent->mirror($ex_url, "downloads/$ext");
+               if ($ex_res->code() == 304) {
+                       # "Not modified" = up to date
+                       next;
+               }
+               if (!$ex_res->is_success()) {
+                       print STDERR "  `->     ", $ex_res->status_line(), "\n";
+                       next;
+               }
+
+               print "  UNPACK  downloads/$ext\n";
+               system "tar", "-xjf", "downloads/$ext";
+       }
+}
+
+sub slash_remove ($)
+{
+       my $s = shift @_;
+       $s =~ s{(\w+://)(.*)}{$1.&slash_remove2($2)}eg;
+       return $s;
+}
+
+sub slash_remove2 ($)
+{
+       my $s = shift @_;
+       $s =~ s{/+}{/}g;
+       return $s;
+}