Quellcode durchsuchen

scripts: Use a new Dpkg::CONFDIR variable instead of literal strings

This will make life easier for downstreams using different paths. Allow
overriding pkgconfdir at configure time.
Guillem Jover vor 13 Jahren
Ursprung
Commit
a55de1500d

+ 2 - 0
configure.ac

@@ -24,6 +24,8 @@ DPKG_BUILD_PROG([start-stop-daemon])
 DPKG_BUILD_PROG([update-alternatives])
 DPKG_BUILD_PROG([update-alternatives])
 
 
 # Allow alternate directories
 # Allow alternate directories
+DPKG_WITH_DIR([pkgconfdir], [${sysconfdir}/${PACKAGE_NAME}],
+              [dpkg configuration directory [SYSCONFDIR/dpkg]])
 DPKG_WITH_DIR([admindir], [${localstatedir}/lib/${PACKAGE_NAME}],
 DPKG_WITH_DIR([admindir], [${localstatedir}/lib/${PACKAGE_NAME}],
               [dpkg database directory [LOCALSTATEDIR/lib/dpkg]])
               [dpkg database directory [LOCALSTATEDIR/lib/dpkg]])
 DPKG_WITH_DIR([logdir], [${localstatedir}/log],
 DPKG_WITH_DIR([logdir], [${localstatedir}/log],

+ 2 - 0
debian/changelog

@@ -86,6 +86,8 @@ dpkg (1.17.0) UNRELEASED; urgency=low
     of two scalars.
     of two scalars.
   * Add a new Dpkg::Vendor get_vendor_dir() function.
   * Add a new Dpkg::Vendor get_vendor_dir() function.
   * Print correct path to vendor directory on error message in dpkg-vendor.
   * Print correct path to vendor directory on error message in dpkg-vendor.
+  * Do not hardcode the dpkg system configuration directory in perl scripts,
+    respect build time setting.
 
 
   [ Updated manpages translations ]
   [ Updated manpages translations ]
   * Fix incorrect translation of "fortify" in French manpage for dpkg-buildflags
   * Fix incorrect translation of "fortify" in French manpage for dpkg-buildflags

+ 2 - 0
scripts/Dpkg.pm

@@ -19,12 +19,14 @@ use warnings;
 our $VERSION = '1.00';
 our $VERSION = '1.00';
 
 
 use base qw(Exporter);
 use base qw(Exporter);
+our @EXPORT_OK = qw($CONFDIR);
 our @EXPORT = qw($version $progname $admindir $dpkglibdir $pkgdatadir);
 our @EXPORT = qw($version $progname $admindir $dpkglibdir $pkgdatadir);
 
 
 our ($progname) = $0 =~ m{(?:.*/)?([^/]*)};
 our ($progname) = $0 =~ m{(?:.*/)?([^/]*)};
 
 
 # The following lines are automatically fixed at install time
 # The following lines are automatically fixed at install time
 our $version = '1.17.x';
 our $version = '1.17.x';
+our $CONFDIR = '/etc/dpkg';
 our $admindir = '/var/lib/dpkg';
 our $admindir = '/var/lib/dpkg';
 our $dpkglibdir = '.';
 our $dpkglibdir = '.';
 our $pkgdatadir = '..';
 our $pkgdatadir = '..';

+ 2 - 1
scripts/Dpkg/BuildFlags.pm

@@ -20,6 +20,7 @@ use warnings;
 
 
 our $VERSION = '1.03';
 our $VERSION = '1.03';
 
 
+use Dpkg qw();
 use Dpkg::Gettext;
 use Dpkg::Gettext;
 use Dpkg::BuildEnv;
 use Dpkg::BuildEnv;
 use Dpkg::BuildOptions;
 use Dpkg::BuildOptions;
@@ -106,7 +107,7 @@ Update flags from the system configuration.
 
 
 sub load_system_config {
 sub load_system_config {
     my ($self) = @_;
     my ($self) = @_;
-    $self->update_from_conffile('/etc/dpkg/buildflags.conf', 'system');
+    $self->update_from_conffile("$Dpkg::CONFDIR/buildflags.conf", 'system');
 }
 }
 
 
 =item $bf->load_user_config()
 =item $bf->load_user_config()

+ 1 - 1
scripts/Dpkg/Control.pm

@@ -89,7 +89,7 @@ Corresponds to a .changes file.
 
 
 =item CTRL_FILE_VENDOR
 =item CTRL_FILE_VENDOR
 
 
-Corresponds to a vendor file in /etc/dpkg/origins/.
+Corresponds to a vendor file in $Dpkg::CONFDIR/origins/.
 
 
 =item CTRL_FILE_STATUS
 =item CTRL_FILE_STATUS
 
 

+ 1 - 1
scripts/Dpkg/Control/Types.pm

@@ -46,7 +46,7 @@ use constant {
     CTRL_PKG_SRC => 16,      # .dsc file of source package
     CTRL_PKG_SRC => 16,      # .dsc file of source package
     CTRL_PKG_DEB => 32,      # DEBIAN/control in binary packages
     CTRL_PKG_DEB => 32,      # DEBIAN/control in binary packages
     CTRL_FILE_CHANGES => 64, # .changes file
     CTRL_FILE_CHANGES => 64, # .changes file
-    CTRL_FILE_VENDOR => 128, # File in /etc/dpkg/origins
+    CTRL_FILE_VENDOR => 128, # File in $Dpkg::CONFDIR/origins
     CTRL_FILE_STATUS => 256, # /var/lib/dpkg/status
     CTRL_FILE_STATUS => 256, # /var/lib/dpkg/status
     CTRL_CHANGELOG => 512,   # Output of dpkg-parsechangelog
     CTRL_CHANGELOG => 512,   # Output of dpkg-parsechangelog
 };
 };

+ 6 - 5
scripts/Dpkg/Vendor.pm

@@ -20,6 +20,7 @@ use warnings;
 
 
 our $VERSION = '1.01';
 our $VERSION = '1.01';
 
 
+use Dpkg qw();
 use Dpkg::ErrorHandling;
 use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
 use Dpkg::Gettext;
 use Dpkg::BuildEnv;
 use Dpkg::BuildEnv;
@@ -29,7 +30,7 @@ use base qw(Exporter);
 our @EXPORT_OK = qw(get_vendor_info get_current_vendor get_vendor_file
 our @EXPORT_OK = qw(get_vendor_info get_current_vendor get_vendor_file
                     get_vendor_dir get_vendor_object run_vendor_hook);
                     get_vendor_dir get_vendor_object run_vendor_hook);
 
 
-my $origins = '/etc/dpkg/origins';
+my $origins = "$Dpkg::CONFDIR/origins";
 $origins = $ENV{DPKG_ORIGINS_DIR} if $ENV{DPKG_ORIGINS_DIR};
 $origins = $ENV{DPKG_ORIGINS_DIR} if $ENV{DPKG_ORIGINS_DIR};
 
 
 =encoding utf8
 =encoding utf8
@@ -40,7 +41,7 @@ Dpkg::Vendor - get access to some vendor specific information
 
 
 =head1 DESCRIPTION
 =head1 DESCRIPTION
 
 
-The files in /etc/dpkg/origins/ can provide information about various
+The files in $Dpkg::CONFDIR/origins/ can provide information about various
 vendors who are providing Debian packages. Currently those files look like
 vendors who are providing Debian packages. Currently those files look like
 this:
 this:
 
 
@@ -73,8 +74,8 @@ sub get_vendor_dir {
 =item $fields = Dpkg::Vendor::get_vendor_info($name)
 =item $fields = Dpkg::Vendor::get_vendor_info($name)
 
 
 Returns a Dpkg::Control object with the information parsed from the
 Returns a Dpkg::Control object with the information parsed from the
-corresponding vendor file in /etc/dpkg/origins/. If $name is omitted,
-it will use /etc/dpkg/origins/default which is supposed to be a symlink
+corresponding vendor file in $Dpkg::CONFDIR/origins/. If $name is omitted,
+it will use $Dpkg::CONFDIR/origins/default which is supposed to be a symlink
 to the vendor of the currently installed operating system. Returns undef
 to the vendor of the currently installed operating system. Returns undef
 if there's no file for the given vendor.
 if there's no file for the given vendor.
 
 
@@ -112,7 +113,7 @@ sub get_vendor_file(;$) {
 =item $name = Dpkg::Vendor::get_current_vendor()
 =item $name = Dpkg::Vendor::get_current_vendor()
 
 
 Returns the name of the current vendor. If DEB_VENDOR is set, it uses
 Returns the name of the current vendor. If DEB_VENDOR is set, it uses
-that first, otherwise it falls back to parsing /etc/dpkg/origins/default.
+that first, otherwise it falls back to parsing $Dpkg::CONFDIR/origins/default.
 If that file doesn't exist, it returns undef.
 If that file doesn't exist, it returns undef.
 
 
 =cut
 =cut

+ 1 - 0
scripts/Makefile.am

@@ -115,6 +115,7 @@ man3_MANS =
 
 
 do_perl_subst = $(AM_V_GEN) \
 do_perl_subst = $(AM_V_GEN) \
 		sed -e "s:^\#![[:space:]]*/usr/bin/perl:\#!$(PERL):" \
 		sed -e "s:^\#![[:space:]]*/usr/bin/perl:\#!$(PERL):" \
+		    -e "s:\$$CONFDIR[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$CONFDIR='$(pkgconfdir)':" \
 		    -e "s:\$$dpkglibdir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$dpkglibdir='$(pkglibdir)':" \
 		    -e "s:\$$dpkglibdir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$dpkglibdir='$(pkglibdir)':" \
 		    -e "s:\$$pkgdatadir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$pkgdatadir='$(pkgdatadir)':" \
 		    -e "s:\$$pkgdatadir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$pkgdatadir='$(pkgdatadir)':" \
 		    -e "s:\$$admindir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$admindir='$(admindir)':" \
 		    -e "s:\$$admindir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$admindir='$(admindir)':" \

+ 4 - 4
scripts/dpkg-shlibdeps.pl

@@ -55,8 +55,8 @@ my $i = 0; my %depstrength = map { $_ => $i++ } @depfields;
 
 
 textdomain('dpkg-dev');
 textdomain('dpkg-dev');
 
 
-my $shlibsoverride = '/etc/dpkg/shlibs.override';
-my $shlibsdefault = '/etc/dpkg/shlibs.default';
+my $shlibsoverride = "$Dpkg::CONFDIR/shlibs.override";
+my $shlibsdefault = "$Dpkg::CONFDIR/shlibs.default";
 my $shlibslocal = 'debian/shlibs.local';
 my $shlibslocal = 'debian/shlibs.local';
 my $packagetype = 'deb';
 my $packagetype = 'deb';
 my $dependencyfield = 'Depends';
 my $dependencyfield = 'Depends';
@@ -726,8 +726,8 @@ sub find_symbols_file {
 	# Fallback to other symbols files but it shouldn't be necessary
 	# Fallback to other symbols files but it shouldn't be necessary
 	push @files, @pkg_symbols;
 	push @files, @pkg_symbols;
     } else {
     } else {
-	push @files, "/etc/dpkg/symbols/$pkg.symbols.$host_arch",
-	    "/etc/dpkg/symbols/$pkg.symbols";
+	push @files, "$Dpkg::CONFDIR/symbols/$pkg.symbols.$host_arch",
+	    "$Dpkg::CONFDIR/symbols/$pkg.symbols";
 	my $control_file = get_control_path($pkg, 'symbols');
 	my $control_file = get_control_path($pkg, 'symbols');
 	push @files, $control_file if defined $control_file;
 	push @files, $control_file if defined $control_file;
     }
     }