This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=a6c7f3cbc6d193026099f7db87da25046a2107dc

commit a6c7f3cbc6d193026099f7db87da25046a2107dc
Author: Guillem Jover <[email protected]>
AuthorDate: Wed Sep 26 05:54:48 2018 +0200

    build: Perform Dpkg module substitution during CPAN module building
    
    We had an empty do_perl_subst variable in the dist-cpan autotools
    target that resulted in copying an empty file, but that was shadowed by
    a subsequent copy of the original. So we were ending up with a pristine
    non-substituted file.
    
    We actually need to substitute the install paths during the CPAN module
    building to preserve system and user settings at that point. Otherwise
    the dpkg autotools configure settings might be completely out of touch
    with the settings from the system where the CPAN module gets built.
---
 cpan.am             |  7 ++-----
 scripts/Build.PL.in | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/cpan.am b/cpan.am
index 2ff9192ac..b472826fc 100644
--- a/cpan.am
+++ b/cpan.am
@@ -13,11 +13,8 @@ dist-cpan:
                 $(top_srcdir)/scripts/t/Dpkg* \
                 $(top_srcdir)/scripts/t/origins \
                 $(CPAN_DIST)/t
-       $(do_perl_subst) <$(top_srcdir)/scripts/Dpkg.pm \
-                        >$(CPAN_DIST)/lib/Dpkg.pm
-       cp -fpR $(top_srcdir)/scripts/Dpkg.pm \
-                $(top_srcdir)/scripts/Dpkg \
-                $(CPAN_DIST)/lib/
+       cp -fpR $(top_srcdir)/scripts/Dpkg.pm $(CPAN_DIST)/lib/
+       cp -fpR $(top_srcdir)/scripts/Dpkg $(CPAN_DIST)/lib/
        cp -fpR $(top_srcdir)/scripts/Test $(CPAN_DIST)/lib/
        cp -fpR $(top_builddir)/scripts/Build.PL $(CPAN_DIST)
 
diff --git a/scripts/Build.PL.in b/scripts/Build.PL.in
index 198c53780..35a64d9be 100644
--- a/scripts/Build.PL.in
+++ b/scripts/Build.PL.in
@@ -22,6 +22,36 @@ my $class = Module::Build->subclass(
             $ENV{DPKG_DATADIR} = 'data';
             $ENV{DPKG_ORIGINS_DIR} = 't/origins';
         }
+
+        sub subst {
+            my ($self, $file) = @_;
+            my $path = $self->install_path();
+            my $version = $self->dist_version();
+
+            unlink "blib/$file"
+                or die "error: cannot remove blib/$file: $!\n";
+            open my $fhin, '<', $file
+                or die "error: cannot open $file: $!\n";
+            open my $fhout, '>', "blib/$file"
+                or die "error: cannot create blib/$file: $!\n";
+            while (<$fhin>) {
+                s{our \$PROGVERSION = .*;}{our \$PROGVERSION = '$version';};
+                s{our \$CONFDIR = .*;}{our \$CONFDIR = '$path->{conf}';};
+                s{our \$DATADIR = .*;}{our \$DATADIR = '$path->{data}';};
+                s{our \$ADMINDIR = .*;}{our \$ADMINDIR = '$path->{admin}';};
+                s{our \$LIBDIR = .*;}{our \$LIBDIR = '$path->{libexec}';};
+                print { $fhout } $_;
+            }
+            close $fhout or die "error: cannot write blib/$file: $!\n";
+            close $fhin;
+        }
+
+        sub ACTION_build {
+            my $self = shift;
+
+            $self->SUPER::ACTION_build;
+            $self->subst('lib/Dpkg.pm');
+        }
     },
 );
 
@@ -71,6 +101,13 @@ my $build = $class->new(
     requires => {
         'perl'                  => '@PERL_MIN_VERSION@',
     },
+
+    install_path => {
+        conf => '/etc/dpkg',
+        data => '/usr/share/dpkg',
+        admin => '/var/lib/dpkg',
+        libexec => '/usr/lib/dpkg',
+    },
 );
 
 $build->create_build_script();

-- 
Dpkg.Org's dpkg

Reply via email to