summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2022-09-03 16:47:27 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2022-09-03 18:12:46 +0100
commit7d1f26b2a495bfa381fb5f07e26326b5265448ac (patch)
treec1386f089296d7c210b4938d99c4b9f9ecb445e6
parentc6b038dc1eb90162f58cbebf62b8849d5b38ad18 (diff)
dgit: quilt fixup: Don't use dpkg-source --commit, but git diff
There are many things that dpkg-source can successfully extract, but which it can't create. (This is because dpkg-source largely delegates application to diff(1), and diff can do many more things nowadays.) Most real packages were made with git-format-patch or equivalent nowadays, so use of these features is common. (Hence #949675 and #995056, where even glibc has patches that dpkg-source cannot make.) Right now the practical consequences are: * Creating an executable file is fixed. This actually completes the work for #949675. * Creating a symlink has a regression in the error handling. Previously, dpkg-source --commit failed during quilt fixup. Now, we happily git diff which generates a patch that dpkg-source can't apply. We're going to fix this soon by aligning the representable change checking with reality. * It's faster and less complicated. Closes: #1018143 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rwxr-xr-xdgit58
-rwxr-xr-xtests/tests/unrepresentable4
2 files changed, 18 insertions, 44 deletions
diff --git a/dgit b/dgit
index 0468ac1..5cf5fec 100755
--- a/dgit
+++ b/dgit
@@ -5389,8 +5389,9 @@ sub quiltify_make_dpkg_patch ($$$$$;$) {
$xinfo //= '';
mkpath '.git/dgit'; # we are in playtree
- my $descfn = ".git/dgit/quilt-description.tmp";
- open O, '>', $descfn or confess "$descfn: $!";
+ my $patchfn = "debian/patches/$patchname";
+ ensuredir dirname $patchfn;
+ open O, '>', $patchfn or confess "$patchfn: $!";
$msg =~ s/\n+/\n\n/;
print O <<END or confess "$!";
From: $author
@@ -5400,12 +5401,14 @@ ${xinfo}Subject: $msg
END
close O or confess "$!";
- {
- local $ENV{'EDITOR'} = cmdoutput qw(realpath --), $0;
- local $ENV{'VISUAL'} = $ENV{'EDITOR'};
- local $ENV{$fakeeditorenv} = cmdoutput qw(realpath --), $descfn;
- runcmd @dpkgsource, qw(--commit --include-removal .), $patchname;
- }
+ my @diffcmd = (@git, qw(diff --no-ext-diff), $oldtreeish, $newtreeish,
+ '--', ':!/debian', ':!/.pc');
+ runcmd qw(sh -ec), 'exec >>"$1"; shift; exec "$@"', 'x', $patchfn,
+ @diffcmd;
+
+ open S, ">> debian/patches/series" or confess "$!";
+ print S "$patchname\n" or confess "$!";
+ close S or confess "$!";
}
sub quiltify_trees_differ ($$;$$$) {
@@ -5891,13 +5894,6 @@ sub quiltify ($$$$) {
$!==ENOENT or confess "$patchname$index $!";
runcmd @git, qw(checkout -q), $cc;
-
- # We use the tip's changelog so that dpkg-source doesn't
- # produce complaining messages from dpkg-parsechangelog. None
- # of the information dpkg-source gets from the changelog is
- # actually relevant - it gets put into the original message
- # which dpkg-source provides our stunt editor, and then
- # overwritten.
runcmd @git, qw(checkout -q), $target, qw(debian/changelog);
quiltify_make_dpkg_patch
@@ -6239,44 +6235,22 @@ sub quilt_fixup_multipatch ($$$) {
# - 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
+ # git commit into a quilt patch, simulating 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:
+ # So we need to find out what the tree for the tip of the patch
+ # stack is.
# 1. Collect all relevant .orig from parent directory
# 2. Generate a debian.tar.gz out of
# debian/{patches,rules,source/format,source/options}
# 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
+ # Then we can actually do the fake dpkg-source --commit.
# Another situation we may have to cope with is gbp-style
# patches-unapplied trees.
@@ -6359,7 +6333,7 @@ END
my $mustdeletepc=0;
if (stat_exists ".pc") {
-d _ or die;
- progress __ "Tree already contains .pc - will use it then delete it.";
+ progress __ "Tree already contains .pc - will delete it.";
$mustdeletepc=1;
} else {
rename '../fake/.pc','.pc' or confess "$!";
diff --git a/tests/tests/unrepresentable b/tests/tests/unrepresentable
index c9ba11c..fa1f985 100755
--- a/tests/tests/unrepresentable
+++ b/tests/tests/unrepresentable
@@ -115,7 +115,7 @@ finish EP:'deletion of symlink' LATE-EP:'Mode change from 20000 to 000000'
start new
ln -s hi new
git add new
-finish 'new version is symlink' 'new version is symlink'
+finish BUILD:'modifies file work/new through a symlink' 'new version is symlink'
start src.c
git rm src.c
@@ -138,7 +138,7 @@ start newx
echo hi >newx
chmod 755 newx
git add newx
-finish BUILD:'differs .* debian/patches' LATE-EP:'Mode change from 644 to 755'
+finish GOOD:add-755 LATE-EP:'Mode change from 644 to 755'
start nothing
finish NOTHING NOTHING