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;
30 our $isuite = 'unstable';
37 our $existing_package = 'dpkg';
39 our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
42 our (@dget) = qw(dget);
43 our (@dput) = qw(dput);
44 our (@debsign) = qw(debsign);
48 open DEBUG, ">/dev/null" or die $!;
50 our %opts_opt_map = ('dget' => \@dget,
52 'debsign' => \@debsign);
54 our $remotename = 'dgit';
55 our $ourdscfield = 'Vcs-Dgit-Master';
56 our $branchprefix = 'dgit';
59 sub lbranch () { return "$branchprefix/$csuite"; }
60 my $lbranch_re = '^refs/heads/'.$branchprefix.'/([^/.]+)$';
61 sub lref () { return "refs/heads/".lbranch(); }
62 sub lrref () { return "refs/remotes/$remotename/$csuite"; }
63 sub rrref () { return "refs/$branchprefix/$csuite"; }
64 sub debiantag ($) { return "debian/$_[0]"; }
68 sub fail () { die "$us: @_\n"; }
70 sub badcfg () { print STDERR "$us: invalid configuration: @_\n"; exit 12; }
72 sub no_such_package () {
73 print STDERR "$us: package $package does not exist in suite $suite\n";
79 return "+".rrref().":".lrref();
86 $ua = LWP::UserAgent->new();
90 print "downloading $what...\n";
91 my $r = $ua->get(@_) or die $!;
92 $r->is_success or fail "failed to fetch $what: ".$r->status_line;
93 return $r->decoded_content();
96 our ($dscdata,$dscurl,$dsc);
100 my $intro = shift @_;
101 print $fh $intro or die $!;
105 if (s{['\\]}{\\$&}g || m{\s} || m{[^-_./0-9a-z]}i) {
106 print $fh " '$_'" or die $!;
108 print $fh " $_" or die $!;
111 print $fh "\n" or die $!;
115 { local ($!); printcmd \*STDERR, "$_[0]: failed command:", @_ or die $!; };
117 fail "failed to fork/exec: $!";
118 } elsif (!($? & 0xff)) {
119 fail "subprocess failed with error exit status ".($?>>8);
121 fail "subprocess crashed (wait status $?)";
123 fail "subprocess produced invalid output";
128 printcmd(\*DEBUG,"+",@_) if $debug>0;
130 failedcmd @_ if system @_;
135 print "dgit ok: @_\n";
137 print "would be ok: @_ (but dry run only)\n";
141 sub cmdoutput_errok {
142 die Dumper(\@_)." ?" if grep { !defined } @_;
143 printcmd(\*DEBUG,"|",@_) if $debug>0;
144 open P, "-|", @_ or die $!;
147 { local $/ = undef; $d = <P>; }
149 if (!close P) { print DEBUG "=>!$?\n" if $debug>0; return undef; }
152 print DEBUG "=> \`$&'",(length $' ? '...' : ''),"\n" if $debug>0; #';
157 my $d = cmdoutput_errok @_;
158 defined $d or failedcmd @_;
163 printcmd(\*STDOUT,"#",@_);
166 sub runcmd_ordryrun {
174 our $helpmsg = <<END;
176 dgit [dgit-opts] clone [dgit-opts] package [suite] [./dir|/dir]
177 dgit [dgit-opts] fetch|pull [dgit-opts] [suite]
178 dgit [dgit-opts] build [git-buildpackage-opts|dpkg-buildpackage-opts]
179 dgit [dgit-opts] push [dgit-opts] [suite]
180 important dgit options:
181 -k<keyid> sign tag and package with <keyid> instead of default
182 --dry-run -n do not change anything, but go through the motions
183 --new -N allow introducing a new package
184 --debug -D increase debug level
185 -c<name>=<value> set git config option (used directly by dgit too)
189 print STDERR "$us: @_\n", $helpmsg or die $!;
194 print $helpmsg or die $!;
198 our %defcfg = ('dgit.default.distro' => 'debian',
199 'dgit.default.username' => '',
200 'dgit.default.archive-query-default-component' => 'main',
201 'dgit.default.ssh' => 'ssh',
202 'dgit-distro.debian.git-host' => 'dgit.debian.net',
203 'dgit-distro.debian.git-proto' => 'git+ssh://',
204 'dgit-distro.debian.git-path' => '/git/dgit-repos',
205 'dgit-distro.debian.git-check' => 'ssh-cmd',
206 'dgit-distro.debian.git-create' => 'ssh-cmd',
207 'dgit-distro.debian.sshdakls-host' => 'coccia.debian.org',
208 'dgit-distro.debian.sshdakls-dir' =>
209 '/srv/ftp-master.debian.org/ftp/dists',
210 'dgit-distro.debian.mirror' => 'http://http.debian.net/debian/');
214 my @cmd = (@git, qw(config --), $c);
217 local ($debug) = $debug-1;
218 $v = cmdoutput_errok @cmd;
225 my $dv = $defcfg{$c};
226 return $dv if defined $dv;
231 sub access_distro () {
232 return cfg("dgit-suite.$isuite.distro",
233 "dgit.default.distro");
238 my $distro = access_distro();
239 my $value = cfg(map { ("dgit-distro.$distro.$_",
240 "dgit.default.$_") } @keys);
244 sub access_someuserhost ($) {
246 my $user = access_cfg("$some-user",'username');
247 my $host = access_cfg("$some-host");
248 return defined($user) && length($user) ? "$user\@$host" : $host;
251 sub access_gituserhost () {
252 return access_someuserhost('git');
255 sub access_giturl () {
256 my $url = access_cfg('git-url');
259 access_cfg('git-proto').
260 access_gituserhost().
261 access_cfg('git-path');
263 return "$url/$package.git";
266 sub parsecontrolfh ($$@) {
267 my ($fh, $desc, @opts) = @_;
268 my $c = Dpkg::Control::Hash->new({ 'name' => $desc, @opts });
269 $c->parse($fh) or die "parsing of $desc failed";
273 my ($file, $desc) = @_;
274 my $fh = new IO::File '<', $file or die "$file: $!";
275 my $c = parsecontrolfh($fh,$desc);
276 $fh->error and die $!;
282 my $c = Dpkg::Control::Hash->new();
283 my $p = new IO::Handle;
284 my @cmd = qw(dpkg-parsechangelog);
285 open $p, '-|', @cmd or die $!;
287 $?=0; $!=0; close $p or failedcmd @cmd;
293 sub archive_query ($) {
295 my $query = access_cfg('archive-query');
297 my $distro = access_distro();
298 if ($distro eq 'debian') {
299 $query = "sshdakls:".
300 access_someuserhost('sshdakls').':'.
301 access_cfg('sshdakls-dir');
303 $query = "madison:$distro";
306 $query =~ s/^(\w+):// or badcfg "invalid archive-query method \`$query'";
309 { no strict qw(refs); &{"${method}_${proto}"}($proto,$data); }
312 sub archive_query_madison ($$) {
313 my ($proto,$data) = @_;
314 die unless $proto eq 'madison';
315 $rmad{$package} ||= cmdoutput
316 qw(rmadison -asource),"-s$isuite","-u$data",$package;
317 my $rmad = $rmad{$package};
318 return madison_parse($rmad);
321 sub archive_query_sshdakls ($$) {
322 my ($proto,$data) = @_;
323 $data =~ s/:.*// or badcfg "invalid sshdakls method string \`$data'";
324 my $dakls = cmdoutput
325 access_cfg('ssh'), $data, qw(dak ls -asource),"-s$isuite",$package;
326 return madison_parse($dakls);
329 sub canonicalise_suite_sshdakls ($$) {
330 my ($proto,$data) = @_;
331 $data =~ m/:/ or badcfg "invalid sshdakls method string \`$data'";
333 access_cfg('ssh'), $`,
335 " if test -h $isuite; then readlink $isuite; exit 0; fi;".
336 " if test -d $isuite; then echo $isuite; exit 0; fi;".
338 my $dakls = cmdoutput @cmd;
339 failedcmd @cmd unless $dakls =~ m/^\w/;
343 sub madison_parse ($) {
348 $rmad =~ m{^ \s*( [^ \t|]+ )\s* \|
349 \s*( [^ \t|]+ )\s* \|
350 \s*( [^ \t|/]+ )(?:/([^ \t|/]+))? \s* \|
351 \s*( [^ \t|]+ )\s* }x or die "$rmad $?";
352 $1 eq $package or die "$rmad $package ?";
359 $component = access_cfg('archive-query-default-component');
361 $5 eq 'source' or die "$rmad ?";
362 my $prefix = substr($package, 0, $package =~ m/^l/ ? 4 : 1);
363 my $subpath = "/pool/$component/$prefix/$package/${package}_$vsn.dsc";
364 return ($vsn,$subpath,$newsuite);
367 sub canonicalise_suite_madison ($$) {
368 my @r = archive_query_madison($_[0],$_[1]);
370 "unable to canonicalise suite using package $package".
371 " which does not appear to exist in suite $suite;".
372 " --existing-package may help";
376 sub canonicalise_suite () {
377 $csuite = archive_query('canonicalise_suite');
378 if ($isuite ne $csuite) {
379 # madison canonicalises for us
380 print "canonical suite name for $isuite is $csuite\n";
384 sub get_archive_dsc () {
385 my ($vsn,$subpath) = archive_query('archive_query');
386 canonicalise_suite();
387 if (!defined $vsn) { $dsc=undef; return undef; }
388 $dscurl = access_cfg('mirror').$subpath;
389 $dscdata = url_get($dscurl);
390 my $dscfh = new IO::File \$dscdata, '<' or die $!;
391 print DEBUG Dumper($dscdata) if $debug>1;
392 $dsc = parsecontrolfh($dscfh,$dscurl, allow_pgp=>1);
393 print DEBUG Dumper($dsc) if $debug>1;
394 my $fmt = $dsc->{Format};
395 fail "unsupported source format $fmt, sorry" unless $format_ok{$fmt};
398 sub check_for_git () {
400 my $how = access_cfg('git-check');
401 if ($how eq 'ssh-cmd') {
403 (access_cfg('ssh'),access_gituserhost(),
404 " set -e; cd ".access_cfg('git-path').";".
405 " if test -d $package.git; then echo 1; else echo 0; fi");
406 my $r= cmdoutput @cmd;
407 failedcmd @cmd unless $r =~ m/^[01]$/;
410 badcfg "unknown git-check \`$how'";
414 sub create_remote_git_repo () {
415 my $how = access_cfg('git-create');
416 if ($how eq 'ssh-cmd') {
418 (access_cfg('ssh'),access_gituserhost(),
419 "set -e; cd ".access_cfg('git-path').";".
420 " mkdir -p $package.git;".
422 " if ! test -d objects; then git init --bare; fi");
424 badcfg "unknown git-create \`$how'";
428 our ($dsc_hash,$upload_hash);
430 our $ud = '.git/dgit/unpack';
438 sub mktree_in_ud_from_only_subdir () {
439 # changes into the subdir
442 $dirs[0] =~ m#^([^/]+)/\.$# or die;
444 chdir $dir or die "$dir $!";
446 die $! unless $!==&ENOENT;
447 runcmd qw(git init -q);
448 rmtree('.git/objects');
449 symlink '../../../../objects','.git/objects' or die $!;
450 runcmd @git, qw(add -Af);
451 my $tree = cmdoutput @git, qw(write-tree);
452 $tree =~ m/^\w+$/ or die "$tree ?";
458 m/^\w+ \d+ (\S+)$/ or
459 fail "could not parse .dsc Files/Checksums line \`$_'";
461 } grep m/\S/, split /\n/, ($dsc->{'Checksums-Sha256'} || $dsc->{Files});
464 sub is_orig_file ($) {
466 m/\.orig(?:-\w+)?\.tar\.\w+$/;
469 sub make_commit ($) {
471 return cmdoutput @git, qw(hash-object -w -t commit), $file;
474 sub generate_commit_from_dsc () {
478 foreach my $f (dsc_files()) {
479 die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
481 link "../../../$f", $f
485 runcmd @dget, qw(--), $dscurl;
486 foreach my $f (grep { is_orig_file($_) } @files) {
487 link $f, "../../../../$f"
491 my ($tree,$dir) = mktree_in_ud_from_only_subdir();
492 runcmd qw(sh -ec), 'dpkg-parsechangelog >../changelog.tmp';
493 my $clogp = parsecontrol('../changelog.tmp',"commit's changelog");
494 my $date = cmdoutput qw(date), '+%s %z', qw(-d),$clogp->{Date};
495 my $author = $clogp->{Maintainer};
496 $author =~ s#,.*##ms;
497 my $authline = "$author $date";
498 $authline =~ m/^[^<>]+ \<\S+\> \d+ [-+]\d+$/ or
499 fail "unexpected commit author line format \`$authline'".
500 " (was generated from changelog Maintainer field)";
501 open C, ">../commit.tmp" or die $!;
502 print C <<END or die $!;
509 # imported from the archive
512 my $outputhash = make_commit qw(../commit.tmp);
513 print "synthesised git commit from .dsc $clogp->{Version}\n";
515 runcmd @git, qw(reset --hard), $upload_hash;
516 runcmd qw(sh -ec), 'dpkg-parsechangelog >>../changelogold.tmp';
517 my $oldclogp = parsecontrol('../changelogold.tmp','previous changelog');
519 version_compare_string($oldclogp->{Version}, $clogp->{Version});
521 # git upload/ is earlier vsn than archive, use archive
522 open C, ">../commit2.tmp" or die $!;
523 print C <<END or die $!;
530 Record $package ($clogp->{Version}) in archive suite $csuite
532 $outputhash = make_commit qw(../commit2.tmp);
533 } elsif ($vcmp > 0) {
534 print STDERR <<END or die $!;
535 Version actually in archive: $clogp->{Version} (older)
536 Last allegedly pushed/uploaded: $oldclogp->{Version} (newer or same)
537 Perhaps the upload is stuck in incoming. Using the version from git.
539 $outputhash = $upload_hash;
540 } elsif ($outputhash ne $upload_hash) {
541 fail "version in archive ($clogp->{Version})".
542 " is same as version in git".
543 " to-be-uploaded (upload/) branch ($oldclogp->{Version})".
544 " but archive version hash no commit hash?!";
547 chdir '../../../..' or die $!;
548 runcmd @git, qw(update-ref -m),"dgit fetch import $clogp->{Version}",
549 'DGIT_ARCHIVE', $outputhash;
550 cmdoutput @git, qw(log -n2), $outputhash;
551 # ... gives git a chance to complain if our commit is malformed
556 sub ensure_we_have_orig () {
557 foreach my $f (dsc_files()) {
558 next unless is_orig_file($f);
560 die "$f ?" unless -f _;
562 die "$f $!" unless $!==&ENOENT;
564 my $origurl = $dscurl;
565 $origurl =~ s{/[^/]+$}{};
567 die "$f ?" unless $f =~ m/^${package}_/;
568 die "$f ?" if $f =~ m#/#;
569 runcmd_ordryrun qw(sh -ec),'cd ..; exec "$@"','x',
575 return cmdoutput @git, qw(rev-parse), "$_[0]~0";
578 sub is_fast_fwd ($$) {
579 my ($ancestor,$child) = @_;
580 my $mb = cmdoutput @git, qw(merge-base), $ancestor, $child;
581 return rev_parse($mb) eq rev_parse($ancestor);
584 sub git_fetch_us () {
585 badusage "cannot dry run with fetch" if $dryrun;
586 runcmd @git, qw(fetch),access_giturl(),fetchspec();
589 sub fetch_from_archive () {
590 # ensures that lrref() is what is actually in the archive,
592 get_archive_dsc() or return 0;
593 $dsc_hash = $dsc->{$ourdscfield};
594 if (defined $dsc_hash) {
595 $dsc_hash =~ m/\w+/ or fail "invalid hash in .dsc \`$dsc_hash'";
597 print "last upload to archive specified git hash\n";
599 print "last upload to archive has NO git hash\n";
602 my $lrref_fn = ".git/".lrref();
603 if (open H, $lrref_fn) {
606 die "$lrref_fn $upload_hash ?" unless $upload_hash =~ m/^\w+$/;
607 } elsif ($! == &ENOENT) {
612 print DEBUG "previous reference hash $upload_hash\n";
614 if (defined $dsc_hash) {
615 fail "missing git history even though dsc has hash -"
616 " could not find commit $dsc_hash"
617 " (should be in ".access_giturl()."#".rref().")";
620 ensure_we_have_orig();
622 $hash = generate_commit_from_dsc();
624 print DEBUG "current hash $hash\n";
626 fail "not fast forward on last upload branch!".
627 " (archive's version left in DGIT_ARCHIVE)"
628 unless is_fast_fwd($upload_hash, $hash);
630 if ($upload_hash ne $hash) {
631 my @upd_cmd = (@git, qw(update-ref -m), 'dgit fetch', lrref(), $hash);
635 dryrun_report @upd_cmd;
643 canonicalise_suite();
644 badusage "dry run makes no sense with clone" if $dryrun;
645 mkdir $dstdir or die "$dstdir $!";
646 chdir "$dstdir" or die "$dstdir $!";
647 runcmd @git, qw(init -q);
648 runcmd @git, qw(config), "remote.$remotename.fetch", fetchspec();
649 open H, "> .git/HEAD" or die $!;
650 print H "ref: ".lref()."\n" or die $!;
652 runcmd @git, qw(remote add), 'origin', access_giturl();
653 if (check_for_git()) {
654 print "fetching existing git history\n";
656 runcmd @git, qw(fetch origin);
658 print "starting new git history\n";
660 fetch_from_archive() or no_such_package;
661 runcmd @git, qw(reset --hard), lrref();
662 printdone "ready for work in $dstdir";
666 if (check_for_git()) {
669 fetch_from_archive() or no_such_package();
670 printdone "fetched into ".lrref();
675 runcmd_ordryrun @git, qw(merge -m),"Merge from $csuite [dgit]",
677 printdone "fetched to ".lrref()." and merged into HEAD";
680 sub check_not_dirty () {
681 runcmd @git, qw(diff --quiet);
684 sub commit_quilty_patch ($) {
686 my $output = cmdoutput @git, qw(status --porcelain);
687 my %fixups = map {$_=>1}
688 (".pc/debian-changes-$vsn/","debian/patches/debian-changes-$vsn");
690 foreach my $l (split /\n/, $output) {
691 next unless $l =~ s/^\?\? //;
692 next unless $fixups{$l};
695 print DEBUG "checking for quilty\n", Dumper(\@files);
697 my $m = "Commit Debian 3.0 (quilt) metadata";
699 runcmd_ordryrun @git, qw(add), @files;
700 runcmd_ordryrun @git, qw(commit -m), $m;
705 print DEBUG "actually entering push\n";
706 my $clogp = parsechangelog();
707 $package = $clogp->{Source};
708 my $dscfn = "${package}_$clogp->{Version}.dsc";
710 fail "looked for .dsc $dscfn, but $!;".
711 " maybe you forgot to build";
712 $dsc = parsecontrol("../$dscfn","$dscfn");
713 print DEBUG "format $dsc->{Format}\n";
714 if ($dsc->{Format} eq '3.0 (quilt)') {
715 print "Format \`$dsc->{Format}', urgh\n";
716 commit_quilty_patch($dsc->{Version});
721 print "checking that $dscfn corresponds to HEAD\n";
722 runcmd qw(dpkg-source -x --), "../../../../$dscfn";
723 my ($tree,$dir) = mktree_in_ud_from_only_subdir();
724 chdir '../../../..' or die $!;
725 printcmd \@DEBUG,"+",@_;
726 my @diffcmd = (@git, qw(diff --exit-code), $tree);
728 if (system @diffcmd) {
730 fail "$dscfn specifies a different tree to your HEAD commit;".
731 " perhaps you forgot to build";
737 #do fast forward check and maybe fake merge
738 # if (!is_fast_fwd(mainbranch
739 # runcmd @git, qw(fetch -p ), "$alioth_git/$package.git",
740 # map { lref($_).":".rref($_) }
742 $dsc->{$ourdscfield} = rev_parse('HEAD');
743 $dsc->save("../$dscfn.tmp") or die $!;
745 rename "../$dscfn.tmp","../$dscfn" or die "$dscfn $!";
747 print "[new .dsc left in $dscfn.tmp]\n";
750 my $pat = "${package}_$clogp->{Version}_*.changes";
751 my @cs = glob "../$pat";
752 fail "failed to find unique changes file".
753 " (looked for $pat in ..); perhaps you need to use dgit -C"
755 ($changesfile) = @cs;
757 my $tag = debiantag($dsc->{Version});
758 if (!check_for_git()) {
759 create_remote_git_repo();
761 runcmd_ordryrun @git, qw(push),access_giturl(),"HEAD:".rrref();
763 my @tag_cmd = (@git, qw(tag -s -m),
764 "Release $dsc->{Version} for $csuite [dgit]");
765 push @tag_cmd, qw(-u),$keyid if defined $keyid;
767 runcmd_ordryrun @tag_cmd;
768 my @debsign_cmd = @debsign;
769 push @debsign_cmd, "-k$keyid" if defined $keyid;
770 push @debsign_cmd, $changesfile;
771 runcmd_ordryrun @debsign_cmd;
773 runcmd_ordryrun @git, qw(push),access_giturl(),"refs/tags/$tag";
774 my $host = access_cfg('upload-host');
775 my @hostarg = defined($host) ? ($host,) : ();
776 runcmd_ordryrun @dput, @hostarg, $changesfile;
777 printdone "pushed and uploaded $dsc->{Version}";
783 badusage "-p is not allowed with clone; specify as argument instead"
787 } elsif (@ARGV==2 && $ARGV[1] =~ m#^\w#) {
788 ($package,$isuite) = @ARGV;
789 } elsif (@ARGV==2 && $ARGV[1] =~ m#^[./]#) {
790 ($package,$dstdir) = @ARGV;
792 ($package,$isuite,$dstdir) = @ARGV;
794 badusage "incorrect arguments to dgit clone";
796 $dstdir ||= "$package";
801 my $branch = cmdoutput_errok @git, qw(symbolic-ref HEAD);
802 if ($branch =~ m#$lbranch_re#o) {
809 sub fetchpullargs () {
810 if (!defined $package) {
811 my $sourcep = parsecontrol('debian/control','debian/control');
812 $package = $sourcep->{Source};
815 # $isuite = branchsuite(); # this doesn't work because dak hates canons
817 my $clogp = parsechangelog();
818 $isuite = $clogp->{Distribution};
820 canonicalise_suite();
821 print "fetching from suite $csuite\n";
824 canonicalise_suite();
826 badusage "incorrect arguments to dgit fetch or dgit pull";
844 badusage "-p is not allowed with dgit push" if defined $package;
845 runcmd @git, qw(diff --quiet HEAD);
846 my $clogp = parsechangelog();
847 $package = $clogp->{Source};
849 $isuite = $clogp->{Distribution};
851 local ($package) = $existing_package; # this is a hack
852 canonicalise_suite();
855 badusage "incorrect arguments to dgit push";
857 if (fetch_from_archive()) {
858 is_fast_fwd(lrref(), 'HEAD') or die;
860 fail "package appears to be new in this suite;".
861 " if this is intentional, use --new";
867 # we pass further options and args to git-buildpackage
868 badusage "-p is not allowed with dgit build" if defined $package;
869 my $clogp = parsechangelog();
870 $isuite = $clogp->{Distribution};
871 $package = $clogp->{Source};
873 (qw(git-buildpackage -us -uc --git-no-sign-tags),
874 '--git-builder=dpkg-buildpackage -i\.git/ -I.git');
875 unless (grep { m/^--git-debian-branch/ } @ARGV) {
876 canonicalise_suite();
877 push @cmd, "--git-debian-branch=".lbranch();
879 runcmd_ordryrun @cmd, @ARGV;
882 sub cmd_quilt_fixup {
883 badusage "incorrect arguments to dgit quilt-fixup";
884 my $clogp = parsechangelog();
885 commit_quilty_patch($clogp->{Version});
891 last unless $ARGV[0] =~ m/^-/;
895 if (m/^--dry-run$/) {
897 } elsif (m/^--no-sign$/) {
899 } elsif (m/^--help$/) {
901 } elsif (m/^--new$/) {
903 } elsif (m/^--(\w+)=(.*)/s && ($om = $opts_opt_map{$1})) {
905 } elsif (m/^--(\w+):(.*)/s && ($om = $opts_opt_map{$1})) {
907 } elsif (m/^--existing-package=(.*)/s) {
908 $existing_package = $1;
910 badusage "unknown long option \`$_'";
919 open DEBUG, ">&STDERR" or die $!;
923 } elsif (s/^-c(.*=.*)//s) {
925 } elsif (s/^-C(.*)//s) {
927 } elsif (s/^-k(.*)//s) {
930 badusage "unknown short option \`$_'";
938 print STDERR "DRY RUN ONLY\n" if $dryrun;
940 print STDERR $helpmsg or die $!;
943 my $cmd = shift @ARGV;
945 { no strict qw(refs); &{"cmd_$cmd"}(); }