~ubuntu-branches/debian/wheezy/dpkg/wheezy

« back to all changes in this revision

Viewing changes to scripts/Dpkg/Source/Patch.pm

  • Committer: Bazaar Package Importer
  • Author(s): Guillem Jover, Guillem Jover, Raphaël Hertzog, Jonathan Nieder, Steve Langasek, Mark Hymers, Updated programs translations, Updated man page translations, Updated scripts translations, Updated dselect translations
  • Date: 2011-04-01 23:56:54 UTC
  • Revision ID: james.westby@ubuntu.com-20110401235654-8y800dtb75skfrh7
Tags: 1.16.0
[ Guillem Jover ]
* Use DPKG_MAINTSCRIPT_PACKAGE environment variable as package name on
  dpkg-divert when no --package or --local options have been specified.
* Do not allow versions starting with non-digit when doing strict parsing,
  warn otherwise.
* Update dpkg(1) to note that --status-fd output does not contain newlines
  in error messages anymore (this was fixed in 1.15.0).
* Add a new --status-logger option to dpkg, similar to --status-fd but
  instead invoke the command ourselves and feed the status information
  to its standard input. Suggested by Raphaël Hertzog.
* Add missing space in update-alternative --set-selections output.
* Add missing options to update-alternative --help output.
* Count “conffile name is duplicated” for dpkg-deb warning count summary.
* Improve and clarify strings for translation. Closes: #604914
* Prefix all fatal error messages with “error: ”.
* Do not check presence of update-rc.d in the PATH in dpkg, as it's not
  a program needed for dpkg correct operation.
* Fix dpkg -GEO options on multiple versions of the same packages.
  Closes: #31141
* Propagate --admindir to programs run from maintainer scritpts.
  Closes: #97076
* Do not fail when trying to remove the root directory. This will only
  happen either on distributions where dpkg is a foreign package manager,
  or on artificial dpkg databases.
* Always warn when parsing any package control data which does not have
  an Architecture field except for status and status log files when
  packages are not-installed or half-installed.
* By default reject installing packages w/o an Architecture field. They
  now need --force-architecture, dpkg will still warn about them though.
* Fix build failure when passing --disable-nls to configure.
* Do not segfault on “dpkg -i --no-act”.
* Add missing semicolon to the vsnprintf() compat declaration.
  Thanks to Robert Millan. Closes: #612203
* On install for Ubuntu adjust the i386 GNU cpu name in cputable.
  Thanks to Colin Watson <cjwatson@ubuntu.com>. Closes: #611741
* Sync the info database directory on unpack instead of the temporary
  control information directory, and print the correct pathname on error
  instead of the last file acted on that directory.
* Document in dpkg-query --help output and man page that --list and --show
  arguments are optional.
* Do not read and write the available file unnecessarily.
  Thanks to Michel Lespinasse <walken@zoy.org>. Closes: #397121
* Fix typo in «dpkg-name --overwrite» argument parsing so that it actually
  works at all. Thanks to Ivan Gagis <igagis@gmail.com>. LP: #728708
* Add armhf support to ostable and triplettable. Closes: #594179
* Set the modification time for unpacked symlinks on supported systems.
* Fix undefined value useage in dpkg-genchanges when adding files w/o a
  matching architecture, because they are not present in debian/control,
  this is most commonly the case due to dpkg-distaddfile.
* Terminate immediately on dpkg-divert rename errors instead of propagating
  up the error codes, this improves error reporting and avoids triggering
  leak detectors. Closes: #620380
* When moving a diverted file across filesystems in dpkg-divert, remove
  the source file.

[ Raphaël Hertzog ]
* Fail properly when debian/source/format is empty. Closes: #600854
* Add new deb-src-control(5) manual page documenting the debian/control
  file contained in source packages.
  - it documents the X[SBC]- prefix. Closes: #476335
  - it documents the VCS-* fields too. Closes: #483119
  Thanks to Oxan van Leeuwen <oxan@oxanvanleeuwen.nl> who wrote it
  as part of the Google Code In program.
* Enhance dpkg-shlibdeps to not fail immediatly when a library is not found.
  Instead continue and fail after all problems have been reported. Thanks
  to Chris Baines <cbaines8@gmail.com> for the patch. Closes: #596841
* Fix dpkg-source to not list Debian packaging files as modified
  upstream files in Format "1.0" when unpacking to a non-standard
  directory.
* Apply patch from Colin Watson to let dpkg-buildflags return -O3
  instead of -O2 when building ppc64 packages on Ubuntu. Closes: #612472
* Add new function get_control_path() to Dpkg::Path, it wraps dpkg-query
  --control-path.
* Update dpkg-shlibdeps to be multiarch-ready:
  - use get_control_path() to find symbols/shlibs files
  - parse correctly the output of dpkg --search
* Small fix to support files >2GB in .deb on 64-bit systems. Closes: #616502
  Thanks to Martin Dorey <mdorey@bluearc.com> for the patch.
* dpkg-source now keeps the file ordering in the autogenerated patch when
  regenerating it. Closes: #606080
  Thanks to Colin Watson for the patch.
* dpkg-source now uses a timestamp retrieved from the filesystem when
  resetting the timestamp of patched files so that a time skew when using
  NFS doesn't introduce any inconsistency. Closes: #613023
  Thanks to Jonathan Nieder <jrnieder@gmail.com> for the patch and the
  diagnosis.
* dpkg-source will now remove quilt's .pc directory when --unapply-patches
  is in use. Closes: #591858
* dpkg-source is now a bit less strict when parsing patches:
  - it accepts seeing the same file twice; Closes: #608829
  - it doesn't match on the English text "No newline at end of file" as it
    might be translated in some cases. Closes: #612465
* Improve parser in Dpkg::Control::Hash to not require an empty line
  before the PGP signature. Closes: #617923
  Thanks to Roger Leigh for the initial patch.
* Fix a regression in dpkg-divert where using --rename led to a failure when
  the rename implies crossing file systems. Thanks to Durk Strooisma for
  spotting it.
* Use the correct mtime when installing a file with statoverrides.
  Regression introduced in 1.16.0. LP: #739179
* Remove duplicate word in german translation of dpkg(1). Closes: #616096
* Strip repeated non-significant spaces before and after newlines
  in Uploaders. Closes: #598922
* Ignore whitespaces after options in headers of changelog entries.
  Closes: #605719
* Fix dpkg-source's regression with empty patches (introduced while fixing
  #613023). Closes: #619541

[ Jonathan Nieder ]
* Remove support for use of synchronous sync(2), due to its pernicious
  side-effects and to ease maintenance.
* Clarify that an up-to-date dpkg only needs to be unpacked for
  dpkg-maintscript-helper to work.

[ Steve Langasek ]
* Add new variables to dpkg-architecture, DEB_HOST_MULTIARCH and
  DEB_BUILD_MULTIARCH, that return the "ideal" GNU triplet for each
  architecture which should be used as the path component for library
  installation.

[ Mark Hymers ]
* Add support for Built-Using field. Closes: #619311

[ Updated programs translations ]
* German (Sven Joachim).
* Portuguese (Miguel Figueiredo).
* Spanish (Javier Fernandez-Sanguino).
* Swedish (Peter Krefting).

[ Updated man page translations ]
* German (Helge Kreutzmann).
* Swedish (Peter Krefting).

[ Updated scripts translations ]
* German (Helge Kreutzmann).
* Swedish (Peter Krefting).

[ Updated dselect translations ]
* Spanish (Javier Fernandez-Sanguino).

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
use Dpkg::Gettext;
25
25
use Dpkg::IPC;
26
26
use Dpkg::ErrorHandling;
 
27
use Dpkg::Source::Functions qw(fs_time);
27
28
 
28
29
use POSIX;
29
30
use File::Find;
113
114
            last;
114
115
        } elsif (m/^[-+\@ ]/) {
115
116
            $difflinefound++;
116
 
        } elsif (m/^\\ No newline at end of file$/) {
 
117
        } elsif (m/^\\ /) {
117
118
            warning(_g("file %s has no final newline (either " .
118
119
                       "original or modified version)"), $new);
119
120
        } else {
154
155
        $diff_ignore = sub { return 0 };
155
156
    }
156
157
 
 
158
    my @diff_files;
157
159
    my %files_in_new;
158
160
    my $scan_new = sub {
159
161
        my $fn = (length > length($new)) ? substr($_, length($new) + 1) : '.';
189
191
            if ($opts{'use_dev_null'}) {
190
192
                $label_old = $old_file if $old_file eq '/dev/null';
191
193
            }
192
 
            my $success = $self->add_diff_file($old_file, "$new/$fn",
193
 
                label_old => $label_old,
194
 
                label_new => "$basedir/$fn",
195
 
                %opts);
196
 
 
197
 
            if ($success and ($old_file eq "/dev/null")) {
198
 
                if (not $size) {
199
 
                    warning(_g("newly created empty file '%s' will not " .
200
 
                               "be represented in diff"), $fn);
201
 
                } else {
202
 
                    if ($mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
203
 
                        warning(_g("executable mode %04o of '%s' will " .
204
 
                                   "not be represented in diff"), $mode, $fn)
205
 
                            unless $fn eq 'debian/rules';
206
 
                    }
207
 
                    if ($mode & (S_ISUID | S_ISGID | S_ISVTX)) {
208
 
                        warning(_g("special mode %04o of '%s' will not " .
209
 
                                   "be represented in diff"), $mode, $fn);
210
 
                    }
211
 
                }
212
 
            }
 
194
            push @diff_files, [$fn, $mode, $size, $old_file, "$new/$fn",
 
195
                               $label_old, "$basedir/$fn"];
213
196
        } elsif (-p _) {
214
197
            unless (-p "$old/$fn") {
215
198
                $self->_fail_not_same_type("$old/$fn", "$new/$fn");
235
218
        lstat("$old/$fn") || syserr(_g("cannot stat file %s"), "$old/$fn");
236
219
        if (-f _) {
237
220
            if ($inc_removal) {
238
 
                $self->add_diff_file("$old/$fn", "/dev/null",
239
 
                    label_old => "$basedir.orig/$fn",
240
 
                    label_new => "/dev/null",
241
 
                    %opts);
 
221
                push @diff_files, [$fn, 0, 0, "$old/$fn", "/dev/null",
 
222
                                   "$basedir.orig/$fn", "/dev/null"];
242
223
            } else {
243
224
                warning(_g("ignoring deletion of file %s"), $fn);
244
225
            }
253
234
 
254
235
    find({ wanted => $scan_new, no_chdir => 1 }, $new);
255
236
    find({ wanted => $scan_old, no_chdir => 1 }, $old);
 
237
 
 
238
    if ($opts{"order_from"} and -e $opts{"order_from"}) {
 
239
        my $order_from = Dpkg::Source::Patch->new(
 
240
            filename => $opts{"order_from"});
 
241
        my $analysis = $order_from->analyze($basedir, verbose => 0);
 
242
        my %patchorder;
 
243
        my $i = 0;
 
244
        foreach my $fn (@{$analysis->{"patchorder"}}) {
 
245
            $fn =~ s{^[^/]+/}{};
 
246
            $patchorder{$fn} = $i++;
 
247
        }
 
248
        # 'quilt refresh' sorts files as follows:
 
249
        #   - Any files in the existing patch come first, in the order in
 
250
        #     which they appear in the existing patch.
 
251
        #   - New files follow, sorted lexicographically.
 
252
        # This seems a reasonable policy to follow, and avoids autopatches
 
253
        # being shuffled when they are regenerated.
 
254
        foreach my $diff_file (sort { $a->[0] cmp $b->[0] } @diff_files) {
 
255
            my $fn = $diff_file->[0];
 
256
            $patchorder{$fn} = $i++ unless exists $patchorder{$fn};
 
257
        }
 
258
        @diff_files = sort { $patchorder{$a->[0]} <=> $patchorder{$b->[0]} }
 
259
                      @diff_files;
 
260
    }
 
261
 
 
262
    foreach my $diff_file (@diff_files) {
 
263
        my ($fn, $mode, $size,
 
264
            $old_file, $new_file, $label_old, $label_new) = @$diff_file;
 
265
        my $success = $self->add_diff_file($old_file, $new_file,
 
266
                                           label_old => $label_old,
 
267
                                           label_new => $label_new, %opts);
 
268
        if ($success and
 
269
            $old_file eq "/dev/null" and $new_file ne "/dev/null") {
 
270
            if (not $size) {
 
271
                warning(_g("newly created empty file '%s' will not " .
 
272
                           "be represented in diff"), $fn);
 
273
            } else {
 
274
                if ($mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
 
275
                    warning(_g("executable mode %04o of '%s' will " .
 
276
                               "not be represented in diff"), $mode, $fn)
 
277
                        unless $fn eq 'debian/rules';
 
278
                }
 
279
                if ($mode & (S_ISUID | S_ISGID | S_ISVTX)) {
 
280
                    warning(_g("special mode %04o of '%s' will not " .
 
281
                               "be represented in diff"), $mode, $fn);
 
282
                }
 
283
            }
 
284
        }
 
285
    }
256
286
}
257
287
 
258
288
sub finish {
284
314
sub analyze {
285
315
    my ($self, $destdir, %opts) = @_;
286
316
 
 
317
    $opts{"verbose"} = 1 if not defined $opts{"verbose"};
287
318
    my $diff = $self->get_filename();
288
319
    my %filepatched;
289
320
    my %dirtocreate;
 
321
    my @patchorder;
290
322
    my $diff_count = 0;
291
323
 
292
324
    sub getline {
394
426
        } elsif ($path{'new'} eq '/dev/null') {
395
427
            error(_g("file removal without proper filename in diff `%s' (line %d)"),
396
428
                  $diff, $. - 1) unless defined $fn{'old'};
397
 
            warning(_g("diff %s removes a non-existing file %s (line %d)"),
398
 
                    $diff, $fn{'old'}, $.) unless -e $fn{'old'};
 
429
            if ($opts{"verbose"}) {
 
430
                warning(_g("diff %s removes a non-existing file %s (line %d)"),
 
431
                        $diff, $fn{'old'}, $.) unless -e $fn{'old'};
 
432
            }
399
433
        }
400
434
        my $fn = intuit_file_patched($fn{'old'}, $fn{'new'});
401
435
 
409
443
        }
410
444
 
411
445
        if ($filepatched{$fn}) {
412
 
            error(_g("diff `%s' patches file %s twice"), $diff, $fn);
 
446
            warning(_g("diff `%s' patches file %s twice"), $diff, $fn)
 
447
                if $opts{"verbose"};
 
448
        } else {
 
449
            $filepatched{$fn} = 1;
 
450
            push @patchorder, $fn;
413
451
        }
414
 
        $filepatched{$fn} = 1;
415
452
 
416
453
        # read hunks
417
454
        my $hunk = 0;
418
455
        while (defined($_ = getline($self))) {
419
456
            # read hunk header (@@)
420
 
            next if /^\\ No newline/;
 
457
            next if /^\\ /;
421
458
            last unless (/^@@ -\d+(,(\d+))? \+\d+(,(\d+))? @\@( .*)?$/);
422
459
            my ($olines, $nlines) = ($1 ? $2 : 1, $3 ? $4 : 1);
423
460
            # read hunk
424
461
            while ($olines || $nlines) {
425
462
                unless (defined($_ = getline($self))) {
426
463
                    if (($olines == $nlines) and ($olines < 3)) {
427
 
                        warning(_g("unexpected end of diff `%s'"), $diff);
 
464
                        warning(_g("unexpected end of diff `%s'"), $diff)
 
465
                            if $opts{"verbose"};
428
466
                        last;
429
467
                    } else {
430
468
                        error(_g("unexpected end of diff `%s'"), $diff);
431
469
                    }
432
470
                }
433
 
                next if /^\\ No newline/;
 
471
                next if /^\\ /;
434
472
                # Check stats
435
473
                if    (/^ / || /^$/)  { --$olines; --$nlines; }
436
474
                elsif (/^-/)  { --$olines; }
448
486
    }
449
487
    close($self);
450
488
    unless ($diff_count) {
451
 
        warning(_g("diff `%s' doesn't contain any patch"), $diff);
 
489
        warning(_g("diff `%s' doesn't contain any patch"), $diff)
 
490
            if $opts{"verbose"};
452
491
    }
453
492
    *$self->{'analysis'}{$destdir}{"dirtocreate"} = \%dirtocreate;
454
493
    *$self->{'analysis'}{$destdir}{"filepatched"} = \%filepatched;
 
494
    *$self->{'analysis'}{$destdir}{"patchorder"} = \@patchorder;
455
495
    return *$self->{'analysis'}{$destdir};
456
496
}
457
497
 
501
541
    $self->close();
502
542
    # Reset the timestamp of all the patched files
503
543
    # and remove .dpkg-orig files
504
 
    my $now = $opts{"timestamp"} || time;
505
 
    foreach my $fn (keys %{$analysis->{'filepatched'}}) {
 
544
    my @files = keys %{$analysis->{'filepatched'}};
 
545
    my $now = $opts{"timestamp"};
 
546
    $now ||= fs_time($files[0]) if $opts{"force_timestamp"} and scalar @files;
 
547
    foreach my $fn (@files) {
506
548
        if ($opts{"force_timestamp"}) {
507
549
            utime($now, $now, $fn) || $! == ENOENT ||
508
550
                syserr(_g("cannot change timestamp for %s"), $fn);