diff options
author | Guillem Jover <guillem@debian.org> | 2014-12-29 17:03:48 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2015-01-28 20:50:30 +0100 |
commit | 6e56dce4194d7a4de56c0a9111020e19e5963bf2 (patch) | |
tree | 1459afbc2f5e993b1069357291f622f3e0513e1f /scripts/Dpkg | |
parent | 08ce938d42f01ebe939f8a527f7b02ec017d3cc7 (diff) | |
download | dpkg-6e56dce4194d7a4de56c0a9111020e19e5963bf2.tar.gz |
scripts: Rename and deprecate _g function with g_
The old function name was inconsistent with the other gettext family
of short aliases which has already caused some code typos, and functions
starting with underscore are considered by convention private in Perl.
Diffstat (limited to 'scripts/Dpkg')
47 files changed, 457 insertions, 440 deletions
diff --git a/scripts/Dpkg/Arch.pm b/scripts/Dpkg/Arch.pm index d474512c5..7d3529429 100644 --- a/scripts/Dpkg/Arch.pm +++ b/scripts/Dpkg/Arch.pm @@ -94,7 +94,7 @@ my %debarch_to_debtriplet; $gcc_host_gnu_type = get_gcc_host_gnu_type(); if ($gcc_host_gnu_type eq '') { - warning(_g("couldn't determine gcc system type, falling back to " . + warning(g_("couldn't determine gcc system type, falling back to " . 'default (native compilation)')); } else { my (@host_archtriplet) = gnutriplet_to_debtriplet($gcc_host_gnu_type); @@ -103,7 +103,7 @@ my %debarch_to_debtriplet; if (defined $host_arch) { $gcc_host_gnu_type = debtriplet_to_gnutriplet(@host_archtriplet); } else { - warning(_g('unknown gcc system type %s, falling back to ' . + warning(g_('unknown gcc system type %s, falling back to ' . 'default (native compilation)'), $gcc_host_gnu_type); $gcc_host_gnu_type = ''; } @@ -149,7 +149,7 @@ sub read_cputable local $/ = "\n"; open my $cputable_fh, '<', "$Dpkg::DATADIR/cputable" - or syserr(_g('cannot open %s'), 'cputable'); + or syserr(g_('cannot open %s'), 'cputable'); while (<$cputable_fh>) { if (m/^(?!\#)(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) { $cputable{$1} = $2; @@ -173,7 +173,7 @@ sub read_ostable local $/ = "\n"; open my $ostable_fh, '<', "$Dpkg::DATADIR/ostable" - or syserr(_g('cannot open %s'), 'ostable'); + or syserr(g_('cannot open %s'), 'ostable'); while (<$ostable_fh>) { if (m/^(?!\#)(\S+)\s+(\S+)\s+(\S+)/) { $ostable{$1} = $2; @@ -206,7 +206,7 @@ sub abitable_load() } close $abitable_fh; } elsif ($! != ENOENT) { - syserr(_g('cannot open %s'), 'abitable'); + syserr(g_('cannot open %s'), 'abitable'); } $abitable_loaded = 1; @@ -223,7 +223,7 @@ sub read_triplettable() local $/ = "\n"; open my $triplettable_fh, '<', "$Dpkg::DATADIR/triplettable" - or syserr(_g('cannot open %s'), 'triplettable'); + or syserr(g_('cannot open %s'), 'triplettable'); while (<$triplettable_fh>) { if (m/^(?!\#)(\S+)\s+(\S+)/) { my $debtriplet = $1; diff --git a/scripts/Dpkg/BuildFlags.pm b/scripts/Dpkg/BuildFlags.pm index d92feede8..ea031b4d3 100644 --- a/scripts/Dpkg/BuildFlags.pm +++ b/scripts/Dpkg/BuildFlags.pm @@ -313,7 +313,7 @@ sub update_from_conffile { local $_; return unless -e $file; - open(my $conf_fh, '<', $file) or syserr(_g('cannot read %s'), $file); + open(my $conf_fh, '<', $file) or syserr(g_('cannot read %s'), $file); while (<$conf_fh>) { chomp; next if /^\s*#/; # Skip comments @@ -321,7 +321,7 @@ sub update_from_conffile { if (/^(append|prepend|set|strip)\s+(\S+)\s+(\S.*\S)\s*$/i) { my ($op, $flag, $value) = ($1, $2, $3); unless (exists $self->{flags}->{$flag}) { - warning(_g('line %d of %s mentions unknown flag %s'), $., $file, $flag); + warning(g_('line %d of %s mentions unknown flag %s'), $., $file, $flag); $self->{flags}->{$flag} = ''; } if (lc($op) eq 'set') { @@ -334,7 +334,7 @@ sub update_from_conffile { $self->prepend($flag, $value, $src); } } else { - warning(_g('line %d of %s is invalid, it has been ignored'), $., $file); + warning(g_('line %d of %s is invalid, it has been ignored'), $., $file); } } close($conf_fh); diff --git a/scripts/Dpkg/BuildOptions.pm b/scripts/Dpkg/BuildOptions.pm index 6816ffc5d..c252215a8 100644 --- a/scripts/Dpkg/BuildOptions.pm +++ b/scripts/Dpkg/BuildOptions.pm @@ -92,7 +92,7 @@ sub merge { my $count = 0; foreach (split(/\s+/, $content)) { unless (/^([a-z][a-z0-9_-]*)(?:=(\S*))?$/) { - warning(_g('invalid flag in %s: %s'), $source, $_); + warning(g_('invalid flag in %s: %s'), $source, $_); next; } $count += $self->set($1, $2, $source); diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm index 054d82bba..94ac679c2 100644 --- a/scripts/Dpkg/Changelog.pm +++ b/scripts/Dpkg/Changelog.pm @@ -167,9 +167,9 @@ sub get_parse_errors { my $res = ''; foreach my $e (@{$self->{parse_errors}}) { if ($e->[3]) { - $res .= report(_g('warning'), _g("%s(l%s): %s\nLINE: %s"), @$e); + $res .= report(g_('warning'), g_("%s(l%s): %s\nLINE: %s"), @$e); } else { - $res .= report(_g('warning'), _g('%s(l%s): %s'), @$e); + $res .= report(g_('warning'), g_('%s(l%s): %s'), @$e); } } return $res; @@ -217,7 +217,7 @@ sub __sanity_check_range { my $data = $self->{data}; if (defined($r->{offset}) and not defined($r->{count})) { - warning(_g("'offset' without 'count' has no effect")) if $self->{verbose}; + warning(g_("'offset' without 'count' has no effect")) if $self->{verbose}; delete $r->{offset}; } @@ -226,7 +226,7 @@ sub __sanity_check_range { (defined($r->{from}) || defined($r->{since}) || defined($r->{to}) || defined($r->{until}))) { - warning(_g("you can't combine 'count' or 'offset' with any other " . + warning(g_("you can't combine 'count' or 'offset' with any other " . 'range option')) if $self->{verbose}; delete $r->{from}; delete $r->{since}; @@ -234,12 +234,12 @@ sub __sanity_check_range { delete $r->{until}; } if (defined($r->{from}) && defined($r->{since})) { - warning(_g("you can only specify one of 'from' and 'since', using " . + warning(g_("you can only specify one of 'from' and 'since', using " . "'since'")) if $self->{verbose}; delete $r->{from}; } if (defined($r->{to}) && defined($r->{until})) { - warning(_g("you can only specify one of 'to' and 'until', using " . + warning(g_("you can only specify one of 'to' and 'until', using " . "'until'")) if $self->{verbose}; delete $r->{to}; } @@ -251,8 +251,8 @@ sub __sanity_check_range { push @versions, $entry->get_version()->as_string(); } if ((defined($r->{since}) and not exists $versions{$r->{since}})) { - warning(_g("'%s' option specifies non-existing version"), 'since'); - warning(_g('use newest entry that is earlier than the one specified')); + warning(g_("'%s' option specifies non-existing version"), 'since'); + warning(g_('use newest entry that is earlier than the one specified')); foreach my $v (@versions) { if (version_compare_relation($v, REL_LT, $r->{since})) { $r->{since} = $v; @@ -261,14 +261,14 @@ sub __sanity_check_range { } if (not exists $versions{$r->{since}}) { # No version was earlier, include all - warning(_g('none found, starting from the oldest entry')); + warning(g_('none found, starting from the oldest entry')); delete $r->{since}; $r->{from} = $versions[-1]; } } if ((defined($r->{from}) and not exists $versions{$r->{from}})) { - warning(_g("'%s' option specifies non-existing version"), 'from'); - warning(_g('use oldest entry that is later than the one specified')); + warning(g_("'%s' option specifies non-existing version"), 'from'); + warning(g_('use oldest entry that is later than the one specified')); my $oldest; foreach my $v (@versions) { if (version_compare_relation($v, REL_GT, $r->{from})) { @@ -278,13 +278,13 @@ sub __sanity_check_range { if (defined($oldest)) { $r->{from} = $oldest; } else { - warning(_g("no such entry found, ignoring '%s' parameter"), 'from'); + warning(g_("no such entry found, ignoring '%s' parameter"), 'from'); delete $r->{from}; # No version was oldest } } if (defined($r->{until}) and not exists $versions{$r->{until}}) { - warning(_g("'%s' option specifies non-existing version"), 'until'); - warning(_g('use oldest entry that is later than the one specified')); + warning(g_("'%s' option specifies non-existing version"), 'until'); + warning(g_('use oldest entry that is later than the one specified')); my $oldest; foreach my $v (@versions) { if (version_compare_relation($v, REL_GT, $r->{until})) { @@ -294,13 +294,13 @@ sub __sanity_check_range { if (defined($oldest)) { $r->{until} = $oldest; } else { - warning(_g("no such entry found, ignoring '%s' parameter"), 'until'); + warning(g_("no such entry found, ignoring '%s' parameter"), 'until'); delete $r->{until}; # No version was oldest } } if (defined($r->{to}) and not exists $versions{$r->{to}}) { - warning(_g("'%s' option specifies non-existing version"), 'to'); - warning(_g('use newest entry that is earlier than the one specified')); + warning(g_("'%s' option specifies non-existing version"), 'to'); + warning(g_('use newest entry that is earlier than the one specified')); foreach my $v (@versions) { if (version_compare_relation($v, REL_LT, $r->{to})) { $r->{to} = $v; @@ -309,17 +309,17 @@ sub __sanity_check_range { } if (not exists $versions{$r->{to}}) { # No version was earlier - warning(_g("no such entry found, ignoring '%s' parameter"), 'to'); + warning(g_("no such entry found, ignoring '%s' parameter"), 'to'); delete $r->{to}; } } if (defined($r->{since}) and $data->[0]->get_version() eq $r->{since}) { - warning(_g("'since' option specifies most recent version, ignoring")); + warning(g_("'since' option specifies most recent version, ignoring")); delete $r->{since}; } if (defined($r->{until}) and $data->[-1]->get_version() eq $r->{until}) { - warning(_g("'until' option specifies oldest version, ignoring")); + warning(g_("'until' option specifies oldest version, ignoring")); delete $r->{until}; } ## use critic diff --git a/scripts/Dpkg/Changelog/Debian.pm b/scripts/Dpkg/Changelog/Debian.pm index ce13d9618..4058b03d4 100644 --- a/scripts/Dpkg/Changelog/Debian.pm +++ b/scripts/Dpkg/Changelog/Debian.pm @@ -53,10 +53,10 @@ use parent qw(Dpkg::Changelog); use Dpkg::Changelog::Entry::Debian qw(match_header match_trailer); use constant { - FIRST_HEADING => _g('first heading'), - NEXT_OR_EOF => _g('next heading or eof'), - START_CHANGES => _g('start of change data'), - CHANGES_OR_TRAILER => _g('more change data or trailer'), + FIRST_HEADING => g_('first heading'), + NEXT_OR_EOF => g_('next heading or eof'), + START_CHANGES => g_('start of change data'), + CHANGES_OR_TRAILER => g_('more change data or trailer'), }; =over 4 @@ -88,7 +88,7 @@ sub parse { if (match_header($_)) { unless ($expect eq FIRST_HEADING || $expect eq NEXT_OR_EOF) { $self->parse_error($file, $., - sprintf(_g('found start of entry where expected %s'), + sprintf(g_('found start of entry where expected %s'), $expect), "$_"); } unless ($entry->is_empty) { @@ -125,11 +125,11 @@ sub parse { # hit it for the first time $self->set_unparsed_tail("$_\n" . file_slurp($fh)); } elsif (m/^\S/) { - $self->parse_error($file, $., _g('badly formatted heading line'), "$_"); + $self->parse_error($file, $., g_('badly formatted heading line'), "$_"); } elsif (match_trailer($_)) { unless ($expect eq CHANGES_OR_TRAILER) { $self->parse_error($file, $., - sprintf(_g('found trailer where expected %s'), $expect), "$_"); + sprintf(g_('found trailer where expected %s'), $expect), "$_"); } $entry->set_part('trailer', $_); $entry->extend_part('blank_after_changes', [ @blanklines ]); @@ -139,10 +139,10 @@ sub parse { } $expect = NEXT_OR_EOF; } elsif (m/^ \-\-/) { - $self->parse_error($file, $., _g('badly formatted trailer line'), "$_"); + $self->parse_error($file, $., g_('badly formatted trailer line'), "$_"); } elsif (m/^\s{2,}(?:\S)/) { unless ($expect eq START_CHANGES or $expect eq CHANGES_OR_TRAILER) { - $self->parse_error($file, $., sprintf(_g('found change data' . + $self->parse_error($file, $., sprintf(g_('found change data' . ' where expected %s'), $expect), "$_"); if ($expect eq NEXT_OR_EOF and not $entry->is_empty) { # lets assume we have missed the actual header line @@ -164,11 +164,11 @@ sub parse { next; } elsif ($expect ne CHANGES_OR_TRAILER) { $self->parse_error($file, $., - sprintf(_g('found blank line where expected %s'), $expect)); + sprintf(g_('found blank line where expected %s'), $expect)); } push @blanklines, $_; } else { - $self->parse_error($file, $., _g('unrecognized line'), "$_"); + $self->parse_error($file, $., g_('unrecognized line'), "$_"); unless ($expect eq START_CHANGES or $expect eq CHANGES_OR_TRAILER) { # lets assume change data if we expected it $entry->extend_part('changes', [ @blanklines, $_]); @@ -179,7 +179,7 @@ sub parse { } unless ($expect eq NEXT_OR_EOF) { - $self->parse_error($file, $., sprintf(_g('found eof where expected %s'), + $self->parse_error($file, $., sprintf(g_('found eof where expected %s'), $expect)); } unless ($entry->is_empty) { diff --git a/scripts/Dpkg/Changelog/Entry/Debian.pm b/scripts/Dpkg/Changelog/Entry/Debian.pm index 956217256..6cbe7cb3d 100644 --- a/scripts/Dpkg/Changelog/Entry/Debian.pm +++ b/scripts/Dpkg/Changelog/Entry/Debian.pm @@ -123,31 +123,31 @@ sub check_header { my %optdone; foreach my $opt (split(/\s*,\s*/, $options)) { unless ($opt =~ m/^([-0-9a-z]+)\=\s*(.*\S)$/i) { - push @errors, sprintf(_g("bad key-value after \`;': \`%s'"), $opt); + push @errors, sprintf(g_("bad key-value after \`;': \`%s'"), $opt); next; } my ($k, $v) = (field_capitalize($1), $2); if ($optdone{$k}) { - push @errors, sprintf(_g('repeated key-value %s'), $k); + push @errors, sprintf(g_('repeated key-value %s'), $k); } $optdone{$k} = 1; if ($k eq 'Urgency') { - push @errors, sprintf(_g('badly formatted urgency value: %s'), $v) + push @errors, sprintf(g_('badly formatted urgency value: %s'), $v) unless ($v =~ m/^([-0-9a-z]+)((\s+.*)?)$/i); } elsif ($k eq 'Binary-Only') { - push @errors, sprintf(_g('bad binary-only value: %s'), $v) + push @errors, sprintf(g_('bad binary-only value: %s'), $v) unless ($v eq 'yes'); } elsif ($k =~ m/^X[BCS]+-/i) { } else { - push @errors, sprintf(_g('unknown key-value %s'), $k); + push @errors, sprintf(g_('unknown key-value %s'), $k); } } my ($ok, $msg) = version_check($version); unless ($ok) { - push @errors, sprintf(_g("version '%s' is invalid: %s"), $version, $msg); + push @errors, sprintf(g_("version '%s' is invalid: %s"), $version, $msg); } } else { - push @errors, _g("the header doesn't match the expected regex"); + push @errors, g_("the header doesn't match the expected regex"); } return @errors; } @@ -157,13 +157,13 @@ sub check_trailer { my @errors; if (defined($self->{trailer}) and $self->{trailer} =~ $regex_trailer) { if ($3 ne ' ') { - push @errors, _g('badly formatted trailer line'); + push @errors, g_('badly formatted trailer line'); } unless (defined str2time($4)) { - push @errors, sprintf(_g("couldn't parse date %s"), $4); + push @errors, sprintf(g_("couldn't parse date %s"), $4); } } else { - push @errors, _g("the trailer doesn't match the expected regex"); + push @errors, g_("the trailer doesn't match the expected regex"); } return @errors; } diff --git a/scripts/Dpkg/Changelog/Parse.pm b/scripts/Dpkg/Changelog/Parse.pm index 6e5e7a0b9..e9595b01c 100644 --- a/scripts/Dpkg/Changelog/Parse.pm +++ b/scripts/Dpkg/Changelog/Parse.pm @@ -103,11 +103,11 @@ sub changelog_parse { local $_; open(my $format_fh, '-|', 'tail', '-n', '40', $changelogfile) - or syserr(_g('cannot create pipe for %s'), 'tail'); + or syserr(g_('cannot create pipe for %s'), 'tail'); while (<$format_fh>) { $format = $1 if m/\schangelog-format:\s+([0-9a-z]+)\W/; } - close($format_fh) or subprocerr(_g('tail of %s'), $changelogfile); + close($format_fh) or subprocerr(g_('tail of %s'), $changelogfile); } # Find the right changelog parser @@ -119,10 +119,10 @@ sub changelog_parse { $parser = $candidate; last; } else { - warning(_g('format parser %s not executable'), $candidate); + warning(g_('format parser %s not executable'), $candidate); } } - error(_g('changelog format %s is unknown'), $format) if not defined $parser; + error(g_('changelog format %s is unknown'), $format) if not defined $parser; # Create the arguments for the changelog parser my @exec = ($parser, "-l$changelogfile"); @@ -139,19 +139,19 @@ sub changelog_parse { # Fork and call the parser my $pid = open(my $parser_fh, '-|'); - syserr(_g('cannot fork for %s'), $parser) unless defined $pid; + syserr(g_('cannot fork for %s'), $parser) unless defined $pid; if (not $pid) { - exec(@exec) or syserr(_g('cannot exec format parser: %s'), $parser); + exec(@exec) or syserr(g_('cannot exec format parser: %s'), $parser); } # Get the output into several Dpkg::Control objects my (@res, $fields); while (1) { $fields = Dpkg::Control::Changelog->new(); - last unless $fields->parse($parser_fh, _g('output of changelog parser')); + last unless $fields->parse($parser_fh, g_('output of changelog parser')); push @res, $fields; } - close($parser_fh) or subprocerr(_g('changelog parser %s'), $parser); + close($parser_fh) or subprocerr(g_('changelog parser %s'), $parser); if (wantarray) { return @res; } else { diff --git a/scripts/Dpkg/Checksums.pm b/scripts/Dpkg/Checksums.pm index 41865f39d..23e27064a 100644 --- a/scripts/Dpkg/Checksums.pm +++ b/scripts/Dpkg/Checksums.pm @@ -170,10 +170,10 @@ sub add_from_file { } push @{$self->{files}}, $key unless exists $self->{size}{$key}; - (my @s = stat($file)) or syserr(_g('cannot fstat file %s'), $file); + (my @s = stat($file)) or syserr(g_('cannot fstat file %s'), $file); if (not $opts{update} and exists $self->{size}{$key} and $self->{size}{$key} != $s[7]) { - error(_g('file %s has size %u instead of expected %u'), + error(g_('file %s has size %u instead of expected %u'), $file, $s[7], $self->{size}{$key}); } $self->{size}{$key} = $s[7]; @@ -187,12 +187,12 @@ sub add_from_file { my $newsum = $1; if (not $opts{update} and exists $self->{checksums}{$key}{$alg} and $self->{checksums}{$key}{$alg} ne $newsum) { - error(_g('file %s has checksum %s instead of expected %s (algorithm %s)'), + error(g_('file %s has checksum %s instead of expected %s (algorithm %s)'), $file, $newsum, $self->{checksums}{$key}{$alg}, $alg); } $self->{checksums}{$key}{$alg} = $newsum; } else { - error(_g("checksum program gave bogus output `%s'"), $output); + error(g_("checksum program gave bogus output `%s'"), $output); } } } @@ -221,18 +221,18 @@ sub add_from_string { for my $checksum (split /\n */, $fieldtext) { next if $checksum eq ''; unless ($checksum =~ m/^($regex)\s+(\d+)\s+($rx_fname)$/) { - error(_g('invalid line in %s checksums string: %s'), + error(g_('invalid line in %s checksums string: %s'), $alg, $checksum); } my ($sum, $size, $file) = ($1, $2, $3); if (not $opts{update} and exists($checksums->{$file}{$alg}) and $checksums->{$file}{$alg} ne $sum) { - error(_g("conflicting checksums '%s' and '%s' for file '%s'"), + error(g_("conflicting checksums '%s' and '%s' for file '%s'"), $checksums->{$file}{$alg}, $sum, $file); } if (not $opts{update} and exists $self->{size}{$file} and $self->{size}{$file} != $size) { - error(_g("conflicting file sizes '%u' and '%u' for file '%s'"), + error(g_("conflicting file sizes '%u' and '%u' for file '%s'"), $self->{size}{$file}, $size, $file); } push @{$self->{files}}, $file unless exists $self->{size}{$file}; diff --git a/scripts/Dpkg/Compression.pm b/scripts/Dpkg/Compression.pm index d2b92a87a..6ebcfa5c4 100644 --- a/scripts/Dpkg/Compression.pm +++ b/scripts/Dpkg/Compression.pm @@ -176,7 +176,7 @@ sub compression_get_default { sub compression_set_default { my ($method) = @_; - error(_g('%s is not a supported compression'), $method) + error(g_('%s is not a supported compression'), $method) unless compression_is_supported($method); $default_compression = $method; } @@ -205,7 +205,7 @@ sub compression_get_default_level { sub compression_set_default_level { my ($level) = @_; - error(_g('%s is not a compression level'), $level) + error(g_('%s is not a compression level'), $level) if defined($level) and not compression_is_valid_level($level); $default_compression_level = $level; } diff --git a/scripts/Dpkg/Compression/FileHandle.pm b/scripts/Dpkg/Compression/FileHandle.pm index e3a07a4da..d24d55b98 100644 --- a/scripts/Dpkg/Compression/FileHandle.pm +++ b/scripts/Dpkg/Compression/FileHandle.pm @@ -400,7 +400,7 @@ sub open_for_write { to_file => $self->get_filename(), %opts); } else { CORE::open($filehandle, '>', $self->get_filename) - or syserr(_g('cannot write %s'), $self->get_filename()); + or syserr(g_('cannot write %s'), $self->get_filename()); } *$self->{mode} = 'w'; *$self->{file} = $filehandle; @@ -419,7 +419,7 @@ sub open_for_read { *$self->{allow_sigpipe} = 1; } else { CORE::open($filehandle, '<', $self->get_filename) - or syserr(_g('cannot read %s'), $self->get_filename()); + or syserr(g_('cannot read %s'), $self->get_filename()); } *$self->{mode} = 'r'; *$self->{file} = $filehandle; diff --git a/scripts/Dpkg/Compression/Process.pm b/scripts/Dpkg/Compression/Process.pm index ff5c8f0fe..0927e817b 100644 --- a/scripts/Dpkg/Compression/Process.pm +++ b/scripts/Dpkg/Compression/Process.pm @@ -70,7 +70,7 @@ B<Dpkg::Compression>). sub set_compression { my ($self, $method) = @_; - error(_g('%s is not a supported compression method'), $method) + error(g_('%s is not a supported compression method'), $method) unless compression_is_supported($method); $self->{compression} = $method; } @@ -85,7 +85,7 @@ B<Dpkg::Compression>). sub set_compression_level { my ($self, $level) = @_; - error(_g('%s is not a compression level'), $level) + error(g_('%s is not a compression level'), $level) unless compression_is_valid_level($level); $self->{compression_level} = $level; } @@ -121,7 +121,7 @@ sub get_uncompress_cmdline { sub _sanity_check { my ($self, %opts) = @_; # Check for proper cleaning before new start - error(_g('Dpkg::Compression::Process can only start one subprocess at a time')) + error(g_('Dpkg::Compression::Process can only start one subprocess at a time')) if $self->{pid}; # Check options my $to = my $from = 0; diff --git a/scripts/Dpkg/Conf.pm b/scripts/Dpkg/Conf.pm index ea4f6ef05..f3b5e4b0d 100644 --- a/scripts/Dpkg/Conf.pm +++ b/scripts/Dpkg/Conf.pm @@ -105,7 +105,7 @@ sub parse { # Skip empty lines and comments next if /^#/ or length == 0; if (/^-[^-]/ and not $self->{allow_short}) { - warning(_g('short option not allowed in %s, line %d'), $desc, $.); + warning(g_('short option not allowed in %s, line %d'), $desc, $.); next; } if (/^([^=]+)(?:=(.*))?$/) { @@ -119,7 +119,7 @@ sub parse { } $count++; } else { - warning(_g('invalid syntax for option in %s, line %d'), $desc, $.); + warning(g_('invalid syntax for option in %s, line %d'), $desc, $.); } } return $count; diff --git a/scripts/Dpkg/Control.pm b/scripts/Dpkg/Control.pm index 6989b60c7..a9cb5fbd8 100644 --- a/scripts/Dpkg/Control.pm +++ b/scripts/Dpkg/Control.pm @@ -150,25 +150,25 @@ sub set_options { $$self->{allow_pgp} = ($t & (CTRL_PKG_SRC | CTRL_FILE_CHANGES)) ? 1 : 0; $$self->{drop_empty} = ($t & (CTRL_INFO_PKG | CTRL_INFO_SRC)) ? 0 : 1; if ($t == CTRL_INFO_SRC) { - $$self->{name} = _g('general section of control info file'); + $$self->{name} = g_('general section of control info file'); } elsif ($t == CTRL_INFO_PKG) { - $$self->{name} = _g("package's section of control info file"); + $$self->{name} = g_("package's section of control info file"); } elsif ($t == CTRL_CHANGELOG) { - $$self->{name} = _g('parsed version of changelog'); + $$self->{name} = g_('parsed version of changelog'); } elsif ($t == CTRL_INDEX_SRC) { - $$self->{name} = sprintf(_g("entry in repository's %s file"), 'Sources'); + $$self->{name} = sprintf(g_("entry in repository's %s file"), 'Sources'); } elsif ($t == CTRL_INDEX_PKG) { - $$self->{name} = sprintf(_g("entry in repository's %s file"), 'Packages'); + $$self->{name} = sprintf(g_("entry in repository's %s file"), 'Packages'); } elsif ($t == CTRL_PKG_SRC) { - $$self->{name} = sprintf(_g('%s file'), '.dsc'); + $$self->{name} = sprintf(g_('%s file'), '.dsc'); } elsif ($t == CTRL_PKG_DEB) { - $$self->{name} = _g('control info of a .deb package'); + $$self->{name} = g_('control info of a .deb package'); } elsif ($t == CTRL_FILE_CHANGES) { - $$self->{name} = sprintf(_g('%s file'), '.changes'); + $$self->{name} = sprintf(g_('%s file'), '.changes'); } elsif ($t == CTRL_FILE_VENDOR) { - $$self->{name} = _g('vendor file'); + $$self->{name} = g_('vendor file'); } elsif ($t == CTRL_FILE_STATUS) { - $$self->{name} = _g("entry in dpkg's status file"); + $$self->{name} = g_("entry in dpkg's status file"); } $self->set_output_order(field_ordered_list($opts{type})); } diff --git a/scripts/Dpkg/Control/FieldsCore.pm b/scripts/Dpkg/Control/FieldsCore.pm index 8a5695b20..6c0d9e2e5 100644 --- a/scripts/Dpkg/Control/FieldsCore.pm +++ b/scripts/Dpkg/Control/FieldsCore.pm @@ -506,8 +506,8 @@ sub field_transfer_single($$;$) { return $field; } } elsif (not field_is_allowed_in($field, $from_type)) { - warning(_g("unknown information field '%s' in input data in %s"), - $field, $from->get_option('name') || _g('control information')); + warning(g_("unknown information field '%s' in input data in %s"), + $field, $from->get_option('name') || g_('control information')); } return; } diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm index 23d7fd010..d06c18f3b 100644 --- a/scripts/Dpkg/Control/HashCore.pm +++ b/scripts/Dpkg/Control/HashCore.pm @@ -174,7 +174,7 @@ sub parse_error { my ($self, $file, $msg) = (shift, shift, shift); $msg = sprintf($msg, @_) if (@_); - error(_g('syntax error in %s at line %d: %s'), $file, $., $msg); + error(g_('syntax error in %s at line %d: %s'), $file, $., $msg); } =item $c->parse($fh, $description) @@ -204,11 +204,11 @@ sub parse { $parabody = 1; my ($name, $value) = ($1, $2); if ($name =~ m/^-/) { - $self->parse_error($desc, _g('field cannot start with a hyphen')); + $self->parse_error($desc, g_('field cannot start with a hyphen')); } if (exists $self->{$name}) { unless ($$self->{allow_duplicate}) { - $self->parse_error($desc, _g('duplicate field %s found'), $name); + $self->parse_error($desc, g_('duplicate field %s found'), $name); } } $self->{$name} = $value; @@ -216,7 +216,7 @@ sub parse { } elsif (m/^\s(\s*\S.*)$/) { my $line = $1; unless (defined($cf)) { - $self->parse_error($desc, _g('continued value line not in field')); + $self->parse_error($desc, g_('continued value line not in field')); } if ($line =~ /^\.+$/) { $line = substr $line, 1; @@ -230,19 +230,19 @@ sub parse { last if m/^\s*$/; } } else { - $self->parse_error($desc, _g('OpenPGP signature not allowed here')); + $self->parse_error($desc, g_('OpenPGP signature not allowed here')); } } elsif (length == 0 || ($expect_pgp_sig && m/^-----BEGIN PGP SIGNATURE-----$/)) { if ($expect_pgp_sig) { # Skip empty lines $_ = <$fh> while defined && m/^\s*$/; unless (length) { - $self->parse_error($desc, _g('expected OpenPGP signature, ' . + $self->parse_error($desc, g_('expected OpenPGP signature, ' . 'found EOF after blank line')); } s/\s*\n$//; unless (m/^-----BEGIN PGP SIGNATURE-----$/) { - $self->parse_error($desc, _g('expected OpenPGP signature, ' . + $self->parse_error($desc, g_('expected OpenPGP signature, ' . "found something else \`%s'"), $_); } # Skip OpenPGP signature @@ -251,7 +251,7 @@ sub parse { last if m/^-----END PGP SIGNATURE-----$/; } unless (defined) { - $self->parse_error($desc, _g('unfinished OpenPGP signature')); + $self->parse_error($desc, g_('unfinished OpenPGP signature')); } # This does not mean the signature is correct, that needs to # be verified by gnupg. @@ -260,12 +260,12 @@ sub parse { last; # Finished parsing one block } else { $self->parse_error($desc, - _g('line with unknown format (not field-colon-value)')); + g_('line with unknown format (not field-colon-value)')); } } if ($expect_pgp_sig and not $$self->{is_pgp_signed}) { - $self->parse_error($desc, _g('unfinished OpenPGP signature')); + $self->parse_error($desc, g_('unfinished OpenPGP signature')); } return defined($cf); @@ -365,7 +365,7 @@ sub output { # Print it out if ($fh) { print { $fh } $kv - or syserr(_g('write error on control data')); + or syserr(g_('write error on control data')); } $str .= $kv if defined wantarray; } diff --git a/scripts/Dpkg/Control/Info.pm b/scripts/Dpkg/Control/Info.pm index f066161a2..a656ca66d 100644 --- a/scripts/Dpkg/Control/Info.pm +++ b/scripts/Dpkg/Control/Info.pm @@ -100,18 +100,18 @@ sub parse { return if not $cdata->parse($fh, $desc); $self->{source} = $cdata; unless (exists $cdata->{Source}) { - $cdata->parse_error($desc, _g('first block lacks a source field')); + $cdata->parse_error($desc, g_('first block lacks a source field')); } while (1) { $cdata = Dpkg::Control->new(type => CTRL_INFO_PKG); last if not $cdata->parse($fh, $desc); push @{$self->{packages}}, $cdata; unless (exists $cdata->{Package}) { - $cdata->parse_error($desc, _g("block lacks the '%s' field"), + $cdata->parse_error($desc, g_("block lacks the '%s' field"), 'Package'); } unless (exists $cdata->{Architecture}) { - $cdata->parse_error($desc, _g("block lacks the '%s' field"), + $cdata->parse_error($desc, g_("block lacks the '%s' field"), 'Architecture'); } diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index 22eb04b1c..7c411920c 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -270,7 +270,7 @@ sub deps_parse { build_dep => $options{build_dep}); if (not defined $dep_simple->{package}) { - warning(_g("can't parse dependency %s"), $dep_or); + warning(g_("can't parse dependency %s"), $dep_or); return; } $dep_simple->{arches} = undef if not $options{use_arch}; @@ -302,7 +302,7 @@ sub deps_parse { } foreach my $dep (@dep_list) { if ($options{union} and not $dep->isa('Dpkg::Deps::Simple')) { - warning(_g('an union dependency can only contain simple dependencies')); + warning(g_('an union dependency can only contain simple dependencies')); return; } $dep_and->add($dep); diff --git a/scripts/Dpkg/Dist/Files.pm b/scripts/Dpkg/Dist/Files.pm index a76429e68..b9f229be1 100644 --- a/scripts/Dpkg/Dist/Files.pm +++ b/scripts/Dpkg/Dist/Files.pm @@ -67,11 +67,11 @@ sub parse { $file{section} = $2; $file{priority} = $3; } else { - error(_g('badly formed line in files list file, line %d'), $.); + error(g_('badly formed line in files list file, line %d'), $.); } if (defined $self->{files}->{$file{filename}}) { - warning(_g('duplicate files list entry for file %s (line %d)'), + warning(g_('duplicate files list entry for file %s (line %d)'), $file{filename}, $.); } else { $count++; diff --git a/scripts/Dpkg/ErrorHandling.pm b/scripts/Dpkg/ErrorHandling.pm index 275c506ab..a97054b2a 100644 --- a/scripts/Dpkg/ErrorHandling.pm +++ b/scripts/Dpkg/ErrorHandling.pm @@ -51,28 +51,28 @@ sub report(@) sub info($;@) { - print { $info_fh } report(_g('info'), @_) if (!$quiet_warnings); + print { $info_fh } report(g_('info'), @_) if (!$quiet_warnings); } sub warning($;@) { - warn report(_g('warning'), @_) if (!$quiet_warnings); + warn report(g_('warning'), @_) if (!$quiet_warnings); } sub syserr($;@) { my $msg = shift; - die report(_g('error'), "$msg: $!", @_); + die report(g_('error'), "$msg: $!", @_); } sub error($;@) { - die report(_g('error'), @_); + die report(g_('error'), @_); } sub errormsg($;@) { - print { *STDERR } report(_g('error'), @_); + print { *STDERR } report(g_('error'), @_); } sub subprocerr(@) @@ -84,15 +84,15 @@ sub subprocerr(@) require POSIX; if (POSIX::WIFEXITED($?)) { - error(_g('%s gave error exit status %s'), $p, POSIX::WEXITSTATUS($?)); + error(g_('%s gave error exit status %s'), $p, POSIX::WEXITSTATUS($?)); } elsif (POSIX::WIFSIGNALED($?)) { - error(_g('%s died from signal %s'), $p, POSIX::WTERMSIG($?)); + error(g_('%s died from signal %s'), $p, POSIX::WTERMSIG($?)); } else { - error(_g('%s failed with unknown exit code %d'), $p, $?); + error(g_('%s failed with unknown exit code %d'), $p, $?); } } -my $printforhelp = _g('Use --help for program usage information.'); +my $printforhelp = g_('Use --help for program usage information.'); sub usageerr(@) { diff --git a/scripts/Dpkg/File.pm b/scripts/Dpkg/File.pm index adc46547d..b28db26b1 100644 --- a/scripts/Dpkg/File.pm +++ b/scripts/Dpkg/File.pm @@ -37,14 +37,14 @@ sub file_lock($$) { # be installed alongside. eval 'use File::FcntlLock'; if ($@) { - warning(_g('File::FcntlLock not available; using flock which is not NFS-safe')); + warning(g_('File::FcntlLock not available; using flock which is not NFS-safe')); flock($fh, LOCK_EX) - or syserr(_g('failed to get a write lock on %s'), $filename); + or syserr(g_('failed to get a write lock on %s'), $filename); } else { eval q{ my $fs = File::FcntlLock->new(l_type => F_WRLCK); $fs->lock($fh, F_SETLKW) - or syserr(_g('failed to get a write lock on %s'), $filename); + or syserr(g_('failed to get a write lock on %s'), $filename); } } } diff --git a/scripts/Dpkg/Gettext.pm b/scripts/Dpkg/Gettext.pm index dbec4bc0b..beba2a649 100644 --- a/scripts/Dpkg/Gettext.pm +++ b/scripts/Dpkg/Gettext.pm @@ -26,8 +26,8 @@ package Dpkg::Gettext; use strict; use warnings; -our $VERSION = '1.00'; -our @EXPORT = qw(_g P_ textdomain ngettext); +our $VERSION = '1.01'; +our @EXPORT = qw(g_ P_ textdomain ngettext _g); use Exporter qw(import); @@ -47,7 +47,7 @@ some commonly used aliases. =over 4 -=item my $trans = _g($msgid) +=item my $trans = g_($msgid) Calls gettext() on the $msgid and returns its translation for the current locale. If gettext() is not available, simply returns $msgid. @@ -66,7 +66,7 @@ BEGIN { eval 'use Locale::gettext'; if ($@) { eval q{ - sub _g { + sub g_ { return shift; } sub textdomain { @@ -85,7 +85,7 @@ BEGIN { }; } else { eval q{ - sub _g { + sub g_ { return gettext(shift); } sub P_ { @@ -95,8 +95,25 @@ BEGIN { } } +# XXX: Backwards compatibility, to be removed on VERSION 2.00. +sub _g ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) +{ + my $msgid = shift; + + require Carp; + Carp::carp 'obsolete _g() function, please use g_() instead'; + + return g_($msgid); +} + =head1 CHANGES +=head2 Version 1.01 + +New function: g_(). + +Deprecated function: _g(). + =head2 Version 1.00 Mark the module as public. diff --git a/scripts/Dpkg/IPC.pm b/scripts/Dpkg/IPC.pm index 6eab6328e..d5e35f633 100644 --- a/scripts/Dpkg/IPC.pm +++ b/scripts/Dpkg/IPC.pm @@ -230,25 +230,25 @@ sub spawn { my ($input_pipe, $output_pipe, $error_pipe); if ($opts{from_pipe}) { pipe($opts{from_handle}, $input_pipe) - or syserr(_g('pipe for %s'), "@prog"); + or syserr(g_('pipe for %s'), "@prog"); ${$opts{from_pipe}} = $input_pipe; push @{$opts{close_in_child}}, $input_pipe; } if ($opts{to_pipe}) { pipe($output_pipe, $opts{to_handle}) - or syserr(_g('pipe for %s'), "@prog"); + or syserr(g_('pipe for %s'), "@prog"); ${$opts{to_pipe}} = $output_pipe; push @{$opts{close_in_child}}, $output_pipe; } if ($opts{error_to_pipe}) { pipe($error_pipe, $opts{error_to_handle}) - or syserr(_g('pipe for %s'), "@prog"); + or syserr(g_('pipe for %s'), "@prog"); ${$opts{error_to_pipe}} = $error_pipe; push @{$opts{close_in_child}}, $error_pipe; } # Fork and exec my $pid = fork(); - syserr(_g('cannot fork for %s'), "@prog") unless defined $pid; + syserr(g_('cannot fork for %s'), "@prog") unless defined $pid; if (not $pid) { # Define environment variables if ($opts{env}) { @@ -270,39 +270,39 @@ sub spawn { } # Change the current directory if ($opts{chdir}) { - chdir($opts{chdir}) or syserr(_g('chdir to %s'), $opts{chdir}); + chdir($opts{chdir}) or syserr(g_('chdir to %s'), $opts{chdir}); } # Redirect STDIN if needed if ($opts{from_file}) { open(STDIN, '<', $opts{from_file}) - or syserr(_g('cannot open %s'), $opts{from_file}); + or syserr(g_('cannot open %s'), $opts{from_file}); } elsif ($opts{from_handle}) { open(STDIN, '<&', $opts{from_handle}) - or syserr(_g('reopen stdin')); + or syserr(g_('reopen stdin')); close($opts{from_handle}); # has been duped, can be closed } # Redirect STDOUT if needed if ($opts{to_file}) { open(STDOUT, '>', $opts{to_file}) - or syserr(_g('cannot write %s'), $opts{to_file}); + or syserr(g_('cannot write %s'), $opts{to_file}); } elsif ($opts{to_handle}) { open(STDOUT, '>&', $opts{to_handle}) - or syserr(_g('reopen stdout')); + or syserr(g_('reopen stdout')); close($opts{to_handle}); # has been duped, can be closed } # Redirect STDERR if needed if ($opts{error_to_file}) { open(STDERR, '>', $opts{error_to_file}) - or syserr(_g('cannot write %s'), $opts{error_to_file}); + or syserr(g_('cannot write %s'), $opts{error_to_file}); } elsif ($opts{error_to_handle}) { open(STDERR, '>&', $opts{error_to_handle}) - or syserr(_g('reopen stdout')); + or syserr(g_('reopen stdout')); close($opts{error_to_handle}); # has been duped, can be closed } # Close some inherited filehandles close($_) foreach (@{$opts{close_in_child}}); # Execute the program - exec({ $prog[0] } @prog) or syserr(_g('unable to execute %s'), "@prog"); + exec({ $prog[0] } @prog) or syserr(g_('unable to execute %s'), "@prog"); } # Close handle that we can't use any more close($opts{from_handle}) if exists $opts{from_handle}; @@ -370,12 +370,12 @@ with an error message. sub wait_child { my ($pid, %opts) = @_; - $opts{cmdline} //= _g('child process'); + $opts{cmdline} //= g_('child process'); croak 'no PID set, cannot wait end of process' unless $pid; eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm($opts{timeout}) if defined($opts{timeout}); - $pid == waitpid($pid, 0) or syserr(_g('wait for %s'), $opts{cmdline}); + $pid == waitpid($pid, 0) or syserr(g_('wait for %s'), $opts{cmdline}); alarm(0) if defined($opts{timeout}); }; if ($@) { diff --git a/scripts/Dpkg/Interface/Storable.pm b/scripts/Dpkg/Interface/Storable.pm index fe31e3dc3..d934d7e59 100644 --- a/scripts/Dpkg/Interface/Storable.pm +++ b/scripts/Dpkg/Interface/Storable.pm @@ -83,14 +83,14 @@ sub load { my ($desc, $fh) = ($file, undef); if ($file eq '-') { $fh = \*STDIN; - $desc = _g('<standard input>'); + $desc = g_('<standard input>'); } else { $fh = Dpkg::Compression::FileHandle->new(); - open($fh, '<', $file) or syserr(_g('cannot read %s'), $file); + open($fh, '<', $file) or syserr(g_('cannot read %s'), $file); } my $res = $self->parse($fh, $desc, @options); if ($file ne '-') { - close($fh) or syserr(_g('cannot close %s'), $file); + close($fh) or syserr(g_('cannot close %s'), $file); } return $res; } @@ -114,11 +114,11 @@ sub save { $fh = \*STDOUT; } else { $fh = Dpkg::Compression::FileHandle->new(); - open($fh, '>', $file) or syserr(_g('cannot write %s'), $file); + open($fh, '>', $file) or syserr(g_('cannot write %s'), $file); } $self->output($fh, @options); if ($file ne '-') { - close($fh) or syserr(_g('cannot close %s'), $file); + close($fh) or syserr(g_('cannot close %s'), $file); } } diff --git a/scripts/Dpkg/Package.pm b/scripts/Dpkg/Package.pm index 8fa0c1027..a276f66ed 100644 --- a/scripts/Dpkg/Package.pm +++ b/scripts/Dpkg/Package.pm @@ -30,13 +30,13 @@ sub pkg_name_is_illegal($) { my $name = shift // ''; if ($name eq '') { - return _g('may not be empty string'); + return g_('may not be empty string'); } if ($name =~ m/[^-+.0-9a-z]/op) { - return sprintf(_g("character '%s' not allowed"), ${^MATCH}); + return sprintf(g_("character '%s' not allowed"), ${^MATCH}); } if ($name !~ m/^[0-9a-z]/o) { - return _g('must start with an alphanumeric character'); + return g_('must start with an alphanumeric character'); } return; diff --git a/scripts/Dpkg/Shlibs.pm b/scripts/Dpkg/Shlibs.pm index fe924ae53..4c0b9d0ce 100644 --- a/scripts/Dpkg/Shlibs.pm +++ b/scripts/Dpkg/Shlibs.pm @@ -85,7 +85,7 @@ sub parse_ldso_conf { my $file = shift; local $_; - open my $fh, '<', $file or syserr(_g('cannot open %s'), $file); + open my $fh, '<', $file or syserr(g_('cannot open %s'), $file); $visited{$file}++; while (<$fh>) { next if /^\s*$/; diff --git a/scripts/Dpkg/Shlibs/Cppfilt.pm b/scripts/Dpkg/Shlibs/Cppfilt.pm index be8731770..e2fe2a757 100644 --- a/scripts/Dpkg/Shlibs/Cppfilt.pm +++ b/scripts/Dpkg/Shlibs/Cppfilt.pm @@ -47,7 +47,7 @@ sub get_cppfilt { $filt->{pid} = spawn(exec => [ 'c++filt', "--format=$type" ], from_pipe => \$filt->{from}, to_pipe => \$filt->{to}); - syserr(_g('unable to execute %s'), 'c++filt') + syserr(g_('unable to execute %s'), 'c++filt') unless defined $filt->{from}; $filt->{from}->autoflush(1); diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm index 7318b23dc..3965358bf 100644 --- a/scripts/Dpkg/Shlibs/Objdump.pm +++ b/scripts/Dpkg/Shlibs/Objdump.pm @@ -122,7 +122,7 @@ sub has_object { sub is_elf { my ($file) = @_; - open(my $file_fh, '<', $file) or syserr(_g('cannot read %s'), $file); + open(my $file_fh, '<', $file) or syserr(g_('cannot read %s'), $file); my ($header, $result) = ('', 0); if (read($file_fh, $header, 4) == 4) { $result = 1 if ($header =~ /^\177ELF$/); @@ -181,7 +181,7 @@ sub analyze { local $ENV{LC_ALL} = 'C'; open(my $objdump, '-|', $OBJDUMP, '-w', '-f', '-p', '-T', '-R', $file) - or syserr(_g('cannot fork for %s'), $OBJDUMP); + or syserr(g_('cannot fork for %s'), $OBJDUMP); my $ret = $self->parse_objdump_output($objdump); close($objdump); return $ret; @@ -222,7 +222,7 @@ sub parse_objdump_output { if (/^\S+\s+(\S+)\s+(\S+)\s*$/) { $self->{dynrelocs}{$2} = $1; } else { - warning(_g("couldn't parse dynamic relocation record: %s"), $_); + warning(g_("couldn't parse dynamic relocation record: %s"), $_); } } elsif ($section eq 'dyninfo') { if (/^\s*NEEDED\s+(\S+)/) { @@ -341,7 +341,7 @@ sub parse_dynamic_symbol { # Ignore some s390-specific output like # REG_G6 g R *UND* 0000000000000000 #scratch } else { - warning(_g("couldn't parse dynamic symbol definition: %s"), $line); + warning(g_("couldn't parse dynamic symbol definition: %s"), $line); } } diff --git a/scripts/Dpkg/Shlibs/Symbol.pm b/scripts/Dpkg/Shlibs/Symbol.pm index ad1ee69b2..6ccaca2c0 100644 --- a/scripts/Dpkg/Shlibs/Symbol.pm +++ b/scripts/Dpkg/Shlibs/Symbol.pm @@ -105,7 +105,7 @@ sub parse_symbolspec { $rest = $2; } } - error(_g('symbol name unspecified: %s'), $symbolspec) if (!$symbol); + error(g_('symbol name unspecified: %s'), $symbolspec) if (!$symbol); } else { # No tag specification. Symbol name is up to the first space # foobarsymbol@Base 1.0 1 @@ -162,7 +162,7 @@ sub initialize { # name@version string. $type = (defined $type) ? 'generic' : 'alias-symver'; if ($self->get_symbolname() eq 'Base') { - error(_g("you can't use symver tag to catch unversioned symbols: %s"), + error(g_("you can't use symver tag to catch unversioned symbols: %s"), $self->get_symbolspec(1)); } } diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm b/scripts/Dpkg/Shlibs/SymbolFile.pm index bd4b0f4cf..931f6bc27 100644 --- a/scripts/Dpkg/Shlibs/SymbolFile.pm +++ b/scripts/Dpkg/Shlibs/SymbolFile.pm @@ -220,7 +220,7 @@ sub parse { if (/^(?:\s+|#(?:DEPRECATED|MISSING): ([^#]+)#\s*)(.*)/) { if (not defined ($$obj_ref)) { - error(_g('symbol information must be preceded by a header (file %s, line %s)'), $file, $.); + error(g_('symbol information must be preceded by a header (file %s, line %s)'), $file, $.); } # Symbol specification my $deprecated = ($1) ? $1 : 0; @@ -228,7 +228,7 @@ sub parse { if ($self->create_symbol($2, base => $sym)) { $self->add_symbol($sym, $$obj_ref); } else { - warning(_g('failed to parse line in %s: %s'), $file, $_); + warning(g_('failed to parse line in %s: %s'), $file, $_); } } elsif (/^(\(.*\))?#include\s+"([^"]+)"/) { my $tagspec = $1; @@ -260,7 +260,7 @@ sub parse { $self->create_object($$obj_ref, "$2"); } } else { - warning(_g('failed to parse a line in %s: %s'), $file, $_); + warning(g_('failed to parse a line in %s: %s'), $file, $_); } } delete $seen->{$file}; @@ -273,7 +273,7 @@ sub merge_object_from_symfile { if (not $self->has_object($objid)) { $self->{objects}{$objid} = $src->get_object($objid); } else { - warning(_g('tried to merge the same object (%s) twice in a symfile'), $objid); + warning(g_('tried to merge the same object (%s) twice in a symfile'), $objid); } } @@ -392,7 +392,7 @@ sub merge_symbols { my ($self, $object, $minver) = @_; my $soname = $object->{SONAME}; - error(_g('cannot merge symbols from objects without SONAME')) + error(g_('cannot merge symbols from objects without SONAME')) unless $soname; my %include_groups = (); diff --git a/scripts/Dpkg/Source/Archive.pm b/scripts/Dpkg/Source/Archive.pm index 2f76ea969..643f73e91 100644 --- a/scripts/Dpkg/Source/Archive.pm +++ b/scripts/Dpkg/Source/Archive.pm @@ -61,7 +61,7 @@ sub _add_entry { croak 'call create() first' unless *$self->{tar_input}; $file = $2 if ($file =~ /^\Q$cwd\E\/(.+)$/); # Relative names print({ *$self->{tar_input} } "$file\0") - or syserr(_g('write on tar input')); + or syserr(g_('write on tar input')); } sub add_file { @@ -88,7 +88,7 @@ sub add_directory { sub finish { my ($self) = @_; - close(*$self->{tar_input}) or syserr(_g('close on tar input')); + close(*$self->{tar_input}) or syserr(g_('close on tar input')); wait_child(*$self->{pid}, cmdline => 'tar -cf -'); delete *$self->{pid}; delete *$self->{tar_input}; @@ -113,7 +113,7 @@ sub extract { my $template = basename($self->get_filename()) . '.tmp-extract.XXXXX'; unless (-e $dest) { # Kludge so that realpath works - mkdir($dest) or syserr(_g('cannot create directory %s'), $dest); + mkdir($dest) or syserr(g_('cannot create directory %s'), $dest); } $tmp = tempdir($template, DIR => Cwd::realpath("$dest/.."), CLEANUP => 1); $spawn_opts{chdir} = $tmp; @@ -144,18 +144,18 @@ sub extract { return if $opts{in_place}; # Rename extracted directory - opendir(my $dir_dh, $tmp) or syserr(_g('cannot opendir %s'), $tmp); + opendir(my $dir_dh, $tmp) or syserr(g_('cannot opendir %s'), $tmp); my @entries = grep { $_ ne '.' && $_ ne '..' } readdir($dir_dh); closedir($dir_dh); my $done = 0; erasedir($dest); if (scalar(@entries) == 1 && ! -l "$tmp/$entries[0]" && -d _) { rename("$tmp/$entries[0]", $dest) - or syserr(_g('unable to rename %s to %s'), + or syserr(g_('unable to rename %s to %s'), "$tmp/$entries[0]", $dest); } else { rename($tmp, $dest) - or syserr(_g('unable to rename %s to %s'), $tmp, $dest); + or syserr(g_('unable to rename %s to %s'), $tmp, $dest); } erasedir($tmp); } diff --git a/scripts/Dpkg/Source/Functions.pm b/scripts/Dpkg/Source/Functions.pm index 8f9c50c29..5dbabbd1e 100644 --- a/scripts/Dpkg/Source/Functions.pm +++ b/scripts/Dpkg/Source/Functions.pm @@ -31,15 +31,15 @@ sub erasedir { my ($dir) = @_; if (not lstat($dir)) { return if $! == ENOENT; - syserr(_g('cannot stat directory %s (before removal)'), $dir); + syserr(g_('cannot stat directory %s (before removal)'), $dir); } system 'rm', '-rf', '--', $dir; subprocerr("rm -rf $dir") if $?; if (not stat($dir)) { return if $! == ENOENT; - syserr(_g("unable to check for removal of dir `%s'"), $dir); + syserr(g_("unable to check for removal of dir `%s'"), $dir); } - error(_g("rm -rf failed to remove `%s'"), $dir); + error(g_("rm -rf failed to remove `%s'"), $dir); } sub fixperms { @@ -75,14 +75,14 @@ sub fs_time($) { my ($file) = @_; my $is_temp = 0; if (not -e $file) { - open(my $temp_fh, '>', $file) or syserr(_g('cannot write %s')); + open(my $temp_fh, '>', $file) or syserr(g_('cannot write %s')); close($temp_fh); $is_temp = 1; } else { utime(undef, undef, $file) or - syserr(_g('cannot change timestamp for %s'), $file); + syserr(g_('cannot change timestamp for %s'), $file); } - stat($file) or syserr(_g('cannot read timestamp from %s'), $file); + stat($file) or syserr(g_('cannot read timestamp from %s'), $file); my $mtime = (stat(_))[9]; unlink($file) if $is_temp; return $mtime; diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index fc5cc2f50..36e62ddba 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -237,7 +237,7 @@ sub init_options { sub initialize { my ($self, $filename) = @_; my ($fn, $dir) = fileparse($filename); - error(_g('%s is not the name of a file'), $filename) unless $fn; + error(g_('%s is not the name of a file'), $filename) unless $fn; $self->{basedir} = $dir || './'; $self->{filename} = $fn; @@ -249,7 +249,7 @@ sub initialize { foreach my $f (qw(Source Version Files)) { unless (defined($fields->{$f})) { - error(_g('missing critical source control field %s'), $f); + error(g_('missing critical source control field %s'), $f); } } @@ -268,8 +268,8 @@ sub upgrade_object_type { my ($version, $variant, $major, $minor) = ($1, $2, $1, undef); if (defined $variant and $variant ne lc $variant) { - error(_g("source package format '%s' is not supported: %s"), - $format, _g('format variant must be in lowercase')); + error(g_("source package format '%s' is not supported: %s"), + $format, g_('format variant must be in lowercase')); } $major =~ s/\.[\d\.]+$//; @@ -282,12 +282,12 @@ sub upgrade_object_type { $self->{fields}{'Format'} .= " ($variant)" if defined $variant; } if ($@) { - error(_g("source package format '%s' is not supported: %s"), + error(g_("source package format '%s' is not supported: %s"), $format, $@); } bless $self, $module; } else { - error(_g("invalid Format field `%s'"), $format); + error(g_("invalid Format field `%s'"), $format); } } @@ -335,7 +335,7 @@ sub get_basename { my ($self, $with_revision) = @_; my $f = $self->{fields}; unless (exists $f->{'Source'} and exists $f->{'Version'}) { - error(_g('source and version are required to compute the source basename')); + error(g_('source and version are required to compute the source basename')); } my $v = Dpkg::Version->new($f->{'Version'}); my $vs = $v->as_string(omit_epoch => 1, omit_revision => !$with_revision); @@ -351,7 +351,7 @@ sub find_original_tarballs { my @tar; foreach my $dir ('.', $self->{basedir}, $self->{options}{origtardir}) { next unless defined($dir) and -d $dir; - opendir(my $dir_dh, $dir) or syserr(_g('cannot opendir %s'), $dir); + opendir(my $dir_dh, $dir) or syserr(g_('cannot opendir %s'), $dir); push @tar, map { "$dir/$_" } grep { ($opts{include_main} and /^\Q$basename\E\.orig\.tar\.$opts{extension}$/) or @@ -420,18 +420,18 @@ sub check_signature { if ($gpg_status == 1 or ($gpg_status && $self->{options}{require_valid_signature})) { - error(_g('failed to verify signature on %s'), $dsc); + error(g_('failed to verify signature on %s'), $dsc); } elsif ($gpg_status) { - warning(_g('failed to verify signature on %s'), $dsc); + warning(g_('failed to verify signature on %s'), $dsc); } } else { subprocerr("@exec"); } } else { if ($self->{options}{require_valid_signature}) { - error(_g("could not verify signature on %s since gpg isn't installed"), $dsc); + error(g_("could not verify signature on %s since gpg isn't installed"), $dsc); } else { - warning(_g("could not verify signature on %s since gpg isn't installed"), $dsc); + warning(g_("could not verify signature on %s since gpg isn't installed"), $dsc); } } } @@ -440,7 +440,7 @@ sub parse_cmdline_options { my ($self, @opts) = @_; foreach my $option (@opts) { if (not $self->parse_cmdline_option($option)) { - warning(_g('%s is not a valid option for %s'), $option, ref $self); + warning(g_('%s is not a valid option for %s'), $option, ref $self); } } } @@ -502,7 +502,7 @@ sub extract { unless (-e $format_file) { mkdir($srcdir) unless -e $srcdir; open(my $format_fh, '>', $format_file) - or syserr(_g('cannot write %s'), $format_file); + or syserr(g_('cannot write %s'), $format_file); print { $format_fh } $self->{fields}{'Format'} . "\n"; close($format_fh); } @@ -513,15 +513,15 @@ sub extract { my @s = lstat($rules); if (not scalar(@s)) { unless ($! == ENOENT) { - syserr(_g('cannot stat %s'), $rules); + syserr(g_('cannot stat %s'), $rules); } - warning(_g('%s does not exist'), $rules) + warning(g_('%s does not exist'), $rules) unless $self->{options}{skip_debianization}; } elsif (-f _) { chmod($s[2] | 0111, $rules) - or syserr(_g('cannot make %s executable'), $rules); + or syserr(g_('cannot make %s executable'), $rules); } else { - warning(_g('%s is not a plain file'), $rules); + warning(g_('%s is not a plain file'), $rules); } } @@ -581,7 +581,7 @@ sub commit { sub do_commit { my ($self, $dir) = @_; - info(_g("'%s' is not supported by the source format '%s'"), + info(g_("'%s' is not supported by the source format '%s'"), 'dpkg-source --commit', $self->{fields}{'Format'}); } @@ -596,12 +596,12 @@ sub write_dsc { unless ($opts{nocheck}) { foreach my $f (qw(Source Version)) { unless (defined($fields->{$f})) { - error(_g('missing information for critical output field %s'), $f); + error(g_('missing information for critical output field %s'), $f); } } foreach my $f (qw(Maintainer Architecture Standards-Version)) { unless (defined($fields->{$f})) { - warning(_g('missing information for output field %s'), $f); + warning(g_('missing information for output field %s'), $f); } } } @@ -613,7 +613,7 @@ sub write_dsc { my $filename = $opts{filename}; $filename //= $self->get_basename(1) . '.dsc'; open(my $dsc_fh, '>', $filename) - or syserr(_g('cannot write %s'), $filename); + or syserr(g_('cannot write %s'), $filename); $fields->apply_substvars($opts{substvars}); $fields->output($dsc_fh); close($dsc_fh); diff --git a/scripts/Dpkg/Source/Package/V1.pm b/scripts/Dpkg/Source/Package/V1.pm index ef1907469..b9d0db612 100644 --- a/scripts/Dpkg/Source/Package/V1.pm +++ b/scripts/Dpkg/Source/Package/V1.pm @@ -66,7 +66,7 @@ sub parse_cmdline_option { my ($self, $opt) = @_; my $o = $self->{options}; if ($opt =~ m/^-s([akpursnAKPUR])$/) { - warning(_g('-s%s option overrides earlier -s%s option'), $1, + warning(g_('-s%s option overrides earlier -s%s option'), $1, $o->{sourcestyle}) if $o->{sourcestyle} ne 'X'; $o->{sourcestyle} = $1; $o->{copy_orig_tarballs} = 0 if $1 eq 'n'; # Extract option -sn @@ -91,7 +91,7 @@ sub do_extract { $sourcestyle =~ y/X/p/; unless ($sourcestyle =~ m/[pun]/) { - usageerr(_g('source handling style -s%s not allowed with -x'), + usageerr(g_('source handling style -s%s not allowed with -x'), $sourcestyle); } @@ -104,20 +104,20 @@ sub do_extract { my ($tarfile, $difffile); foreach my $file ($self->get_files()) { if ($file =~ /^(?:\Q$basename\E\.orig|\Q$basenamerev\E)\.tar\.gz$/) { - error(_g('multiple tarfiles in v1.0 source package')) if $tarfile; + error(g_('multiple tarfiles in v1.0 source package')) if $tarfile; $tarfile = $file; } elsif ($file =~ /^\Q$basenamerev\E\.diff\.gz$/) { $difffile = $file; } else { - error(_g('unrecognized file for a %s source package: %s'), + error(g_('unrecognized file for a %s source package: %s'), 'v1.0', $file); } } - error(_g('no tarfile in Files field')) unless $tarfile; + error(g_('no tarfile in Files field')) unless $tarfile; my $native = $difffile ? 0 : 1; if ($native and ($tarfile =~ /\.orig\.tar\.gz$/)) { - warning(_g('native package with .orig.tar')); + warning(g_('native package with .orig.tar')); $native = 0; # V3::Native doesn't handle orig.tar } @@ -130,43 +130,43 @@ sub do_extract { erasedir($newdirectory); if (-e $expectprefix) { rename($expectprefix, "$newdirectory.tmp-keep") - or syserr(_g("unable to rename `%s' to `%s'"), $expectprefix, + or syserr(g_("unable to rename `%s' to `%s'"), $expectprefix, "$newdirectory.tmp-keep"); } - info(_g('unpacking %s'), $tarfile); + info(g_('unpacking %s'), $tarfile); my $tar = Dpkg::Source::Archive->new(filename => "$dscdir$tarfile"); $tar->extract($expectprefix); if ($sourcestyle =~ /u/) { # -su: keep .orig directory unpacked if (-e "$newdirectory.tmp-keep") { - error(_g('unable to keep orig directory (already exists)')); + error(g_('unable to keep orig directory (already exists)')); } system('cp', '-ar', '--', $expectprefix, "$newdirectory.tmp-keep"); subprocerr("cp $expectprefix to $newdirectory.tmp-keep") if $?; } rename($expectprefix, $newdirectory) - or syserr(_g('failed to rename newly-extracted %s to %s'), + or syserr(g_('failed to rename newly-extracted %s to %s'), $expectprefix, $newdirectory); # rename the copied .orig directory if (-e "$newdirectory.tmp-keep") { rename("$newdirectory.tmp-keep", $expectprefix) - or syserr(_g('failed to rename saved %s to %s'), + or syserr(g_('failed to rename saved %s to %s'), "$newdirectory.tmp-keep", $expectprefix); } } if ($difffile and not $self->{options}{skip_debianization}) { my $patch = "$dscdir$difffile"; - info(_g('applying %s'), $difffile); + info(g_('applying %s'), $difffile); my $patch_obj = Dpkg::Source::Patch->new(filename => $patch); my $analysis = $patch_obj->apply($newdirectory, force_timestamp => 1); my @files = grep { ! m{^\Q$newdirectory\E/debian/} } sort keys %{$analysis->{filepatched}}; - info(_g('upstream files that have been modified: %s'), + info(g_('upstream files that have been modified: %s'), "\n " . join("\n ", @files)) if scalar @files; } } @@ -176,7 +176,7 @@ sub can_build { # As long as we can use gzip, we can do it as we have # native packages as fallback - return (0, _g('only supports gzip compression')) + return (0, g_('only supports gzip compression')) unless $self->{options}{compression} eq 'gzip'; return 1; } @@ -189,13 +189,13 @@ sub do_build { my $diff_ignore_regex = $self->{options}{diff_ignore_regex}; if (scalar(@argv) > 1) { - usageerr(_g('-b takes at most a directory and an orig source ' . + usageerr(g_('-b takes at most a directory and an orig source ' . 'argument (with v1.0 source package)')); } $sourcestyle =~ y/X/A/; unless ($sourcestyle =~ m/[akpursnAKPUR]/) { - usageerr(_g('source handling style -s%s not allowed with -b'), + usageerr(g_('source handling style -s%s not allowed with -b'), $sourcestyle); } @@ -210,7 +210,7 @@ sub do_build { my $origtargz = $self->get_basename() . '.orig.tar.gz'; if (-e $origtargz) { unless (-f $origtargz) { - error(_g("packed orig `%s' exists but is not a plain file"), $origtargz); + error(g_("packed orig `%s' exists but is not a plain file"), $origtargz); } } else { $origtargz = undef; @@ -222,13 +222,13 @@ sub do_build { my $origarg = shift(@argv); if (length($origarg)) { stat($origarg) - or syserr(_g('cannot stat orig argument %s'), $origarg); + or syserr(g_('cannot stat orig argument %s'), $origarg); if (-d _) { $origdir = File::Spec->catdir($origarg); $sourcestyle =~ y/aA/rR/; unless ($sourcestyle =~ m/[ursURS]/) { - error(_g('orig argument is unpacked but source handling ' . + error(g_('orig argument is unpacked but source handling ' . 'style -s%s calls for packed (.orig.tar.<ext>)'), $sourcestyle); } @@ -236,18 +236,18 @@ sub do_build { $origtargz = $origarg; $sourcestyle =~ y/aA/pP/; unless ($sourcestyle =~ m/[kpsKPS]/) { - error(_g('orig argument is packed but source handling ' . + error(g_('orig argument is packed but source handling ' . 'style -s%s calls for unpacked (.orig/)'), $sourcestyle); } } else { - error(_g('orig argument %s is not a plain file or directory'), + error(g_('orig argument %s is not a plain file or directory'), $origarg); } } else { $sourcestyle =~ y/aA/nn/; unless ($sourcestyle =~ m/n/) { - error(_g('orig argument is empty (means no orig, no diff) ' . + error(g_('orig argument is empty (means no orig, no diff) ' . 'but source handling style -s%s wants something'), $sourcestyle); } @@ -261,12 +261,12 @@ sub do_build { } else { if (stat($origdir)) { unless (-d _) { - error(_g("unpacked orig `%s' exists but is not a directory"), + error(g_("unpacked orig `%s' exists but is not a directory"), $origdir); } $sourcestyle =~ y/aA/rR/; # .orig directory } elsif ($! != ENOENT) { - syserr(_g("unable to stat putative unpacked orig `%s'"), $origdir); + syserr(g_("unable to stat putative unpacked orig `%s'"), $origdir); } else { $sourcestyle =~ y/aA/nn/; # Native tar.gz } @@ -275,7 +275,7 @@ sub do_build { my ($dirname, $dirbase) = fileparse($dir); if ($dirname ne $basedirname) { - warning(_g("source directory '%s' is not <sourcepackage>" . + warning(g_("source directory '%s' is not <sourcepackage>" . "-<upstreamversion> '%s'"), $dir, $basedirname); } @@ -284,7 +284,7 @@ sub do_build { my ($origdirname, $origdirbase) = fileparse($origdir); if ($origdirname ne "$basedirname.orig") { - warning(_g('.orig directory name %s is not <package>' . + warning(g_('.orig directory name %s is not <package>' . '-<upstreamversion> (wanted %s)'), $origdirname, "$basedirname.orig"); } @@ -293,7 +293,7 @@ sub do_build { $tarname = $origtargz || "$basename.orig.tar.gz"; unless ($tarname =~ /\Q$basename\E\.orig\.tar\.gz/) { - warning(_g('.orig.tar name %s is not <package>_<upstreamversion>' . + warning(g_('.orig.tar name %s is not <package>_<upstreamversion>' . '.orig.tar (wanted %s)'), $tarname, "$basename.orig.tar.gz"); } @@ -305,14 +305,14 @@ sub do_build { } elsif ($sourcestyle =~ m/[nurUR]/) { if (stat($tarname)) { unless ($sourcestyle =~ m/[nUR]/) { - error(_g("tarfile `%s' already exists, not overwriting, " . + error(g_("tarfile `%s' already exists, not overwriting, " . 'giving up; use -sU or -sR to override'), $tarname); } } elsif ($! != ENOENT) { - syserr(_g("unable to check for existence of `%s'"), $tarname); + syserr(g_("unable to check for existence of `%s'"), $tarname); } - info(_g('building %s in %s'), + info(g_('building %s in %s'), $sourcepackage, $tarname); my ($ntfh, $newtar) = tempfile("$tarname.new.XXXXXX", @@ -324,12 +324,12 @@ sub do_build { $tar->add_directory($tardirname); $tar->finish(); rename($newtar, $tarname) - or syserr(_g("unable to rename `%s' (newly created) to `%s'"), + or syserr(g_("unable to rename `%s' (newly created) to `%s'"), $newtar, $tarname); chmod(0666 &~ umask(), $tarname) - or syserr(_g("unable to change permission of `%s'"), $tarname); + or syserr(g_("unable to change permission of `%s'"), $tarname); } else { - info(_g('building %s using existing %s'), + info(g_('building %s using existing %s'), $sourcepackage, $tarname); } @@ -338,7 +338,7 @@ sub do_build { if ($sourcestyle =~ m/[kpKP]/) { if (stat($origdir)) { unless ($sourcestyle =~ m/[KP]/) { - error(_g("orig dir `%s' already exists, not overwriting, ". + error(g_("orig dir `%s' already exists, not overwriting, ". 'giving up; use -sA, -sK or -sP to override'), $origdir); } @@ -346,7 +346,7 @@ sub do_build { erasedir($origdir); pop_exit_handler(); } elsif ($! != ENOENT) { - syserr(_g("unable to check for existence of orig dir `%s'"), + syserr(g_("unable to check for existence of orig dir `%s'"), $origdir); } @@ -357,7 +357,7 @@ sub do_build { my $ur; # Unrepresentable changes if ($sourcestyle =~ m/[kpursKPUR]/) { my $diffname = "$basenamerev.diff.gz"; - info(_g('building %s in %s'), + info(g_('building %s in %s'), $sourcepackage, $diffname); my ($ndfh, $newdiffgz) = tempfile("$diffname.new.XXXXXX", DIR => getcwd(), UNLINK => 0); @@ -379,19 +379,19 @@ sub do_build { map { my $file = $_; $file =~ s{^[^/]+/+}{}; $file } sort keys %{$analysis->{filepatched}}; if (scalar @files) { - warning(_g('the diff modifies the following upstream files: %s'), + warning(g_('the diff modifies the following upstream files: %s'), "\n " . join("\n ", @files)); - info(_g("use the '3.0 (quilt)' format to have separate and " . + info(g_("use the '3.0 (quilt)' format to have separate and " . 'documented changes to upstream files, see dpkg-source(1)')); - error(_g('aborting due to --abort-on-upstream-changes')) + error(g_('aborting due to --abort-on-upstream-changes')) if $self->{options}{abort_on_upstream_changes}; } rename($newdiffgz, $diffname) - or syserr(_g("unable to rename `%s' (newly created) to `%s'"), + or syserr(g_("unable to rename `%s' (newly created) to `%s'"), $newdiffgz, $diffname); chmod(0666 &~ umask(), $diffname) - or syserr(_g("unable to change permission of `%s'"), $diffname); + or syserr(g_("unable to change permission of `%s'"), $diffname); $self->add_file($diffname); } @@ -401,7 +401,7 @@ sub do_build { } if ($ur) { - printf { *STDERR } _g('%s: unrepresentable changes to source') . "\n", + printf { *STDERR } g_('%s: unrepresentable changes to source') . "\n", $Dpkg::PROGNAME; exit(1); } diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index 14e7a55f4..e985b0de8 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -122,7 +122,7 @@ sub do_extract { my $uncompressed = $file; $uncompressed =~ s/\.$re_ext$/.*/; $uncompressed =~ s/\.$re_ext\.asc$/.*.asc/; - 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$/) { @@ -136,23 +136,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'), + 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')); } if ($tarsign and $tarfile ne substr $tarsign, 0, -4) { - error(_g('mismatched orig.tar %s for signature %s in source package'), + error(g_('mismatched orig.tar %s for signature %s in source package'), $tarfile, $tarsign); } foreach my $name (keys %addonsign) { - error(_g('missing addon orig.tar for signature %s in source package'), + error(g_('missing addon orig.tar for signature %s in source package'), $addonsign{$name}) if not exists $addonfile{$name}; - error(_g('mismatched addon orig.tar %s for signature %s in source package'), + error(g_('mismatched addon orig.tar %s for signature %s in source package'), $addonfile{$name}, $addonsign{$name}) if $addonfile{$name} ne substr $addonsign{$name}, 0, -4; } @@ -160,7 +160,7 @@ sub do_extract { 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', @@ -172,9 +172,9 @@ sub do_extract { # Extract additional orig tarballs foreach my $subdir (sort keys %addonfile) { my $file = $addonfile{$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); + warning(g_("required removal of `%s' installed by original tarball"), $subdir); erasedir("$newdirectory/$subdir"); } $tar = Dpkg::Source::Archive->new(filename => "$dscdir$file"); @@ -185,7 +185,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 @@ -218,7 +218,7 @@ sub get_patches { my $pd = "$dir/debian/patches"; my $auto_patch = $self->get_autopatch_name(); if (-d $pd) { - opendir(my $dir_dh, $pd) or syserr(_g('cannot opendir %s'), $pd); + opendir(my $dir_dh, $pd) or 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"; @@ -237,12 +237,12 @@ sub apply_patches { return unless scalar(@patches); my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied'); open(my $applied_fh, '>', $applied) - or syserr(_g('cannot write %s'), $applied); + or 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}; + 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, @@ -260,7 +260,7 @@ sub unapply_patches { 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}; + 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, @@ -283,7 +283,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())); } @@ -298,7 +298,7 @@ sub after_build { my $reason = ''; if (-e $applied) { open(my $applied_fh, '<', $applied) - or syserr(_g('cannot read %s'), $applied); + or syserr(g_('cannot read %s'), $applied); $reason = <$applied_fh>; close($applied_fh); } @@ -337,7 +337,7 @@ sub check_patches_applied { my ($self, $dir) = @_; 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'); } } @@ -355,7 +355,7 @@ sub generate_patch { foreach my $file (sort $self->find_original_tarballs()) { if ($file =~ /\.orig\.tar\.$comp_ext_regex$/) { if (defined($tarfile)) { - error(_g('several orig.tar files found (%s and %s) but only ' . + error(g_('several orig.tar files found (%s and %s) but only ' . 'one is allowed'), $tarfile, $file); } $tarfile = $file; @@ -368,11 +368,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'), + info(g_('building %s using existing %s'), $self->{fields}{'Source'}, "@origtarballs"); } @@ -394,7 +394,7 @@ 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 $?; + subprocerr(g_('copy of the debian directory')) if $?; # Apply all patches except the last automatic one $opts{skip_auto} //= 0; @@ -419,10 +419,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"; @@ -441,7 +441,7 @@ sub do_build { my ($self, $dir) = @_; my @argv = @{$self->{options}{ARGV}}; if (scalar(@argv)) { - usageerr(_g("-b takes only one parameter with format `%s'"), + usageerr(g_("-b takes only one parameter with format `%s'"), $self->{fields}{'Format'}); } $self->prepare_build($dir); @@ -460,7 +460,7 @@ 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++; } } @@ -478,13 +478,13 @@ sub do_build { my $reldir = File::Spec->abs2rel($File::Find::dir, $dir); my $cwd = getcwd(); # Apply the pattern both from the top dir and from the inspected dir - chdir($dir) or syserr(_g("unable to chdir to `%s'"), $dir); + chdir($dir) or syserr(g_("unable to chdir to `%s'"), $dir); $exclude{$_} = 1 foreach glob($tar_ignore_glob); - chdir($cwd) or syserr(_g("unable to chdir to `%s'"), $cwd); + chdir($cwd) or syserr(g_("unable to chdir to `%s'"), $cwd); chdir($File::Find::dir) - or syserr(_g("unable to chdir to `%s'"), $File::Find::dir); + or syserr(g_("unable to chdir to `%s'"), $File::Find::dir); $exclude{$_} = 1 foreach glob($tar_ignore_glob); - chdir($cwd) or syserr(_g("unable to chdir to `%s'"), $cwd); + chdir($cwd) or syserr(g_("unable to chdir to `%s'"), $cwd); my @result; foreach my $fn (@_) { unless (exists $exclude{$fn} or exists $exclude{"$reldir/$fn"}) { @@ -509,9 +509,9 @@ sub do_build { my $file = $opts{filename}; $binaryfiles->new_binary_found($file); unless ($include_binaries or $binaryfiles->binary_is_allowed($file)) { - errormsg(_g('cannot represent change to %s: %s'), $file, - _g('binary file contents changed')); - errormsg(_g('add %s in debian/source/include-binaries if you want ' . + errormsg(g_('cannot represent change to %s: %s'), $file, + 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'), $file); $self->register_error(); @@ -527,9 +527,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'), + info(g_('you can integrate the local changes with %s'), 'dpkg-source --commit'); - error(_g('aborting due to unexpected upstream changes, see %s'), + error(g_('aborting due to unexpected upstream changes, see %s'), $tmpdiff); } push_exit_handler(sub { unlink($tmpdiff) }); @@ -540,16 +540,16 @@ sub do_build { 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 } - unlink($tmpdiff) or syserr(_g('cannot remove %s'), $tmpdiff); + unlink($tmpdiff) or syserr(g_('cannot remove %s'), $tmpdiff); pop_exit_handler(); # 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, compression_level => $self->{options}{comp_level}); $tar->create(options => \@tar_ignore, chdir => $dir); @@ -570,7 +570,7 @@ sub get_patch_header { } my $text; if (-f $ph) { - open(my $ph_fh, '<', $ph) or syserr(_g('cannot read %s'), $ph); + open(my $ph_fh, '<', $ph) or syserr(g_('cannot read %s'), $ph); $text = file_slurp($ph_fh); close($ph_fh); return $text; @@ -610,16 +610,16 @@ sub register_patch { my $patch = File::Spec->catfile($dir, 'debian', 'patches', $patch_name); if (-s $patch_file) { copy($patch_file, $patch) - or syserr(_g('failed to copy %s to %s'), $patch_file, $patch); + or syserr(g_('failed to copy %s to %s'), $patch_file, $patch); chmod(0666 & ~ umask(), $patch) - or syserr(_g("unable to change permission of `%s'"), $patch); + or syserr(g_("unable to change permission of `%s'"), $patch); my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied'); open(my $applied_fh, '>>', $applied) - or syserr(_g('cannot write %s'), $applied); + or syserr(g_('cannot write %s'), $applied); print { $applied_fh } "$patch\n"; - close($applied_fh) or syserr(_g('cannot close %s'), $applied); + close($applied_fh) or syserr(g_('cannot close %s'), $applied); } elsif (-e $patch) { - unlink($patch) or syserr(_g('cannot remove %s'), $patch); + unlink($patch) or syserr(g_('cannot remove %s'), $patch); } return $patch; } @@ -632,7 +632,7 @@ sub _is_bad_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; } @@ -649,7 +649,7 @@ sub do_commit { if ($tmpdiff and not -e $tmpdiff) { $tmpdiff = File::Spec->catfile($dir, $tmpdiff) unless File::Spec->file_name_is_absolute($tmpdiff); - error(_g("patch file '%s' doesn't exist"), $tmpdiff) if not -e $tmpdiff; + error(g_("patch file '%s' doesn't exist"), $tmpdiff) if not -e $tmpdiff; } my $binaryfiles = Dpkg::Source::Package::V2::BinaryFiles->new($dir); @@ -666,13 +666,13 @@ sub do_commit { } push_exit_handler(sub { unlink($tmpdiff) }); unless (-s $tmpdiff) { - unlink($tmpdiff) or syserr(_g('cannot remove %s'), $tmpdiff); - info(_g('there are no local changes to record')); + unlink($tmpdiff) or 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 _g('Enter the desired patch name: '); + print g_('Enter the desired patch name: '); $patch_name = <STDIN>; next unless defined $patch_name; chomp $patch_name; @@ -684,13 +684,13 @@ sub do_commit { my @editors = ('sensible-editor', $ENV{VISUAL}, $ENV{EDITOR}, 'vi'); my $editor = first { find_command($_) } @editors; if (not $editor) { - error(_g('cannot find an editor')); + error(g_('cannot find an editor')); } system($editor, $patch); subprocerr($editor) if $?; - unlink($tmpdiff) or syserr(_g('cannot remove %s'), $tmpdiff); + unlink($tmpdiff) or syserr(g_('cannot remove %s'), $tmpdiff); pop_exit_handler(); - 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; @@ -727,7 +727,7 @@ sub load_allowed_binaries { my $incbin_file = $self->{include_binaries_path}; if (-f $incbin_file) { open(my $incbin_fh, '<', $incbin_file) - or syserr(_g('cannot read %s'), $incbin_file); + or syserr(g_('cannot read %s'), $incbin_file); while (<$incbin_fh>) { chomp; s/^\s*//; s/\s*$//; next if /^#/ or length == 0; @@ -752,10 +752,10 @@ sub update_debian_source_include_binaries { my $incbin_file = $self->{include_binaries_path}; mkpath(File::Spec->catdir($self->{dir}, 'debian', 'source')); open(my $incbin_fh, '>>', $incbin_file) - or syserr(_g('cannot write %s'), $incbin_file); + or 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); diff --git a/scripts/Dpkg/Source/Package/V3/Bzr.pm b/scripts/Dpkg/Source/Package/V3/Bzr.pm index bf91a84d2..da1182c4a 100644 --- a/scripts/Dpkg/Source/Package/V3/Bzr.pm +++ b/scripts/Dpkg/Source/Package/V3/Bzr.pm @@ -49,7 +49,7 @@ sub import { return 1; } } - error(_g('cannot unpack bzr-format source package because ' . + error(g_('cannot unpack bzr-format source package because ' . 'bzr is not in the PATH')); } @@ -57,20 +57,20 @@ sub sanity_check { my $srcdir = shift; if (! -d "$srcdir/.bzr") { - error(_g('source directory is not the top directory of a bzr repository (%s/.bzr not present), but Format bzr was specified'), + error(g_('source directory is not the top directory of a bzr repository (%s/.bzr not present), but Format bzr was specified'), $srcdir); } # Symlinks from .bzr to outside could cause unpack failures, or # point to files they shouldn't, so check for and don't allow. if (-l "$srcdir/.bzr") { - error(_g('%s is a symlink'), "$srcdir/.bzr"); + error(g_('%s is a symlink'), "$srcdir/.bzr"); } my $abs_srcdir = Cwd::abs_path($srcdir); find(sub { if (-l) { if (Cwd::abs_path(readlink) !~ /^\Q$abs_srcdir\E(?:\/|$)/) { - error(_g('%s is a symlink to outside %s'), + error(g_('%s is a symlink to outside %s'), $File::Find::name, $srcdir); } } @@ -82,7 +82,7 @@ sub sanity_check { sub can_build { my ($self, $dir) = @_; - return (0, _g("doesn't contain a bzr repository")) unless -d "$dir/.bzr"; + return (0, g_("doesn't contain a bzr repository")) unless -d "$dir/.bzr"; return 1; } @@ -97,7 +97,7 @@ sub do_build { my ($dirname, $updir) = fileparse($dir); if (scalar(@argv)) { - usageerr(_g("-b takes only one parameter with format `%s'"), + usageerr(g_("-b takes only one parameter with format `%s'"), $self->{fields}{'Format'}); } @@ -110,7 +110,7 @@ sub do_build { sanity_check($dir); my $old_cwd = getcwd(); - chdir($dir) or syserr(_g("unable to chdir to `%s'"), $dir); + chdir($dir) or syserr(g_("unable to chdir to `%s'"), $dir); local $_; @@ -128,13 +128,13 @@ sub do_build { push @files, $_; } } - close($bzr_status_fh) or syserr(_g('bzr status exited nonzero')); + close($bzr_status_fh) or syserr(g_('bzr status exited nonzero')); if (@files) { - error(_g('uncommitted, not-ignored changes in working directory: %s'), + error(g_('uncommitted, not-ignored changes in working directory: %s'), join(' ', @files)); } - chdir($old_cwd) or syserr(_g("unable to chdir to `%s'"), $old_cwd); + chdir($old_cwd) or syserr(g_("unable to chdir to `%s'"), $old_cwd); my $tmp = tempdir("$dirname.bzr.XXXXXX", DIR => $updir); push_exit_handler(sub { erasedir($tmp) }); @@ -153,7 +153,7 @@ sub do_build { # Create the tar file my $debianfile = "$basenamerev.bzr.tar." . $self->{options}{comp_ext}; - info(_g('building %s in %s'), + info(g_('building %s in %s'), $sourcepackage, $debianfile); my $tar = Dpkg::Source::Archive->new(filename => $debianfile, compression => $self->{options}{compression}, @@ -180,19 +180,19 @@ sub do_extract { my @files = $self->get_files(); if (@files > 1) { - error(_g('format v3.0 uses only one source file')); + error(g_('format v3.0 uses only one source file')); } my $tarfile = $files[0]; my $comp_ext_regex = compression_get_file_extension_regex(); if ($tarfile !~ /^\Q$basenamerev\E\.bzr\.tar\.$comp_ext_regex$/) { - error(_g('expected %s, got %s'), + error(g_('expected %s, got %s'), "$basenamerev.bzr.tar.$comp_ext_regex", $tarfile); } 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); @@ -200,13 +200,13 @@ sub do_extract { my $old_cwd = getcwd(); chdir($newdirectory) - or syserr(_g("unable to chdir to `%s'"), $newdirectory); + or syserr(g_("unable to chdir to `%s'"), $newdirectory); # Reconstitute the working tree. system('bzr', 'checkout'); subprocerr('bzr checkout') if $?; - chdir($old_cwd) or syserr(_g("unable to chdir to `%s'"), $old_cwd); + chdir($old_cwd) or syserr(g_("unable to chdir to `%s'"), $old_cwd); } 1; diff --git a/scripts/Dpkg/Source/Package/V3/Custom.pm b/scripts/Dpkg/Source/Package/V3/Custom.pm index 3ea9d05f8..68051132a 100644 --- a/scripts/Dpkg/Source/Package/V3/Custom.pm +++ b/scripts/Dpkg/Source/Package/V3/Custom.pm @@ -37,13 +37,13 @@ sub parse_cmdline_option { return 0; } sub do_extract { - error(_g("Format `3.0 (custom)' is only used to create source packages")); + error(g_("Format `3.0 (custom)' is only used to create source packages")); } sub can_build { my ($self, $dir) = @_; - return (0, _g('no files indicated on command line')) + return (0, g_('no files indicated on command line')) unless scalar(@{$self->{options}{ARGV}}); return 1; } @@ -52,7 +52,7 @@ sub do_build { my ($self, $dir) = @_; # Update real target format my $format = $self->{options}{target_format}; - error(_g('--target-format option is missing')) unless $format; + error(g_('--target-format option is missing')) unless $format; $self->{fields}{'Format'} = $format; # Add all files foreach my $file (@{$self->{options}{ARGV}}) { diff --git a/scripts/Dpkg/Source/Package/V3/Git.pm b/scripts/Dpkg/Source/Package/V3/Git.pm index 65e72f31f..7a1eaafe1 100644 --- a/scripts/Dpkg/Source/Package/V3/Git.pm +++ b/scripts/Dpkg/Source/Package/V3/Git.pm @@ -52,7 +52,7 @@ sub import { return 1; } } - error(_g('cannot unpack git-format source package because ' . + error(g_('cannot unpack git-format source package because ' . 'git is not in the PATH')); } @@ -60,12 +60,12 @@ sub sanity_check { my $srcdir = shift; if (! -d "$srcdir/.git") { - error(_g('source directory is not the top directory of a git ' . + error(g_('source directory is not the top directory of a git ' . 'repository (%s/.git not present), but Format git was ' . 'specified'), $srcdir); } if (-s "$srcdir/.gitmodules") { - error(_g('git repository %s uses submodules; this is not yet supported'), + error(g_('git repository %s uses submodules; this is not yet supported'), $srcdir); } @@ -88,7 +88,7 @@ sub parse_cmdline_option { sub can_build { my ($self, $dir) = @_; - return (0, _g("doesn't contain a git repository")) unless -d "$dir/.git"; + return (0, g_("doesn't contain a git repository")) unless -d "$dir/.git"; return 1; } @@ -103,7 +103,7 @@ sub do_build { sanity_check($dir); my $old_cwd = getcwd(); - chdir($dir) or syserr(_g("unable to chdir to `%s'"), $dir); + chdir($dir) or syserr(g_("unable to chdir to `%s'"), $dir); # Check for uncommitted files. # To support dpkg-source -i, get a list of files @@ -132,9 +132,9 @@ sub do_build { } } } - close($git_ls_files_fh) or syserr(_g('git ls-files exited nonzero')); + close($git_ls_files_fh) or syserr(g_('git ls-files exited nonzero')); if (@files) { - error(_g('uncommitted, not-ignored changes in working directory: %s'), + error(g_('uncommitted, not-ignored changes in working directory: %s'), join(' ', @files)); } @@ -143,19 +143,19 @@ sub do_build { my $tmp; my $shallowfile; if ($self->{options}{git_depth}) { - chdir($old_cwd) or syserr(_g("unable to chdir to `%s'"), $old_cwd); + chdir($old_cwd) or syserr(g_("unable to chdir to `%s'"), $old_cwd); $tmp = tempdir("$dirname.git.XXXXXX", DIR => $updir); push_exit_handler(sub { erasedir($tmp) }); my $clone_dir = "$tmp/repo.git"; # file:// is needed to avoid local cloning, which does not # create a shallow clone. - info(_g('creating shallow clone with depth %s'), + info(g_('creating shallow clone with depth %s'), $self->{options}{git_depth}); system('git', 'clone', '--depth=' . $self->{options}{git_depth}, '--quiet', '--bare', 'file://' . abs_path($dir), $clone_dir); subprocerr('git clone') if $?; chdir($clone_dir) - or syserr(_g("unable to chdir to `%s'"), $clone_dir); + or syserr(g_("unable to chdir to `%s'"), $clone_dir); $shallowfile = "$basenamerev.gitshallow"; system('cp', '-f', 'shallow', "$old_cwd/$shallowfile"); subprocerr('cp shallow') if $?; @@ -165,7 +165,7 @@ sub do_build { my $bundlefile = "$basenamerev.git"; my @bundle_arg=$self->{options}{git_ref} ? (@{$self->{options}{git_ref}}) : '--all'; - info(_g('bundling: %s'), join(' ', @bundle_arg)); + info(g_('bundling: %s'), join(' ', @bundle_arg)); system('git', 'bundle', 'create', "$old_cwd/$bundlefile", @bundle_arg, 'HEAD', # ensure HEAD is included no matter what @@ -173,7 +173,7 @@ sub do_build { ); subprocerr('git bundle') if $?; - chdir($old_cwd) or syserr(_g("unable to chdir to `%s'"), $old_cwd); + chdir($old_cwd) or syserr(g_("unable to chdir to `%s'"), $old_cwd); if (defined $tmp) { erasedir($tmp); @@ -200,33 +200,33 @@ sub do_extract { if (! defined $bundle) { $bundle = $file; } else { - error(_g('format v3.0 (git) uses only one .git file')); + error(g_('format v3.0 (git) uses only one .git file')); } } elsif ($file =~ /^\Q$basenamerev\E\.gitshallow$/) { if (! defined $shallow) { $shallow = $file; } else { - error(_g('format v3.0 (git) uses only one .gitshallow file')); + error(g_('format v3.0 (git) uses only one .gitshallow file')); } } else { - error(_g('format v3.0 (git) unknown file: %s', $file)); + error(g_('format v3.0 (git) unknown file: %s', $file)); } } if (! defined $bundle) { - error(_g('format v3.0 (git) expected %s'), "$basenamerev.git"); + error(g_('format v3.0 (git) expected %s'), "$basenamerev.git"); } erasedir($newdirectory); # Extract git bundle. - info(_g('cloning %s'), $bundle); + info(g_('cloning %s'), $bundle); system('git', 'clone', '--quiet', $dscdir . $bundle, $newdirectory); subprocerr('git bundle') if $?; if (defined $shallow) { # Move shallow info file into place, so git does not # try to follow parents of shallow refs. - info(_g('setting up shallow clone')); + info(g_('setting up shallow clone')); system('cp', '-f', $dscdir . $shallow, "$newdirectory/.git/shallow"); subprocerr('cp') if $?; } diff --git a/scripts/Dpkg/Source/Package/V3/Native.pm b/scripts/Dpkg/Source/Package/V3/Native.pm index 5b833e1af..c488a5349 100644 --- a/scripts/Dpkg/Source/Package/V3/Native.pm +++ b/scripts/Dpkg/Source/Package/V3/Native.pm @@ -50,17 +50,17 @@ sub do_extract { my $comp_ext_regex = compression_get_file_extension_regex(); foreach my $file ($self->get_files()) { if ($file =~ /^\Q$basenamerev\E\.tar\.$comp_ext_regex$/) { - error(_g('multiple tarfiles in v1.0 source package')) if $tarfile; + error(g_('multiple tarfiles in v1.0 source package')) if $tarfile; $tarfile = $file; } else { - error(_g('unrecognized file for a native source package: %s'), $file); + error(g_('unrecognized file for a native source package: %s'), $file); } } - error(_g('no tarfile in Files field')) unless $tarfile; + error(g_('no tarfile in Files field')) unless $tarfile; erasedir($newdirectory); - info(_g('unpacking %s'), $tarfile); + info(g_('unpacking %s'), $tarfile); my $tar = Dpkg::Source::Archive->new(filename => "$dscdir$tarfile"); $tar->extract($newdirectory); } @@ -69,7 +69,7 @@ sub can_build { my ($self, $dir) = @_; my $v = Dpkg::Version->new($self->{fields}->{'Version'}); - return (0, _g('native package version may not have a revision')) + return (0, g_('native package version may not have a revision')) unless $v->is_native(); return 1; @@ -81,7 +81,7 @@ sub do_build { my @argv = @{$self->{options}{ARGV}}; if (scalar(@argv)) { - usageerr(_g("-b takes only one parameter with format `%s'"), + usageerr(g_("-b takes only one parameter with format `%s'"), $self->{fields}{'Format'}); } @@ -89,7 +89,7 @@ sub do_build { my $basenamerev = $self->get_basename(1); my $tarname = "$basenamerev.tar." . $self->{options}{comp_ext}; - info(_g('building %s in %s'), $sourcepackage, $tarname); + info(g_('building %s in %s'), $sourcepackage, $tarname); my ($ntfh, $newtar) = tempfile("$tarname.new.XXXXXX", DIR => getcwd(), UNLINK => 0); @@ -103,11 +103,11 @@ sub do_build { $tar->add_directory($dirname); $tar->finish(); rename($newtar, $tarname) - or syserr(_g("unable to rename `%s' (newly created) to `%s'"), + or syserr(g_("unable to rename `%s' (newly created) to `%s'"), $newtar, $tarname); pop_exit_handler(); chmod(0666 &~ umask(), $tarname) - or syserr(_g("unable to change permission of `%s'"), $tarname); + or syserr(g_("unable to change permission of `%s'"), $tarname); $self->add_file($tarname); } diff --git a/scripts/Dpkg/Source/Package/V3/Quilt.pm b/scripts/Dpkg/Source/Package/V3/Quilt.pm index 39f04f0cb..b43d734d0 100644 --- a/scripts/Dpkg/Source/Package/V3/Quilt.pm +++ b/scripts/Dpkg/Source/Package/V3/Quilt.pm @@ -74,7 +74,7 @@ sub can_build { return ($code, $msg) if $code == 0; my $v = Dpkg::Version->new($self->{fields}->{'Version'}); - return (0, _g('non-native package version does not contain a revision')) + return (0, g_('non-native package version does not contain a revision')) if $v->is_native(); my $quilt = $self->build_quilt_object($dir); @@ -117,7 +117,7 @@ sub apply_patches { unlink($dest) if -l $dest; unless (-f _) { # Don't overwrite real files symlink($basename, $dest) - or syserr(_g("can't create symlink %s"), $dest); + or syserr(g_("can't create symlink %s"), $dest); } } @@ -129,7 +129,7 @@ sub apply_patches { # them afterwards in --after-build my $pc_unapply = $quilt->get_db_file('.dpkg-source-unapply'); open(my $unapply_fh, '>', $pc_unapply) - or syserr(_g('cannot write %s'), $pc_unapply); + or syserr(g_('cannot write %s'), $pc_unapply); close($unapply_fh); } @@ -187,9 +187,9 @@ sub do_build { if (any { $version eq $_ } @{$self->{options}{allow_version_of_quilt_db}}) { - warning(_g('unsupported version of the quilt metadata: %s'), $version); + warning(g_('unsupported version of the quilt metadata: %s'), $version); } else { - error(_g('unsupported version of the quilt metadata: %s'), $version); + error(g_('unsupported version of the quilt metadata: %s'), $version); } } @@ -229,11 +229,11 @@ sub register_patch { if (-s $tmpdiff) { copy($tmpdiff, $patch) - or syserr(_g('failed to copy %s to %s'), $tmpdiff, $patch); + or syserr(g_('failed to copy %s to %s'), $tmpdiff, $patch); chmod(0666 & ~ umask(), $patch) - or syserr(_g("unable to change permission of `%s'"), $patch); + or syserr(g_("unable to change permission of `%s'"), $patch); } elsif (-e $patch) { - unlink($patch) or syserr(_g('cannot remove %s'), $patch); + unlink($patch) or syserr(g_('cannot remove %s'), $patch); } if (-e $patch) { diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm index 3dab91dc9..ed2acce9b 100644 --- a/scripts/Dpkg/Source/Patch.pm +++ b/scripts/Dpkg/Source/Patch.pm @@ -68,7 +68,7 @@ sub add_diff_file { my $handle_binary = $opts{handle_binary_func} // sub { my ($self, $old, $new, %opts) = @_; my $file = $opts{filename}; - $self->_fail_with_msg($file, _g('binary file contents changed')); + $self->_fail_with_msg($file, g_('binary file contents changed')); }; # Optimization to avoid forking diff if unnecessary return 1 if compare($old, $new, 4096) == 0; @@ -118,17 +118,17 @@ sub add_diff_file { } elsif (m/^[-+\@ ]/) { $difflinefound++; } elsif (m/^\\ /) { - warning(_g('file %s has no final newline (either ' . + warning(g_('file %s has no final newline (either ' . 'original or modified version)'), $new); } else { chomp; - error(_g("unknown line from diff -u on %s: `%s'"), $new, $_); + error(g_("unknown line from diff -u on %s: `%s'"), $new, $_); } if (*$self->{empty} and defined(*$self->{header})) { - $self->print(*$self->{header}) or syserr(_g('failed to write')); + $self->print(*$self->{header}) or syserr(g_('failed to write')); *$self->{empty} = 0; } - print { $self } $_ or syserr(_g('failed to write')); + print { $self } $_ or syserr(g_('failed to write')); } close($diffgen) or syserr('close on diff pipe'); wait_child($diff_pid, nocheck => 1, @@ -138,7 +138,7 @@ sub add_diff_file { # Ignore error if binary content detected my $exit = WEXITSTATUS($?); unless (WIFEXITED($?) && ($exit == 0 || $exit == 1 || $binary)) { - subprocerr(_g('diff on %s'), $new); + subprocerr(g_('diff on %s'), $new); } return ($exit == 0 || $exit == 1); } @@ -164,7 +164,7 @@ sub add_diff_directory { my $fn = (length > length($new)) ? substr($_, length($new) + 1) : '.'; return if &$diff_ignore($fn); $files_in_new{$fn} = 1; - lstat("$new/$fn") or syserr(_g('cannot stat file %s'), "$new/$fn"); + lstat("$new/$fn") or syserr(g_('cannot stat file %s'), "$new/$fn"); my $mode = S_IMODE((lstat(_))[2]); my $size = (lstat(_))[7]; if (-l _) { @@ -174,11 +174,11 @@ sub add_diff_directory { } my $n = readlink("$new/$fn"); unless (defined $n) { - syserr(_g('cannot read link %s'), "$new/$fn"); + syserr(g_('cannot read link %s'), "$new/$fn"); } my $n2 = readlink("$old/$fn"); unless (defined $n2) { - syserr(_g('cannot read link %s'), "$old/$fn"); + syserr(g_('cannot read link %s'), "$old/$fn"); } unless ($n eq $n2) { $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn); @@ -187,7 +187,7 @@ sub add_diff_directory { my $old_file = "$old/$fn"; if (not lstat("$old/$fn")) { if ($! != ENOENT) { - syserr(_g('cannot stat file %s'), "$old/$fn"); + syserr(g_('cannot stat file %s'), "$old/$fn"); } $old_file = '/dev/null'; } elsif (not -f _) { @@ -207,35 +207,35 @@ sub add_diff_directory { } } elsif (-b _ || -c _ || -S _) { $self->_fail_with_msg("$new/$fn", - _g('device or socket is not allowed')); + g_('device or socket is not allowed')); } elsif (-d _) { if (not lstat("$old/$fn")) { if ($! != ENOENT) { - syserr(_g('cannot stat file %s'), "$old/$fn"); + syserr(g_('cannot stat file %s'), "$old/$fn"); } } elsif (not -d _) { $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn); } } else { - $self->_fail_with_msg("$new/$fn", _g('unknown file type')); + $self->_fail_with_msg("$new/$fn", g_('unknown file type')); } }; my $scan_old = sub { my $fn = (length > length($old)) ? substr($_, length($old) + 1) : '.'; return if &$diff_ignore($fn); return if $files_in_new{$fn}; - lstat("$old/$fn") or syserr(_g('cannot stat file %s'), "$old/$fn"); + lstat("$old/$fn") or syserr(g_('cannot stat file %s'), "$old/$fn"); if (-f _) { if ($inc_removal) { push @diff_files, [$fn, 0, 0, "$old/$fn", '/dev/null', "$basedir.orig/$fn", '/dev/null']; } else { - warning(_g('ignoring deletion of file %s, use --include-removal to override'), $fn); + warning(g_('ignoring deletion of file %s, use --include-removal to override'), $fn); } } elsif (-d _) { - warning(_g('ignoring deletion of directory %s'), $fn); + warning(g_('ignoring deletion of directory %s'), $fn); } elsif (-l _) { - warning(_g('ignoring deletion of symlink %s'), $fn); + warning(g_('ignoring deletion of symlink %s'), $fn); } else { $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn); } @@ -280,16 +280,16 @@ sub add_diff_directory { if ($success and $old_file eq '/dev/null' and $new_file ne '/dev/null') { if (not $size) { - warning(_g("newly created empty file '%s' will not " . + warning(g_("newly created empty file '%s' will not " . 'be represented in diff'), $fn); } else { if ($mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { - warning(_g("executable mode %04o of '%s' will " . + warning(g_("executable mode %04o of '%s' will " . 'not be represented in diff'), $mode, $fn) unless $fn eq 'debian/rules'; } if ($mode & (S_ISUID | S_ISGID | S_ISVTX)) { - warning(_g("special mode %04o of '%s' will not " . + warning(g_("special mode %04o of '%s' will not " . 'be represented in diff'), $mode, $fn); } } @@ -299,7 +299,7 @@ sub add_diff_directory { sub finish { my ($self) = @_; - close($self) or syserr(_g('cannot close %s'), $self->get_filename()); + close($self) or syserr(g_('cannot close %s'), $self->get_filename()); return not *$self->{errors}; } @@ -309,16 +309,16 @@ sub register_error { } sub _fail_with_msg { my ($self, $file, $msg) = @_; - errormsg(_g('cannot represent change to %s: %s'), $file, $msg); + errormsg(g_('cannot represent change to %s: %s'), $file, $msg); $self->register_error(); } sub _fail_not_same_type { my ($self, $old, $new, $file) = @_; my $old_type = get_type($old); my $new_type = get_type($new); - errormsg(_g('cannot represent change to %s:'), $file); - errormsg(_g(' new version is %s'), $new_type); - errormsg(_g(' old version is %s'), $old_type); + errormsg(g_('cannot represent change to %s:'), $file); + errormsg(g_(' new version is %s'), $new_type); + errormsg(g_(' old version is %s'), $old_type); $self->register_error(); } @@ -343,7 +343,7 @@ sub _fetch_filename { # Is it a C-style string? if ($header =~ m/^"/) { - error(_g('diff %s patches file with C-style encoded filename'), $diff); + error(g_('diff %s patches file with C-style encoded filename'), $diff); } else { # Tab is the official separator, it's always used when # filename contain spaces. Try it first, otherwise strip on space @@ -421,22 +421,22 @@ sub analyze { $diff_count++; # read file header (---/+++ pair) unless ($line =~ s/^--- //) { - error(_g("expected ^--- in line %d of diff `%s'"), $., $diff); + error(g_("expected ^--- in line %d of diff `%s'"), $., $diff); } $path{old} = $line = _fetch_filename($diff, $line); if ($line ne '/dev/null' and $line =~ s{^[^/]*/+}{$destdir/}) { $fn{old} = $line; } if ($line =~ /\.dpkg-orig$/) { - error(_g("diff `%s' patches file with name ending .dpkg-orig"), $diff); + error(g_("diff `%s' patches file with name ending .dpkg-orig"), $diff); } $line = _getline($self); unless (defined $line) { - error(_g("diff `%s' finishes in middle of ---/+++ (line %d)"), $diff, $.); + error(g_("diff `%s' finishes in middle of ---/+++ (line %d)"), $diff, $.); } unless ($line =~ s/^\+\+\+ //) { - error(_g("line after --- isn't as expected in diff `%s' (line %d)"), $diff, $.); + error(g_("line after --- isn't as expected in diff `%s' (line %d)"), $diff, $.); } $path{new} = $line = _fetch_filename($diff, $line); if ($line ne '/dev/null' and $line =~ s{^[^/]*/+}{$destdir/}) { @@ -444,7 +444,7 @@ sub analyze { } unless (defined $fn{old} or defined $fn{new}) { - error(_g("none of the filenames in ---/+++ are valid in diff '%s' (line %d)"), + error(g_("none of the filenames in ---/+++ are valid in diff '%s' (line %d)"), $diff, $.); } @@ -452,12 +452,12 @@ sub analyze { foreach my $key ('old', 'new') { next unless defined $fn{$key}; if ($path{$key} =~ m{/\.\./}) { - error(_g('%s contains an insecure path: %s'), $diff, $path{$key}); + error(g_('%s contains an insecure path: %s'), $diff, $path{$key}); } my $path = $fn{$key}; while (1) { if (-l $path) { - error(_g('diff %s modifies file %s through a symlink: %s'), + error(g_('diff %s modifies file %s through a symlink: %s'), $diff, $fn{$key}, $path); } last unless $path =~ s{/+[^/]*$}{}; @@ -466,13 +466,13 @@ sub analyze { } if ($path{old} eq '/dev/null' and $path{new} eq '/dev/null') { - error(_g("original and modified files are /dev/null in diff `%s' (line %d)"), + error(g_("original and modified files are /dev/null in diff `%s' (line %d)"), $diff, $.); } elsif ($path{new} eq '/dev/null') { - error(_g("file removal without proper filename in diff `%s' (line %d)"), + error(g_("file removal without proper filename in diff `%s' (line %d)"), $diff, $. - 1) unless defined $fn{old}; if ($opts{verbose}) { - warning(_g('diff %s removes a non-existing file %s (line %d)'), + warning(g_('diff %s removes a non-existing file %s (line %d)'), $diff, $fn{old}, $.) unless -e $fn{old}; } } @@ -484,11 +484,11 @@ sub analyze { } if (-e $fn and not -f _) { - error(_g("diff `%s' patches something which is not a plain file"), $diff); + error(g_("diff `%s' patches something which is not a plain file"), $diff); } if ($filepatched{$fn}) { - warning(_g("diff `%s' patches file %s twice"), $diff, $fn) + warning(g_("diff `%s' patches file %s twice"), $diff, $fn) if $opts{verbose}; } else { $filepatched{$fn} = 1; @@ -506,11 +506,11 @@ sub analyze { while ($olines || $nlines) { unless (defined($line = _getline($self))) { if (($olines == $nlines) and ($olines < 3)) { - warning(_g("unexpected end of diff `%s'"), $diff) + warning(g_("unexpected end of diff `%s'"), $diff) if $opts{verbose}; last; } else { - error(_g("unexpected end of diff `%s'"), $diff); + error(g_("unexpected end of diff `%s'"), $diff); } } next if $line =~ /^\\ /; @@ -523,19 +523,19 @@ sub analyze { } elsif ($line =~ /^\+/) { --$nlines; } else { - error(_g("expected [ +-] at start of line %d of diff `%s'"), + error(g_("expected [ +-] at start of line %d of diff `%s'"), $., $diff); } } $hunk++; } unless ($hunk) { - error(_g("expected ^\@\@ at line %d of diff `%s'"), $., $diff); + error(g_("expected ^\@\@ at line %d of diff `%s'"), $., $diff); } } close($self); unless ($diff_count) { - warning(_g("diff `%s' doesn't contain any patch"), $diff) + warning(g_("diff `%s' doesn't contain any patch"), $diff) if $opts{verbose}; } *$self->{analysis}{$destdir}{dirtocreate} = \%dirtocreate; @@ -550,7 +550,7 @@ sub prepare_apply { if ($opts{create_dirs}) { foreach my $dir (keys %{$analysis->{dirtocreate}}) { eval { mkpath($dir, 0, 0777); }; - syserr(_g('cannot create directory %s'), $dir) if $@; + syserr(g_('cannot create directory %s'), $dir) if $@; } } } @@ -597,11 +597,11 @@ sub apply { foreach my $fn (@files) { if ($opts{force_timestamp}) { utime($now, $now, $fn) or $! == ENOENT - or syserr(_g('cannot change timestamp for %s'), $fn); + or syserr(g_('cannot change timestamp for %s'), $fn); } if ($opts{remove_backup}) { $fn .= '.dpkg-orig'; - unlink($fn) or syserr(_g('remove patch backup file %s'), $fn); + unlink($fn) or syserr(g_('remove patch backup file %s'), $fn); } } return $analysis; @@ -641,16 +641,16 @@ sub check_apply { sub get_type { my $file = shift; if (not lstat($file)) { - return _g('nonexistent') if $! == ENOENT; - syserr(_g('cannot stat %s'), $file); + return g_('nonexistent') if $! == ENOENT; + syserr(g_('cannot stat %s'), $file); } else { - -f _ && return _g('plain file'); - -d _ && return _g('directory'); - -l _ && return sprintf(_g('symlink to %s'), readlink($file)); - -b _ && return _g('block device'); - -c _ && return _g('character device'); - -p _ && return _g('named pipe'); - -S _ && return _g('named socket'); + -f _ && return g_('plain file'); + -d _ && return g_('directory'); + -l _ && return sprintf(g_('symlink to %s'), readlink($file)); + -b _ && return g_('block device'); + -c _ && return g_('character device'); + -p _ && return g_('named pipe'); + -S _ && return g_('named socket'); } } diff --git a/scripts/Dpkg/Source/Quilt.pm b/scripts/Dpkg/Source/Quilt.pm index e0089062b..005ec5902 100644 --- a/scripts/Dpkg/Source/Quilt.pm +++ b/scripts/Dpkg/Source/Quilt.pm @@ -52,11 +52,11 @@ sub setup_db { my ($self) = @_; my $db_dir = $self->get_db_file(); if (not -d $db_dir) { - mkdir $db_dir or syserr(_g('cannot mkdir %s'), $db_dir); + mkdir $db_dir or syserr(g_('cannot mkdir %s'), $db_dir); } my $file = $self->get_db_file('.version'); if (not -e $file) { - open(my $version_fh, '>', $file) or syserr(_g('cannot write %s'), $file); + open(my $version_fh, '>', $file) or syserr(g_('cannot write %s'), $file); print { $version_fh } "2\n"; close($version_fh); } @@ -65,13 +65,13 @@ sub setup_db { # in Debian). $file = $self->get_db_file('.quilt_patches'); if (not -e $file) { - open(my $qpatch_fh, '>', $file) or syserr(_g('cannot write %s'), $file); + open(my $qpatch_fh, '>', $file) or syserr(g_('cannot write %s'), $file); print { $qpatch_fh } "debian/patches\n"; close($qpatch_fh); } $file = $self->get_db_file('.quilt_series'); if (not -e $file) { - open(my $qseries_fh, '>', $file) or syserr(_g('cannot write %s'), $file); + open(my $qseries_fh, '>', $file) or syserr(g_('cannot write %s'), $file); my $series = $self->get_series_file(); $series = (File::Spec->splitpath($series))[2]; print { $qseries_fh } "$series\n"; @@ -173,7 +173,7 @@ sub push { my $path = $self->get_patch_file($patch); my $obj = Dpkg::Source::Patch->new(filename => $path); - info(_g('applying %s'), $patch) if $opts{verbose}; + info(g_('applying %s'), $patch) if $opts{verbose}; eval { $obj->apply($self->{dir}, timestamp => $opts{timestamp}, verbose => $opts{verbose}, @@ -183,8 +183,8 @@ sub push { '-B', ".pc/$patch/", '--reject-file=-' ]); }; if ($@) { - info(_g('the patch has fuzz which is not allowed, or is malformed')); - info(_g("if patch '%s' is correctly applied by quilt, use '%s' to update it"), + info(g_('the patch has fuzz which is not allowed, or is malformed')); + info(g_("if patch '%s' is correctly applied by quilt, use '%s' to update it"), $patch, 'quilt refresh'); $self->restore_quilt_backup_files($patch, %opts); erasedir($self->get_db_file($patch)); @@ -203,7 +203,7 @@ sub pop { my $patch = $self->top(); return unless defined $patch; - info(_g('unapplying %s'), $patch) if $opts{verbose}; + info(g_('unapplying %s'), $patch) if $opts{verbose}; my $backup_dir = $self->get_db_file($patch); if (-d $backup_dir and not $opts{reverse_apply}) { # Use the backup copies to restore @@ -229,7 +229,7 @@ sub get_db_version { my ($self) = @_; my $pc_ver = $self->get_db_file('.version'); if (-f $pc_ver) { - open(my $ver_fh, '<', $pc_ver) or syserr(_g('cannot read %s'), $pc_ver); + open(my $ver_fh, '<', $pc_ver) or syserr(g_('cannot read %s'), $pc_ver); my $version = <$ver_fh>; chomp $version; close($ver_fh); @@ -242,11 +242,11 @@ sub find_problems { my ($self) = @_; my $patch_dir = $self->get_patch_file(); if (-e $patch_dir and not -d _) { - return sprintf(_g('%s should be a directory or non-existing'), $patch_dir); + return sprintf(g_('%s should be a directory or non-existing'), $patch_dir); } my $series = $self->get_series_file(); if (-e $series and not -f _) { - return sprintf(_g('%s should be a file or non-existing'), $series); + return sprintf(g_('%s should be a file or non-existing'), $series); } return; } @@ -286,7 +286,7 @@ sub get_patch_dir { sub _file_load { my ($self, $file) = @_; - open my $file_fh, '<', $file or syserr(_g('cannot read %s'), $file); + open my $file_fh, '<', $file or syserr(g_('cannot read %s'), $file); my @lines = <$file_fh>; close $file_fh; @@ -301,7 +301,7 @@ sub _file_add_line { CORE::push @lines, $line; chomp @lines; - open my $file_fh, '>', $file or syserr(_g('cannot write %s'), $file); + open my $file_fh, '>', $file or syserr(g_('cannot write %s'), $file); print { $file_fh } "$_\n" foreach @lines; close $file_fh; } @@ -310,7 +310,7 @@ sub _file_drop_line { my ($self, $file, $re) = @_; my @lines = $self->_file_load($file); - open my $file_fh, '>', $file or syserr(_g('cannot write %s'), $file); + open my $file_fh, '>', $file or syserr(g_('cannot write %s'), $file); print { $file_fh } $_ foreach grep { not /^\Q$re\E\s*$/ } @lines; close $file_fh; } @@ -320,7 +320,7 @@ sub read_patch_list { return () if not defined $file or not -f $file; $opts{warn_options} //= 0; my @patches; - open(my $series_fh, '<' , $file) or syserr(_g('cannot read %s'), $file); + open(my $series_fh, '<' , $file) or syserr(g_('cannot read %s'), $file); while (defined(my $line = <$series_fh>)) { chomp $line; # Strip leading/trailing spaces @@ -332,14 +332,14 @@ sub read_patch_list { if ($line =~ /^(\S+)\s+(.*)$/) { $line = $1; if ($2 ne '-p1') { - warning(_g('the series file (%s) contains unsupported ' . + warning(g_('the series file (%s) contains unsupported ' . "options ('%s', line %s); dpkg-source might " . 'fail when applying patches'), $file, $2, $.) if $opts{warn_options}; } } if ($line =~ m{(^|/)\.\./}) { - error(_g('%s contains an insecure path: %s'), $file, $line); + error(g_('%s contains an insecure path: %s'), $file, $line); } CORE::push @patches, $line; } @@ -350,7 +350,7 @@ sub read_patch_list { sub write_patch_list { my ($self, $series, $patches) = @_; - open my $series_fh, '>', $series or syserr(_g('cannot write %s'), $series); + open my $series_fh, '>', $series or syserr(g_('cannot write %s'), $series); foreach my $patch (@{$patches}) { print { $series_fh } "$patch\n"; } @@ -361,7 +361,7 @@ sub restore_quilt_backup_files { my ($self, $patch, %opts) = @_; my $patch_dir = $self->get_db_file($patch); return unless -d $patch_dir; - info(_g('restoring quilt backup files for %s'), $patch) if $opts{verbose}; + info(g_('restoring quilt backup files for %s'), $patch) if $opts{verbose}; find({ no_chdir => 1, wanted => sub { @@ -373,9 +373,9 @@ sub restore_quilt_backup_files { make_path(dirname($target)); unless (link($_, $target)) { copy($_, $target) - or syserr(_g('failed to copy %s to %s'), $_, $target); + or syserr(g_('failed to copy %s to %s'), $_, $target); chmod((stat(_))[2], $target) - or syserr(_g("unable to change permission of `%s'"), $target); + or syserr(g_("unable to change permission of `%s'"), $target); } } else { # empty files are "backups" for new files that patch created diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index 81bd258bf..ffd54c3ae 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/scripts/Dpkg/Substvars.pm @@ -203,7 +203,7 @@ sub parse { next if m/^\s*\#/ || !m/\S/; s/\s*\n$//; if (! m/^(\w[-:0-9A-Za-z]*)\=(.*)$/) { - error(_g('bad line in substvars file %s at line %d'), + error(g_('bad line in substvars file %s at line %d'), $varlistfile, $.); } $self->set($1, $2); @@ -280,7 +280,7 @@ sub substvars { if ($count >= $maxsubsts) { error($opts{msg_prefix} . - _g("too many substitutions - recursive ? - in \`%s'"), $v); + g_("too many substitutions - recursive ? - in \`%s'"), $v); } $lhs = $1; $vn = $2; $rhs = $3; if (defined($self->{vars}{$vn})) { @@ -290,10 +290,10 @@ sub substvars { if (not $opts{no_warn} and $self->{attr}{$vn} & SUBSTVAR_ATTR_OLD) { warning($opts{msg_prefix} . - _g('deprecated substitution variable ${%s}'), $vn); + g_('deprecated substitution variable ${%s}'), $vn); } } else { - warning($opts{msg_prefix} . _g('unknown substitution variable ${%s}'), + warning($opts{msg_prefix} . g_('unknown substitution variable ${%s}'), $vn) unless $opts{no_warn}; $v = $lhs . $rhs; } @@ -317,7 +317,7 @@ sub warn_about_unused { # that they are not required in the current situation # (example: debhelper's misc:Depends in many cases) next if $self->{vars}{$vn} eq ''; - warning($opts{msg_prefix} . _g('unused substitution variable ${%s}'), + warning($opts{msg_prefix} . g_('unused substitution variable ${%s}'), $vn); } } diff --git a/scripts/Dpkg/Vars.pm b/scripts/Dpkg/Vars.pm index 0186bcdd5..6c1d51b0f 100644 --- a/scripts/Dpkg/Vars.pm +++ b/scripts/Dpkg/Vars.pm @@ -37,12 +37,12 @@ sub get_source_package { sub set_source_package { my $v = shift; my $err = pkg_name_is_illegal($v); - error(_g("source package name '%s' is illegal: %s"), $v, $err) if $err; + error(g_("source package name '%s' is illegal: %s"), $v, $err) if $err; if (not defined($sourcepackage)) { $sourcepackage = $v; } elsif ($v ne $sourcepackage) { - error(_g('source package has two conflicting values - %s and %s'), + error(g_('source package has two conflicting values - %s and %s'), $sourcepackage, $v); } } diff --git a/scripts/Dpkg/Vendor.pm b/scripts/Dpkg/Vendor.pm index fb3faa145..d619afe21 100644 --- a/scripts/Dpkg/Vendor.pm +++ b/scripts/Dpkg/Vendor.pm @@ -89,7 +89,7 @@ sub get_vendor_info(;$) { my $file = get_vendor_file($vendor); return unless $file; my $fields = Dpkg::Control::HashCore->new(); - $fields->load($file) or error(_g('%s is empty'), $file); + $fields->load($file) or error(g_('%s is empty'), $file); $VENDOR_CACHE{$vendor} = $fields; return $fields; } diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 34bf28134..2918f035f 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -90,12 +90,12 @@ sub _parse_build_options { if (exists $use_feature->{$feature}) { $use_feature->{$feature} = $value; } else { - warning(_g('unknown %s feature in %s variable: %s'), + warning(g_('unknown %s feature in %s variable: %s'), $area, $variable, $feature); } } } else { - warning(_g('incorrect value in %s option of %s variable: %s'), + warning(g_('incorrect value in %s option of %s variable: %s'), $area, $variable, $feature); } } @@ -174,7 +174,7 @@ sub _add_hardening_flags { my ($abi, $os, $cpu) = debarch_to_debtriplet($arch); unless (defined $abi and defined $os and defined $cpu) { - warning(_g("unknown host architecture '%s'"), $arch); + warning(g_("unknown host architecture '%s'"), $arch); ($abi, $os, $cpu) = ('', '', ''); } diff --git a/scripts/Dpkg/Vendor/Ubuntu.pm b/scripts/Dpkg/Vendor/Ubuntu.pm index e83147e77..fffdab280 100644 --- a/scripts/Dpkg/Vendor/Ubuntu.pm +++ b/scripts/Dpkg/Vendor/Ubuntu.pm @@ -59,13 +59,13 @@ sub run_hook { $fields->{'Version'} =~ /ubuntu/) { if ($fields->{'Maintainer'} !~ /ubuntu/i) { if (length $ENV{DEBEMAIL} and $ENV{DEBEMAIL} =~ /\@ubuntu\.com/) { - error(_g('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address')); + error(g_('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address')); } else { - warning(_g('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address')); + warning(g_('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address')); } } unless ($fields->{'Original-Maintainer'}) { - warning(_g('Version number suggests Ubuntu changes, but there is no XSBC-Original-Maintainer field')); + warning(g_('Version number suggests Ubuntu changes, but there is no XSBC-Original-Maintainer field')); } } @@ -123,7 +123,7 @@ sub run_hook { my $flag = 'DEB_BUILD_HARDENING'; if ($hardening ne '0') { if (!find_command('hardened-cc')) { - syserr(_g("'hardening' flag found but 'hardening-wrapper' not installed")); + syserr(g_("'hardening' flag found but 'hardening-wrapper' not installed")); } if ($hardening ne '1') { my @options = split(/,\s*/, $hardening); @@ -142,7 +142,7 @@ sub run_hook { } } if (defined $ENV{$flag}) { - info(_g('overriding %s in environment: %s'), $flag, $hardening); + info(g_('overriding %s in environment: %s'), $flag, $hardening); } $flags->set($flag, $hardening, 'env'); } diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm index 49fb9f6b6..956b4e840 100644 --- a/scripts/Dpkg/Version.pm +++ b/scripts/Dpkg/Version.pm @@ -232,9 +232,9 @@ If $a or $b are not valid version numbers, it dies with an error. sub version_compare($$) { my ($a, $b) = @_; my $va = Dpkg::Version->new($a, check => 1); - defined($va) || error(_g('%s is not a valid version'), "$a"); + defined($va) || error(g_('%s is not a valid version'), "$a"); my $vb = Dpkg::Version->new($b, check => 1); - defined($vb) || error(_g('%s is not a valid version'), "$b"); + defined($vb) || error(g_('%s is not a valid version'), "$b"); return $va <=> $vb; } @@ -402,22 +402,22 @@ sub version_check($) { $version = Dpkg::Version->new($str) unless ref($version); } if (not defined($str) or not length($str)) { - my $msg = _g('version number cannot be empty'); + my $msg = g_('version number cannot be empty'); return (0, $msg) if wantarray; return 0; } if ($version->version() =~ m/^[^\d]/) { - my $msg = _g('version number does not start with digit'); + my $msg = g_('version number does not start with digit'); return (0, $msg) if wantarray; return 0; } if ($str =~ m/([^-+:.0-9a-zA-Z~])/o) { - my $msg = sprintf(_g("version number contains illegal character `%s'"), $1); + my $msg = sprintf(g_("version number contains illegal character `%s'"), $1); return (0, $msg) if wantarray; return 0; } if ($version->epoch() !~ /^\d*$/) { - my $msg = sprintf(_g('epoch part of the version number ' . + my $msg = sprintf(g_('epoch part of the version number ' . "is not a number: '%s'"), $version->epoch()); return (0, $msg) if wantarray; return 0; |