From: Frank Lichtenheld Date: Sat, 14 Jul 2007 20:55:52 +0000 (+0000) Subject: dpkg-shlibdeps.pl/dpkg-gensymbols.pl: Whitespace cleanup X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9345d9bbc3493f67ae06664b6563ec5c5bee1075;p=dpkg dpkg-shlibdeps.pl/dpkg-gensymbols.pl: Whitespace cleanup --- diff --git a/scripts/dpkg-gensymbols.pl b/scripts/dpkg-gensymbols.pl index 2e81d22f..321def83 100755 --- a/scripts/dpkg-gensymbols.pl +++ b/scripts/dpkg-gensymbols.pl @@ -7,7 +7,7 @@ our $version; our $dpkglibdir; BEGIN { $version="1.14.4"; # This line modified by Makefile - $dpkglibdir="/usr/lib/dpkg"; # This line modified by Makefile + $dpkglibdir="."; # This line modified by Makefile push(@INC,$dpkglibdir); } require 'controllib.pl'; @@ -79,7 +79,7 @@ my @files; while (@ARGV) { $_=shift(@ARGV); if (m/^-p([-+0-9a-z.]+)$/) { - $oppackage= $1; + $oppackage= $1; } elsif (m/^-c(\d)?$/) { $compare = defined($1) ? $1 : 1; } elsif (m/^-d$/) { @@ -94,20 +94,20 @@ while (@ARGV) { push @files, glob($file); } } elsif (m/^-p(.*)/) { - &error(sprintf(_g("Illegal package name \`%s'"), $1)); + &error(sprintf(_g("Illegal package name \`%s'"), $1)); } elsif (m/^-P(.*)$/) { - $packagebuilddir = $1; - $packagebuilddir =~ s{/+$}{}; + $packagebuilddir = $1; + $packagebuilddir =~ s{/+$}{}; } elsif (m/^-O$/) { - $stdout= 1; + $stdout= 1; } elsif (m/^-O(.+)$/) { - $output= $1; + $output= $1; } elsif (m/^-(h|-help)$/) { - &usage; exit(0); + &usage; exit(0); } elsif (m/^--version$/) { - &version; exit(0); + &version; exit(0); } else { - &usageerr(sprintf(_g("unknown option \`%s'"), $_)); + &usageerr(sprintf(_g("unknown option \`%s'"), $_)); } } @@ -119,7 +119,7 @@ if (not defined($oppackage)) { parsecontrolfile($controlfile); my @packages = grep(m/^C /, keys %p2i); @packages==1 || - &error(sprintf(_g("must specify package since control info has many (%s)"), "@packages")); + &error(sprintf(_g("must specify package since control info has many (%s)"), "@packages")); $oppackage = $packages[0]; $oppackage =~ s/^C //; } @@ -145,7 +145,7 @@ if (not scalar @files) { my $libdir = "$packagebuilddir$path"; $libdir =~ s{/+}{/}g; next if not -d $libdir; - opendir(DIR, "$libdir") || + opendir(DIR, "$libdir") || syserr(sprintf(_g("Can't read directory %s: %s"), $libdir, $!)); push @files, grep { /(\.so\.|\.so$)/ && @@ -195,7 +195,7 @@ my $exitcode = 0; if ($compare) { use File::Temp; use Digest::MD5; - # Compare + # Compare if ($symfile->has_new_libs($ref_symfile)) { warning(_g("new libraries appeared in the symbols file.")); $exitcode = 4 if ($compare >= 4); @@ -222,7 +222,7 @@ if ($compare) { $md5_after->addfile($after); if ($md5_before->hexdigest() ne $md5_after->hexdigest()) { if (defined($ref_symfile->{file})) { - warning(sprintf(_g("%s doesn't match completely %s\n"), + warning(sprintf(_g("%s doesn't match completely %s\n"), $output, $ref_symfile->{file})); } else { warning(sprintf(_g("no debian/symbols file used as basis for generating %s\n"), $output)); diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index 949412b0..0163d494 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -24,7 +24,8 @@ use Dpkg::Shlibs::SymbolFile; our $host_arch= `dpkg-architecture -qDEB_HOST_ARCH`; chomp $host_arch; -my @depfields= qw(Suggests Recommends Depends Pre-Depends); # By increasing importance +# By increasing importance +my @depfields= qw(Suggests Recommends Depends Pre-Depends); my $i=0; my %depstrength = map { $_ => $i++ } @depfields; require 'controllib.pl'; @@ -43,42 +44,44 @@ my $debug= 0; my (@pkg_shlibs, @pkg_symbols); if (-d "debian") { find sub { - push @pkg_shlibs, $File::Find::name if ($File::Find::name =~ m{/DEBIAN/shlibs$}); - push @pkg_symbols, $File::Find::name if ($File::Find::name =~ m{/DEBIAN/symbols$}); + push @pkg_shlibs, $File::Find::name + if ($File::Find::name =~ m{/DEBIAN/shlibs$}); + push @pkg_symbols, $File::Find::name + if ($File::Find::name =~ m{/DEBIAN/symbols$}); }, "debian"; } my ($stdout, %exec); foreach (@ARGV) { if (m/^-T(.*)$/) { - $varlistfile= $1; + $varlistfile= $1; } elsif (m/^-p(\w[-:0-9A-Za-z]*)$/) { - $varnameprefix= $1; + $varnameprefix= $1; } elsif (m/^-L(.*)$/) { - $shlibslocal= $1; + $shlibslocal= $1; } elsif (m/^-O$/) { - $stdout= 1; + $stdout= 1; } elsif (m/^-(h|-help)$/) { - usage(); exit(0); + usage(); exit(0); } elsif (m/^--version$/) { - version(); exit(0); + version(); exit(0); } elsif (m/^--admindir=(.*)$/) { - $admindir = $1; - -d $admindir || - error(sprintf(_g("administrative directory '%s' does not exist"), - $admindir)); + $admindir = $1; + -d $admindir || + error(sprintf(_g("administrative directory '%s' does not exist"), + $admindir)); } elsif (m/^-d(.*)$/) { - $dependencyfield= capit($1); - defined($depstrength{$dependencyfield}) || - warning(sprintf(_g("unrecognised dependency field \`%s'"), $dependencyfield)); + $dependencyfield= capit($1); + defined($depstrength{$dependencyfield}) || + warning(sprintf(_g("unrecognised dependency field \`%s'"), $dependencyfield)); } elsif (m/^-e(.*)$/) { $exec{$1} = $dependencyfield; } elsif (m/^-t(.*)$/) { - $packagetype = $1; + $packagetype = $1; } elsif (m/-v$/) { $debug = 1; } elsif (m/^-/) { - usageerr(sprintf(_g("unknown option \`%s'"), $_)); + usageerr(sprintf(_g("unknown option \`%s'"), $_)); } else { $exec{$_} = $dependencyfield; } @@ -161,9 +164,9 @@ foreach my $file (keys %exec) { $used_sonames{$symdep->{soname}}++; foreach my $subdep (split /\s*,\s*/, $d) { if (exists $dependencies{$cur_field}{$subdep} and - defined($dependencies{$cur_field}{$subdep})) + defined($dependencies{$cur_field}{$subdep})) { - if ($dependencies{$cur_field}{$subdep} eq '' or + if ($dependencies{$cur_field}{$subdep} eq '' or vercmp($m, $dependencies{$cur_field}{$subdep}) > 0) { $dependencies{$cur_field}{$subdep} = $m; @@ -176,9 +179,10 @@ foreach my $file (keys %exec) { my $syminfo = $dumplibs_wo_symfile->locate_symbol($name); if (not defined($syminfo)) { my $print_name = $name; - $print_name =~ s/\@Base$//; # Drop the default suffix for readability + # Drop the default suffix for readability + $print_name =~ s/\@Base$//; warning(sprintf( - _g("symbol %s used by %s found in none of the libraries."), + _g("symbol %s used by %s found in none of the libraries."), $print_name, $file)) unless $sym->{weak}; } else { $used_sonames{$syminfo->{soname}}++; @@ -201,24 +205,24 @@ if ($stdout) { $fh = \*STDOUT; } else { open(NEW, ">", "$varlistfile.new") || - syserr(sprintf(_g("open new substvars file \`%s'"), "$varlistfile.new")); + syserr(sprintf(_g("open new substvars file \`%s'"), "$varlistfile.new")); if (-e $varlistfile) { - open(OLD, "<", $varlistfile) || + open(OLD, "<", $varlistfile) || syserr(sprintf(_g("open old varlist file \`%s' for reading"), $varlistfile)); - foreach my $entry (grep { not /^\Q$varnameprefix\E:/ } ()) { + foreach my $entry (grep { not m/^\Q$varnameprefix\E:/ } ()) { print(NEW $entry) || syserr(sprintf(_g("copy old entry to new varlist file \`%s'"), "$varlistfile.new")); } } $fh = \*NEW; -} +} -# Write out the shlibs substvars +# Write out the shlibs substvars my %depseen; foreach my $field (reverse @depfields) { my $dep = ""; if (exists $dependencies{$field} and scalar keys %{$dependencies{$field}}) { - $dep = join ", ", + $dep = join ", ", map { # Translate dependency templates into real dependencies if ($dependencies{$field}{$_}) { @@ -228,14 +232,14 @@ foreach my $field (reverse @depfields) { } s/\s+/ /g; $_; - } grep { + } grep { # Don't include dependencies if they are already # mentionned in a higher priority field if (not defined($depseen{$_})) { $depseen{$_} = $dependencies{$field}{$_}; 1; } else { - # Since dependencies can be versionned, we have to + # Since dependencies can be versionned, we have to # verify if the dependency is stronger than the # previously seen one if (vercmp($depseen{$_}, $dependencies{$field}{$_}) > 0) { @@ -256,7 +260,7 @@ foreach my $field (reverse @depfields) { if (!$stdout) { close($fh); rename("$varlistfile.new",$varlistfile) || - syserr(sprintf(_g("install new varlist file \`%s'"), $varlistfile)); + syserr(sprintf(_g("install new varlist file \`%s'"), $varlistfile)); } ## @@ -306,7 +310,7 @@ Dependency fields recognised are: sub add_shlibs_dep { my ($soname, $pkg) = @_; foreach my $file ($shlibslocal, $shlibsoverride, @pkg_shlibs, - "$admindir/info/$pkg.shlibs") + "$admindir/info/$pkg.shlibs") { next if not -e $file; my $dep = extract_from_shlibs($soname, $file); @@ -333,14 +337,16 @@ sub extract_from_shlibs { } # Open shlibs file $shlibfile = "./$shlibfile" if $shlibfile =~ m/^\s/; - open(SHLIBS, "<", $shlibfile) || syserr(sprintf(_g("unable to open shared libs info file \`%s'"), $shlibfile)); + open(SHLIBS, "<", $shlibfile) + || syserr(sprintf(_g("unable to open shared libs info file \`%s'"), $shlibfile)); my $dep; while () { - s/\s*\n$//; next if m/^\#/; - if (!m/^\s*(?:(\S+):\s+)?(\S+)\s+(\S+)\s+(\S.*\S)\s*$/) { - warning(sprintf(_g("shared libs info file \`%s' line %d: bad line \`%s'"), $shlibfile, $., $_)); - next; - } + s/\s*\n$//; + next if m/^\#/; + if (!m/^\s*(?:(\S+):\s+)?(\S+)\s+(\S+)\s+(\S.*\S)\s*$/) { + warning(sprintf(_g("shared libs info file \`%s' line %d: bad line \`%s'"), $shlibfile, $., $_)); + next; + } my $type = defined($1) ? $1 : "deb"; next if $type ne $packagetype; if (($libname eq $2) && ($libversion eq $3)) { @@ -357,7 +363,7 @@ sub find_symbols_file { foreach my $file (@pkg_symbols, "/etc/dpkg/symbols/$pkg.symbols.$host_arch", "/etc/dpkg/symbols/$pkg.symbols", - "$admindir/info/$pkg.symbols") + "$admindir/info/$pkg.symbols") { if (-e $file and symfile_has_soname($file, $soname)) { return $file; @@ -408,13 +414,15 @@ sub find_packages { close STDERR; open STDERR, ">", "/dev/null"; $ENV{LC_ALL} = "C"; - exec("dpkg", "--search", "--", @files) or syserr(_g("cannot exec dpkg"));; + exec("dpkg", "--search", "--", @files) + || syserr(_g("cannot exec dpkg")); } while(defined($_ = )) { chomp($_); if (m/^local diversion |^diversion by/) { warning(_g("diversions involved - output may be incorrect")); - print(STDERR " $_\n") || syserr(_g("write diversion info to stderr")); + print(STDERR " $_\n") + || syserr(_g("write diversion info to stderr")); } elsif (m/^([^:]+): (\S+)$/) { $pkgmatch->{$2} = [ split(/, /, $1) ]; } else {