chiark / gitweb /
promote cmdoutput nfc
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 4d9a71a8c3682049aa23223f13e5f99be075d167..fef71e5493355de0410b046a190245e8e3d65408 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -13,7 +13,7 @@ open DEBUG, ">&STDERR" or die $!;
 our $pdo = 'http://packages.debian.org/';
 #our $mirror = 'http://mirror.relativity.greenend.org.uk/mirror/debian-ftp/';
 our $suite = 'sid';
-our $package = '2vcard';
+our $package;
 
 our $aliothname = 'iwj@git.debian.org';
 our $aliothpath = '/git/dgit-test';
@@ -42,6 +42,22 @@ sub url_get {
 
 our ($dscdata,$dscurl,$dsc);
 
+sub runcmd {
+    $!=0; $?=0;
+    die "@_ $! $?" if system @_;
+}
+
+sub cmdoutput {
+    open P, "-|", @_ or die $!;
+    my $d;
+    $!=0; $?=0;
+    { local $/ = undef; $d = <P>; }
+    die if P->error;
+    close P or die "@_ $? $!";
+    chomp $d;
+    return $d;
+}
+
 sub parsecontrol {
     my $c = Dpkg::Control::Hash->new();
     $c->load(@_) or return undef;
@@ -87,22 +103,6 @@ sub check_for_git () {
     return $r+0;
 }
 
-sub runcmd {
-    $!=0; $?=0;
-    die "@_ $! $?" if system @_;
-}
-
-sub cmdoutput {
-    open P, "-|", @_ or die $!;
-    my $d;
-    $!=0; $?=0;
-    { local $/ = undef; $d = <P>; }
-    die if P->error;
-    close P or die "@_ $? $!";
-    chomp $d;
-    return $d;
-}
-
 our ($dsc_hash,$lastupl_hash);
 
 sub generate_commit_from_dsc () {
@@ -221,26 +221,6 @@ sub fetch_from_archive () {
     }
 }
 
-#sub combine () {
-#    if (
-       
-#      runcmd qw(git write-tree
-       
-       
-       runcmd qw(mkdir -p '');
-#      chdir '.git/dgit/unpack' or die $!;
-       
-       
-#      with_tmpdir($td,{
-           
-#    });
-
-#    }
-
-#      open P, "-|", qw(git rev-parse --), $dsc_hash;
-       
-#}
-
 sub clone () {
     get_archive_dsc();
     $dsc_hash = $dsc->{'Vcs-git-master'};
@@ -280,6 +260,25 @@ sub clone () {
 sub fetch () {
     
 }
-    
-#print Dumper(get_archive_dsc());
-clone();
+
+sub cmd_clone {
+    if (@ARGV==1) {
+       ($package) = @ARGV;
+    } elsif (@ARGV==2) {
+       ($package,$suite) = @ARGV;
+    } else {
+       die;
+    }
+    clone();
+}
+
+sub parseopts () {
+    die if @ARGV && $ARGV[0] =~ m/^\-/;
+}
+
+parseopts();
+die unless @ARGV;
+my $cmd = shift @ARGV;
+parseopts();
+
+{ no strict qw(refs); &{"cmd_$cmd"}(); }