diff options
Diffstat (limited to 'scripts/Dpkg/Source/Package/V2.pm')
-rw-r--r-- | scripts/Dpkg/Source/Package/V2.pm | 196 |
1 files changed, 98 insertions, 98 deletions
diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index 4da8bdae2..be1d363a7 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -18,7 +18,7 @@ package Dpkg::Source::Package::V2; use strict; use warnings; -our $VERSION = "0.01"; +our $VERSION = '0.01'; use base 'Dpkg::Source::Package'; @@ -43,7 +43,7 @@ use File::Spec; use File::Find; use File::Copy; -our $CURRENT_MINOR_VERSION = "0"; +our $CURRENT_MINOR_VERSION = '0'; sub init_options { my ($self) = @_; @@ -120,7 +120,7 @@ sub do_extract { my $re_ext = $compression_re_file_ext; foreach my $file ($self->get_files()) { (my $uncompressed = $file) =~ s/\.$re_ext$//; - error(_g("duplicate files in %s source package: %s.*"), "v2.0", + error(_g('duplicate files in %s source package: %s.*'), 'v2.0', $uncompressed) if $seen{$uncompressed}; $seen{$uncompressed} = 1; if ($file =~ /^\Q$basename\E\.orig\.tar\.$re_ext$/) { @@ -130,23 +130,23 @@ sub do_extract { } elsif ($file =~ /^\Q$basenamerev\E\.debian\.tar\.$re_ext$/) { $debianfile = $file; } else { - error(_g("unrecognized file for a %s source package: %s"), - "v2.0", $file); + error(_g('unrecognized file for a %s source package: %s'), + 'v2.0', $file); } } unless ($tarfile and $debianfile) { - error(_g("missing orig.tar or debian.tar file in v2.0 source package")); + error(_g('missing orig.tar or debian.tar file in v2.0 source package')); } erasedir($newdirectory); # Extract main tarball - info(_g("unpacking %s"), $tarfile); + info(_g('unpacking %s'), $tarfile); my $tar = Dpkg::Source::Archive->new(filename => "$dscdir$tarfile"); $tar->extract($newdirectory, no_fixperms => 1, - options => [ "--anchored", "--no-wildcards-match-slash", - "--exclude", "*/.pc", "--exclude", ".pc" ]); + options => [ '--anchored', '--no-wildcards-match-slash', + '--exclude', '*/.pc', '--exclude', '.pc' ]); # The .pc exclusion is only needed for 3.0 (quilt) and to avoid # having an upstream tarball provide a directory with symlinks # that would be blindly followed when applying the patches @@ -154,7 +154,7 @@ sub do_extract { # Extract additional orig tarballs foreach my $subdir (keys %origtar) { my $file = $origtar{$subdir}; - info(_g("unpacking %s"), $file); + info(_g('unpacking %s'), $file); if (-e "$newdirectory/$subdir") { warning(_g("required removal of `%s' installed by original tarball"), $subdir); erasedir("$newdirectory/$subdir"); @@ -167,7 +167,7 @@ sub do_extract { return if $self->{options}{skip_debianization}; # Extract debian tarball after removing the debian directory - info(_g("unpacking %s"), $debianfile); + info(_g('unpacking %s'), $debianfile); erasedir("$newdirectory/debian"); # Exclude existing symlinks from extraction of debian.tar.gz as we # don't want to overwrite something outside of $newdirectory due to a @@ -176,7 +176,7 @@ sub do_extract { my $wanted = sub { return if not -l $_; my $fn = File::Spec->abs2rel($_, $newdirectory); - push @exclude_symlinks, "--exclude", $fn; + push @exclude_symlinks, '--exclude', $fn; }; find({ wanted => $wanted, no_chdir => 1 }, $newdirectory); $tar = Dpkg::Source::Archive->new(filename => "$dscdir$debianfile"); @@ -190,7 +190,7 @@ sub do_extract { } sub get_autopatch_name { - return "zz_debian-diff-auto"; + return 'zz_debian-diff-auto'; } sub get_patches { @@ -200,7 +200,7 @@ sub get_patches { my $pd = "$dir/debian/patches"; my $auto_patch = $self->get_autopatch_name(); if (-d $pd) { - opendir(my $dir_dh, $pd) || syserr(_g("cannot opendir %s"), $pd); + opendir(my $dir_dh, $pd) || syserr(_g('cannot opendir %s'), $pd); foreach my $patch (sort readdir($dir_dh)) { # patches match same rules as run-parts next unless $patch =~ /^[\w-]+$/ and -f "$pd/$patch"; @@ -217,14 +217,14 @@ sub apply_patches { $opts{skip_auto} //= 0; my @patches = $self->get_patches($dir, %opts); return unless scalar(@patches); - my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied"); + my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied'); open(my $applied_fh, '>', $applied) || - syserr(_g("cannot write %s"), $applied); + syserr(_g('cannot write %s'), $applied); print $applied_fh "# During $opts{usage}\n"; my $timestamp = fs_time($applied); foreach my $patch ($self->get_patches($dir, %opts)) { - my $path = File::Spec->catfile($dir, "debian", "patches", $patch); - info(_g("applying %s"), $patch) unless $opts{skip_auto}; + my $path = File::Spec->catfile($dir, 'debian', 'patches', $patch); + info(_g('applying %s'), $patch) unless $opts{skip_auto}; my $patch_obj = Dpkg::Source::Patch->new(filename => $path); $patch_obj->apply($dir, force_timestamp => 1, timestamp => $timestamp, @@ -238,11 +238,11 @@ sub unapply_patches { my ($self, $dir, %opts) = @_; my @patches = reverse($self->get_patches($dir, %opts)); return unless scalar(@patches); - my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied"); + my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied'); my $timestamp = fs_time($applied); foreach my $patch (@patches) { - my $path = File::Spec->catfile($dir, "debian", "patches", $patch); - info(_g("unapplying %s"), $patch) unless $opts{quiet}; + my $path = File::Spec->catfile($dir, 'debian', 'patches', $patch); + info(_g('unapplying %s'), $patch) unless $opts{quiet}; my $patch_obj = Dpkg::Source::Patch->new(filename => $path); $patch_obj->apply($dir, force_timestamp => 1, verbose => 0, timestamp => $timestamp, @@ -253,11 +253,11 @@ sub unapply_patches { sub upstream_tarball_template { my ($self) = @_; - my $ext = "{" . join(",", + my $ext = '{' . join(',', sort map { - compression_get_property($_, "file_ext") - } compression_get_list()) . "}"; - return "../" . $self->get_basename() . ".orig.tar.$ext"; + compression_get_property($_, 'file_ext') + } compression_get_list()) . '}'; + return '../' . $self->get_basename() . ".orig.tar.$ext"; } sub can_build { @@ -265,7 +265,7 @@ sub can_build { return 1 if $self->find_original_tarballs(include_supplementary => 0); return 1 if $self->{options}{create_empty_orig} and $self->find_original_tarballs(include_main => 0); - return (0, sprintf(_g("no upstream tarball found at %s"), + return (0, sprintf(_g('no upstream tarball found at %s'), $self->upstream_tarball_template())); } @@ -276,17 +276,17 @@ sub before_build { sub after_build { my ($self, $dir) = @_; - my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied"); - my $reason = ""; + my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied'); + my $reason = ''; if (-e $applied) { - open(my $applied_fh, "<", $applied) || - syserr(_g("cannot read %s"), $applied); + open(my $applied_fh, '<', $applied) || + syserr(_g('cannot read %s'), $applied); $reason = <$applied_fh>; close($applied_fh); } my $opt_unapply = $self->{options}{unapply_patches}; - if (($opt_unapply eq "auto" and $reason =~ /^# During preparation/) or - $opt_unapply eq "yes") { + if (($opt_unapply eq 'auto' and $reason =~ /^# During preparation/) or + $opt_unapply eq 'yes') { $self->unapply_patches($dir); } } @@ -300,13 +300,13 @@ sub prepare_build { include_timestamp => $self->{options}{include_timestamp}, use_dev_null => 1, }; - push @{$self->{options}{tar_ignore}}, "debian/patches/.dpkg-source-applied"; + push @{$self->{options}{tar_ignore}}, 'debian/patches/.dpkg-source-applied'; $self->check_patches_applied($dir) if $self->{options}{preparation}; if ($self->{options}{create_empty_orig} and not $self->find_original_tarballs(include_supplementary => 0)) { # No main orig.tar, create a dummy one - my $filename = $self->get_basename() . ".orig.tar." . + my $filename = $self->get_basename() . '.orig.tar.' . $self->{options}{comp_ext}; my $tar = Dpkg::Source::Archive->new(filename => $filename); $tar->create(); @@ -316,9 +316,9 @@ sub prepare_build { sub check_patches_applied { my ($self, $dir) = @_; - my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied"); + my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied'); unless (-e $applied) { - info(_g("patches are not applied, applying them now")); + info(_g('patches are not applied, applying them now')); $self->apply_patches($dir, usage => 'preparation'); } } @@ -335,8 +335,8 @@ sub generate_patch { foreach (sort $self->find_original_tarballs()) { if (/\.orig\.tar\.$compression_re_file_ext$/) { if (defined($tarfile)) { - error(_g("several orig.tar files found (%s and %s) but only " . - "one is allowed"), $tarfile, $_); + error(_g('several orig.tar files found (%s and %s) but only ' . + 'one is allowed'), $tarfile, $_); } $tarfile = $_; push @origtarballs, $_; @@ -348,11 +348,11 @@ sub generate_patch { } } - error(_g("no upstream tarball found at %s"), + error(_g('no upstream tarball found at %s'), $self->upstream_tarball_template()) unless $tarfile; - if ($opts{usage} eq "build") { - info(_g("building %s using existing %s"), + if ($opts{usage} eq 'build') { + info(_g('building %s using existing %s'), $self->{fields}{'Source'}, "@origtarballs"); } @@ -373,19 +373,19 @@ sub generate_patch { # Copy over the debian directory erasedir("$tmp/debian"); - system("cp", "-a", "--", "$dir/debian", "$tmp/"); - subprocerr(_g("copy of the debian directory")) if $?; + system('cp', '-a', '--', "$dir/debian", "$tmp/"); + subprocerr(_g('copy of the debian directory')) if $?; # Apply all patches except the last automatic one $opts{skip_auto} //= 0; $self->apply_patches($tmp, skip_auto => $opts{skip_auto}, usage => 'build'); # Create a patch - my ($difffh, $tmpdiff) = tempfile($self->get_basename(1) . ".diff.XXXXXX", + my ($difffh, $tmpdiff) = tempfile($self->get_basename(1) . '.diff.XXXXXX', DIR => File::Spec->tmpdir(), UNLINK => 0); push @Dpkg::Exit::handlers, sub { unlink($tmpdiff) }; my $diff = Dpkg::Source::Patch->new(filename => $tmpdiff, - compression => "none"); + compression => 'none'); $diff->create(); if ($opts{header_from} and -e $opts{header_from}) { my $header_from = Dpkg::Source::Patch->new( @@ -399,10 +399,10 @@ sub generate_patch { %{$self->{diff_options}}, handle_binary_func => $opts{handle_binary}, order_from => $opts{order_from}); - error(_g("unrepresentable changes to source")) if not $diff->finish(); + error(_g('unrepresentable changes to source')) if not $diff->finish(); if (-s $tmpdiff) { - info(_g("local changes detected, the modified files are:")); + info(_g('local changes detected, the modified files are:')); my $analysis = $diff->analyze($dir, verbose => 0); foreach my $fn (sort keys %{$analysis->{filepatched}}) { print " $fn\n"; @@ -440,17 +440,17 @@ sub do_build { my $fn = File::Spec->abs2rel($_, $dir); $binaryfiles->new_binary_found($fn); unless ($include_binaries or $binaryfiles->binary_is_allowed($fn)) { - errormsg(_g("unwanted binary file: %s"), $fn); + errormsg(_g('unwanted binary file: %s'), $fn); $unwanted_binaries++; } } }; - my $tar_ignore_glob = "{" . join(",", + my $tar_ignore_glob = '{' . join(',', map { my $copy = $_; $copy =~ s/,/\\,/g; $copy; - } @{$self->{options}{tar_ignore}}) . "}"; + } @{$self->{options}{tar_ignore}}) . '}'; my $filter_ignore = sub { # Filter out files that are not going to be included in the debian # tarball due to ignores. @@ -474,11 +474,11 @@ sub do_build { return @result; }; find({ wanted => $check_binary, preprocess => $filter_ignore, - no_chdir => 1 }, File::Spec->catdir($dir, "debian")); - error(P_("detected %d unwanted binary file (add it in " . - "debian/source/include-binaries to allow its inclusion).", - "detected %d unwanted binary files (add them in " . - "debian/source/include-binaries to allow their inclusion).", + no_chdir => 1 }, File::Spec->catdir($dir, 'debian')); + error(P_('detected %d unwanted binary file (add it in ' . + 'debian/source/include-binaries to allow its inclusion).', + 'detected %d unwanted binary files (add them in ' . + 'debian/source/include-binaries to allow their inclusion).', $unwanted_binaries), $unwanted_binaries) if $unwanted_binaries; @@ -488,17 +488,17 @@ sub do_build { my $relfn = File::Spec->abs2rel($new, $dir); $binaryfiles->new_binary_found($relfn); unless ($include_binaries or $binaryfiles->binary_is_allowed($relfn)) { - errormsg(_g("cannot represent change to %s: %s"), $relfn, - _g("binary file contents changed")); - errormsg(_g("add %s in debian/source/include-binaries if you want" . - " to store the modified binary in the debian tarball"), + errormsg(_g('cannot represent change to %s: %s'), $relfn, + _g('binary file contents changed')); + errormsg(_g('add %s in debian/source/include-binaries if you want ' . + 'to store the modified binary in the debian tarball'), $relfn); $self->register_error(); } }; # Create a patch - my $autopatch = File::Spec->catfile($dir, "debian", "patches", + my $autopatch = File::Spec->catfile($dir, 'debian', 'patches', $self->get_autopatch_name()); my $tmpdiff = $self->generate_patch($dir, order_from => $autopatch, header_from => $autopatch, @@ -506,9 +506,9 @@ sub do_build { skip_auto => $self->{options}{auto_commit}, usage => 'build'); unless (-z $tmpdiff or $self->{options}{auto_commit}) { - info(_g("you can integrate the local changes with %s"), - "dpkg-source --commit"); - error(_g("aborting due to unexpected upstream changes, see %s"), + info(_g('you can integrate the local changes with %s'), + 'dpkg-source --commit'); + error(_g('aborting due to unexpected upstream changes, see %s'), $tmpdiff); } push @Dpkg::Exit::handlers, sub { unlink($tmpdiff) }; @@ -516,22 +516,22 @@ sub do_build { # Install the diff as the new autopatch if ($self->{options}{auto_commit}) { - mkpath(File::Spec->catdir($dir, "debian", "patches")); + mkpath(File::Spec->catdir($dir, 'debian', 'patches')); $autopatch = $self->register_patch($dir, $tmpdiff, $self->get_autopatch_name()); - info(_g("local changes have been recorded in a new patch: %s"), + info(_g('local changes have been recorded in a new patch: %s'), $autopatch) if -e $autopatch; - rmdir(File::Spec->catdir($dir, "debian", "patches")); # No check on purpose + rmdir(File::Spec->catdir($dir, 'debian', 'patches')); # No check on purpose } - unlink($tmpdiff) || syserr(_g("cannot remove %s"), $tmpdiff); + unlink($tmpdiff) || syserr(_g('cannot remove %s'), $tmpdiff); pop @Dpkg::Exit::handlers; # Create the debian.tar my $debianfile = "$basenamerev.debian.tar." . $self->{options}{comp_ext}; - info(_g("building %s in %s"), $sourcepackage, $debianfile); + info(_g('building %s in %s'), $sourcepackage, $debianfile); my $tar = Dpkg::Source::Archive->new(filename => $debianfile); $tar->create(options => \@tar_ignore, chdir => $dir); - $tar->add_directory("debian"); + $tar->add_directory('debian'); foreach my $binary ($binaryfiles->get_seen_binaries()) { $tar->add_file($binary) unless $binary =~ m{^debian/}; } @@ -542,19 +542,19 @@ sub do_build { sub get_patch_header { my ($self, $dir) = @_; - my $ph = File::Spec->catfile($dir, "debian", "source", "local-patch-header"); + my $ph = File::Spec->catfile($dir, 'debian', 'source', 'local-patch-header'); unless (-f $ph) { - $ph = File::Spec->catfile($dir, "debian", "source", "patch-header"); + $ph = File::Spec->catfile($dir, 'debian', 'source', 'patch-header'); } my $text; if (-f $ph) { - open(my $ph_fh, "<", $ph) || syserr(_g("cannot read %s"), $ph); - $text = join("", <$ph_fh>); + open(my $ph_fh, '<', $ph) || syserr(_g('cannot read %s'), $ph); + $text = join('', <$ph_fh>); close($ph_fh); return $text; } my $ch_info = changelog_parse(offset => 0, count => 1, - file => File::Spec->catfile($dir, "debian", "changelog")); + file => File::Spec->catfile($dir, 'debian', 'changelog')); return '' if not defined $ch_info; my $header = Dpkg::Control->new(type => CTRL_UNKNOWN); $header->{'Description'} = "<short summary of the patch>\n"; @@ -567,7 +567,7 @@ it.\n"; $header->{'Description'} .= $ch_info->{'Changes'} . "\n"; $header->{'Author'} = $ch_info->{'Maintainer'}; $text = "$header"; - run_vendor_hook("extend-patch-header", \$text, $ch_info); + run_vendor_hook('extend-patch-header', \$text, $ch_info); $text .= "\n--- The information above should follow the Patch Tagging Guidelines, please checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here @@ -585,19 +585,19 @@ Last-Update: <YYYY-MM-DD>\n\n"; sub register_patch { my ($self, $dir, $patch_file, $patch_name) = @_; - my $patch = File::Spec->catfile($dir, "debian", "patches", $patch_name); + my $patch = File::Spec->catfile($dir, 'debian', 'patches', $patch_name); if (-s $patch_file) { copy($patch_file, $patch) || - syserr(_g("failed to copy %s to %s"), $patch_file, $patch); + syserr(_g('failed to copy %s to %s'), $patch_file, $patch); chmod(0666 & ~ umask(), $patch) || syserr(_g("unable to change permission of `%s'"), $patch); - my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied"); + my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied'); open(my $applied_fh, '>>', $applied) || - syserr(_g("cannot write %s"), $applied); + syserr(_g('cannot write %s'), $applied); print $applied_fh "$patch\n"; - close($applied_fh) || syserr(_g("cannot close %s"), $applied); + close($applied_fh) || syserr(_g('cannot close %s'), $applied); } elsif (-e $patch) { - unlink($patch) || syserr(_g("cannot remove %s"), $patch); + unlink($patch) || syserr(_g('cannot remove %s'), $patch); } return $patch; } @@ -608,9 +608,9 @@ sub _is_bad_patch_name { return 1 if not defined($patch_name); return 1 if not length($patch_name); - my $patch = File::Spec->catfile($dir, "debian", "patches", $patch_name); + my $patch = File::Spec->catfile($dir, 'debian', 'patches', $patch_name); if (-e $patch) { - warning(_g("cannot register changes in %s, this patch already exists"), + warning(_g('cannot register changes in %s, this patch already exists'), $patch); return 1; } @@ -639,28 +639,28 @@ sub do_commit { unless ($tmpdiff) { $tmpdiff = $self->generate_patch($dir, handle_binary => $handle_binary, - usage => "commit"); + usage => 'commit'); $binaryfiles->update_debian_source_include_binaries(); } push @Dpkg::Exit::handlers, sub { unlink($tmpdiff) }; unless (-s $tmpdiff) { - unlink($tmpdiff) || syserr(_g("cannot remove %s"), $tmpdiff); - info(_g("there are no local changes to record")); + unlink($tmpdiff) || syserr(_g('cannot remove %s'), $tmpdiff); + info(_g('there are no local changes to record')); return; } while (_is_bad_patch_name($dir, $patch_name)) { # Ask the patch name interactively - print STDOUT _g("Enter the desired patch name: "); + print STDOUT _g('Enter the desired patch name: '); chomp($patch_name = <STDIN>); $patch_name =~ s/\s+/-/g; $patch_name =~ s/\///g; } - mkpath(File::Spec->catdir($dir, "debian", "patches")); + mkpath(File::Spec->catdir($dir, 'debian', 'patches')); my $patch = $self->register_patch($dir, $tmpdiff, $patch_name); - system("sensible-editor", $patch); - unlink($tmpdiff) || syserr(_g("cannot remove %s"), $tmpdiff); + system('sensible-editor', $patch); + unlink($tmpdiff) || syserr(_g('cannot remove %s'), $tmpdiff); pop @Dpkg::Exit::handlers; - info(_g("local changes have been recorded in a new patch: %s"), $patch); + info(_g('local changes have been recorded in a new patch: %s'), $patch); } package Dpkg::Source::Package::V2::BinaryFiles; @@ -679,7 +679,7 @@ sub new { allowed_binaries => {}, seen_binaries => {}, include_binaries_path => - File::Spec->catfile($dir, "debian", "source", "include-binaries"), + File::Spec->catfile($dir, 'debian', 'source', 'include-binaries'), }; bless $self, $class; $self->load_allowed_binaries(); @@ -696,8 +696,8 @@ sub load_allowed_binaries { my ($self) = @_; my $incbin_file = $self->{include_binaries_path}; if (-f $incbin_file) { - open(my $incbin_fh, "<", $incbin_file) || - syserr(_g("cannot read %s"), $incbin_file); + open(my $incbin_fh, '<', $incbin_file) || + syserr(_g('cannot read %s'), $incbin_file); while (defined($_ = <$incbin_fh>)) { chomp; s/^\s*//; s/\s*$//; next if /^#/ or /^$/; @@ -720,12 +720,12 @@ sub update_debian_source_include_binaries { return unless scalar(@unknown_binaries); my $incbin_file = $self->{include_binaries_path}; - mkpath(File::Spec->catdir($self->{dir}, "debian", "source")); - open(my $incbin_fh, ">>", $incbin_file) || - syserr(_g("cannot write %s"), $incbin_file); + mkpath(File::Spec->catdir($self->{dir}, 'debian', 'source')); + open(my $incbin_fh, '>>', $incbin_file) || + syserr(_g('cannot write %s'), $incbin_file); foreach my $binary (@unknown_binaries) { print $incbin_fh "$binary\n"; - info(_g("adding %s to %s"), $binary, "debian/source/include-binaries"); + info(_g('adding %s to %s'), $binary, 'debian/source/include-binaries'); $self->{allowed_binaries}{$binary} = 1; } close($incbin_fh); |