summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2014-10-27 17:51:35 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2014-11-08 16:16:42 +0000
commit979ce26f5de342743c7b6fa207cd22c66f55af1d (patch)
treef5c70207374223400053516a76ead47069e030ff
parent25be7c924fe6d7cc12725f54f1f1c78e5981df6f (diff)
Do not have .pc in dgit's git history for format `3.0 (quilt)'
packages. * When constructing a git tree from a .dsc (which we do by unpacking it in a temporary directory), drop any .pc directory. * Rewrite the quilt fixup preparation: we now fake up a .dsc so that we can regenerate the .pc, which is needed by dpkg-source. * If after we have committed any quilt fixup, there is a .pc directory, make a commit removing it. * We now construct new quilt patches in a temporary directory, so there is no problem about ignored files or --ignore-dirty. Remove the mention of this limitation from the manpage. * Be less critical of `3.0 (quilt)' and improve the documentation relating to the interaction between dpkg-source and dgit. Mention git-dpm. * When `committing quilty patches', do not re-add a deleted .pc directory (while still permitting updates to an existing .pc - although the .pc will then disappear in the next commit). * In the test suite, disregard differences found in .pc. * cmd_quilt_fixup sets $package for the benefit of build_maybe_quilt_fixup
-rw-r--r--debian/changelog6
-rwxr-xr-xdgit141
-rw-r--r--dgit.182
-rw-r--r--tests/lib2
4 files changed, 168 insertions, 63 deletions
diff --git a/debian/changelog b/debian/changelog
index 48e3c78..a00153e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,11 @@
dgit (0.23~) unstable; urgency=low
+ * New handling for .pc directory: dgit history now no longer contains
+ .pc at all. It is deleted whenever we find it. (When doing quilt
+ fixup, we recreate a suitable .pc in a temporary directory so that we
+ can do dpkg-source --comit.) Closes:#764606. INCOMPATIBLE CHANGE -
+ older versions of dgit will have trouble with these git histories.
+
* Replace many calls to stat with new wrapper stat_exists; improves
error handling and simplifies the code.
diff --git a/dgit b/dgit
index 97bc187..41a7fe2 100755
--- a/dgit
+++ b/dgit
@@ -30,6 +30,7 @@ use Dpkg::Version;
use POSIX;
use IPC::Open2;
use Digest::SHA;
+use Digest::MD5;
use Config;
our $our_version = 'UNRELEASED'; ###substituted###
@@ -996,6 +997,10 @@ sub mktree_in_ud_from_only_subdir () {
changedir $dir;
fail "source package contains .git directory" if stat_exists '.git';
mktree_in_ud_here();
+ my $format=get_source_format();
+ if (madformat($format)) {
+ rmtree '.pc';
+ }
runcmd @git, qw(add -Af);
my $tree = cmdoutput @git, qw(write-tree);
$tree =~ m/^\w+$/ or die "$tree ?";
@@ -1386,6 +1391,7 @@ sub commit_quilty_patch () {
$adds{$1}++;
}
}
+ delete $adds{'.pc'}; # if there wasn't one before, don't add it
if (!%adds) {
progress "nothing quilty to commit, ok.";
return;
@@ -1408,11 +1414,11 @@ sub get_source_format () {
sub madformat ($) {
my ($format) = @_;
return 0 unless $format eq '3.0 (quilt)';
- progress "Format \`$format', urgh";
if ($noquilt) {
progress "Not doing any fixup of \`$format' due to --no-quilt-fixup";
return 0;
}
+ progress "Format \`$format', checking/updating patch stack";
return 1;
}
@@ -1966,21 +1972,121 @@ sub build_maybe_quilt_fixup () {
my $format=get_source_format;
return unless madformat $format;
# sigh
-
- my @cmd = (@git, qw(ls-files --exclude-standard -iodm));
- my $problems = cmdoutput @cmd;
- if (length $problems) {
- print STDERR "problematic files:\n";
- print STDERR " $_\n" foreach split /\n/, $problems;
- fail "Cannot do quilt fixup in tree containing ignored files. ".
- "Perhaps your package's clean target is broken, in which".
- " case -wg (which says to use git-clean -xdf) may help.";
- }
+
+ # Our objective is:
+ # - honour any existing .pc in case it has any strangeness
+ # - determine the git commit corresponding to the tip of
+ # the patch stack (if there is one)
+ # - if there is such a git commit, convert each subsequent
+ # git commit into a quilt patch with dpkg-source --commit
+ # - otherwise convert all the differences in the tree into
+ # a single git commit
+ #
+ # To do this we:
+
+ # Our git tree doesn't necessarily contain .pc. (Some versions of
+ # dgit would include the .pc in the git tree.) If there isn't
+ # one, we need to generate one by unpacking the patches that we
+ # have.
+ #
+ # We first look for a .pc in the git tree. If there is one, we
+ # will use it. (This is not the normal case.)
+ #
+ # Otherwise need to regenerate .pc so that dpkg-source --commit
+ # can work. We do this as follows:
+ # 1. Collect all relevant .orig from parent directory
+ # 2. Generate a debian.tar.gz out of
+ # debian/{patches,rules,source/format}
+ # 3. Generate a fake .dsc containing just these fields:
+ # Format Source Version Files
+ # 4. Extract the fake .dsc
+ # Now the fake .dsc has a .pc directory.
+ # (In fact we do this in every case, because in future we will
+ # want to search for a good base commit for generating patches.)
+ #
+ # Then we can actually do the dpkg-source --commit
+ # 1. Make a new working tree with the same object
+ # store as our main tree and check out the main
+ # tree's HEAD.
+ # 2. Copy .pc from the fake's extraction, if necessary
+ # 3. Run dpkg-source --commit
+ # 4. If the result has changes to debian/, then
+ # - git-add them them
+ # - git-add .pc if we had a .pc in-tree
+ # - git-commit
+ # 5. If we had a .pc in-tree, delete it, and git-commit
+ # 6. Back in the main tree, fast forward to the new HEAD
my $clogp = parsechangelog();
- my $version = getfield $clogp, 'Version';
- my $author = getfield $clogp, 'Maintainer';
my $headref = rev_parse('HEAD');
+
+ prep_ud();
+ changedir $ud;
+
+ my $upstreamversion=$version;
+ $upstreamversion =~ s/-[^-]*$//;
+
+ my $fakeversion="$upstreamversion-~~DGITFAKE";
+
+ my $fakedsc=new IO::File 'fake.dsc', '>' or die $!;
+ print $fakedsc <<END or die $!;
+Format: 3.0 (quilt)
+Source: $package
+Version: $fakeversion
+Files:
+END
+
+ my $dscaddfile=sub {
+ my ($b) = @_;
+
+ my $md = new Digest::MD5;
+
+ my $fh = new IO::File $b, '<' or die "$b $!";
+ stat $fh or die $!;
+ my $size = -s _;
+
+ $md->addfile($fh);
+ print $fakedsc " ".$md->hexdigest." $size $b\n" or die $!;
+ };
+
+ foreach my $f (<../../../../*>) { #/){
+ my $b=$f; $b =~ s{.*/}{};
+ next unless is_orig_file $b, srcfn $upstreamversion,'';
+ link $f, $b or die "$b $!";
+ $dscaddfile->($b);
+ }
+
+ my @files=qw(debian/source/format debian/rules);
+ if (stat_exists '../../../debian/patches') {
+ push @files, 'debian/patches';
+ }
+
+ my $debtar= srcfn $fakeversion,'.debian.tar.gz';
+ runcmd qw(env GZIP=-1 tar -zcf), "./$debtar", qw(-C ../../..), @files;
+
+ $dscaddfile->($debtar);
+ close $fakedsc or die $!;
+
+ runcmd qw(sh -ec), 'exec dpkg-source --no-check -x fake.dsc >/dev/null';
+
+ my $fakexdir= $package.'-'.(stripepoch $upstreamversion);
+ rename $fakexdir, "fake" or die "$fakexdir $!";
+
+ mkdir "work" or die $!;
+ changedir "work";
+ mktree_in_ud_here();
+ runcmd @git, qw(reset --hard), $headref;
+
+ my $mustdeletepc=0;
+ if (stat_exists ".pc") {
+ -d _ or die;
+ progress "Tree already contains .pc - will use it then delete it.";
+ $mustdeletepc=1;
+ } else {
+ rename '../fake/.pc','.pc' or die $!;
+ }
+
+ my $author = getfield $clogp, 'Maintainer';
my $time = time;
my $ncommits = 3;
my $patchname = "auto-$version-$headref-$time";
@@ -2015,6 +2121,14 @@ END
}
commit_quilty_patch();
+
+ if ($mustdeletepc) {
+ runcmd @git, qw(rm -rq .pc);
+ commit_admin "Commit removal of .pc (quilt series tracking data)";
+ }
+
+ changedir '../../../..';
+ runcmd @git, qw(pull --ff-only -q .git/dgit/unpack/work master);
}
sub quilt_fixup_editor () {
@@ -2169,6 +2283,7 @@ sub cmd_quilt_fixup {
badusage "incorrect arguments to dgit quilt-fixup" if @ARGV;
my $clogp = parsechangelog();
$version = getfield $clogp, 'Version';
+ $package = getfield $clogp, 'Source';
build_maybe_quilt_fixup();
}
diff --git a/dgit.1 b/dgit.1
index 4b27cda..1676bb8 100644
--- a/dgit.1
+++ b/dgit.1
@@ -183,10 +183,11 @@ the invocation host. The build-host needs gnupg installed, with your
public key in its keyring (but not your private key, obviously).
.TP
.B dgit quilt-fixup
-Looks to see if the tree is one which dpkg-source cannot properly
-represent. If it isn't, dgit will fix it up for you (in quilt terms,
-by making a new debian/ patch containing your unquilty changes) and
-make a commit of the changes it has made.
+`3.0 (quilt)' format source packages need changes representing not
+only in-tree but also as patches in debian/patches. dgit quilt-fixup
+checks whether this has been done; if not, dgit will make appropriate
+patches in debian/patches and also commit the resulting changes to
+git.
This is normally done automatically by dgit build and dgit push.
.TP
@@ -244,10 +245,6 @@ Do not complain if the working tree does not match your git HEAD.
This can be useful with build, if you plan to commit later. (dgit
push will still ensure that the .dsc you upload and the git tree
you push are identical, so this option won't make broken pushes.)
-
-This option may not work properly on `3.0 (quilt)' packages, as in
-that case dgit needs to use and perhaps commit parts of your working
-tree.
.TP
.BR --no-quilt-fixup
Do not fix up source format `3.0 (quilt)' metadata. If you use this
@@ -531,44 +528,31 @@ If you are not the maintainer, you do not need to worry about the
source format of the package. You can just make changes as you like
in git. If the package is a `3.0 (quilt)' package, the patch stack
will usually not be represented in the git history.
-
-If you are the maintainer of a non-native package, you currently have
-two sensible options:
-
-Firstly, you can regard your git history as primary, and the archive
-as an export format. For example, you could maintain topic branches
-in git and a fast-forwarding release branch; or you could do your work
-directly in a merging way on the
-.BI dgit/ suite
-branches. If you do this you should probably use a `1.0' format
-source package if you can. In the archive, the delta between upstream
-will be represented in the single Debian patch.
-
-Secondly, you can use `3.0 (quilt)', and regard your quiltish patch
-stack in the archive as primary. You will have to use other tools
-besides dgit to import and export this patch stack. But see below:
.SH FORMAT 3.0 (QUILT)
For a format `3.0 (quilt)' source package, dgit may have to make a
commit on your current branch to contain metadata used by quilt and
dpkg-source.
-This is because (i) the `3.0 (quilt)' source format cannot represent
-certain trees, and (ii) packing up a tree in `3.0 (quilt)' and then
-unpacking it does not always yield the same tree. Instead,
-dpkg-source insists on the trees having extra quilty metadata and
-patch files in the debian/ and .pc/ directories, which dpkg-source
-sometimes modifies.
+This is because `3.0 (quilt)' source format represents the patch stack
+as files in debian/patches/ actually inside the source tree. This
+means that, taking the whole tree (as seen by git or ls) (i)
+dpkg-source cannot represent certain trees, and (ii) packing up a tree
+in `3.0 (quilt)' and then unpacking it does not always yield the same
+tree.
-dgit will automatically work around this braindamage for you when
-building and pushing. The only thing you need to know is that dgit
-build, sbuild, etc., may make a new commit on your HEAD. If you're
-not a quilt user this commit won't contain any changes to files you
-care about.
+dgit will automatically work around this for you when building and
+pushing. The only thing you need to know is that dgit build, sbuild,
+etc., may make new commit (or, very occasionally, two) on your HEAD.
+If you're not a quilt user this commit won't contain any changes to
+files you care about.
You can explicitly request that dgit do just this fixup, by running
dgit quilt-fixup.
-We recommend against the use of `3.0 (quilt)'.
+If you are a quilt user you need to know that dgit's git trees do not
+contain the .pc directory which is used by quilt to record which
+patches are applied. If you want to manipulate the patch stack you
+probably want to be looking at tools like git-dpm.
.SH FILES IN THE SOURCE PACKAGE BUT NOT IN GIT
This section is mainly of interest to maintainers who want to use dgit
with their existing git history for the Debian package.
@@ -698,16 +682,16 @@ Debian Maintainers are currently not able to push, as there is not
currently any mechanism for determining and honouring the archive's
ideas about access control. Currently only DDs can push.
-dgit's representation of format `3.0 (quilt)' source packages does not
-represent the patch stack. Currently the patch series representation
-cannot round trip through the archive. Ideally dgit would represent a
-quilty package with an origin commit of some kind followed by the
-patch stack as a series of commits followed by a pseudo-merge (to make
-the branch fast-forwarding). This would also mean a new `dgit
-rebase-prep' command or some such to turn such a fast-forwarding
-branch back into a rebasing patch stack, and a `force' option to dgit
-push (perhaps enabled automatically by a note left by rebase-prep)
-which will make the required pseudo-merge.
+dgit's git representation of format `3.0 (quilt)' source packages does
+not represent the patch stack as git commits. Currently the patch
+series representation cannot round trip between git and the archive.
+Ideally dgit would represent a quilty package with an origin commit of
+some kind followed by the patch stack as a series of commits followed
+by a pseudo-merge (to make the branch fast-forwarding). This would
+also mean a new `dgit rebase-prep' command or some such to turn such a
+fast-forwarding branch back into a rebasing patch stack, and a `force'
+option to dgit push (perhaps enabled automatically by a note left by
+rebase-prep) which will make the required pseudo-merge.
If the dgit push fails halfway through, it should be restartable and
idempotent. However this is not true for the git tag operation.
@@ -721,11 +705,11 @@ Doing this is made more complicated by the possibility of a `3.0
dgit's build functions, and dgit push, should not make any changes to
your current HEAD. Sadly this is necessary for packages in the `3.0
-(quilt)' source format. This is ultimately due to design problems in
-quilt and dpkg-source.
+(quilt)' source format. This is ultimately due to what I consider
+design problems in quilt and dpkg-source.
There should be an option which arranges for the `3.0 (quilt)'
-autocommit to not appear on your HEAD, but instead only in the
+autocommit(s) to not appear on your HEAD, but instead only in the
remote tracking suite branch.
The option parser requires values to be cuddled to the option name.
diff --git a/tests/lib b/tests/lib
index e17be7f..0133987 100644
--- a/tests/lib
+++ b/tests/lib
@@ -116,7 +116,7 @@ t-dgit () {
}
t-diff-nogit () {
- diff --exclude=.git -ruN $*
+ diff --exclude=.git --exclude=.pc -ruN $*
}
t-cloned-fetched-good () {