This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=c5c5b8d995d3fae3eed303fbc4e81f06b7ddaad7 commit c5c5b8d995d3fae3eed303fbc4e81f06b7ddaad7 Author: Guillem Jover <[email protected]> AuthorDate: Tue Feb 21 01:31:24 2023 +0100 perl: Rename filename related variables to distinguish them from field ones The code prominently handles fields, so using $f or similarly short variants of that (as part of a hash variable name) is confusing when surrounding code is handling fields in also $f named variables. --- scripts/Dpkg/Path.pm | 4 +-- scripts/dpkg-genchanges.pl | 61 ++++++++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/scripts/Dpkg/Path.pm b/scripts/Dpkg/Path.pm index 36a48f3bb..ae8c73464 100644 --- a/scripts/Dpkg/Path.pm +++ b/scripts/Dpkg/Path.pm @@ -314,8 +314,8 @@ sub find_build_file($) { my $host_arch = get_host_arch(); my ($abi, $libc, $host_os, $cpu) = debarch_to_debtuple($host_arch); my @files; - foreach my $f ("$base.$host_arch", "$base.$host_os", "$base") { - push @files, $f if -f $f; + foreach my $fn ("$base.$host_arch", "$base.$host_os", "$base") { + push @files, $fn if -f $fn; } return @files if wantarray; return $files[0] if scalar @files; diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 35373071c..dc4b6393c 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -60,9 +60,12 @@ my $host_arch = get_host_arch(); my @profiles = get_build_profiles(); my $changes_format = '1.8'; -my %p2f; # - package to file map, has entries for "packagename" -my %f2seccf; # - package to section map, from control file -my %f2pricf; # - package to priority map, from control file +# Package to file map, has entries for "packagename". +my %pkg2file; +# Package to section map, from control file. +my %file2ctrlsec; +# Package to priority map, from control file. +my %file2ctrlpri; my %sourcedefault; # - default values as taken from source (used for Section, # Priority and Maintainer) @@ -289,9 +292,9 @@ if (build_has_any(BUILD_SOURCE)) { any { m/\.(?:debian\.tar|diff)\.$ext$/ } $checksums->get_files()) { $origsrcmsg = g_('not including original source code in upload'); - foreach my $f (grep { m/\.orig(-.+)?\.tar\.$ext$/ } $checksums->get_files()) { - $checksums->remove_file($f); - $checksums->remove_file("$f.asc"); + foreach my $fn (grep { m/\.orig(-.+)?\.tar\.$ext$/ } $checksums->get_files()) { + $checksums->remove_file($fn); + $checksums->remove_file("$fn.asc"); } } else { if ($sourcestyle =~ m/d/ && @@ -304,8 +307,8 @@ if (build_has_any(BUILD_SOURCE)) { push @archvalues, 'source'; # Only add attributes for files being distributed. - for my $f ($checksums->get_files()) { - $dist->add_file($f, $sec, $pri); + for my $fn ($checksums->get_files()) { + $dist->add_file($fn, $sec, $pri); } } elsif (build_is(BUILD_ARCH_DEP)) { $origsrcmsg = g_('binary-only arch-specific upload ' . @@ -322,13 +325,13 @@ my $dist_binaries = 0; $dist->load($fileslistfile) if -e $fileslistfile; foreach my $file ($dist->get_files()) { - my $f = $file->{filename}; + my $fn = $file->{filename}; my $p = $file->{package}; my $a = $file->{arch}; if (defined $p && $file->{package_type} eq 'buildinfo') { # We always distribute the .buildinfo file. - $checksums->add_from_file("$uploadfilesdir/$f", key => $f); + $checksums->add_from_file("$uploadfilesdir/$fn", key => $fn); next; } @@ -344,11 +347,11 @@ foreach my $file ($dist->get_files()) { push @archvalues, $a if not $archadded{$a}++; } if (defined $p && $file->{package_type} =~ m/^u?deb$/) { - $p2f{$p} //= []; - push @{$p2f{$p}}, $f; + $pkg2file{$p} //= []; + push @{$pkg2file{$p}}, $fn; } - $checksums->add_from_file("$uploadfilesdir/$f", key => $f); + $checksums->add_from_file("$uploadfilesdir/$fn", key => $fn); $dist_binaries++; } @@ -368,7 +371,7 @@ foreach my $pkg ($control->get_packages()) { my @restrictions; @restrictions = parse_build_profiles($bp) if defined $bp; - if (not defined($p2f{$p})) { + if (not defined $pkg2file{$p}) { # No files for this package... warn if it's unexpected if (((build_has_any(BUILD_ARCH_INDEP) and debarch_eq('all', $a)) or (build_has_any(BUILD_ARCH_DEP) and @@ -389,15 +392,15 @@ foreach my $pkg ($control->get_packages()) { push @descriptions, $desc; # List of files for this binary package. - my @f = @{$p2f{$p}}; + my @files = @{$pkg2file{$p}}; foreach (keys %{$pkg}) { my $v = $pkg->{$_}; if (m/^Section$/) { - $f2seccf{$_} = $v foreach (@f); + $file2ctrlsec{$_} = $v foreach @files; } elsif (m/^Priority$/) { - $f2pricf{$_} = $v foreach (@f); + $file2ctrlpri{$_} = $v foreach @files; } elsif (m/^Architecture$/) { if (build_has_any(BUILD_ARCH_DEP) and (any { debarch_is($host_arch, $_) } debarch_list_parse($v, positive => 1))) { @@ -430,7 +433,7 @@ if ($changesdescription) { $fields->{'Changes'} = "\n" . file_slurp($changesdescription); } -for my $p (keys %p2f) { +for my $p (keys %pkg2file) { if (not defined $control->get_pkg_by_name($p)) { # Skip automatically generated packages (such as debugging symbol # packages), by using the Auto-Built-Package field. @@ -438,16 +441,16 @@ for my $p (keys %p2f) { my $file = $dist->get_file($_); $file->{attrs}->{automatic} eq 'yes' - } @{$p2f{$p}}; + } @{$pkg2file{$p}}; warning(g_('package %s listed in files list but not in control info'), $p); next; } - foreach my $f (@{$p2f{$p}}) { - my $file = $dist->get_file($f); + foreach my $fn (@{$pkg2file{$p}}) { + my $file = $dist->get_file($fn); - my $sec = $f2seccf{$f} || $sourcedefault{'Section'} // '-'; + my $sec = $file2ctrlsec{$fn} || $sourcedefault{'Section'} // '-'; if ($sec eq '-') { warning(g_("missing Section for binary package %s; using '-'"), $p); } @@ -456,7 +459,7 @@ for my $p (keys %p2f) { 'files list'), $p, $sec, $file->{section}); } - my $pri = $f2pricf{$f} || $sourcedefault{'Priority'} // '-'; + my $pri = $file2ctrlpri{$fn} || $sourcedefault{'Priority'} // '-'; if ($pri eq '-') { warning(g_("missing Priority for binary package %s; using '-'"), $p); } @@ -477,7 +480,7 @@ if (length $fields->{'Date'} == 0) { setlocale(LC_TIME, ''); } -$fields->{'Binary'} = join ' ', sort keys %p2f; +$fields->{'Binary'} = join ' ', sort keys %pkg2file; # Avoid overly long line by splitting over multiple lines if (length($fields->{'Binary'}) > 980) { $fields->{'Binary'} =~ s/(.{0,980}) /$1\n/g; @@ -491,12 +494,12 @@ $fields->{'Description'} = "\n" . join("\n", sort @descriptions); $fields->{'Files'} = ''; -foreach my $f ($checksums->get_files()) { - my $file = $dist->get_file($f); +foreach my $fn ($checksums->get_files()) { + my $file = $dist->get_file($fn); - $fields->{'Files'} .= "\n" . $checksums->get_checksum($f, 'md5') . - ' ' . $checksums->get_size($f) . - " $file->{section} $file->{priority} $f"; + $fields->{'Files'} .= "\n" . $checksums->get_checksum($fn, 'md5') . + ' ' . $checksums->get_size($fn) . + " $file->{section} $file->{priority} $fn"; } $checksums->export_to_control($fields); # redundant with the Files field -- Dpkg.Org's dpkg

