X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=dgit;h=ab3d593ec0e751a4deb08406042cc816d39af21b;hb=refs%2Ftags%2Fdebian%2F0.3;hp=d4a091056331d2041e4a566d0f85e8b5fffb5a8f;hpb=09174e8172ee86effe190827c24045fd8096d26f;p=dgit.git diff --git a/dgit b/dgit index d4a09105..ab3d593e 100755 --- a/dgit +++ b/dgit @@ -24,15 +24,17 @@ use Data::Dumper; use LWP::UserAgent; use Dpkg::Control::Hash; use File::Path; +use Dpkg::Version; use POSIX; -our $suite = 'sid'; +our $isuite = 'unstable'; our $package; our $sign = 1; our $dryrun = 0; our $changesfile; our $new_package = 0; +our $existing_package = 'dpkg'; our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)"); @@ -52,16 +54,17 @@ our %opts_opt_map = ('dget' => \@dget, our $remotename = 'dgit'; our $ourdscfield = 'Vcs-Dgit-Master'; our $branchprefix = 'dgit'; +our $csuite; -sub lbranch () { return "$branchprefix/$suite"; } +sub lbranch () { return "$branchprefix/$csuite"; } my $lbranch_re = '^refs/heads/'.$branchprefix.'/([^/.]+)$'; sub lref () { return "refs/heads/".lbranch(); } -sub lrref () { return "refs/remotes/$remotename/$suite"; } -sub rrref () { return "refs/$branchprefix/$suite"; } +sub lrref () { return "refs/remotes/$remotename/$csuite"; } +sub rrref () { return "refs/$branchprefix/$csuite"; } sub debiantag ($) { return "debian/$_[0]"; } sub fetchspec () { - local $suite = '*'; + local $csuite = '*'; return "+".rrref().":".lrref(); } @@ -102,6 +105,14 @@ sub runcmd { die "@_ $! $?" if system @_; } +sub printdone { + if (!$dryrun) { + print "dgit ok: @_\n"; + } else { + print "would be ok: @_ (but dry run only)\n"; + } +} + sub cmdoutput_errok { die Dumper(\@_)." ?" if grep { !defined } @_; printcmd(\*DEBUG,"|",@_) if $debug>0; @@ -110,8 +121,10 @@ sub cmdoutput_errok { $!=0; $?=0; { local $/ = undef; $d =
; }
die if P->error;
- close P or return undef;
+ if (!close P) { print DEBUG "=>!$?\n" if $debug>0; return undef; }
chomp $d;
+ $d =~ m/^.*/;
+ print DEBUG "=> \`$&'",(length $' ? '...' : ''),"\n" if $debug>0; #';
return $d;
}
@@ -142,7 +155,10 @@ our %defcfg = ('dgit.default.distro' => 'debian',
'dgit-distro.debian.git-path' => '/git/dgit-repos',
'dgit-distro.debian.git-check' => 'ssh-cmd',
'dgit-distro.debian.git-create' => 'ssh-cmd',
- 'dgit-distro.debian.mirror' => 'http://ftp.debian.org/debian/');
+ 'dgit-distro.debian.sshdakls-host' => 'coccia.debian.org',
+ 'dgit-distro.debian.sshdakls-dir' =>
+ '/srv/ftp-master.debian.org/ftp/dists',
+ 'dgit-distro.debian.mirror' => 'http://http.debian.net/debian/');
sub cfg {
foreach my $c (@_) {
@@ -152,7 +168,6 @@ sub cfg {
$v = cmdoutput_errok(@git, qw(config --), $c);
};
if ($?==0) {
- chomp $v;
return $v;
} elsif ($?!=256) {
die "$c $?";
@@ -164,24 +179,29 @@ sub cfg {
}
sub access_distro () {
- return cfg("dgit-suite.$suite.distro",
+ return cfg("dgit-suite.$isuite.distro",
"dgit.default.distro");
}
-sub access_cfg ($) {
- my ($key) = @_;
+sub access_cfg (@) {
+ my (@keys) = @_;
my $distro = access_distro();
- my $value = cfg("dgit-distro.$distro.$key",
- "dgit.default.$key");
+ my $value = cfg(map { ("dgit-distro.$distro.$_",
+ "dgit.default.$_") } @keys);
return $value;
}
-sub access_gituserhost () {
- my $user = access_cfg('git-user');
- my $host = access_cfg('git-host');
+sub access_someuserhost ($) {
+ my ($some) = @_;
+ my $user = access_cfg("$some-user",'username');
+ my $host = access_cfg("$some-host");
return defined($user) && length($user) ? "$user\@$host" : $host;
}
+sub access_gituserhost () {
+ return access_someuserhost('git');
+}
+
sub access_giturl () {
my $url = access_cfg('git-url');
if (!defined $url) {
@@ -208,30 +228,69 @@ sub parsechangelog {
return $c;
}
-our $rmad;
+our %rmad;
-sub archive_query () {
+sub archive_query ($) {
+ my ($method) = @_;
my $query = access_cfg('archive-query');
- $query ||= "madison:".access_distro();
+ if (!$query) {
+ my $distro = access_distro();
+ if ($distro eq 'debian') {
+ $query = "sshdakls:".
+ access_someuserhost('sshdakls').':'.
+ access_cfg('sshdakls-dir');
+ } else {
+ $query = "madison:$distro";
+ }
+ }
$query =~ s/^(\w+):// or die "$query ?";
my $proto = $1;
- my $url = $'; #';
+ my $data = $'; #';
+ { no strict qw(refs); &{"${method}_${proto}"}($proto,$data); }
+}
+
+sub archive_query_madison ($$) {
+ my ($proto,$data) = @_;
die unless $proto eq 'madison';
- $rmad ||= cmdoutput qw(rmadison -asource),"-s$suite","-u$url",$package;
+ $rmad{$package} ||= cmdoutput
+ qw(rmadison -asource),"-s$isuite","-u$data",$package;
+ my $rmad = $rmad{$package};
+ return madison_parse($rmad);
+}
+
+sub archive_query_sshdakls ($$) {
+ my ($proto,$data) = @_;
+ $data =~ s/:.*// or die "$data ?";
+ my $dakls = cmdoutput
+ access_cfg('ssh'), $data, qw(dak ls -asource),"-s$isuite",$package;
+ return madison_parse($dakls);
+}
+
+sub canonicalise_suite_sshdakls ($$) {
+ my ($proto,$data) = @_;
+ $data =~ m/:/ or die "$data ?";
+ my $dakls = cmdoutput
+ access_cfg('ssh'), $`,
+ "set -e; cd $';".
+ " if test -h $isuite; then readlink $isuite; exit 0; fi;".
+ " if test -d $isuite; then echo $isuite; exit 0; fi;".
+ " exit 1";
+ die unless $dakls =~ m/^\w/;
+ return $dakls;
+}
+
+sub madison_parse ($) {
+ my ($rmad) = @_;
if (!length $rmad) {
return ();
}
$rmad =~ m{^ \s*( [^ \t|]+ )\s* \|
\s*( [^ \t|]+ )\s* \|
- \s*( [^ \t|/]+ )(?:/([^ \t|/]+)) \s* \|
+ \s*( [^ \t|/]+ )(?:/([^ \t|/]+))? \s* \|
\s*( [^ \t|]+ )\s* }x or die "$rmad $?";
$1 eq $package or die "$rmad $package ?";
my $vsn = $2;
- if ($suite ne $3) {
- # madison canonicalises for us
- print "canonical suite name for $suite is $3\n";
- $suite = $3;
- }
+ my $newsuite = $3;
my $component;
if (defined $4) {
$component = $4;
@@ -241,15 +300,26 @@ sub archive_query () {
$5 eq 'source' or die "$rmad ?";
my $prefix = substr($package, 0, $package =~ m/^l/ ? 4 : 1);
my $subpath = "/pool/$component/$prefix/$package/${package}_$vsn.dsc";
- return ($vsn,$subpath);
+ return ($vsn,$subpath,$newsuite);
+}
+
+sub canonicalise_suite_madison ($$) {
+ my @r = archive_query_madison($_[0],$_[1]);
+ @r or die;
+ return $r[2];
}
sub canonicalise_suite () {
- archive_query();
+ $csuite = archive_query('canonicalise_suite');
+ if ($isuite ne $csuite) {
+ # madison canonicalises for us
+ print "canonical suite name for $isuite is $csuite\n";
+ }
}
sub get_archive_dsc () {
- my ($vsn,$subpath) = archive_query();
+ my ($vsn,$subpath) = archive_query('archive_query');
+ canonicalise_suite();
if (!defined $vsn) { $dsc=undef; return undef; }
$dscurl = access_cfg('mirror').$subpath;
$dscdata = url_get($dscurl);
@@ -270,7 +340,6 @@ sub check_for_git () {
(access_cfg('ssh'),access_gituserhost(),
" set -e; cd ".access_cfg('git-path').";".
" if test -d $package.git; then echo 1; else echo 0; fi");
- print DEBUG "got \`$r'\n";
die "$r $! $?" unless $r =~ m/^[01]$/;
return $r+0;
} else {
@@ -316,7 +385,7 @@ sub mktree_in_ud_from_only_subdir () {
symlink '../../../../objects','.git/objects' or die $!;
runcmd @git, qw(add -Af);
my $tree = cmdoutput @git, qw(write-tree);
- chomp $tree; $tree =~ m/^\w+$/ or die "$tree ?";
+ $tree =~ m/^\w+$/ or die "$tree ?";
return ($tree,$dir);
}
@@ -332,6 +401,11 @@ sub is_orig_file ($) {
m/\.orig(?:-\w+)?\.tar\.\w+$/;
}
+sub make_commit ($) {
+ my ($file) = @_;
+ return cmdoutput @git, qw(hash-object -w -t commit), $file;
+}
+
sub generate_commit_from_dsc () {
prep_ud();
chdir $ud or die $!;
@@ -358,48 +432,57 @@ sub generate_commit_from_dsc () {
my $authline = "$author $date";
$authline =~ m/^[^<>]+ \<\S+\> \d+ [-+]\d+$/ or die $authline;
open C, ">../commit.tmp" or die $!;
- print C "tree $tree\n" or die $!;
- print C "parent $upload_hash\n" or die $! if $upload_hash;
print C <