chiark
/
gitweb
/
~ianmdlvl
/
dgit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New --initiator-tempdir option.
[dgit.git]
/
dgit
diff --git
a/dgit
b/dgit
index 549b2515f0a5633077320bbf755b26b3b9c3c50d..60020fc2fe8d09ede9d17bc7d08c8900706b8037 100755
(executable)
--- a/
dgit
+++ b/
dgit
@@
-46,6
+46,7
@@
our $noquilt = 0;
our $existing_package = 'dpkg';
our $cleanmode = 'dpkg-source';
our $we_are_responder;
our $existing_package = 'dpkg';
our $cleanmode = 'dpkg-source';
our $we_are_responder;
+our $initiator_tempdir;
our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
@@
-133,6
+134,12
@@
sub fetchspec () {
return "+".rrref().":".lrref();
}
return "+".rrref().":".lrref();
}
+sub changedir ($) {
+ my ($newdir) = @_;
+ printdebug "CD $newdir\n";
+ chdir $newdir or die "chdir: $newdir: $!";
+}
+
#---------- remote protocol support, common ----------
# remote push initiator/responder protocol:
#---------- remote protocol support, common ----------
# remote push initiator/responder protocol:
@@
-714,7
+721,7
@@
sub mktree_in_ud_from_only_subdir () {
die unless @dirs==1;
$dirs[0] =~ m#^([^/]+)/\.$# or die;
my $dir = $1;
die unless @dirs==1;
$dirs[0] =~ m#^([^/]+)/\.$# or die;
my $dir = $1;
- ch
dir $dir or die "$dir $!"
;
+ ch
angedir $dir
;
fail "source package contains .git directory" if stat '.git';
die $! unless $!==&ENOENT;
runcmd qw(git init -q);
fail "source package contains .git directory" if stat '.git';
die $! unless $!==&ENOENT;
runcmd qw(git init -q);
@@
-781,7
+788,7
@@
sub clogp_authline ($) {
sub generate_commit_from_dsc () {
prep_ud();
sub generate_commit_from_dsc () {
prep_ud();
- ch
dir $ud or die $!
;
+ ch
angedir $ud
;
my @files;
foreach my $f (dsc_files()) {
die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
my @files;
foreach my $f (dsc_files()) {
die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
@@
-847,7
+854,7
@@
END
$outputhash = $lastpush_hash;
}
}
$outputhash = $lastpush_hash;
}
}
- ch
dir '../../../..' or die $!
;
+ ch
angedir '../../../..'
;
runcmd @git, qw(update-ref -m),"dgit fetch import $cversion",
'DGIT_ARCHIVE', $outputhash;
cmdoutput @git, qw(log -n2), $outputhash;
runcmd @git, qw(update-ref -m),"dgit fetch import $cversion",
'DGIT_ARCHIVE', $outputhash;
cmdoutput @git, qw(log -n2), $outputhash;
@@
-1021,7
+1028,7
@@
sub clone ($) {
canonicalise_suite();
badusage "dry run makes no sense with clone" unless act_local();
mkdir $dstdir or die "$dstdir $!";
canonicalise_suite();
badusage "dry run makes no sense with clone" unless act_local();
mkdir $dstdir or die "$dstdir $!";
- ch
dir "$dstdir" or die "$dstdir $!"
;
+ ch
angedir $dstdir
;
runcmd @git, qw(init -q);
runcmd @git, qw(config), "remote.$remotename.fetch", fetchspec();
open H, "> .git/HEAD" or die $!;
runcmd @git, qw(init -q);
runcmd @git, qw(config), "remote.$remotename.fetch", fetchspec();
open H, "> .git/HEAD" or die $!;
@@
-1213,11
+1220,11
@@
sub dopush () {
commit_quilty_patch();
}
check_not_dirty();
commit_quilty_patch();
}
check_not_dirty();
- ch
dir $ud or die $!
;
+ ch
angedir $ud
;
progress "checking that $dscfn corresponds to HEAD";
runcmd qw(dpkg-source -x --), "../../../../$dscfn";
my ($tree,$dir) = mktree_in_ud_from_only_subdir();
progress "checking that $dscfn corresponds to HEAD";
runcmd qw(dpkg-source -x --), "../../../../$dscfn";
my ($tree,$dir) = mktree_in_ud_from_only_subdir();
- ch
dir '../../../..' or die $!
;
+ ch
angedir '../../../..'
;
my @diffcmd = (@git, qw(diff --exit-code), $tree);
printcmd \*DEBUG,$debugprefix."+",@diffcmd;
$!=0; $?=0;
my @diffcmd = (@git, qw(diff --exit-code), $tree);
printcmd \*DEBUG,$debugprefix."+",@diffcmd;
$!=0; $?=0;
@@
-1410,7
+1417,7
@@
sub cmd_remote_push_responder {
@ARGV = @ARGV[$nrargs..$#ARGV];
die unless @rargs;
my ($dir) = @rargs;
@ARGV = @ARGV[$nrargs..$#ARGV];
die unless @rargs;
my ($dir) = @rargs;
- ch
dir $dir or die "$dir: $!"
;
+ ch
angedir $dir
;
$we_are_responder = 1;
$debugprefix = ' ';
autoflush STDOUT 1;
$we_are_responder = 1;
$debugprefix = ' ';
autoflush STDOUT 1;
@@
-1423,7
+1430,8
@@
our $i_tmp;
sub i_cleanup {
local ($@);
return unless defined $i_tmp;
sub i_cleanup {
local ($@);
return unless defined $i_tmp;
- chdir "/" or die $!;
+ return if defined $initiator_tempdir;
+ changedir "/";
eval { rmtree $i_tmp; };
}
eval { rmtree $i_tmp; };
}
@@
-1452,9
+1460,15
@@
sub cmd_rpush {
my @cmd = (@ssh, $host, shellquote @rdgit);
printcmd \*DEBUG,$debugprefix."+",@cmd;
eval {
my @cmd = (@ssh, $host, shellquote @rdgit);
printcmd \*DEBUG,$debugprefix."+",@cmd;
eval {
- $i_tmp = tempdir();
+ if (defined $initiator_tempdir) {
+ rmtree $initiator_tempdir;
+ mkdir $initiator_tempdir, 0700 or die "$initiator_tempdir: $!";
+ $i_tmp = $initiator_tempdir;
+ } else {
+ $i_tmp = tempdir();
+ }
my $pid = open2(\*RO, \*RI, @cmd);
my $pid = open2(\*RO, \*RI, @cmd);
- ch
dir $i_tmp or die "$i_tmp $!"
;
+ ch
angedir $i_tmp
;
initiator_expect { m/^dgit-remote-push-ready/ };
for (;;) {
my ($icmd,$iargs) = initiator_expect {
initiator_expect { m/^dgit-remote-push-ready/ };
for (;;) {
my ($icmd,$iargs) = initiator_expect {
@@
-1667,9
+1681,9
@@
sub build_source {
}
my $pwd = cmdoutput qw(env - pwd);
my $leafdir = basename $pwd;
}
my $pwd = cmdoutput qw(env - pwd);
my $leafdir = basename $pwd;
- ch
dir ".." or die $!
;
+ ch
angedir ".."
;
runcmd_ordryrun_local @dpkgsource, qw(-b --), $leafdir;
runcmd_ordryrun_local @dpkgsource, qw(-b --), $leafdir;
- ch
dir $pwd or die $!
;
+ ch
angedir $pwd
;
runcmd_ordryrun_local qw(sh -ec),
'exec >$1; shift; exec "$@"','x',
"../$sourcechanges",
runcmd_ordryrun_local qw(sh -ec),
'exec >$1; shift; exec "$@"','x',
"../$sourcechanges",
@@
-1685,7
+1699,7
@@
sub cmd_build_source {
sub cmd_sbuild {
build_source();
sub cmd_sbuild {
build_source();
- ch
dir ".." or die $!
;
+ ch
angedir ".."
;
my $pat = "${package}_".(stripepoch $version)."_*.changes";
if (act_local()) {
stat $dscfn or fail "$dscfn (in parent directory): $!";
my $pat = "${package}_".(stripepoch $version)."_*.changes";
if (act_local()) {
stat $dscfn or fail "$dscfn (in parent directory): $!";
@@
-1761,6
+1775,11
@@
sub parseopts () {
} elsif (m/^--existing-package=(.*)/s) {
push @ropts, $_;
$existing_package = $1;
} elsif (m/^--existing-package=(.*)/s) {
push @ropts, $_;
$existing_package = $1;
+ } elsif (m/^--initiator-tempdir=(.*)/s) {
+ $initiator_tempdir = $1;
+ $initiator_tempdir =~ m#^/# or
+ badusage "--initiator-tempdir must be used specify an".
+ " absolute, not relative, directory."
} elsif (m/^--distro=(.*)/s) {
push @ropts, $_;
$idistro = $1;
} elsif (m/^--distro=(.*)/s) {
push @ropts, $_;
$idistro = $1;