chiark / gitweb /
finish support and docs for DGIT_SSH etc. config
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 9 Oct 2013 07:37:12 +0000 (08:37 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 9 Oct 2013 07:37:12 +0000 (08:37 +0100)
TODO
debian/changelog
dgit
dgit.1

diff --git a/TODO b/TODO
index a5999feff78d4f8bfee677b04b35393543975288..bf48ebc84c1da4758e39a06267d143feb3fef24f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,3 +1 @@
---ssh= etc. @ssh should be in manual
-support SSH and DGIT_SSH
 --dgit= etc. @dgit should be in manual
 --dgit= etc. @dgit should be in manual
index 34f6cdb7fbf06df53710bac0abb27cf4976e47c2..b6288098580000ea2981f6db166670097fb02cb6 100644 (file)
@@ -5,6 +5,7 @@ dgit (0.16~experimental2) experimental; urgency=low
   * push actually takes an optional suite, like it says in the synopsis.
   * Command execution reports from --dry-run go to stderr.
   * Support --gpg=... to provide a replacement command for gpg.
   * push actually takes an optional suite, like it says in the synopsis.
   * Command execution reports from --dry-run go to stderr.
   * Support --gpg=... to provide a replacement command for gpg.
+  * Support --ssh=... and --ssh:... to affect how we run ssh.
 
  --
 
 
  --
 
diff --git a/dgit b/dgit
index 3c24c2c1b5ae9a70d3f9a42f0bbcb0ade4f0aefe..6a3f7b7626c97c91150d8ebf329f6bd8b11b850f 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -55,7 +55,7 @@ our (@dput) = qw(dput);
 our (@debsign) = qw(debsign);
 our (@gpg) = qw(gpg);
 our (@sbuild) = qw(sbuild -A);
 our (@debsign) = qw(debsign);
 our (@gpg) = qw(gpg);
 our (@sbuild) = qw(sbuild -A);
-our (@ssh) = qw(ssh);
+our (@ssh) = 'ssh';
 our (@dgit) = qw(dgit);
 our (@dpkgbuildpackage) = qw(dpkg-buildpackage -i\.git/ -I.git);
 our (@dpkgsource) = qw(dpkg-source -i\.git/ -I.git);
 our (@dgit) = qw(dgit);
 our (@dpkgbuildpackage) = qw(dpkg-buildpackage -i\.git/ -I.git);
 our (@dpkgsource) = qw(dpkg-source -i\.git/ -I.git);
@@ -447,6 +447,24 @@ sub access_cfg (@) {
     return $value;
 }
 
     return $value;
 }
 
+sub string_to_ssh ($) {
+    my ($spec) = @_;
+    if ($spec =~ m/\s/) {
+       return qw(sh -ec), 'exec '.$spec.' "$@"', 'x';
+    } else {
+       return ($spec);
+    }
+}
+
+sub access_cfg_ssh () {
+    my $gitssh = access_cfg('ssh', 'RETURN-UNDEF');
+    if (!defined $gitssh) {
+       return @ssh;
+    } else {
+       return string_to_ssh $gitssh;
+    }
+}
+
 sub access_someuserhost ($) {
     my ($some) = @_;
     my $user = access_cfg("$some-user",'username');
 sub access_someuserhost ($) {
     my ($some) = @_;
     my $user = access_cfg("$some-user",'username');
@@ -538,7 +556,7 @@ sub archive_query_sshdakls ($$) {
     my ($proto,$data) = @_;
     $data =~ s/:.*// or badcfg "invalid sshdakls method string \`$data'";
     my $dakls = cmdoutput
     my ($proto,$data) = @_;
     $data =~ s/:.*// or badcfg "invalid sshdakls method string \`$data'";
     my $dakls = cmdoutput
-       access_cfg('ssh'), $data, qw(dak ls -asource),"-s$isuite",$package;
+       access_cfg_ssh, $data, qw(dak ls -asource),"-s$isuite",$package;
     return madison_parse($dakls);
 }
 
     return madison_parse($dakls);
 }
 
@@ -546,7 +564,7 @@ sub canonicalise_suite_sshdakls ($$) {
     my ($proto,$data) = @_;
     $data =~ m/:/ or badcfg "invalid sshdakls method string \`$data'";
     my @cmd =
     my ($proto,$data) = @_;
     $data =~ m/:/ or badcfg "invalid sshdakls method string \`$data'";
     my @cmd =
-       (access_cfg('ssh'), $`,
+       (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;".
         "set -e; cd $';".
         " if test -h $isuite; then readlink $isuite; exit 0; fi;".
         " if test -d $isuite; then echo $isuite; exit 0; fi;".
@@ -627,7 +645,7 @@ sub check_for_git () {
     my $how = access_cfg('git-check');
     if ($how eq 'ssh-cmd') {
        my @cmd =
     my $how = access_cfg('git-check');
     if ($how eq 'ssh-cmd') {
        my @cmd =
-           (access_cfg('ssh'),access_gituserhost(),
+           (access_cfg_ssh, access_gituserhost(),
             " set -e; cd ".access_cfg('git-path').";".
             " if test -d $package.git; then echo 1; else echo 0; fi");
        my $r= cmdoutput @cmd;
             " set -e; cd ".access_cfg('git-path').";".
             " if test -d $package.git; then echo 1; else echo 0; fi");
        my $r= cmdoutput @cmd;
@@ -642,7 +660,7 @@ sub create_remote_git_repo () {
     my $how = access_cfg('git-create');
     if ($how eq 'ssh-cmd') {
        runcmd_ordryrun
     my $how = access_cfg('git-create');
     if ($how eq 'ssh-cmd') {
        runcmd_ordryrun
-           (access_cfg('ssh'),access_gituserhost(),
+           (access_cfg_ssh, access_gituserhost(),
             "set -e; cd ".access_cfg('git-path').";".
             " cp -a _template $package.git");
     } else {
             "set -e; cd ".access_cfg('git-path').";".
             " cp -a _template $package.git");
     } else {
@@ -1669,6 +1687,13 @@ sub cmd_version {
 
 sub parseopts () {
     my $om;
 
 sub parseopts () {
     my $om;
+
+    if (defined $ENV{'DGIT_SSH'}) {
+       @ssh = string_to_ssh $ENV{'DGIT_SSH'};
+    } elsif (defined $ENV{'GIT_SSH'}) {
+       @ssh = ($ENV{'GIT_SSH'});
+    }
+
     while (@ARGV) {
        last unless $ARGV[0] =~ m/^-/;
        $_ = shift @ARGV;
     while (@ARGV) {
        last unless $ARGV[0] =~ m/^-/;
        $_ = shift @ARGV;
diff --git a/dgit.1 b/dgit.1
index 2f7ceccd1d5a231dea601e7a2b5cc925d57d8495..11e2a5d8c4bcfeea6808bf7c86b389f436c8f350 100644 (file)
--- a/dgit.1
+++ b/dgit.1
@@ -237,11 +237,27 @@ Specifies alternative programs to use instead of
 .BR dpkg-genchanges ,
 .BR sbuild ,
 .BR gpg ,
 .BR dpkg-genchanges ,
 .BR sbuild ,
 .BR gpg ,
+.BR ssh ,
 or
 .BR mergechanges .
 
 For dpkg-buildpackage, dpkg-genchanges, mergechanges and sbuild,
 this applies only when the program is invoked directly by dgit.
 or
 .BR mergechanges .
 
 For dpkg-buildpackage, dpkg-genchanges, mergechanges and sbuild,
 this applies only when the program is invoked directly by dgit.
+
+For ssh, the default value is taken from the
+.B DGIT_SSH
+or
+.B GIT_SSH
+environment variables, if set (see below).  And, for ssh, when accessing the
+archive and dgit-repos, this command line setting is overridden by the
+git config variables
+.BI dgit-distro. distro .ssh
+and
+.B .dgit.default.ssh
+(which can in turn be overridden with -c).  Also, when dgit is using
+git to access dgit-repos, only git's idea of what ssh to use (eg,
+.BR GIT_SSH )
+is relevant.
 .TP
 .RI \fB--dget:\fR option |\fB--dput:\fR option |...
 Specifies a single additional option to pass to
 .TP
 .RI \fB--dget:\fR option |\fB--dput:\fR option |...
 Specifies a single additional option to pass to
@@ -252,6 +268,7 @@ Specifies a single additional option to pass to
 .BR dpkg-buildpackage ,
 .BR dpkg-genchanges ,
 .BR sbuild ,
 .BR dpkg-buildpackage ,
 .BR dpkg-genchanges ,
 .BR sbuild ,
+.BR ssh ,
 or
 .BR mergechanges .
 Can be repeated as necessary.
 or
 .BR mergechanges .
 Can be repeated as necessary.
@@ -261,6 +278,8 @@ this applies only when the program is invoked directly by dgit.
 Usually, for passing options to dpkg-genchanges, you should use
 .BR --ch: \fIoption\fR.
 
 Usually, for passing options to dpkg-genchanges, you should use
 .BR --ch: \fIoption\fR.
 
+See note above regarding ssh.
+
 NB that --gpg:option is not supported (because debsign does not
 have that facility).  But see -k.
 .TP
 NB that --gpg:option is not supported (because debsign does not
 have that facility).  But see -k.
 .TP
@@ -547,6 +566,21 @@ on the dgit command line.
 .BR dgit.default. *
 for each
 .BR dgit-distro. \fIdistro\fR . *
 .BR dgit.default. *
 for each
 .BR dgit-distro. \fIdistro\fR . *
+.SH ENVIRONMENT VARIABLES
+.TP
+.BR DGIT_SSH ", " GIT_SSH
+specify an alternative default program (and perhaps arguments) to use
+instead of ssh.  DGIT_SSH is consulted first and may contain arguments;
+if it contains any whitespace will be passed to the shell.  GIT_SSH
+specifies just the program; no arguments can be specified, so dgit
+interprets it the same way as git does.
+See
+also the --ssh= and --ssh: options.
+.TP
+.BR gpg ", " dpkg- "..., " debsign ", " git ", " dget ", " dput ", " LWP::UserAgent
+and other subprograms and modules used by dgit are affected by various
+environment variables.  Consult the documentaton for those programs
+for details.
 .SH BUGS
 We should be using some kind of vhost/vpath setup for the git repos on
 alioth, so that they can be moved later if and when this turns out to
 .SH BUGS
 We should be using some kind of vhost/vpath setup for the git repos on
 alioth, so that they can be moved later if and when this turns out to