From a5e3f549182cb5776bba9e1b1fd8bac409fab842 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 22 Jul 2007 00:31:25 +0000 Subject: [PATCH] Switch perl programs to use the new Dpkg module and its variables. --- ChangeLog | 33 +++++++++++++++++++++++++++++++++ debian/changelog | 2 +- scripts/cleanup-info.pl | 4 ++-- scripts/controllib.pl | 10 +--------- scripts/dpkg-architecture.pl | 5 +---- scripts/dpkg-checkbuilddeps.pl | 6 +----- scripts/dpkg-distaddfile.pl | 5 +---- scripts/dpkg-divert.pl | 13 +++++-------- scripts/dpkg-genchanges.pl | 6 +----- scripts/dpkg-gencontrol.pl | 6 +----- scripts/dpkg-parsechangelog.pl | 5 +---- scripts/dpkg-scanpackages.pl | 10 +++------- scripts/dpkg-scansources.pl | 11 +++++------ scripts/dpkg-shlibdeps.pl | 6 +----- scripts/dpkg-source.pl | 5 +---- scripts/dpkg-statoverride.pl | 11 +++-------- scripts/install-info.pl | 9 +++------ scripts/update-alternatives.pl | 15 ++++++--------- 18 files changed, 70 insertions(+), 92 deletions(-) diff --git a/ChangeLog b/ChangeLog index f78c72e8..e79bda57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2007-07-22 Guillem Jover + + * scripts/cleanup-info.pl: Use new Dpkg module, and remove variable + declarations already done in the module. + * scripts/controllib.pl: Likewise. + * scripts/dpkg-architecture.pl: Likewise. + * scripts/dpkg-checkbuilddeps.pl: Likewise. + * scripts/dpkg-distaddfile.pl: Likewise. + * scripts/dpkg-divert.pl: Likewise. + * scripts/dpkg-genchanges.pl: Likewise. + * scripts/dpkg-gencontrol.pl: Likewise. + * scripts/dpkg-parsechangelog.pl: Likewise. + * scripts/dpkg-scanpackages.pl: Likewise. + * scripts/dpkg-scansources.pl: Likewise. + * scripts/dpkg-shlibdeps.pl: Likewise. + * scripts/dpkg-source.pl: Likewise. + * scripts/dpkg-statoverride.pl: Likewise. + * scripts/install-info.pl: Likewise. + * scripts/update-alternatives.pl: Likewise. + + * scripts/controllib.pl (init_substvars): Remove comment about + $version needing to be a global variable set elsewhere. + + * scripts/dpkg-scanpackages.pl: Remove $0 mangling. + (version, usage): Use $progname instead of $0. + * scripts/dpkg-statoverride.pl: Likewise. + * scripts/install-info.pl: Likewise. + * scripts/dpkg-divert.pl: Likewise. + (quit, badusage): Use $progname instead of $0. + * scripts/update-alternatives.pl: Likewise. + * scripts/dpkg-scansources.pl ($Me): Remove declaration. + (xwarndie_mess, version, usage): Use $progname instead of $Me. + 2007-07-21 Guillem Jover * m4/perl.m4 (DPKG_PROG_PERL): Add support for user overridable diff --git a/debian/changelog b/debian/changelog index 735ffe01..8a44db8a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,7 +15,7 @@ dpkg (1.14.6) UNRELEASED; urgency=low - Split option descriptions so that it gets easier to distinguish. - Unify author and copyright information formatting. * Move variables automatically modified at build time to a new style perl - module. + module and make all programs use the new module.. [ Updated scripts translations ] * French (Frédéric Bothamy, Christian Perrier). diff --git a/scripts/cleanup-info.pl b/scripts/cleanup-info.pl index 7324d197..5fcbdc8b 100755 --- a/scripts/cleanup-info.pl +++ b/scripts/cleanup-info.pl @@ -24,14 +24,14 @@ use strict; use warnings; -my $dpkglibdir = "."; # This line modified by Makefile +use Dpkg; + push(@INC,$dpkglibdir); require 'dpkg-gettext.pl'; textdomain("dpkg"); ($0) = $0 =~ m:.*/(.+):; -my $version = '1.1.6'; # This line modified by Makefile sub version { printf _g("Debian %s version %s.\n"), $0, $version; diff --git a/scripts/controllib.pl b/scripts/controllib.pl index 9cf03826..96731cab 100755 --- a/scripts/controllib.pl +++ b/scripts/controllib.pl @@ -5,9 +5,7 @@ use warnings; use English; use POSIX qw(:errno_h); - -our $dpkglibdir; -our $pkgdatadir; +use Dpkg; push(@INC,$dpkglibdir); require 'dpkg-gettext.pl'; @@ -36,10 +34,6 @@ our @src_dep_fields = qw(Build-Depends Build-Depends-Indep our $warnable_error = 1; our $quiet_warnings = 0; -our $version; -our $progname = $0; -$progname = $& if $progname =~ m,[^/]+$,; - sub getfowner { @@ -551,8 +545,6 @@ sub init_substvars $substvar{'source:Upstream-Version'} = $fi{"L Version"}; $substvar{'source:Upstream-Version'} =~ s/-[^-]*$//; - # FIXME: this needs all progs using controllib to set $version as 'our'. - # We expect the calling program to set $version. $substvar{"dpkg:Version"} = $version; $substvar{"dpkg:Upstream-Version"} = $version; $substvar{"dpkg:Upstream-Version"} =~ s/-[^-]+$//; diff --git a/scripts/dpkg-architecture.pl b/scripts/dpkg-architecture.pl index 9b89a2f7..c199e0ba 100755 --- a/scripts/dpkg-architecture.pl +++ b/scripts/dpkg-architecture.pl @@ -22,10 +22,7 @@ use strict; use warnings; -our $progname; -our $version = "1.0.0"; # This line modified by Makefile -our $dpkglibdir = "."; # This line modified by Makefile -our $pkgdatadir = ".."; # This line modified by Makefile +use Dpkg; push(@INC,$dpkglibdir); require 'controllib.pl'; diff --git a/scripts/dpkg-checkbuilddeps.pl b/scripts/dpkg-checkbuilddeps.pl index 79cd2d9c..88163168 100755 --- a/scripts/dpkg-checkbuilddeps.pl +++ b/scripts/dpkg-checkbuilddeps.pl @@ -4,13 +4,9 @@ use strict; use warnings; -our $progname; -our $dpkglibdir = "."; # This line modified by Makefile -our $pkgdatadir = ".."; # This line modified by Makefile - use Getopt::Long; +use Dpkg; -my $admindir = "/var/lib/dpkg"; push(@INC,$dpkglibdir); require 'controllib.pl'; diff --git a/scripts/dpkg-distaddfile.pl b/scripts/dpkg-distaddfile.pl index 5002cb46..15555011 100755 --- a/scripts/dpkg-distaddfile.pl +++ b/scripts/dpkg-distaddfile.pl @@ -3,12 +3,9 @@ use strict; use warnings; -our $progname; -our $version = '1.3.0'; # This line modified by Makefile -our $dpkglibdir = "."; # This line modified by Makefile - use POSIX; use POSIX qw(:errno_h :signal_h); +use Dpkg; push(@INC,$dpkglibdir); require 'controllib.pl'; diff --git a/scripts/dpkg-divert.pl b/scripts/dpkg-divert.pl index 9e666152..78484717 100755 --- a/scripts/dpkg-divert.pl +++ b/scripts/dpkg-divert.pl @@ -3,10 +3,7 @@ use strict; use warnings; -my $version = '1.0.11'; # This line modified by Makefile -my $admindir = "/var/lib/dpkg"; # This line modified by Makefile -my $dpkglibdir = "../utils"; # This line modified by Makefile -($0) = $0 =~ m:.*/(.+):; +use Dpkg; push (@INC, $dpkglibdir); require 'dpkg-gettext.pl'; @@ -16,7 +13,7 @@ my $enoent = `$dpkglibdir/enoent` || die sprintf(_g("Cannot get ENOENT value fro sub ENOENT { $enoent; } sub version { - printf _g("Debian %s version %s.\n"), $0, $version; + printf _g("Debian %s version %s.\n"), $progname, $version; printf _g(" Copyright (C) 1995 Ian Jackson. @@ -53,7 +50,7 @@ Options: When adding, default is --local and --divert .distrib. When removing, --package or --local and --divert must match if specified. Package preinst/postrm scripts should always specify --package and --divert. -"), $0); +"), $progname); } my $testmode = 0; @@ -296,13 +293,13 @@ sub infon sub quit { - printf STDERR "%s: %s\n", $0, "@_"; + printf STDERR "%s: %s\n", $progname, "@_"; exit(2); } sub badusage { - printf STDERR "%s: %s\n\n", $0, "@_"; + printf STDERR "%s: %s\n\n", $progname, "@_"; &usage; exit(2); } diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 54abf1bb..51c90a6d 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -3,13 +3,9 @@ use strict; use warnings; -our $progname; -our $version = '1.3.0'; # This line modified by Makefile -our $dpkglibdir = "."; # This line modified by Makefile -our $pkgdatadir = ".."; # This line modified by Makefile - use POSIX; use POSIX qw(:errno_h :signal_h); +use Dpkg; push(@INC,$dpkglibdir); require 'controllib.pl'; diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index 56ac9af5..6f7ec1a5 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -3,17 +3,13 @@ use strict; use warnings; -our $version = '1.3.0'; # This line modified by Makefile -our $dpkglibdir = "."; # This line modified by Makefile -our $pkgdatadir = ".."; # This line modified by Makefile - use POSIX; use POSIX qw(:errno_h); +use Dpkg; push(@INC,$dpkglibdir); require 'controllib.pl'; -our $progname; our %substvar; our (%f, %fi); our %fieldimps; diff --git a/scripts/dpkg-parsechangelog.pl b/scripts/dpkg-parsechangelog.pl index 4a7df3ce..2ef223b5 100755 --- a/scripts/dpkg-parsechangelog.pl +++ b/scripts/dpkg-parsechangelog.pl @@ -3,12 +3,9 @@ use strict; use warnings; -our $progname; -our $version = '1.3.0'; # This line modified by Makefile -our $dpkglibdir = "/usr/lib/dpkg"; # This line modified by Makefile - use POSIX; use POSIX qw(:errno_h); +use Dpkg; push(@INC,$dpkglibdir); require 'controllib.pl'; diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl index a6d83d83..2581391e 100755 --- a/scripts/dpkg-scanpackages.pl +++ b/scripts/dpkg-scanpackages.pl @@ -5,11 +5,7 @@ use strict; use IO::Handle; use IO::File; - -my $version= '1.2.6'; # This line modified by Makefile -my $dpkglibdir= "."; # This line modified by Makefile - -($0) = $0 =~ m:.*/(.+):; +use Dpkg; push(@INC,$dpkglibdir); require 'controllib.pl'; @@ -48,7 +44,7 @@ my %options = (help => sub { &usage; exit 0; }, my $result = GetOptions(\%options,'help|h|?','version','udeb|u!','arch|a=s','multiversion|m!'); sub version { - printf _g("Debian %s version %s.\n"), $0, $version; + printf _g("Debian %s version %s.\n"), $progname, $version; exit; } @@ -62,7 +58,7 @@ Options: -m, --multiversion allow multiple versions of a single package. -h, --help show this help message. --version show the version. -"), $0; +"), $progname; } sub load_override diff --git a/scripts/dpkg-scansources.pl b/scripts/dpkg-scansources.pl index a3857a22..4eade815 100755 --- a/scripts/dpkg-scansources.pl +++ b/scripts/dpkg-scansources.pl @@ -29,7 +29,8 @@ use strict; use warnings; -my $dpkglibdir= "."; # This line modified by Makefile +use Dpkg; + push(@INC,$dpkglibdir); require 'dpkg-gettext.pl'; textdomain("dpkg-dev"); @@ -37,8 +38,6 @@ textdomain("dpkg-dev"); use Getopt::Long (); my $Exit = 0; -(my $Me = $0) =~ s-.*/--; -my $version= '1.6.2.1'; # This line modified by Makefile # %Override is a hash of lists. The subs following describe what's in # the lists. @@ -76,7 +75,7 @@ sub debug { } sub xwarndie_mess { - my @mess = ("$Me: ", @_); + my @mess = ("$progname: ", @_); $mess[$#mess] =~ s/:$/: $!\n/; # XXX loses if it's really /:\n/ return @mess; } @@ -95,7 +94,7 @@ sub xwarn_noerror { } sub version { - printf _g("Debian %s version %s.\n"), $Me, $version; + printf _g("Debian %s version %s.\n"), $progname, $version; exit; } @@ -113,7 +112,7 @@ Options: --version show the version. See the man page for the full documentation. -"), $Me; +"), $progname; exit; } diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index 67f45d5a..198d7267 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -6,13 +6,9 @@ use strict; use warnings; -our $progname; -our $version = "1.4.1.19"; # This line modified by Makefile -our $dpkglibdir = "/usr/lib/dpkg"; -my $admindir = "/var/lib/dpkg"; - use English; use POSIX qw(:errno_h :signal_h); +use Dpkg; my $shlibsoverride= '/etc/dpkg/shlibs.override'; my $shlibsdefault= '/etc/dpkg/shlibs.default'; diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 97a54262..4c92e3b1 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -3,10 +3,7 @@ use strict; use warnings; -our $progname; -our $version = "1.3.0"; # This line modified by Makefile -our $dpkglibdir = "."; # This line modified by Makefile -our $pkgdatadir = ".."; # This line modified by Makefile +use Dpkg; my @filesinarchive; my %dirincluded; diff --git a/scripts/dpkg-statoverride.pl b/scripts/dpkg-statoverride.pl index 5ee877e9..e75eceff 100755 --- a/scripts/dpkg-statoverride.pl +++ b/scripts/dpkg-statoverride.pl @@ -5,13 +5,8 @@ use warnings; use POSIX; use POSIX qw(:errno_h :signal_h); +use Dpkg; -my $admindir = "/var/lib/dpkg"; # This line modified by Makefile -my $version = '1.3.0'; # This line modified by Makefile - -($0) = $0 =~ m:.*/(.+):; - -my $dpkglibdir= "."; # This line modified by Makefile push (@INC, $dpkglibdir); require 'dpkg-gettext.pl'; textdomain("dpkg"); @@ -26,7 +21,7 @@ my %group; my %mode; sub version { - printf _g("Debian %s version %s.\n"), $0, $version; + printf _g("Debian %s version %s.\n"), $progname, $version; printf _g(" Copyright (C) 2000 Wichert Akkerman."); @@ -54,7 +49,7 @@ Options: --quiet quiet operation, minimal output. --help show this help message. --version show the version. -"), $0; +"), $progname; } sub CheckModeConflict { diff --git a/scripts/install-info.pl b/scripts/install-info.pl index a0c9571a..35f30d32 100755 --- a/scripts/install-info.pl +++ b/scripts/install-info.pl @@ -1,20 +1,17 @@ #!/usr/bin/perl -- use Text::Wrap; +use Dpkg; -my $dpkglibdir = "."; # This line modified by Makefile push (@INC, $dpkglibdir); require 'dpkg-gettext.pl'; textdomain("dpkg"); -($0) = $0 =~ m:.*/(.+):; - # fixme: sort entries # fixme: send to FSF ? -$version= '0.93.42.2'; # This line modified by Makefile sub version { - printf _g("Debian %s version %s.\n"), $0, $version; + printf _g("Debian %s version %s.\n"), $progname, $version; printf _g(" Copyright (C) 1994,1995 Ian Jackson."); @@ -48,7 +45,7 @@ Options: --quiet do not show output messages. --help show this help message. --version show the version. -"), $0; +"), $progname; } $dirfile = '/usr/share/info/dir'; diff --git a/scripts/update-alternatives.pl b/scripts/update-alternatives.pl index 0cd589c1..1f879a0c 100755 --- a/scripts/update-alternatives.pl +++ b/scripts/update-alternatives.pl @@ -3,15 +3,12 @@ use strict; use warnings; -my $admindir = "/var/lib/dpkg"; # This line modified by Makefile -my $dpkglibdir = "../utils"; # This line modified by Makefile -my $version = '0.93.80'; # This line modified by Makefile +use Dpkg; + push (@INC, $dpkglibdir); require 'dpkg-gettext.pl'; textdomain("dpkg"); -($0) = $0 =~ m:.*/(.+):; - # Global variables: my $altdir = '/etc/alternatives'; @@ -61,7 +58,7 @@ my $enoent = `$dpkglibdir/enoent` || die sprintf(_g("Cannot get ENOENT value fro sub ENOENT { $enoent; } sub version { - printf _g("Debian %s version %s.\n"), $0, $version; + printf _g("Debian %s version %s.\n"), $progname, $version; printf _g(" Copyright (C) 1995 Ian Jackson. @@ -108,18 +105,18 @@ Options: --quiet quiet operation, minimal output. --help show this help message. --version show the version. -"), $0, $altdir; +"), $progname, $altdir; } sub quit { - printf STDERR "%s: %s\n", $0, "@_"; + printf STDERR "%s: %s\n", $progname, "@_"; exit(2); } sub badusage { - printf STDERR "%s: %s\n\n", $0, "@_"; + printf STDERR "%s: %s\n\n", $progname, "@_"; &usage; exit(2); } -- 2.39.5