3 # Integration between git and Debian-style archives
5 # Copyright (C)2013 Ian Jackson
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 use Dpkg::Control::Hash;
27 use File::Temp qw(tempdir);
33 our $our_version = 'UNRELEASED'; ###substituted###
35 our $isuite = 'unstable';
41 our $dryrun_level = 0;
46 our $existing_package = 'dpkg';
47 our $cleanmode = 'dpkg-source';
48 our $we_are_responder;
50 our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
53 our (@dget) = qw(dget);
54 our (@dput) = qw(dput);
55 our (@debsign) = qw(debsign);
57 our (@sbuild) = qw(sbuild -A);
59 our (@dgit) = qw(dgit);
60 our (@dpkgbuildpackage) = qw(dpkg-buildpackage -i\.git/ -I.git);
61 our (@dpkgsource) = qw(dpkg-source -i\.git/ -I.git);
62 our (@dpkggenchanges) = qw(dpkg-genchanges);
63 our (@mergechanges) = qw(mergechanges -f);
64 our (@changesopts) = ('');
66 our %opts_opt_map = ('dget' => \@dget,
68 'debsign' => \@debsign,
73 'dpkg-source' => \@dpkgsource,
74 'dpkg-buildpackage' => \@dpkgbuildpackage,
75 'dpkg-genchanges' => \@dpkggenchanges,
76 'ch' => \@changesopts,
77 'mergechanges' => \@mergechanges);
79 our %opts_opt_cmdonly = ('gpg' => 1);
84 open DEBUG, ">/dev/null" or die $!;
88 our $remotename = 'dgit';
89 our @ourdscfield = qw(Dgit Vcs-Dgit-Master);
90 our $branchprefix = 'dgit';
93 sub lbranch () { return "$branchprefix/$csuite"; }
94 my $lbranch_re = '^refs/heads/'.$branchprefix.'/([^/.]+)$';
95 sub lref () { return "refs/heads/".lbranch(); }
96 sub lrref () { return "refs/remotes/$remotename/$branchprefix/$csuite"; }
97 sub rrref () { return "refs/$branchprefix/$csuite"; }
112 return "${package}_".(stripepoch $vsn).".dsc";
115 sub changesopts () { return @changesopts[1..$#changesopts]; }
118 our $debugprefix = ' ';
120 sub printdebug { print DEBUG $debugprefix, @_ or die $!; }
122 sub fail { die "$us: @_\n"; }
124 sub badcfg { print STDERR "$us: invalid configuration: @_\n"; exit 12; }
126 sub no_such_package () {
127 print STDERR "$us: package $package does not exist in suite $isuite\n";
133 return "+".rrref().":".lrref();
136 #---------- remote protocol support, common ----------
138 # remote push initiator/responder protocol:
139 # < dgit-remote-push-ready [optional extra info ignored by old initiators]
141 # > file parsed-changelog
142 # [indicates that output of dpkg-parsechangelog follows]
143 # > data-block NBYTES
144 # > [NBYTES bytes of data (no newline)]
145 # [maybe some more blocks]
157 # [indicates that signed tag is wanted]
158 # < data-block NBYTES
159 # < [NBYTES bytes of data (no newline)]
160 # [maybe some more blocks]
164 # > want signed-dsc-changes
165 # < data-block NBYTES [transfer of signed dsc]
167 # < data-block NBYTES [transfer of signed changes]
175 fail "connection lost: $!" if $fh->error;
176 fail "connection terminated" if $fh->eof;
177 fail "protocol violation; $m not expected";
180 sub protocol_expect (&$) {
181 my ($match, $fh) = @_;
184 defined && chomp or badproto $fh, "eof";
192 badproto $fh, "\`$_'";
195 sub protocol_send_file ($$) {
196 my ($fh, $ourfn) = @_;
197 open PF, "<", $ourfn or die "$ourfn: $!";
200 my $got = read PF, $d, 65536;
201 die "$ourfn: $!" unless defined $got;
203 print $fh "data-block ".length($d)."\n" or die $!;
206 print $fh "data-end\n" or die $!;
210 sub protocol_read_bytes ($$) {
211 my ($fh, $nbytes) = @_;
212 $nbytes =~ m/^\d{1,6}$/ or badproto \*RO, "bad byte count";
214 my $got = read $fh, $d, $nbytes;
215 $got==$nbytes or badproto $fh, "eof during data block";
219 sub protocol_receive_file ($$) {
220 my ($fh, $ourfn) = @_;
221 open PF, ">", $ourfn or die "$ourfn: $!";
223 my ($y,$l) = protocol_expect {
224 m/^data-block (.*})$|data-end$/;
225 length $1 ? (1,$1) : (0);
228 my $d = protocol_read_bytes $fh, $1;
229 print PF $d or die $!;
231 printdebug "received into $ourfn\n";
234 #---------- remote protocol support, responder ----------
236 sub responder_send_command ($) {
238 return unless $we_are_responder;
239 # called even without $we_are_responder
240 printdebug "<< $command\n";
241 print $command, "\n" or die $!;
244 sub responder_send_file ($$) {
245 my ($keyword, $ourfn) = @_;
246 return unless $we_are_responder;
247 printdebug "[[ $keyword $ourfn\n";
248 responder_send_command "file $keyword";
249 protocol_send_file \*STDOUT, $ourfn;
252 sub responder_receive_files ($@) {
253 my ($keyword, @ourfns) = @_;
254 die unless $we_are_responder;
255 printdebug "]] $keyword @ourfns\n";
256 responder_send_command "want $keyword";
257 foreach my $fn (@ourfns) {
258 protocol_receive_file \*STDIN, $fn;
260 protocol_expect { m/^files-end$/ } \*STDIN;
263 #---------- remote protocol support, initiator ----------
265 sub initiator_expect (&) {
267 protocol_expect { &$match } \*RO;
270 #---------- end remote code ----------
273 if ($we_are_responder) {
275 responder_send_command "progress ".length($m) or die $!;
286 $ua = LWP::UserAgent->new();
290 progress "downloading $what...";
291 my $r = $ua->get(@_) or die $!;
292 return undef if $r->code == 404;
293 $r->is_success or fail "failed to fetch $what: ".$r->status_line;
294 return $r->decoded_content();
297 our ($dscdata,$dscurl,$dsc,$skew_warning_vsn);
304 if (s{['\\]}{\\$&}g || m{\s} || m{[^-_./0-9a-z]}i) {
310 return join ' ', @out;
315 my $intro = shift @_;
316 print $fh $intro," " or die $!;
317 print $fh shellquote @_ or die $!;
318 print $fh "\n" or die $!;
322 { local ($!); printcmd \*STDERR, "$_[0]: failed command:", @_ or die $!; };
324 fail "failed to fork/exec: $!";
325 } elsif (!($? & 0xff)) {
326 fail "subprocess failed with error exit status ".($?>>8);
328 fail "subprocess crashed (wait status $?)";
330 fail "subprocess produced invalid output";
335 printcmd(\*DEBUG,$debugprefix."+",@_) if $debug>0;
337 failedcmd @_ if system @_;
340 sub act_local () { return $dryrun_level <= 1; }
341 sub act_scary () { return !$dryrun_level; }
344 if (!$dryrun_level) {
345 progress "dgit ok: @_";
347 progress "would be ok: @_ (but dry run only)";
351 sub cmdoutput_errok {
352 die Dumper(\@_)." ?" if grep { !defined } @_;
353 printcmd(\*DEBUG,$debugprefix."|",@_) if $debug>0;
354 open P, "-|", @_ or die $!;
357 { local $/ = undef; $d = <P>; }
359 if (!close P) { printdebug "=>!$?\n" if $debug>0; return undef; }
362 printdebug "=> \`$&'",(length $' ? '...' : ''),"\n" if $debug>0; #';
367 my $d = cmdoutput_errok @_;
368 defined $d or failedcmd @_;
373 printcmd(\*STDERR,$debugprefix."#",@_);
376 sub runcmd_ordryrun {
384 sub runcmd_ordryrun_local {
393 my ($first_shell, @cmd) = @_;
394 return qw(sh -ec), $first_shell.'; exec "$@"', 'x', @cmd;
397 our $helpmsg = <<END;
399 dgit [dgit-opts] clone [dgit-opts] package [suite] [./dir|/dir]
400 dgit [dgit-opts] fetch|pull [dgit-opts] [suite]
401 dgit [dgit-opts] build [git-buildpackage-opts|dpkg-buildpackage-opts]
402 dgit [dgit-opts] push [dgit-opts] [suite]
403 dgit [dgit-opts] rpush build-host:build-dir ...
404 important dgit options:
405 -k<keyid> sign tag and package with <keyid> instead of default
406 --dry-run -n do not change anything, but go through the motions
407 --damp-run -L like --dry-run but make local changes, without signing
408 --new -N allow introducing a new package
409 --debug -D increase debug level
410 -c<name>=<value> set git config option (used directly by dgit too)
413 our $later_warning_msg = <<END;
414 Perhaps the upload is stuck in incoming. Using the version from git.
418 print STDERR "$us: @_\n", $helpmsg or die $!;
423 @ARGV or badusage "too few arguments";
424 return scalar shift @ARGV;
428 print $helpmsg or die $!;
432 our %defcfg = ('dgit.default.distro' => 'debian',
433 'dgit.default.username' => '',
434 'dgit.default.archive-query-default-component' => 'main',
435 'dgit.default.ssh' => 'ssh',
436 'dgit-distro.debian.git-host' => 'git.debian.org',
437 'dgit-distro.debian.git-proto' => 'git+ssh://',
438 'dgit-distro.debian.git-path' => '/git/dgit-repos/repos',
439 'dgit-distro.debian.git-check' => 'ssh-cmd',
440 'dgit-distro.debian.git-create' => 'ssh-cmd',
441 'dgit-distro.debian.sshdakls-host' => 'coccia.debian.org',
442 'dgit-distro.debian.sshdakls-dir' =>
443 '/srv/ftp-master.debian.org/ftp/dists',
444 'dgit-distro.debian.upload-host' => 'ftp-master', # for dput
445 'dgit-distro.debian.mirror' => 'http://ftp.debian.org/debian/');
449 return undef if $c =~ /RETURN-UNDEF/;
450 my @cmd = (@git, qw(config --), $c);
453 local ($debug) = $debug-1;
454 $v = cmdoutput_errok @cmd;
461 my $dv = $defcfg{$c};
462 return $dv if defined $dv;
464 badcfg "need value for one of: @_";
467 sub access_distro () {
468 return cfg("dgit-suite.$isuite.distro",
469 "dgit.default.distro");
474 my $distro = $idistro || access_distro();
475 my $value = cfg(map { ("dgit-distro.$distro.$_",
476 "dgit.default.$_") } @keys);
480 sub string_to_ssh ($) {
482 if ($spec =~ m/\s/) {
483 return qw(sh -ec), 'exec '.$spec.' "$@"', 'x';
489 sub access_cfg_ssh () {
490 my $gitssh = access_cfg('ssh', 'RETURN-UNDEF');
491 if (!defined $gitssh) {
494 return string_to_ssh $gitssh;
498 sub access_someuserhost ($) {
500 my $user = access_cfg("$some-user",'username');
501 my $host = access_cfg("$some-host");
502 return length($user) ? "$user\@$host" : $host;
505 sub access_gituserhost () {
506 return access_someuserhost('git');
509 sub access_giturl () {
510 my $url = access_cfg('git-url','RETURN-UNDEF');
513 access_cfg('git-proto').
514 access_gituserhost().
515 access_cfg('git-path');
517 return "$url/$package.git";
520 sub parsecontrolfh ($$@) {
521 my ($fh, $desc, @opts) = @_;
522 my %opts = ('name' => $desc, @opts);
523 my $c = Dpkg::Control::Hash->new(%opts);
524 $c->parse($fh) or die "parsing of $desc failed";
529 my ($file, $desc) = @_;
530 my $fh = new IO::Handle;
531 open $fh, '<', $file or die "$file: $!";
532 my $c = parsecontrolfh($fh,$desc);
533 $fh->error and die $!;
539 my ($dctrl,$field) = @_;
540 my $v = $dctrl->{$field};
541 return $v if defined $v;
542 fail "missing field $field in ".$v->get_option('name');
546 my $c = Dpkg::Control::Hash->new();
547 my $p = new IO::Handle;
548 my @cmd = (qw(dpkg-parsechangelog), @_);
549 open $p, '-|', @cmd or die $!;
551 $?=0; $!=0; close $p or failedcmd @cmd;
557 sub archive_query ($) {
559 my $query = access_cfg('archive-query','RETURN-UNDEF');
560 if (!defined $query) {
561 my $distro = access_distro();
562 if ($distro eq 'debian') {
563 $query = "sshdakls:".
564 access_someuserhost('sshdakls').':'.
565 access_cfg('sshdakls-dir');
567 $query = "madison:$distro";
570 $query =~ s/^(\w+):// or badcfg "invalid archive-query method \`$query'";
573 { no strict qw(refs); &{"${method}_${proto}"}($proto,$data); }
576 sub archive_query_madison ($$) {
577 my ($proto,$data) = @_;
578 die unless $proto eq 'madison';
579 $rmad{$package} ||= cmdoutput
580 qw(rmadison -asource),"-s$isuite","-u$data",$package;
581 my $rmad = $rmad{$package};
582 return madison_parse($rmad);
585 sub archive_query_sshdakls ($$) {
586 my ($proto,$data) = @_;
587 $data =~ s/:.*// or badcfg "invalid sshdakls method string \`$data'";
588 my $dakls = cmdoutput
589 access_cfg_ssh, $data, qw(dak ls -asource),"-s$isuite",$package;
590 return madison_parse($dakls);
593 sub canonicalise_suite_sshdakls ($$) {
594 my ($proto,$data) = @_;
595 $data =~ m/:/ or badcfg "invalid sshdakls method string \`$data'";
599 " if test -h $isuite; then readlink $isuite; exit 0; fi;".
600 " if test -d $isuite; then echo $isuite; exit 0; fi;".
602 my $dakls = cmdoutput @cmd;
603 failedcmd @cmd unless $dakls =~ m/^\w/;
607 sub madison_parse ($) {
610 foreach my $l (split /\n/, $rmad) {
611 $l =~ m{^ \s*( [^ \t|]+ )\s* \|
612 \s*( [^ \t|]+ )\s* \|
613 \s*( [^ \t|/]+ )(?:/([^ \t|/]+))? \s* \|
614 \s*( [^ \t|]+ )\s* }x or die "$rmad $?";
615 $1 eq $package or die "$rmad $package ?";
622 $component = access_cfg('archive-query-default-component');
624 $5 eq 'source' or die "$rmad ?";
625 my $prefix = substr($package, 0, $package =~ m/^l/ ? 4 : 1);
626 my $subpath = "/pool/$component/$prefix/$package/".dscfn($vsn);
627 push @out, [$vsn,$subpath,$newsuite];
629 return sort { -version_compare_string($a->[0],$b->[0]); } @out;
632 sub canonicalise_suite_madison ($$) {
633 my @r = archive_query_madison($_[0],$_[1]);
635 "unable to canonicalise suite using package $package".
636 " which does not appear to exist in suite $isuite;".
637 " --existing-package may help";
641 sub canonicalise_suite () {
642 return if defined $csuite;
643 fail "cannot operate on $isuite suite" if $isuite eq 'UNRELEASED';
644 $csuite = archive_query('canonicalise_suite');
645 if ($isuite ne $csuite) {
646 # madison canonicalises for us
647 progress "canonical suite name for $isuite is $csuite";
651 sub get_archive_dsc () {
652 canonicalise_suite();
653 my @vsns = archive_query('archive_query');
654 foreach my $vinfo (@vsns) {
655 my ($vsn,$subpath) = @$vinfo;
656 $dscurl = access_cfg('mirror').$subpath;
657 $dscdata = url_get($dscurl);
659 $skew_warning_vsn = $vsn if !defined $skew_warning_vsn;
662 my $dscfh = new IO::File \$dscdata, '<' or die $!;
663 printdebug Dumper($dscdata) if $debug>1;
664 $dsc = parsecontrolfh($dscfh,$dscurl, allow_pgp=>1);
665 printdebug Dumper($dsc) if $debug>1;
666 my $fmt = getfield $dsc, 'Format';
667 fail "unsupported source format $fmt, sorry" unless $format_ok{$fmt};
673 sub check_for_git () {
675 my $how = access_cfg('git-check');
676 if ($how eq 'ssh-cmd') {
678 (access_cfg_ssh, access_gituserhost(),
679 " set -e; cd ".access_cfg('git-path').";".
680 " if test -d $package.git; then echo 1; else echo 0; fi");
681 my $r= cmdoutput @cmd;
682 failedcmd @cmd unless $r =~ m/^[01]$/;
685 badcfg "unknown git-check \`$how'";
689 sub create_remote_git_repo () {
690 my $how = access_cfg('git-create');
691 if ($how eq 'ssh-cmd') {
693 (access_cfg_ssh, access_gituserhost(),
694 "set -e; cd ".access_cfg('git-path').";".
695 " cp -a _template $package.git");
697 badcfg "unknown git-create \`$how'";
701 our ($dsc_hash,$lastpush_hash);
703 our $ud = '.git/dgit/unpack';
711 sub mktree_in_ud_from_only_subdir () {
712 # changes into the subdir
715 $dirs[0] =~ m#^([^/]+)/\.$# or die;
717 chdir $dir or die "$dir $!";
718 fail "source package contains .git directory" if stat '.git';
719 die $! unless $!==&ENOENT;
720 runcmd qw(git init -q);
721 rmtree('.git/objects');
722 symlink '../../../../objects','.git/objects' or die $!;
723 runcmd @git, qw(add -Af);
724 my $tree = cmdoutput @git, qw(write-tree);
725 $tree =~ m/^\w+$/ or die "$tree ?";
729 sub dsc_files_info () {
730 foreach my $csumi (['Checksums-Sha256','Digest::SHA', 'new(256)'],
731 ['Checksums-Sha1', 'Digest::SHA', 'new(1)'],
732 ['Files', 'Digest::MD5', 'new()']) {
733 my ($fname, $module, $method) = @$csumi;
734 my $field = $dsc->{$fname};
735 next unless defined $field;
736 eval "use $module; 1;" or die $@;
738 foreach (split /\n/, $field) {
740 m/^(\w+) (\d+) (\S+)$/ or
741 fail "could not parse .dsc $fname line \`$_'";
742 my $digester = eval "$module"."->$method;" or die $@;
747 Digester => $digester,
752 fail "missing any supported Checksums-* or Files field in ".
753 $dsc->get_option('name');
757 map { $_->{Filename} } dsc_files_info();
760 sub is_orig_file ($) {
762 m/\.orig(?:-\w+)?\.tar\.\w+$/;
765 sub make_commit ($) {
767 return cmdoutput @git, qw(hash-object -w -t commit), $file;
770 sub clogp_authline ($) {
772 my $author = getfield $clogp, 'Maintainer';
773 $author =~ s#,.*##ms;
774 my $date = cmdoutput qw(date), '+%s %z', qw(-d), getfield($clogp,'Date');
775 my $authline = "$author $date";
776 $authline =~ m/^[^<>]+ \<\S+\> \d+ [-+]\d+$/ or
777 fail "unexpected commit author line format \`$authline'".
778 " (was generated from changelog Maintainer field)";
782 sub generate_commit_from_dsc () {
786 foreach my $f (dsc_files()) {
787 die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
789 link "../../../$f", $f
793 runcmd @dget, qw(--), $dscurl;
794 foreach my $f (grep { is_orig_file($_) } @files) {
795 link $f, "../../../../$f"
799 my ($tree,$dir) = mktree_in_ud_from_only_subdir();
800 runcmd qw(sh -ec), 'dpkg-parsechangelog >../changelog.tmp';
801 my $clogp = parsecontrol('../changelog.tmp',"commit's changelog");
802 my $authline = clogp_authline $clogp;
803 my $changes = getfield $clogp, 'Changes';
804 open C, ">../commit.tmp" or die $!;
805 print C <<END or die $!;
812 # imported from the archive
815 my $outputhash = make_commit qw(../commit.tmp);
816 my $cversion = getfield $clogp, 'Version';
817 progress "synthesised git commit from .dsc $cversion";
818 if ($lastpush_hash) {
819 runcmd @git, qw(reset --hard), $lastpush_hash;
820 runcmd qw(sh -ec), 'dpkg-parsechangelog >>../changelogold.tmp';
821 my $oldclogp = parsecontrol('../changelogold.tmp','previous changelog');
822 my $oversion = getfield $oldclogp, 'Version';
824 version_compare_string($oversion, $cversion);
826 # git upload/ is earlier vsn than archive, use archive
827 open C, ">../commit2.tmp" or die $!;
828 print C <<END or die $!;
830 parent $lastpush_hash
835 Record $package ($cversion) in archive suite $csuite
837 $outputhash = make_commit qw(../commit2.tmp);
838 } elsif ($vcmp > 0) {
839 print STDERR <<END or die $!;
841 Version actually in archive: $cversion (older)
842 Last allegedly pushed/uploaded: $oversion (newer or same)
845 $outputhash = $lastpush_hash;
847 $outputhash = $lastpush_hash;
850 chdir '../../../..' or die $!;
851 runcmd @git, qw(update-ref -m),"dgit fetch import $cversion",
852 'DGIT_ARCHIVE', $outputhash;
853 cmdoutput @git, qw(log -n2), $outputhash;
854 # ... gives git a chance to complain if our commit is malformed
859 sub ensure_we_have_orig () {
860 foreach my $fi (dsc_files_info()) {
861 my $f = $fi->{Filename};
862 next unless is_orig_file($f);
863 if (open F, "<", "../$f") {
864 $fi->{Digester}->reset();
865 $fi->{Digester}->addfile(*F);
867 my $got = $fi->{Digester}->hexdigest();
868 $got eq $fi->{Hash} or
869 fail "existing file $f has hash $got but .dsc".
870 " demands hash $fi->{Hash}".
871 " (perhaps you should delete this file?)";
872 progress "using existing $f";
875 die "$f $!" unless $!==&ENOENT;
877 my $origurl = $dscurl;
878 $origurl =~ s{/[^/]+$}{};
880 die "$f ?" unless $f =~ m/^${package}_/;
881 die "$f ?" if $f =~ m#/#;
882 runcmd_ordryrun_local shell_cmd 'cd ..', @dget,'--',$origurl;
887 return cmdoutput @git, qw(rev-parse), "$_[0]~0";
890 sub is_fast_fwd ($$) {
891 my ($ancestor,$child) = @_;
892 my @cmd = (@git, qw(merge-base), $ancestor, $child);
893 my $mb = cmdoutput_errok @cmd;
895 return rev_parse($mb) eq rev_parse($ancestor);
897 $?==256 or failedcmd @cmd;
902 sub git_fetch_us () {
903 runcmd_ordryrun_local @git, qw(fetch),access_giturl(),fetchspec();
906 sub fetch_from_archive () {
907 # ensures that lrref() is what is actually in the archive,
912 foreach my $field (@ourdscfield) {
913 $dsc_hash = $dsc->{$field};
914 last if defined $dsc_hash;
916 if (defined $dsc_hash) {
917 $dsc_hash =~ m/\w+/ or fail "invalid hash in .dsc \`$dsc_hash'";
919 progress "last upload to archive specified git hash";
921 progress "last upload to archive has NO git hash";
924 progress "no version available from the archive";
927 my $lrref_fn = ".git/".lrref();
928 if (open H, $lrref_fn) {
929 $lastpush_hash = <H>;
930 chomp $lastpush_hash;
931 die "$lrref_fn $lastpush_hash ?" unless $lastpush_hash =~ m/^\w+$/;
932 } elsif ($! == &ENOENT) {
937 printdebug "previous reference hash=$lastpush_hash\n";
939 if (defined $dsc_hash) {
940 fail "missing git history even though dsc has hash -".
941 " could not find commit $dsc_hash".
942 " (should be in ".access_giturl()."#".rrref().")"
943 unless $lastpush_hash;
945 ensure_we_have_orig();
946 if ($dsc_hash eq $lastpush_hash) {
947 } elsif (is_fast_fwd($dsc_hash,$lastpush_hash)) {
948 print STDERR <<END or die $!;
950 Git commit in archive is behind the last version allegedly pushed/uploaded.
951 Commit referred to by archive: $dsc_hash
952 Last allegedly pushed/uploaded: $lastpush_hash
955 $hash = $lastpush_hash;
957 fail "archive's .dsc refers to ".$dsc_hash.
958 " but this is an ancestor of ".$lastpush_hash;
961 $hash = generate_commit_from_dsc();
962 } elsif ($lastpush_hash) {
963 # only in git, not in the archive yet
964 $hash = $lastpush_hash;
965 print STDERR <<END or die $!;
967 Package not found in the archive, but has allegedly been pushed using dgit.
971 printdebug "nothing found!\n";
972 if (defined $skew_warning_vsn) {
973 print STDERR <<END or die $!;
975 Warning: relevant archive skew detected.
976 Archive allegedly contains $skew_warning_vsn
977 But we were not able to obtain any version from the archive or git.
983 printdebug "current hash=$hash\n";
984 if ($lastpush_hash) {
985 fail "not fast forward on last upload branch!".
986 " (archive's version left in DGIT_ARCHIVE)"
987 unless is_fast_fwd($lastpush_hash, $hash);
989 if (defined $skew_warning_vsn) {
991 printdebug "SKEW CHECK WANT $skew_warning_vsn\n";
992 my $clogf = ".git/dgit/changelog.tmp";
993 runcmd shell_cmd "exec >$clogf",
994 @git, qw(cat-file blob), "$hash:debian/changelog";
995 my $gotclogp = parsechangelog("-l$clogf");
996 my $got_vsn = getfield $gotclogp, 'Version';
997 printdebug "SKEW CHECK GOT $got_vsn\n";
998 if (version_compare_string($got_vsn, $skew_warning_vsn) < 0) {
999 print STDERR <<END or die $!;
1001 Warning: archive skew detected. Using the available version:
1002 Archive allegedly contains $skew_warning_vsn
1003 We were able to obtain only $got_vsn
1008 if ($lastpush_hash ne $hash) {
1009 my @upd_cmd = (@git, qw(update-ref -m), 'dgit fetch', lrref(), $hash);
1013 dryrun_report @upd_cmd;
1021 canonicalise_suite();
1022 badusage "dry run makes no sense with clone" unless act_local();
1023 mkdir $dstdir or die "$dstdir $!";
1024 chdir "$dstdir" or die "$dstdir $!";
1025 runcmd @git, qw(init -q);
1026 runcmd @git, qw(config), "remote.$remotename.fetch", fetchspec();
1027 open H, "> .git/HEAD" or die $!;
1028 print H "ref: ".lref()."\n" or die $!;
1030 runcmd @git, qw(remote add), 'origin', access_giturl();
1031 if (check_for_git()) {
1032 progress "fetching existing git history";
1034 runcmd_ordryrun_local @git, qw(fetch origin);
1036 progress "starting new git history";
1038 fetch_from_archive() or no_such_package;
1039 runcmd @git, qw(reset --hard), lrref();
1040 printdone "ready for work in $dstdir";
1044 if (check_for_git()) {
1047 fetch_from_archive() or no_such_package();
1048 printdone "fetched into ".lrref();
1053 runcmd_ordryrun_local @git, qw(merge -m),"Merge from $csuite [dgit]",
1055 printdone "fetched to ".lrref()." and merged into HEAD";
1058 sub check_not_dirty () {
1059 return if $ignoredirty;
1060 my @cmd = (@git, qw(diff --quiet HEAD));
1061 printcmd(\*DEBUG,$debugprefix."+",@cmd) if $debug>0;
1062 $!=0; $?=0; system @cmd;
1063 return if !$! && !$?;
1064 if (!$! && $?==256) {
1065 fail "working tree is dirty (does not match HEAD)";
1071 sub commit_quilty_patch () {
1072 my $output = cmdoutput @git, qw(status --porcelain);
1074 foreach my $l (split /\n/, $output) {
1075 next unless $l =~ m/\S/;
1076 if ($l =~ m{^(?:\?\?| M) (.pc|debian/patches)}) {
1081 progress "nothing quilty to commit, ok.";
1084 runcmd_ordryrun_local @git, qw(add), sort keys %adds;
1085 my $m = "Commit Debian 3.0 (quilt) metadata";
1087 runcmd_ordryrun_local @git, qw(commit -m), $m;
1092 return 0 unless $format eq '3.0 (quilt)';
1093 progress "Format \`$format', urgh";
1095 progress "Not doing any fixup of \`$format' due to --no-quilt-fixup";
1101 sub push_parse_changelog ($) {
1104 my $clogp = Dpkg::Control::Hash->new();
1105 $clogp->load($clogpfn);
1107 $package = getfield $clogp, 'Source';
1108 my $cversion = getfield $clogp, 'Version';
1109 my $tag = debiantag($cversion);
1110 runcmd @git, qw(check-ref-format), $tag;
1112 my $dscfn = dscfn($cversion);
1114 return ($clogp, $cversion, $tag, $dscfn);
1117 sub push_parse_dsc ($$$) {
1118 my ($dscfn,$dscfnwhat, $cversion) = @_;
1119 $dsc = parsecontrol($dscfn,$dscfnwhat);
1120 my $dversion = getfield $dsc, 'Version';
1121 my $dscpackage = getfield $dsc, 'Source';
1122 ($dscpackage eq $package && $dversion eq $cversion) or
1123 fail "$dsc is for $dscpackage $dversion".
1124 " but debian/changelog is for $package $cversion";
1127 sub push_mktag ($$$$$$$$) {
1128 my ($head,$clogp,$tag,
1130 $changesfile,$changesfilewhat,
1133 $dsc->{$ourdscfield[0]} = $head;
1134 $dsc->save("$dscfn.tmp") or die $!;
1136 my $changes = parsecontrol($changesfile,$changesfilewhat);
1137 foreach my $field (qw(Source Distribution Version)) {
1138 $changes->{$field} eq $clogp->{$field} or
1139 fail "changes field $field \`$changes->{$field}'".
1140 " does not match changelog \`$clogp->{$field}'";
1143 my $cversion = getfield $clogp, 'Version';
1145 # We make the git tag by hand because (a) that makes it easier
1146 # to control the "tagger" (b) we can do remote signing
1147 my $authline = clogp_authline $clogp;
1148 open TO, '>', $tfn->('.tmp') or die $!;
1149 print TO <<END or die $!;
1155 $package release $cversion for $csuite [dgit]
1159 my $tagobjfn = $tfn->('.tmp');
1161 if (!defined $keyid) {
1162 $keyid = access_cfg('keyid','RETURN-UNDEF');
1164 unlink $tfn->('.tmp.asc') or $!==&ENOENT or die $!;
1165 my @sign_cmd = (@gpg, qw(--detach-sign --armor));
1166 push @sign_cmd, qw(-u),$keyid if defined $keyid;
1167 push @sign_cmd, $tfn->('.tmp');
1168 runcmd_ordryrun @sign_cmd;
1170 $tagobjfn = $tfn->('.signed.tmp');
1171 runcmd shell_cmd "exec >$tagobjfn", qw(cat --),
1172 $tfn->('.tmp'), $tfn->('.tmp.asc');
1179 sub sign_changes ($) {
1180 my ($changesfile) = @_;
1182 my @debsign_cmd = @debsign;
1183 push @debsign_cmd, "-k$keyid" if defined $keyid;
1184 push @debsign_cmd, "-p$gpg[0]" if $gpg[0] ne 'gpg';
1185 push @debsign_cmd, $changesfile;
1186 runcmd_ordryrun @debsign_cmd;
1191 printdebug "actually entering push\n";
1194 my $clogpfn = ".git/dgit/changelog.822.tmp";
1195 runcmd shell_cmd "exec >$clogpfn", qw(dpkg-parsechangelog);
1197 responder_send_file('parsed-changelog', $clogpfn);
1199 my ($clogp, $cversion, $tag, $dscfn) =
1200 push_parse_changelog("$clogpfn");
1203 fail "looked for .dsc $dscfn, but $!;".
1204 " maybe you forgot to build";
1206 responder_send_file('dsc', "../$dscfn");
1208 push_parse_dsc("../$dscfn", $dscfn, $cversion);
1210 my $format = getfield $dsc, 'Format';
1211 printdebug "format $format\n";
1212 if (madformat($format)) {
1213 commit_quilty_patch();
1216 chdir $ud or die $!;
1217 progress "checking that $dscfn corresponds to HEAD";
1218 runcmd qw(dpkg-source -x --), "../../../../$dscfn";
1219 my ($tree,$dir) = mktree_in_ud_from_only_subdir();
1220 chdir '../../../..' or die $!;
1221 my @diffcmd = (@git, qw(diff --exit-code), $tree);
1222 printcmd \*DEBUG,$debugprefix."+",@diffcmd;
1224 if (system @diffcmd) {
1225 if ($! && $?==256) {
1226 fail "$dscfn specifies a different tree to your HEAD commit;".
1227 " perhaps you forgot to build";
1233 #do fast forward check and maybe fake merge
1234 # if (!is_fast_fwd(mainbranch
1235 # runcmd @git, qw(fetch -p ), "$alioth_git/$package.git",
1236 # map { lref($_).":".rref($_) }
1238 my $head = rev_parse('HEAD');
1239 if (!$changesfile) {
1240 my $multi = "../${package}_".(stripepoch $cversion)."_multi.changes";
1241 if (stat "$multi") {
1242 $changesfile = $multi;
1244 $!==&ENOENT or die "$multi: $!";
1245 my $pat = "${package}_".(stripepoch $cversion)."_*.changes";
1246 my @cs = glob "../$pat";
1247 fail "failed to find unique changes file".
1248 " (looked for $pat in .., or $multi);".
1249 " perhaps you need to use dgit -C"
1251 ($changesfile) = @cs;
1255 responder_send_file('changes',$changesfile);
1257 my $tfn = sub { ".git/dgit/tag$_[0]"; };
1260 ? responder_receive_files('signed-tag', $tfn->('.signed.tmp'))
1261 : push_mktag($head,$clogp,$tag,
1263 $changesfile,$changesfile,
1266 my $tag_obj_hash = cmdoutput @git, qw(hash-object -w -t tag), $tagobjfn;
1267 runcmd_ordryrun @git, qw(verify-tag), $tag_obj_hash;
1268 runcmd_ordryrun_local @git, qw(update-ref), "refs/tags/$tag", $tag_obj_hash;
1269 runcmd_ordryrun @git, qw(tag -v --), $tag;
1271 if (!check_for_git()) {
1272 create_remote_git_repo();
1274 runcmd_ordryrun @git, qw(push),access_giturl(),"HEAD:".rrref();
1275 runcmd_ordryrun @git, qw(update-ref -m), 'dgit push', lrref(), 'HEAD';
1277 if (!$we_are_responder) {
1279 rename "../$dscfn.tmp","../$dscfn" or die "$dscfn $!";
1281 progress "[new .dsc left in $dscfn.tmp]";
1285 if ($we_are_responder) {
1286 my $dryrunsuffix = act_local() ? "" : ".tmp";
1287 responder_receive_files('signed-dsc-changes',
1288 "../$dscfn$dryrunsuffix",
1289 "$changesfile$dryrunsuffix");
1291 sign_changes $changesfile;
1294 runcmd_ordryrun @git, qw(push),access_giturl(),"refs/tags/$tag";
1295 my $host = access_cfg('upload-host','RETURN-UNDEF');
1296 my @hostarg = defined($host) ? ($host,) : ();
1297 runcmd_ordryrun @dput, @hostarg, $changesfile;
1298 printdone "pushed and uploaded $cversion";
1300 responder_send_command("complete");
1306 badusage "-p is not allowed with clone; specify as argument instead"
1307 if defined $package;
1310 } elsif (@ARGV==2 && $ARGV[1] =~ m#^\w#) {
1311 ($package,$isuite) = @ARGV;
1312 } elsif (@ARGV==2 && $ARGV[1] =~ m#^[./]#) {
1313 ($package,$dstdir) = @ARGV;
1314 } elsif (@ARGV==3) {
1315 ($package,$isuite,$dstdir) = @ARGV;
1317 badusage "incorrect arguments to dgit clone";
1319 $dstdir ||= "$package";
1323 sub branchsuite () {
1324 my $branch = cmdoutput_errok @git, qw(symbolic-ref HEAD);
1325 if ($branch =~ m#$lbranch_re#o) {
1332 sub fetchpullargs () {
1333 if (!defined $package) {
1334 my $sourcep = parsecontrol('debian/control','debian/control');
1335 $package = getfield $sourcep, 'Source';
1338 # $isuite = branchsuite(); # this doesn't work because dak hates canons
1340 my $clogp = parsechangelog();
1341 $isuite = getfield $clogp, 'Distribution';
1343 canonicalise_suite();
1344 progress "fetching from suite $csuite";
1345 } elsif (@ARGV==1) {
1347 canonicalise_suite();
1349 badusage "incorrect arguments to dgit fetch or dgit pull";
1367 badusage "-p is not allowed with dgit push" if defined $package;
1369 my $clogp = parsechangelog();
1370 $package = getfield $clogp, 'Source';
1373 } elsif (@ARGV==1) {
1374 ($specsuite) = (@ARGV);
1376 badusage "incorrect arguments to dgit push";
1378 $isuite = getfield $clogp, 'Distribution';
1380 local ($package) = $existing_package; # this is a hack
1381 canonicalise_suite();
1383 if (defined $specsuite && $specsuite ne $isuite) {
1384 canonicalise_suite();
1385 $csuite eq $specsuite or
1386 fail "dgit push: changelog specifies $isuite ($csuite)".
1387 " but command line specifies $specsuite";
1389 if (check_for_git()) {
1392 if (fetch_from_archive()) {
1393 is_fast_fwd(lrref(), 'HEAD') or
1394 fail "dgit push: HEAD is not a descendant".
1395 " of the archive's version.\n".
1396 "$us: To overwrite it, use git-merge -s ours ".lrref().".";
1399 fail "package appears to be new in this suite;".
1400 " if this is intentional, use --new";
1405 #---------- remote commands' implementation ----------
1407 sub cmd_remote_push_responder {
1408 my ($nrargs) = shift @ARGV;
1409 my (@rargs) = @ARGV[0..$nrargs-1];
1410 @ARGV = @ARGV[$nrargs..$#ARGV];
1413 chdir $dir or die "$dir: $!";
1414 $we_are_responder = 1;
1417 responder_send_command("dgit-remote-push-ready");
1425 return unless defined $i_tmp;
1426 chdir "/" or die $!;
1427 eval { rmtree $i_tmp; };
1431 my ($base,$selector,@args) = @_;
1432 $selector =~ s/\-/_/g;
1433 { no strict qw(refs); &{"${base}_${selector}"}(@args); }
1439 if ($host =~ m/^((?:[^][]|\[[^][]*\])*)\:/) {
1449 push @rdgit, @ropts;
1450 push @rdgit, qw(remote-push-responder), (scalar @rargs), @rargs;
1452 my @cmd = (@ssh, $host, shellquote @rdgit);
1453 printcmd \*DEBUG,$debugprefix."+",@cmd;
1456 my $pid = open2(\*RO, \*RI, @cmd);
1457 chdir $i_tmp or die "$i_tmp $!";
1458 initiator_expect { m/^dgit-remote-push-ready/ };
1460 my ($icmd,$iargs) = initiator_expect {
1461 m/^(\S+)(?: (.*))?$/;
1464 i_method "i_resp", $icmd, $iargs;
1471 sub i_resp_progress ($) {
1473 my $msg = protocol_read_bytes \*RO, $rhs;
1477 sub i_resp_complete {
1482 sub i_resp_file ($) {
1484 my $localname = i_method "i_localname", $keyword;
1485 my $localpath = "$i_tmp/$localname";
1486 stat $localpath and badproto \*RO, "file $keyword ($localpath) twice";
1487 protocol_receive_file \*RO, $localpath;
1493 $_[0] =~ m/^(\S+) (.*)$/;
1499 sub i_resp_want ($) {
1501 die "$keyword ?" if $i_wanted{$keyword}++;
1502 my @localpaths = i_method "i_want", $keyword;
1503 printdebug "]] $keyword @localpaths\n";
1504 foreach my $localpath (@localpaths) {
1505 protocol_send_file \*RI, $localpath;
1507 print RI "end-files\n" or die $!;
1510 our ($i_clogp, $i_version, $i_tag, $i_dscfn);
1512 sub i_localname_parsed_changelog { return "remote-changelog.822"; }
1513 sub i_localname_changes { return "remote.changes"; }
1514 sub i_localname_dsc {
1515 ($i_clogp, $i_version, $i_tag, $i_dscfn) =
1516 push_parse_changelog 'remote-changelog.822';
1517 die if $i_dscfn =~ m#/|^\W#;
1521 sub i_want_signed_tag {
1522 defined $i_param{'head'} && defined $i_dscfn
1523 or badproto \*RO, "sequencing error";
1524 my $head = $i_param{'head'};
1525 die if $head =~ m/[^0-9a-f]/ || $head !~ m/^../;
1527 push_parse_dsc $i_dscfn, 'remote dsc',
1529 push_mktag $head, $i_clogp, $i_tag,
1531 'remote.changes', 'remote changes',
1537 sub i_want_signed_dsc_changes {
1538 rename "$i_dscfn.tmp","$i_dscfn" or die "$i_dscfn $!";
1539 sign_changes 'remote.changes';
1540 return ($i_dscfn, 'remote.changes');
1543 #---------- building etc. ----------
1549 our $fakeeditorenv = 'DGIT_FAKE_EDITOR_QUILT';
1551 sub build_maybe_quilt_fixup () {
1552 if (!open F, "debian/source/format") {
1553 die $! unless $!==&ENOENT;
1557 F->error and die $!;
1559 return unless madformat($_);
1561 my $clogp = parsechangelog();
1562 my $version = getfield $clogp, 'Version';
1563 my $author = getfield $clogp, 'Maintainer';
1564 my $headref = rev_parse('HEAD');
1567 my $patchname = "auto-$version-$headref-$time";
1568 my $msg = cmdoutput @git, qw(log), "-n$ncommits";
1570 my $descfn = ".git/dgit/quilt-description.tmp";
1571 open O, '>', $descfn or die "$descfn: $!";
1573 $msg =~ s/^\s+$/ ./mg;
1574 print O <<END or die $!;
1575 Description: Automatically generated patch ($clogp->{Version})
1576 Last (up to) $ncommits git changes, FYI:
1586 local $ENV{'EDITOR'} = cmdoutput qw(realpath --), $0;
1587 local $ENV{'VISUAL'} = $ENV{'EDITOR'};
1588 local $ENV{$fakeeditorenv} = cmdoutput qw(realpath --), $descfn;
1589 runcmd_ordryrun_local @dpkgsource, qw(--commit .), $patchname;
1592 if (!open P, '>>', ".pc/applied-patches") {
1593 $!==&ENOENT or die $!;
1598 commit_quilty_patch();
1601 sub quilt_fixup_editor () {
1602 my $descfn = $ENV{$fakeeditorenv};
1603 my $editing = $ARGV[$#ARGV];
1604 open I1, '<', $descfn or die "$descfn: $!";
1605 open I2, '<', $editing or die "$editing: $!";
1606 unlink $editing or die "$editing: $!";
1607 open O, '>', $editing or die "$editing: $!";
1608 while (<I1>) { print O or die $!; } I1->error and die $!;
1611 $copying ||= m/^\-\-\- /;
1612 next unless $copying;
1615 I2->error and die $!;
1621 badusage "-p is not allowed when building" if defined $package;
1623 my $clogp = parsechangelog();
1624 $isuite = getfield $clogp, 'Distribution';
1625 $package = getfield $clogp, 'Source';
1626 $version = getfield $clogp, 'Version';
1627 build_maybe_quilt_fixup();
1631 badusage "dgit build implies --clean=dpkg-source"
1632 if $cleanmode ne 'dpkg-source';
1634 runcmd_ordryrun_local @dpkgbuildpackage, qw(-us -uc), changesopts(), @ARGV;
1635 printdone "build successful\n";
1639 badusage "dgit git-build implies --clean=dpkg-source"
1640 if $cleanmode ne 'dpkg-source';
1643 (qw(git-buildpackage -us -uc --git-no-sign-tags),
1644 "--git-builder=@dpkgbuildpackage");
1645 unless (grep { m/^--git-debian-branch|^--git-ignore-branch/ } @ARGV) {
1646 canonicalise_suite();
1647 push @cmd, "--git-debian-branch=".lbranch();
1649 push @cmd, changesopts();
1650 runcmd_ordryrun_local @cmd, @ARGV;
1651 printdone "build successful\n";
1656 $sourcechanges = "${package}_".(stripepoch $version)."_source.changes";
1657 $dscfn = dscfn($version);
1658 if ($cleanmode eq 'dpkg-source') {
1659 runcmd_ordryrun_local (@dpkgbuildpackage, qw(-us -uc -S)),
1662 if ($cleanmode eq 'git') {
1663 runcmd_ordryrun_local @git, qw(clean -xdf);
1664 } elsif ($cleanmode eq 'none') {
1668 my $pwd = cmdoutput qw(env - pwd);
1669 my $leafdir = basename $pwd;
1670 chdir ".." or die $!;
1671 runcmd_ordryrun_local @dpkgsource, qw(-b --), $leafdir;
1672 chdir $pwd or die $!;
1673 runcmd_ordryrun_local qw(sh -ec),
1674 'exec >$1; shift; exec "$@"','x',
1675 "../$sourcechanges",
1676 @dpkggenchanges, qw(-S), changesopts();
1680 sub cmd_build_source {
1681 badusage "build-source takes no additional arguments" if @ARGV;
1683 printdone "source built, results in $dscfn and $sourcechanges";
1688 chdir ".." or die $!;
1689 my $pat = "${package}_".(stripepoch $version)."_*.changes";
1691 stat $dscfn or fail "$dscfn (in parent directory): $!";
1692 stat $sourcechanges or fail "$sourcechanges (in parent directory): $!";
1693 foreach my $cf (glob $pat) {
1694 next if $cf eq $sourcechanges;
1695 unlink $cf or fail "remove $cf: $!";
1698 runcmd_ordryrun_local @sbuild, @ARGV, qw(-d), $isuite, $dscfn;
1699 runcmd_ordryrun_local @mergechanges, glob $pat;
1700 my $multichanges = "${package}_".(stripepoch $version)."_multi.changes";
1702 stat $multichanges or fail "$multichanges: $!";
1704 printdone "build successful, results in $multichanges\n" or die $!;
1707 sub cmd_quilt_fixup {
1708 badusage "incorrect arguments to dgit quilt-fixup" if @ARGV;
1709 my $clogp = parsechangelog();
1710 $version = getfield $clogp, 'Version';
1711 build_maybe_quilt_fixup();
1714 #---------- argument parsing and main program ----------
1717 print "dgit version $our_version\n" or die $!;
1724 if (defined $ENV{'DGIT_SSH'}) {
1725 @ssh = string_to_ssh $ENV{'DGIT_SSH'};
1726 } elsif (defined $ENV{'GIT_SSH'}) {
1727 @ssh = ($ENV{'GIT_SSH'});
1731 last unless $ARGV[0] =~ m/^-/;
1735 if (m/^--dry-run$/) {
1738 } elsif (m/^--damp-run$/) {
1741 } elsif (m/^--no-sign$/) {
1744 } elsif (m/^--help$/) {
1746 } elsif (m/^--version$/) {
1748 } elsif (m/^--new$/) {
1751 } elsif (m/^--(\w+)=(.*)/s &&
1752 ($om = $opts_opt_map{$1}) &&
1756 } elsif (m/^--(\w+):(.*)/s &&
1757 !$opts_opt_cmdonly{$1} &&
1758 ($om = $opts_opt_map{$1})) {
1761 } elsif (m/^--existing-package=(.*)/s) {
1763 $existing_package = $1;
1764 } elsif (m/^--distro=(.*)/s) {
1767 } elsif (m/^--clean=(dpkg-source|git|none)$/s) {
1770 } elsif (m/^--clean=(.*)$/s) {
1771 badusage "unknown cleaning mode \`$1'";
1772 } elsif (m/^--ignore-dirty$/s) {
1775 } elsif (m/^--no-quilt-fixup$/s) {
1779 badusage "unknown long option \`$_'";
1786 } elsif (s/^-L/-/) {
1789 } elsif (s/^-h/-/) {
1791 } elsif (s/^-D/-/) {
1793 open DEBUG, ">&STDERR" or die $!;
1796 } elsif (s/^-N/-/) {
1799 } elsif (m/^-[vm]/) {
1801 push @changesopts, $_;
1803 } elsif (s/^-c(.*=.*)//s) {
1805 push @git, '-c', $1;
1806 } elsif (s/^-d(.*)//s) {
1809 } elsif (s/^-C(.*)//s) {
1812 } elsif (s/^-k(.*)//s) {
1814 } elsif (s/^-wn//s) {
1816 $cleanmode = 'none';
1817 } elsif (s/^-wg//s) {
1820 } elsif (s/^-wd//s) {
1822 $cleanmode = 'dpkg-source';
1824 badusage "unknown short option \`$_'";
1831 if ($ENV{$fakeeditorenv}) {
1832 quilt_fixup_editor();
1835 delete $ENV{'DGET_UNPACK'};
1838 print STDERR "DRY RUN ONLY\n" if $dryrun_level > 1;
1839 print STDERR "DAMP RUN - WILL MAKE LOCAL (UNSIGNED) CHANGES\n"
1840 if $dryrun_level == 1;
1842 print STDERR $helpmsg or die $!;
1845 my $cmd = shift @ARGV;
1847 { no strict qw(refs); &{"cmd_$cmd"}(); }