Skip to contentSkip to conversation

cpan-base.bbclass: Move PERLVERSION logic to a new file

PATCH Superseded Tom Rini 2 participants 9 messages Jun 9, 2017 – Jun 11, 2017

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/3 cpan-base.bbclass: Move PERLVERSION logic to a new file

It is possible for non-CPAN recipes to contain perl modules. These perl modules must reside in the versioned perl library directory in order to work in normal circumstances.. Export this logic to a separate class so that it can be reused without the rest of the cpan logic.

Without this, dpkg will not export its perl code to the correct location and will not be found by utilities that expect to use it.

---
 meta/classes/cpan-base.bbclass    | 24 +-----------------------
 meta/classes/perl-version.bbclass | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 23 deletions(-)
 create mode 100644 meta/classes/perl-version.bbclass
meta/classes/cpan-base.bbclass +1 -23
index 55ac0526953a..577fcd63ce9f 100644
@@ -7,27 +7,7 @@ FILES_${PN} += "${libdir}/perl ${datadir}/perl"
 DEPENDS  += "${@["perl", "perl-native"][(bb.data.inherits_class('native', d))]}"
 RDEPENDS_${PN} += "${@["perl", ""][(bb.data.inherits_class('native', d))]}"
 
-PERL_OWN_DIR = "${@["", "/perl-native"][(bb.data.inherits_class('native', d))]}"
-
-# Determine the staged version of perl from the perl configuration file
-# Assign vardepvalue, because otherwise signature is changed before and after
-# perl is built (from None to real version in config.sh).
-get_perl_version[vardepvalue] = "${PERL_OWN_DIR}"
-def get_perl_version(d):
-    import re
-    cfg = d.expand('${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/config.sh')
-    try:
-        f = open(cfg, 'r')
-    except IOError:
-        return None
-    l = f.readlines();
-    f.close();
-    r = re.compile("^version='(\d*\.\d*\.\d*)'")
-    for s in l:
-        m = r.match(s)
-        if m:
-            return m.group(1)
-    return None
+inherit perl-version
 
 def is_target(d):
     if not bb.data.inherits_class('native', d):
@@ -36,5 +16,3 @@ def is_target(d):
 
 PERLLIBDIRS = "${libdir}/perl"
 PERLLIBDIRS_class-native = "${libdir}/perl-native"
-PERLVERSION := "${@get_perl_version(d)}"
-PERLVERSION[vardepvalue] = ""
meta/classes/perl-version.bbclass new file +24 -0
new file mode 100644
index 000000000000..fafe68a775f7
@@ -0,0 +1,24 @@
+PERL_OWN_DIR = "${@["", "/perl-native"][(bb.data.inherits_class('native', d))]}"
+
+# Determine the staged version of perl from the perl configuration file
+# Assign vardepvalue, because otherwise signature is changed before and after
+# perl is built (from None to real version in config.sh).
+get_perl_version[vardepvalue] = "${PERL_OWN_DIR}"
+def get_perl_version(d):
+    import re
+    cfg = d.expand('${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/config.sh')
+    try:
+        f = open(cfg, 'r')
+    except IOError:
+        return None
+    l = f.readlines();
+    f.close();
+    r = re.compile("^version='(\d*\.\d*\.\d*)'")
+    for s in l:
+        m = r.match(s)
+        if m:
+            return m.group(1)
+    return None
+
+PERLVERSION := "${@get_perl_version(d)}"
+PERLVERSION[vardepvalue] = ""
Signature · 1 line
1.9.1
author
#6 lore raw

PATCH 3/3 dpkg: Add missing RDEPENDS for dpkg-perl

In order to be able to use dpkg-perl on a system various stock perl modules must also be installed on the system. Create the list of required modules based on a read of the code and testing with additional utilities and list them in RDEPENDS_${PN}-perl.

---
 meta/recipes-devtools/dpkg/dpkg.inc | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
meta/recipes-devtools/dpkg/dpkg.inc +19 -0
index a61839b21540..836bb1a82252 100644
@@ -69,6 +69,25 @@ RPROVIDES_update-alternatives-dpkg += "update-alternatives"
 PACKAGES += "${PN}-perl"
 FILES_${PN}-perl = "${libdir}/perl/${PERLVERSION}"
 
+RDEPENDS_${PN}-perl += "perl-module-carp perl-module-constant \
+                        perl-module-cwd perl-module-digest \
+                        perl-module-digest-md5 perl-module-errno \
+                        perl-module-exporter perl-module-fcntl \
+                        perl-module-feature perl-module-file-basename \
+                        perl-module-file-compare perl-module-file-copy \
+                        perl-module-file-find perl-module-file-path \
+                        perl-module-file-spec perl-module-file-temp \
+                        perl-module-list-util perl-module-overload \
+                        perl-module-parent perl-module-storable \
+                        perl-module-filehandle perl-module-io \
+                        perl-module-io-handle perl-module-io-seekable \
+                        perl-module-posix perl-module-scalar-util \
+                        perl-module-selectsaver perl-module-symbol \
+                        perl-module-term-ansicolor perl-module-tie-handle \
+                        perl-module-tie-hash perl-module-storable \
+                        perl-module-time-hires perl-module-time-piece \
+                        perl-module-xsloader"
+
 # Split out start-stop-daemon to its own package.  Note that it
 # is installed in a different directory than the one used for
 # the bitbake version.
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/3 dpkg: Fix perl modules by moving them to the versioned perl directory

In reply to Tom Rini

In order for the dpkg perl modules to be used the must reside in the versioned perl library directory (as to be in the default include path). Be explicit about this location in our FILES_${PN}-perl directive, so that if this breaks in the future, the recipe will fail). We can now drop the custom do_configure as it wasn't fixing this problem.

---
 meta/recipes-devtools/dpkg/dpkg.inc | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
meta/recipes-devtools/dpkg/dpkg.inc +4 -10
index 870117a3250c..a61839b21540 100644
@@ -9,7 +9,7 @@ RDEPENDS_${PN}_class-native = ""
 
 UPSTREAM_CHECK_URI = "${DEBIAN_MIRROR}/main/d/dpkg/"
 
-inherit autotools gettext perlnative pkgconfig systemd
+inherit autotools gettext perlnative pkgconfig systemd perl-version
 
 python () {
     if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
@@ -20,8 +20,8 @@ python () {
 export PERL = "${bindir}/perl"
 PERL_class-native = "${STAGING_BINDIR_NATIVE}/perl-native/perl"
 
-export PERL_LIBDIR = "${libdir}/perl"
-PERL_LIBDIR_class-native = "${libdir}/perl-native/perl"
+export PERL_LIBDIR = "${libdir}/perl/${PERLVERSION}"
+PERL_LIBDIR_class-native = "${libdir}/perl-native/perl/${PERLVERSION}"
 
 EXTRA_OECONF = "\
 		--disable-dselect \
@@ -37,12 +37,6 @@ PACKAGECONFIG[liblzma] = "--with-liblzma,--without-liblzma, xz"
 EXTRA_OECONF += "TAR=tar"
 EXTRA_OECONF_append_class-target = " DEB_HOST_ARCH=${DPKG_ARCH}"
 
-do_configure () {
-    echo >> ${S}/m4/compiler.m4
-    sed -i -e 's#PERL_LIBDIR=.*$#PERL_LIBDIR="${libdir}/perl"#' ${S}/configure
-    autotools_do_configure
-}
-
 do_install_append () {
 	if [ "${PN}" = "dpkg-native" ]; then
 		# update-alternatives doesn't have an offline mode
@@ -73,7 +67,7 @@ FILES_update-alternatives-dpkg = "${bindir}/update-alternatives ${localstatedir}
 RPROVIDES_update-alternatives-dpkg += "update-alternatives"
 
 PACKAGES += "${PN}-perl"
-FILES_${PN}-perl = "${libdir}/perl"
+FILES_${PN}-perl = "${libdir}/perl/${PERLVERSION}"
 
 # Split out start-stop-daemon to its own package.  Note that it
 # is installed in a different directory than the one used for
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 2/3] dpkg: Fix perl modules by moving them to the versioned perl directory

Quoted 6 lines · Tom Rini

In order for the dpkg perl modules to be used the must reside in the versioned perl library directory (as to be in the default include path). Be explicit about this location in our FILES_${PN}-perl directive, so that if this breaks in the future, the recipe will fail). We can now drop the custom do_configure as it wasn't fixing this problem.

* FILES: removed "/usr/lib/perl", added "/usr/lib/perl/None"

Obviously something didn't work right!

Ross

author
#3 lore raw

Re: [PATCH 2/3] dpkg: Fix perl modules by moving them to the versioned perl directory

Quoted 11 lines · Ross
Quoted 5 lines · Tom Rini

In order for the dpkg perl modules to be used the must reside in the versioned perl library directory (as to be in the default include path). Be explicit about this location in our FILES_${PN}-perl directive, so that if this breaks in the future, the recipe will fail). We can now drop the custom do_configure as it wasn't fixing this problem.

* FILES: removed "/usr/lib/perl", added "/usr/lib/perl/None"

Obviously something didn't work right!

Indeed. How did you try building it, and was 1/3 already applied?

Signature · 1 line
Tom
author
#4 lore raw

Re: [PATCH 2/3] dpkg: Fix perl modules by moving them to the versioned perl directory

In reply to Burton, Ross
Quoted 9 lines · Ross
Quoted 6 lines · Tom Rini

In order for the dpkg perl modules to be used the must reside in the versioned perl library directory (as to be in the default include path). Be explicit about this location in our FILES_${PN}-perl directive, so that if this breaks in the future, the recipe will fail). We can now drop the custom do_configure as it wasn't fixing this problem.

Quoted 3 lines

* FILES: removed "/usr/lib/perl", added "/usr/lib/perl/None"

Obviously something didn't work right!

Oh, I see. Yes, an existing feature is that if perl isn't built yet then no, you don't get a sane PERLVERSION. That's true today, for example, see liburi-perl.

Signature · 1 line
Tom
author
#5 lore raw

Re: [PATCH 2/3] dpkg: Fix perl modules by moving them to the versioned perl directory

Quoted 10 lines · Tom Rini
Quoted 9 lines · Ross
Quoted 6 lines · Tom Rini

In order for the dpkg perl modules to be used the must reside in the versioned perl library directory (as to be in the default include path). Be explicit about this location in our FILES_${PN}-perl directive, so that if this breaks in the future, the recipe will fail). We can now drop the custom do_configure as it wasn't fixing this problem.

Quoted 7 lines
Quoted 3 lines

* FILES: removed "/usr/lib/perl", added "/usr/lib/perl/None"

Obviously something didn't work right!

Oh, I see. Yes, an existing feature is that if perl isn't built yet then no, you don't get a sane PERLVERSION. That's true today, for example, see liburi-perl.

Oh oh, I see. Sorry, hit a per recipe staging issue. I've reproduced and figured out the fix.

Signature · 1 line
Tom
author
#7 lore raw

PATCH v2 1/3 cpan-base.bbclass: Move PERLVERSION and get_perl_version to a new file

In reply to Tom Rini

It is possible for non-CPAN recipes to contain perl modules. These perl modules must reside in the versioned perl library directory in order to work in normal circumstances.. Export this logic to a separate class so that it can be reused without the rest of the cpan logic.

Without this, dpkg will not export its perl code to the correct location and will not be found by utilities that expect to use it.

---
Changes in v2:
- Reword the commit message to emphasize get_perl_version as this is what other recipes need to make use of.

 meta/classes/cpan-base.bbclass    | 24 +-----------------------
 meta/classes/perl-version.bbclass | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 23 deletions(-)
 create mode 100644 meta/classes/perl-version.bbclass
meta/classes/cpan-base.bbclass +1 -23
index 55ac0526953a..577fcd63ce9f 100644
@@ -7,27 +7,7 @@ FILES_${PN} += "${libdir}/perl ${datadir}/perl"
 DEPENDS  += "${@["perl", "perl-native"][(bb.data.inherits_class('native', d))]}"
 RDEPENDS_${PN} += "${@["perl", ""][(bb.data.inherits_class('native', d))]}"
 
-PERL_OWN_DIR = "${@["", "/perl-native"][(bb.data.inherits_class('native', d))]}"
-
-# Determine the staged version of perl from the perl configuration file
-# Assign vardepvalue, because otherwise signature is changed before and after
-# perl is built (from None to real version in config.sh).
-get_perl_version[vardepvalue] = "${PERL_OWN_DIR}"
-def get_perl_version(d):
-    import re
-    cfg = d.expand('${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/config.sh')
-    try:
-        f = open(cfg, 'r')
-    except IOError:
-        return None
-    l = f.readlines();
-    f.close();
-    r = re.compile("^version='(\d*\.\d*\.\d*)'")
-    for s in l:
-        m = r.match(s)
-        if m:
-            return m.group(1)
-    return None
+inherit perl-version
 
 def is_target(d):
     if not bb.data.inherits_class('native', d):
@@ -36,5 +16,3 @@ def is_target(d):
 
 PERLLIBDIRS = "${libdir}/perl"
 PERLLIBDIRS_class-native = "${libdir}/perl-native"
-PERLVERSION := "${@get_perl_version(d)}"
-PERLVERSION[vardepvalue] = ""
meta/classes/perl-version.bbclass new file +24 -0
new file mode 100644
index 000000000000..fafe68a775f7
@@ -0,0 +1,24 @@
+PERL_OWN_DIR = "${@["", "/perl-native"][(bb.data.inherits_class('native', d))]}"
+
+# Determine the staged version of perl from the perl configuration file
+# Assign vardepvalue, because otherwise signature is changed before and after
+# perl is built (from None to real version in config.sh).
+get_perl_version[vardepvalue] = "${PERL_OWN_DIR}"
+def get_perl_version(d):
+    import re
+    cfg = d.expand('${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/config.sh')
+    try:
+        f = open(cfg, 'r')
+    except IOError:
+        return None
+    l = f.readlines();
+    f.close();
+    r = re.compile("^version='(\d*\.\d*\.\d*)'")
+    for s in l:
+        m = r.match(s)
+        if m:
+            return m.group(1)
+    return None
+
+PERLVERSION := "${@get_perl_version(d)}"
+PERLVERSION[vardepvalue] = ""
Signature · 1 line
1.9.1
author
#8 lore raw

PATCH v2 2/3 dpkg: Fix perl modules by moving them to the versioned perl directory

In order for the dpkg perl modules to be used the must reside in the versioned perl library directory (as to be in the default include path). Be explicit about this location in our FILES_${PN}-perl directive, so that if this breaks in the future, the recipe will fail). We can now drop the custom do_configure as it wasn't fixing this problem.

---
Changes in v2:
Use ${@get_perl_version(d)} not $[PERLVERSION} as only the former evaluates correctly with per-recipe sysroots.

---
 meta/recipes-devtools/dpkg/dpkg.inc | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
meta/recipes-devtools/dpkg/dpkg.inc +4 -10
index 870117a3250c..3dd8193f7fa3 100644
@@ -9,7 +9,7 @@ RDEPENDS_${PN}_class-native = ""
 
 UPSTREAM_CHECK_URI = "${DEBIAN_MIRROR}/main/d/dpkg/"
 
-inherit autotools gettext perlnative pkgconfig systemd
+inherit autotools gettext perlnative pkgconfig systemd perl-version
 
 python () {
     if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
@@ -20,8 +20,8 @@ python () {
 export PERL = "${bindir}/perl"
 PERL_class-native = "${STAGING_BINDIR_NATIVE}/perl-native/perl"
 
-export PERL_LIBDIR = "${libdir}/perl"
-PERL_LIBDIR_class-native = "${libdir}/perl-native/perl"
+export PERL_LIBDIR = "${libdir}/perl/${@get_perl_version(d)}"
+PERL_LIBDIR_class-native = "${libdir}/perl-native/perl/${@get_perl_version(d)}"
 
 EXTRA_OECONF = "\
 		--disable-dselect \
@@ -37,12 +37,6 @@ PACKAGECONFIG[liblzma] = "--with-liblzma,--without-liblzma, xz"
 EXTRA_OECONF += "TAR=tar"
 EXTRA_OECONF_append_class-target = " DEB_HOST_ARCH=${DPKG_ARCH}"
 
-do_configure () {
-    echo >> ${S}/m4/compiler.m4
-    sed -i -e 's#PERL_LIBDIR=.*$#PERL_LIBDIR="${libdir}/perl"#' ${S}/configure
-    autotools_do_configure
-}
-
 do_install_append () {
 	if [ "${PN}" = "dpkg-native" ]; then
 		# update-alternatives doesn't have an offline mode
@@ -73,7 +67,7 @@ FILES_update-alternatives-dpkg = "${bindir}/update-alternatives ${localstatedir}
 RPROVIDES_update-alternatives-dpkg += "update-alternatives"
 
 PACKAGES += "${PN}-perl"
-FILES_${PN}-perl = "${libdir}/perl"
+FILES_${PN}-perl = "${libdir}/perl/${@get_perl_version(d)}"
 
 # Split out start-stop-daemon to its own package.  Note that it
 # is installed in a different directory than the one used for
Signature · 1 line
1.9.1