From 5616b78952e95f848c30600f23ca34db0bd4148b Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 24 Aug 2013 14:42:02 +0100 Subject: New cleaning arrangements (wip). --- debian/changelog | 6 ++++++ dgit | 61 ++++++++++++++++++++++++++++++++++++++++++++----------- dgit.1 | 62 +++++++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 110 insertions(+), 19 deletions(-) diff --git a/debian/changelog b/debian/changelog index 87d00e1..50bcfe9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +dgit (0.9) unstable; urgency=low + + * New cleaning arrangements (wip). + + -- + dgit (0.8) unstable; urgency=low * Fix comparison of archive's .dsc's hash and git branch head diff --git a/dgit b/dgit index 4792c53..37b235b 100755 --- a/dgit +++ b/dgit @@ -37,7 +37,7 @@ our $dryrun = 0; our $changesfile; our $new_package = 0; our $existing_package = 'dpkg'; -our $build_use_dpkgbuildpackage = 0; +our $clean = 'dpkg-source'; our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)"); @@ -48,8 +48,9 @@ our (@debsign) = qw(debsign); our (@sbuild) = qw(sbuild -A); our (@dpkgbuildpackage) = qw(dpkg-buildpackage -i\.git/ -I.git); our (@dpkgsource) = qw(dpkg-source -i\.git/ -I.git); +our (@dpkggenchanges) = qw(dpkg-genchanges); our (@mergechanges) = qw(mergechanges -f); - +our (@changesopts) = (''); our %opts_opt_map = ('dget' => \@dget, 'dput' => \@dput, @@ -57,6 +58,8 @@ our %opts_opt_map = ('dget' => \@dget, 'sbuild' => \@sbuild, 'dpkg-source' => \@dpkgsource, 'dpkg-buildpackage' => \@dpkgbuildpackage, + 'dpkg-genchanges' => \@dpkggenchanges, + 'ch' => \@changesopts, 'mergechanges' => \@mergechanges); our $keyid; @@ -82,6 +85,8 @@ sub debiantag ($) { sub dscfn ($) { return "${package}_$_[0].dsc"; } +sub changesopts () { return @changesopts[1..$#changesopts]; } + our $us = 'dgit'; sub fail { die "$us: @_\n"; } @@ -958,6 +963,7 @@ sub cmd_push { sub cmd_build { # we pass further options and args to git-buildpackage badusage "-p is not allowed with dgit build" if defined $package; + badusage "dgit build implies --clean=dpkg-source" if defined $package; my $clogp = parsechangelog(); $isuite = getfield $clogp, 'Distribution'; $package = getfield $clogp, 'Source'; @@ -968,22 +974,33 @@ sub cmd_build { canonicalise_suite(); push @cmd, "--git-debian-branch=".lbranch(); } + push @cmd, changesopts(); runcmd_ordryrun @cmd, @ARGV; printdone "build successful\n"; } -sub cmd_sbuild { +our $version; +our $sourcechanges; +our $dscfn; + +sub build_source { check_not_dirty(); - badusage "-p is not allowed with dgit sbuild" if defined $package; + badusage "-p is not allowed with this action" if defined $package; my $clogp = parsechangelog(); $package = getfield $clogp, 'Source'; my $isuite = getfield $clogp, 'Distribution'; - my $version = getfield $clogp, 'Version'; - my $sourcechanges = "${package}_${version}_source.changes"; - my $dscfn = dscfn($version); - if ($build_use_dpkgbuildpackage) { - runcmd_ordryrun (@dpkgbuildpackage, qw(-us -uc -S)); + $version = getfield $clogp, 'Version'; + $sourcechanges = "${package}_${version}_source.changes"; + $dscfn = dscfn($version); + if ($cleanmode eq 'dpkg-source') { + runcmd_ordryrun (@dpkgbuildpackage, qw(-us -uc -S)), changesopts(); } else { + if ($cleanmode eq 'git') { + runcmd_ordryrun @git, qw(clean -xdf); + } elsif ($cleanmode eq 'none') { + } else { + die "$cleanmode ?"; + } my $pwd = cmdoutput qw(env - pwd); my $leafdir = basename $pwd; chdir ".." or die $!; @@ -992,8 +1009,18 @@ sub cmd_sbuild { runcmd_ordryrun qw(sh -ec), 'exec >$1; shift; exec "$@"','x', $sourcechanges, - qw(dpkg-genchanges -S); + @dpkggenchanges, qw(-S), changesopts(); } +} + +sub cmd_build_source { + badusage "build-source takes no additional arguments" if @ARGV; + build_source(); + printdone "source built, results in $dscfn and $sourcechanges"; +} + +sub cmd_sbuild { + build_source(); chdir ".." or die $!; my $pat = "${package}_${version}_*.changes"; if (!$dryrun) { @@ -1034,14 +1061,21 @@ sub parseopts () { helponly(); } elsif (m/^--new$/) { $new_package=1; - } elsif (m/^--(\w+)=(.*)/s && ($om = $opts_opt_map{$1})) { + } elsif (m/^--(\w+)=(.*)/s && + ($om = $opts_opt_map{$1}) && + length $om->[0]) { $om->[0] = $2; - } elsif (m/^--(\w+):(.*)/s && ($om = $opts_opt_map{$1})) { + } elsif (m/^--(\w+):(.*)/s && + ($om = $opts_opt_map{$1})) { push @$om, $2; } elsif (m/^--existing-package=(.*)/s) { $existing_package = $1; } elsif (m/^--distro=(.*)/s) { $idistro = $1; + } elsif (m/^--clean=(dpkg-source|git|none)$/s) { + $cleanmode = $1; + } elsif (m/^--clean=(.*)$/s) { + badusage "unknown cleaning mode \`$1'"; } else { badusage "unknown long option \`$_'"; } @@ -1056,6 +1090,9 @@ sub parseopts () { $debug++; } elsif (s/^-N/-/) { $new_package=1; + } elsif (m/^-[vm]/) { + push @changesopts, $_; + $_ = ''; } elsif (s/^-c(.*=.*)//s) { push @git, '-c', $1; } elsif (s/^-d(.*)//s) { diff --git a/dgit.1 b/dgit.1 index 652ffbb..322bc3b 100644 --- a/dgit.1 +++ b/dgit.1 @@ -12,7 +12,7 @@ dgit \- git integration with the Debian archive [\fIsuite\fP] .br .B dgit -[\fIdgit\-opts\fP] \fBbuild\fP|\fBsbuild\fP +[\fIdgit\-opts\fP] \fBbuild\fP|\fBsbuild\fP|\fBbuild-source\fP [\fIbuild\-opts\fp] .br .B dgit @@ -33,9 +33,10 @@ as which lives outside the Debian archive (currently, on Alioth). The usual workflow is: 1. clone or fetch; 2. make and commit changes -in git as desired; 3. run dgit build or dgit sbuild, or generate the -source and binary packages for upload some other way; 4. do -pre-upload tests of the proposed upload; 5. run dgit push. +in git as desired; 3. run dgit build, dgit sbuild or dgit +build-source, or generate the source and binary packages for upload +some other way; 4. do pre-upload tests of the proposed upload; 5. run +dgit push. .TP \fBdgit clone\fR \fIpackage\fP [\fIsuite\fP] [\fB./\fP\fIdir|\fB/\fP\fIdir\fR] Consults the archive and dgit-repos to construct the git view of @@ -86,7 +87,22 @@ with some suitable options. Options and argumments after build will be passed on to git-buildpackage. It is not necessary to use dgit build when using dgit; it is OK to use any approach which ensures that the generated source package corresponds to the relevant git -commit. Tagging and signing should be left to dgit push. +commit. + +.B NB +that this function will be changed in the future to use +dpkg-buildpackage directly. + +Tagging, signing and actually uploading should be left to dgit push. +.TP +\fBdgit build-source\fR ... +Builds the source package, and a changes file for a prospective +source-only upload. The output is left in +.IR package \fB_\fR version \fB.dsc\fR +and +.IR package \fB_\fR version \fB_source.changes\fR. + +Tagging, signing and actually uploading should be left to dgit push. .TP \fBdgit sbuild\fR ... Constructs the source package, and uses sbuild to do a binary @@ -96,6 +112,8 @@ to sbuild. Changes files matching .IB package _ version _*.changes in the parent directory will be removed; the output is left in .IR package \fB_\fR version \fB_multi.changes\fR. + +Tagging, signing and actually uploading should be left to dgit push. .TP .B dgit push Does an `upload', pushing the current HEAD to the archive (as a source @@ -288,6 +306,21 @@ Specifies that we should process source package rather than looking in debian/control or debian/changelog. Valid with dgit fetch and dgit pull, only. .TP +.BR --clean=git | -wg +The source tree should be cleaned, before building a source package +with one of the build options, using +.BR "git clean -xdf" . +This will delete all files which are not tracked by git. +.TP +.BR --clean=none | -wn +Do not clean the tree before building a source package. If there are +files which are not in git, a subsequent dgit push will fail. +.TP +.BR --clean=dpkg-source | -wd +Use dpkg-buildpackage to do the build, so that the source package +is cleaned by dpkg-source running the package's clean target. +This is the default. It requires the package's build dependencies. +.TP .BR -N | --new The package may be new in this suite. Without this, dgit will refuse to push. @@ -300,26 +333,41 @@ more output (currently, up to -DD is meaningfully different). Specifies a git configuration option. dgit itself is also controlled by git configuration options. .TP +.RI \fB-v\fR version |\fB-m\fR maintaineraddress +Passed to dpkg-genchanges (eventually). +.TP +.RI \fB--ch:\fR option +Specifies a single additional option to pass, eventually, to +dpkg-genchanges. +.TP .RI \fB--dget=\fR program |\fB--dput=\fR program |... Specifies alternative programs to use instead of .BR dget , .BR dput , .BR debsign , -.BR dpkg-buildpackage +.BR dpkg-source , +.BR dpkg-buildpackage , +.BR dpkg-genchanges , .BR sbuild , or .BR mergechanges . +This applies only when the program is invoked directly by dgit. .TP .RI \fB--dget:\fR option |\fB--dput:\fR option |... Specifies a single additional option to pass to .BR dget , .BR dput , .BR debsign , -.BR dpkg-buildpackage +.BR dpkg-source , +.BR dpkg-buildpackage , +.BR dpkg-genchanges , .BR sbuild , or .BR mergechanges . Can be repeated as necessary. +This applies only when the program is invoked directly by dgit. +Usually, for passing options to dpkg-genchanges, use +.BR --ch: \fIoption\fR. .TP .BR -d "\fIdistro\fR | " --distro= \fIdistro\fR Specifies that the suite to be operated on is part of distro -- cgit v1.2.3