From 710b2575704d9b2d3b4144eecd031da36340ee3c Mon Sep 17 00:00:00 2001 From: Adrian Kreher Date: Sat, 22 Nov 2008 02:19:22 -0600 Subject: [PATCH] manual_fetch.pl: Perl script to fetch repo HEAD with minimal requirements --- manual_fetch.pl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 manual_fetch.pl diff --git a/manual_fetch.pl b/manual_fetch.pl new file mode 100644 index 0000000..95c7ed4 --- /dev/null +++ b/manual_fetch.pl @@ -0,0 +1,35 @@ +#! /usr/bin/env perl + +use warnings; +use strict; + +### manual_fetch.pl +# a small Perl script to fetch the latest snapshot of a git repo from gitweb +# using minimal requirements (perl, tar, gzip, and (curl or wget)) + +# URL of this repo in gitweb +my $URL = 'http://majnematic.com/cgi-bin/gitweb.cgi?p=davesdots.git'; + +my $html = http_fetch($URL); +my($hash) = $html =~ m{ + gitweb\.cgi\?p=davesdots\.git;a=snapshot;h=([0-9a-fA-F]+);sf=tgz "> snapshot +}xi; + +print "fetching: $URL;a=snapshot;h=$hash;sf=tgz\n"; +my $tgz = http_fetch("$URL;a=snapshot;h=$hash;sf=tgz"); +extract_tgz($tgz); + +sub http_fetch { + use LWP::Simple 'get'; + + my $url = shift; + return get($url); +} + +sub extract_tgz { + my $data = shift; + + open(my $pipe, '|-', 'tar', '-xz') || die "manual_fetch.pl: tar failed: $!"; + print $pipe $data; + close($pipe); +}