Subject: Bug#578864: dpkg-source -b in 3.0 (quilt) package modifies timestamp of, manually changed files

From: Guo Yixuan <[email-masked]>
Date: Sun, 20 May 2012 13:12:47 +0800

Hi Raphael,

On 04/19/2012 06:09 AM, Raphael Hertzog wrote:
> On Wed, 18 Apr 2012, Guo Yixuan wrote:
>> This bug seems to be fixed, as I tried what Timo has done:
>>
>> $ dget http://people.debian.org/~hertzog/packages/debsrc3.0/sample7_1.0-1.dsc
>> $ dpkg-source -x sample*.dsc
>> $ cd sample7-1.0
>
> Here you need to modify upstream/README to actually match the case
> described in this bug report:
> $ echo "foo">>upstream/README
>
>> $ touch -d 1970-01-01 upstream/README
>> $ dpkg-buildpackage -rfakeroot -us -uc
>
> And here, nowadays, you have to allow the change to be automatically recorded:
> $ dpkg-buildpackage -us -uc --source-option=--auto-commit
>
>> $ ls -l upstream/
>> total 4
>> -rw-r--r-- 1 gyx gyx 437 Jan  1  1970 README
>
> And then you can see that it's not fixed:
> $ ls -l upstream/
> total 4
> -rw-r--r-- 1 rhertzog rhertzog 441 avril 19 00:07 README

Thanks for you answer. I looked into dpkg-source and find the code that 
modify timestamp.

In scripts/Dpkg/Source/Package/V3/quilt.pm, sub register_patch, ll. 379-385

     # Ensure quilt meta-data are created and in sync with some trickery:
     # reverse-apply the patch, drop .pc/$patch, re-apply it
     # with the correct options to recreate the backup files
     my $patch_obj = Dpkg::Source::Patch->new(filename => $patch);
     $patch_obj->apply($dir, add_options => ['-R', '-E'], verbose => 0);
     erasedir(File::Spec->catdir($dir, ".pc", $patch_name));
     $self->apply_quilt_patch($dir, $patch_name);

So in order to have correct meta-data for quilt, the debian-changes-* is 
first reverse applied (by patch -R -E), then applied by 
$self->apply_quilt_patch(...). So the timestamp is flushed in the way.

The quilt meta-data just contains the original files that 
debian-changes-* modifies, so there should be a more reasonable way to 
correct these files instead of relying on the unpatch-patch trickery.

Cheers,

Guo Yixuan