a package infrastructure for Perl/CPAN modules
v10 cover a package infrastructure for Perl/CPAN modules
delta V9 vs V10
- reorder patches (Note that patch 1/6 can go in immediately, perhaps even for 2014.02)
- scancpan
+ remove spurious final empty line in Config.in
+ POD description
+ generates target/host variants only when needed
- manual
delta V8 vs V9 :
- scancpan
+ back to fatpack
+ use 5.018;
delta V7 vs V8 :
- typo and minor improvements
delta V6 vs V7 :
- global
+ substitute 'perl_5' by 'Artistic or GPLv1+'
- scancpan
+ remove 'NO ABSTRACT'
+ check Module::CoreList::is_core with the target Perl version
+ add packages Module-CoreList and MetaCPAN-API-Tiny instead of use Fatpack
+ add GPL
delta V5 vs V6 :
- export PERL5LIB
- rename PKG_PERL_ARCHNAME to PERL_ARCHNAME
- remove $(2)_*_OPT (with empty default value)
- remove PERL_INSTALL_TARGET_GOALS
Francois Perrad (6):
perl: remove PERL_INSTALL_TARGET_GOALS
pkg-perl: new infrastructure
host-perl-xml-parser: rename and refactor with perl infrastructure
host-perl-module-build: new package
manual: adding packages perl
scancpan: a new script
Config.in | 11 + docs/manual/adding-packages-perl.txt | 108 ++++ docs/manual/adding-packages.txt | 2 + package/Config.in | 1 - package/Makefile.in | 4 +- package/intltool/intltool.mk | 2 +- package/libxml-parser-perl/Config.in | 10 - package/libxml-parser-perl/libxml-parser-perl.mk | 35 -- package/metacity/metacity.mk | 2 +- package/perl-module-build/perl-module-build.mk | 12 + package/perl-xml-parser/perl-xml-parser.mk | 17 + package/perl/perl.mk | 4 +- package/pkg-perl.mk | 181 ++++++ support/scripts/scancpan | 732 ++++++++++++++++++++++ 14 files changed, 1069 insertions(+), 52 deletions(-) create mode 100644 docs/manual/adding-packages-perl.txt delete mode 100644 package/libxml-parser-perl/Config.in delete mode 100644 package/libxml-parser-perl/libxml-parser-perl.mk create mode 100644 package/perl-module-build/perl-module-build.mk create mode 100644 package/perl-xml-parser/perl-xml-parser.mk create mode 100644 package/pkg-perl.mk create mode 100755 support/scripts/scancpan
Signature · 1 line
1.7.9.5
PATCH v10 1/6 perl: remove PERL_INSTALL_TARGET_GOALS
useless since previous commit (removal of BR2_HAVE_DOCUMENTATION)
see http://git.buildroot.net/buildroot/diff/package/perl/perl.mk?id=7164a32632d14cb83698ddec45e84ad2f3252e9e
--- package/perl/perl.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
package/perl/perl.mk +1 -3
@@ -90,10 +90,8 @@ define PERL_INSTALL_STAGING_CMDS $(MAKE1) -C $(@D) DESTDIR="$(STAGING_DIR)" install.perl endef -PERL_INSTALL_TARGET_GOALS = install.perl - define PERL_INSTALL_TARGET_CMDS - $(MAKE1) -C $(@D) DESTDIR="$(TARGET_DIR)" $(PERL_INSTALL_TARGET_GOALS) + $(MAKE1) -C $(@D) DESTDIR="$(TARGET_DIR)" install.perl endef $(eval $(generic-package))
Signature · 1 line
1.7.9.5
PATCH v10 2/6 pkg-perl: new infrastructure
In reply to Francois Perrad--- Config.in | 11 ++++ package/Makefile.in | 4 +- package/pkg-perl.mk | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 package/pkg-perl.mk
Config.in +11 -0
@@ -225,6 +225,17 @@ config BR2_LUAROCKS_MIRROR See http://luarocks.org +config BR2_CPAN_MIRROR + string "CPAN mirror (Perl packages)" + default "http://search.cpan.org/CPAN" + help + CPAN (Comprehensive Perl Archive Network) is a repository + of Perl packages. It has multiple software mirrors scattered + around the world. This option allows you to select a mirror. + + The list of mirrors is available at: + http://search.cpan.org/mirror + endmenu config BR2_JLEVEL
package/Makefile.in +3 -1
@@ -206,7 +206,8 @@ HOST_PATH=$(HOST_DIR)/bin:$(HOST_DIR)/usr/bin:$(PATH) HOSTCC_VERSION:=$(shell $(HOSTCC_NOCCACHE) --version | \ sed -n 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)[ ]*.*$$/\1\2\3/p') -export PERL5LIB := $(HOST_DIR)/usr/lib/perl +HOST_PERL_ARCHNAME := $(shell perl -MConfig -e "print Config->{archname}") +export PERL5LIB := $(HOST_DIR)/usr/lib/perl5/$(HOST_PERL_ARCHNAME):$(HOST_DIR)/usr/lib/perl5 TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \ AR="$(TARGET_AR)" \
@@ -359,5 +360,6 @@ include package/pkg-download.mk include package/pkg-autotools.mk include package/pkg-cmake.mk include package/pkg-luarocks.mk +include package/pkg-perl.mk include package/pkg-python.mk include package/pkg-generic.mk
package/pkg-perl.mk new file +181 -0
181 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v10 3/6 host-perl-xml-parser: rename and refactor with perl infrastructure
In reply to Francois PerradEven though libxml-parser-perl had a Config.in file with an option to enable it on the target, this option was hidden by a dependency on BR2_HOST_ONLY. So in practice, it was not possible to enable libxml-parser-perl on the target. This allows us to rename libxml-parser-perl to perl-xml-parser to follow the new naming convention of Perl packages, without having to introduce Config.in.legacy material.
In addition to this rename, the package is converted to use the newly introduced Perl package infrastructure.
--- package/Config.in | 1 - package/intltool/intltool.mk | 2 +- package/libxml-parser-perl/Config.in | 10 ------- package/libxml-parser-perl/libxml-parser-perl.mk | 35 ---------------------- package/metacity/metacity.mk | 2 +- package/perl-xml-parser/perl-xml-parser.mk | 17 +++++++++++ 6 files changed, 19 insertions(+), 48 deletions(-) delete mode 100644 package/libxml-parser-perl/Config.in delete mode 100644 package/libxml-parser-perl/libxml-parser-perl.mk create mode 100644 package/perl-xml-parser/perl-xml-parser.mk
package/Config.in +0 -1
@@ -632,7 +632,6 @@ source "package/json-c/Config.in" source "package/json-glib/Config.in" source "package/libjson/Config.in" source "package/libroxml/Config.in" -source "package/libxml-parser-perl/Config.in" source "package/libxml2/Config.in" source "package/libxmlpp/Config.in" source "package/libxslt/Config.in"
package/intltool/intltool.mk +1 -1
@@ -9,7 +9,7 @@ INTLTOOL_SITE = https://launchpad.net/intltool/trunk/$(INTLTOOL_VERSION)/+downlo INTLTOOL_LICENSE = GPLv2+ INTLTOOL_LICENSE_FILES = COPYING -HOST_INTLTOOL_DEPENDENCIES = host-gettext host-libxml-parser-perl +HOST_INTLTOOL_DEPENDENCIES = host-gettext host-perl-xml-parser $(eval $(autotools-package)) $(eval $(host-autotools-package))
package/libxml-parser-perl/Config.in deleted +0 -10
@@ -1,10 +0,0 @@ -config BR2_PACKAGE_LIBXML_PARSER_PERL - bool "libxml-parser-perl" - select BR2_PACKAGE_EXPAT - # Hide from configuration as we only support the host package - # for the moment - depends on BR2_HOST_ONLY - help - The Perl XML::Parser module. - - http://www.cpan.org/modules/by-module/XML/
package/libxml-parser-perl/libxml-parser-perl.mk deleted +0 -35
@@ -1,35 +0,0 @@ -################################################################################ -# -# libxml-parser-perl -# -################################################################################ - -LIBXML_PARSER_PERL_VERSION = 2.36 -LIBXML_PARSER_PERL_SOURCE = XML-Parser-$(LIBXML_PARSER_PERL_VERSION).tar.gz -LIBXML_PARSER_PERL_SITE = http://www.cpan.org/modules/by-module/XML/ - -LIBXML_PARSER_PERL_DEPENDENCIES = expat - -define HOST_LIBXML_PARSER_PERL_CONFIGURE_CMDS - (cd $(@D) ; \ - $(HOST_CONFIGURE_OPTS) perl Makefile.PL \ - PREFIX=$(HOST_DIR)/usr \ - EXPATLIBPATH=$(HOST_DIR)/usr/lib \ - EXPATINCPATH=$(HOST_DIR)/usr/include \ - INSTALLDIRS=site \ - INSTALLSITELIB=$(HOST_DIR)/usr/lib/perl \ - INSTALLSITEARCH=$(HOST_DIR)/usr/lib/perl \ - USE_MM_LD_RUN_PATH=1 \ - ) -endef - -define HOST_LIBXML_PARSER_PERL_BUILD_CMDS - $(HOST_MAKE_ENV) $(MAKE) -C $(@D) -endef - -define HOST_LIBXML_PARSER_PERL_INSTALL_CMDS - $(HOST_MAKE_ENV) $(MAKE) -C $(@D) install -endef - -$(eval $(generic-package)) -$(eval $(host-generic-package))
package/metacity/metacity.mk +1 -1
@@ -19,7 +19,7 @@ METACITY_CONF_OPT = --x-includes=$(STAGING_DIR)/usr/include/X11 \ METACITY_DEPENDENCIES = libgtk2 \ xlib_libX11 \ - host-libxml-parser-perl \ + host-perl-xml-parser \ xlib_libXcomposite \ xlib_libXfixes \ xlib_libXrender \
package/perl-xml-parser/perl-xml-parser.mk new file +17 -0
@@ -0,0 +1,17 @@ +################################################################################ +# +# perl-xml-parser +# +################################################################################ + +PERL_XML_PARSER_VERSION = 2.41 +PERL_XML_PARSER_SOURCE = XML-Parser-$(PERL_XML_PARSER_VERSION).tar.gz +PERL_XML_PARSER_SITE = $(BR2_CPAN_MIRROR)/authors/id/T/TO/TODDR/ +PERL_XML_PARSER_DEPENDENCIES = expat +PERL_XML_PARSER_LICENSE = Artistic or GPLv1+ + +HOST_LIBXML_PARSER_PERL_CONF_OPT = \ + EXPATLIBPATH=$(HOST_DIR)/usr/lib \ + EXPATINCPATH=$(HOST_DIR)/usr/include + +$(eval $(host-perl-package))
Signature · 1 line
1.7.9.5
PATCH v10 4/6 host-perl-module-build: new package
In reply to Francois PerradSome Perl packages depend on very recent versions of Module-Build which are not yet shipped with a stable perl version.
But the cpan client is able to update Module-Build as pre-requirement. On Buildroot, we must install the latest Module-Build.
--- package/perl-module-build/perl-module-build.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 package/perl-module-build/perl-module-build.mk
package/perl-module-build/perl-module-build.mk new file +12 -0
@@ -0,0 +1,12 @@ +################################################################################ +# +# perl-module-build +# +################################################################################ + +PERL_MODULE_BUILD_VERSION = 0.4204 +PERL_MODULE_BUILD_SOURCE = Module-Build-$(PERL_MODULE_BUILD_VERSION).tar.gz +PERL_MODULE_BUILD_SITE = $(BR2_CPAN_MIRROR)/authors/id/L/LE/LEONT/ +PERL_MODULE_BUILD_LICENSE = Artistic or GPLv1+ + +$(eval $(host-perl-package))
Signature · 1 line
1.7.9.5
PATCH v10 5/6 manual: adding packages perl
In reply to Francois Perrad--- docs/manual/adding-packages-perl.txt | 108 ++++++++++++++++++++++++++++++++++ docs/manual/adding-packages.txt | 2 + 2 files changed, 110 insertions(+) create mode 100644 docs/manual/adding-packages-perl.txt
docs/manual/adding-packages-perl.txt new file +108 -0
@@ -0,0 +1,108 @@ +// -*- mode:doc; -*- +// vim: set syntax=asciidoc: + +Infrastructure for Perl/CPAN packages +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +[[perl-package-tutorial]] + ++perl-package+ tutorial +^^^^^^^^^^^^^^^^^^^^^^^ + +First, let's see how to write a +.mk+ file for a Perl/CPAN package, +with an example : + +------------------------ +01: ################################################################################ +02: # +03: # perl-foo-bar +04: # +05: ################################################################################ +06: +07: PERL_FOO_BAR_VERSION = 0.02 +08: PERL_FOO_BAR_SOURCE = Foo-Bar-$(PERL_FOO_BAR_VERSION).tar.gz +09: PERL_FOO_BAR_SITE = $(BR2_CPAN_MIRROR)/authors/id/M/MO/MONGER/ +10: PERL_FOO_BAR_DEPENDENCIES = perl-strictures +11: PERL_FOO_BAR_LICENSE = Artistic or GPLv1+ +12: PERL_FOO_BAR_LICENSE_FILES = LICENSE +13: +14: $(eval $(perl-package)) +------------------------ + +On line 7, we declare the version of the package. + +On line 8 and 9, we declare the name of the tarball and the location +of the tarball on a CPAN server. Buildroot will automatically download +the tarball from this location. + +On line 10, we declare our dependencies, so that they are built +before the build process of our package starts. + +On line 11 and 12, we give licensing details about the package (its +license on line 11, and the file containing the license text on line +12). + +Finally, on line 14, we invoke the +perl-package+ macro that +generates all the Makefile rules that actually allow the package to be +built. + +Most of these data can be retrieved from https://metacpan.org/. +So, this file and the Config.in can be generated by running +the script +supports/scripts/scancpan Foo-Bar+ in the +TOPDIR+ directory +(or in the +BR2_EXTERNAL+ directory). +This script recursively creates packages for all required Perl/CPAN +dependencies. + +[[perl-package-reference]] + ++perl-package+ reference +^^^^^^^^^^^^^^^^^^^^^^^^ + +As a policy, packages that provide Perl/CPAN modules should all be +named +perl-<something>+ in Buildroot. + +This infrastructure handles various Perl build systems : ++ExtUtils-MakeMaker+, +Module-Build+ and +Module-Build-Tiny+. ++Build.PL+ is always preferred when a package provides a +Makefile.PL+ +and a +Build.PL+. + +The main macro of the Perl/CPAN package infrastructure is ++perl-package+. It is similar to the +generic-package+ macro. The ability to +have target and host packages is also available, with the ++host-perl-package+ macro. + +Just like the generic infrastructure, the Perl/CPAN infrastructure +works by defining a number of variables before calling the ++perl-package+ macro. + +First, all the package metadata information variables that exist in the +generic infrastructure also exist in the Perl/CPAN infrastructure: ++PERL_FOO_VERSION+, +PERL_FOO_SOURCE+, ++PERL_FOO_PATCH+, +PERL_FOO_SITE+, ++PERL_FOO_SUBDIR+, +PERL_FOO_DEPENDENCIES+, ++PERL_FOO_INSTALL_TARGET+. + +Note that setting +PERL_FOO_INSTALL_STAGING+ to +YES+ has no effect +unless a +PERL_FOO_INSTALL_STAGING_CMDS+ variable is defined. The perl +infrastructure doesn't define these commands since Perl modules generally +don't need to be installed to the +staging+ directory. + +A few additional variables, specific to the Perl/CPAN infrastructure, +can also be defined. Many of them are only useful in very specific +cases, typical packages will therefore only use a few of them. + +* +PERL_FOO_CONF_OPT+, to specify additional configure + options to pass to the +perl Makefile.PL+ or +perl Build.PL+. + By default, empty. + +* +PERL_FOO_BUILD_OPT+, to specify additional options to + pass to +make pure_all+ or +perl Build build+ in the build step. + By default, empty. + +* +PERL_FOO_INSTALL_TARGET_OPT+, to specify additional options to + pass to +make pure_install+ or +perl Build install+ in the install step. + By default, empty. + +* +HOST_PERL_FOO_INSTALL_OPT+, to specify additional options to + pass to +make pure_install+ or +perl Build install+ in the install step. + By default, empty.
docs/manual/adding-packages.txt +2 -0
@@ -22,6 +22,8 @@ include::adding-packages-python.txt[] include::adding-packages-luarocks.txt[] +include::adding-packages-perl.txt[] + include::adding-packages-hooks.txt[] include::adding-packages-gettext.txt[]
Signature · 1 line
1.7.9.5
PATCH v10 5/6 manual: adding packages perl
Ah, documentation, always a big attractor of small corrections...
Quoted 54 lines · Francois Perrad
Signed-off-by Francois Perrad <[email protected]>--- docs/manual/adding-packages-perl.txt | 108 ++++++++++++++++++++++++++++++++++ docs/manual/adding-packages.txt | 2 + 2 files changed, 110 insertions(+) create mode 100644 docs/manual/adding-packages-perl.txtdocs/manual/adding-packages-perl.txt new file +41
-0@@ -0,0 +1,108 @@ +// -*- mode:doc; -*- +// vim: set syntax=asciidoc: + +Infrastructure for Perl/CPAN packages +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +[[perl-package-tutorial]] + ++perl-package+ tutorial +^^^^^^^^^^^^^^^^^^^^^^^ + +First, let's see how to write a +.mk+ file for a Perl/CPAN package, +with an example : + +------------------------ +01: ################################################################################ +02: # +03: # perl-foo-bar +04: # +05: ################################################################################ +06: +07: PERL_FOO_BAR_VERSION = 0.02 +08: PERL_FOO_BAR_SOURCE = Foo-Bar-$(PERL_FOO_BAR_VERSION).tar.gz +09: PERL_FOO_BAR_SITE = $(BR2_CPAN_MIRROR)/authors/id/M/MO/MONGER/ +10: PERL_FOO_BAR_DEPENDENCIES = perl-strictures +11: PERL_FOO_BAR_LICENSE = Artistic or GPLv1+ +12: PERL_FOO_BAR_LICENSE_FILES = LICENSE +13: +14: $(eval $(perl-package)) +------------------------ + +On line 7, we declare the version of the package. + +On line 8 and 9, we declare the name of the tarball and the location +of the tarball on a CPAN server. Buildroot will automatically download +the tarball from this location. + +On line 10, we declare our dependencies, so that they are built +before the build process of our package starts. + +On line 11 and 12, we give licensing details about the package (its
docs/manual/adding-packages-perl.txt line 51
Quoted 10 lines
docs/manual/adding-packages-perl.txt new file +10
-0+license on line 11, and the file containing the license text on line +12). + +Finally, on line 14, we invoke the +perl-package+ macro that +generates all the Makefile rules that actually allow the package to be +built. + +Most of these data can be retrieved from https://metacpan.org/. +So, this file and the Config.in can be generated by running +the script +supports/scripts/scancpan Foo-Bar+ in the +TOPDIR+ directory
TOPDIR -> buildroot
(I have a feeling that the TOPDIR was actually inserted because of an earlier review comment, so maybe my feedback is not correct).
docs/manual/adding-packages-perl.txt line 54
Quoted 3 lines
docs/manual/adding-packages-perl.txt new file +3
-0+(or in the +BR2_EXTERNAL+ directory). +This script recursively creates packages for all required Perl/CPAN +dependencies.
How about:
This script creates a Config.in file and foo-bar.mk file for the
requested package, and also recursively for all dependencies specified by CPAN. You should still manually edit the result. In particular, the following things should be checked.
* The +PERL_FOO_BAR_LICENSE_FILES+ variable is not set, because metacpan doesn't have this information. Also, the name of the license file(s) varies between packages, and some don't even have a license file.
* If the perl module links with a shared library that is provided by another (non-perl) package, this dependency is not added automatically. It has to be added manually to +PERL_FOO_BAR_DEPENDENCIES+.
* The +package/Config.in+ file has to be updated manually to include the generated Config.in files. As a hint, the +scancpan+ script prints out the required +source "..."+ statements, sorted alphabetically.
docs/manual/adding-packages-perl.txt line 65
Quoted 11 lines
docs/manual/adding-packages-perl.txt new file +11
-0+ +[[perl-package-reference]] + ++perl-package+ reference +^^^^^^^^^^^^^^^^^^^^^^^^ + +As a policy, packages that provide Perl/CPAN modules should all be +named +perl-<something>+ in Buildroot. + +This infrastructure handles various Perl build systems : ++ExtUtils-MakeMaker+, +Module-Build+ and +Module-Build-Tiny+.
Shouldn't that be ExtUtils::MakeMaker etc?
Quoted 19 lines
docs/manual/adding-packages-perl.txt new file +19
-0++Build.PL+ is always preferred when a package provides a +Makefile.PL+ +and a +Build.PL+. + +The main macro of the Perl/CPAN package infrastructure is ++perl-package+. It is similar to the +generic-package+ macro. The ability to +have target and host packages is also available, with the ++host-perl-package+ macro. + +Just like the generic infrastructure, the Perl/CPAN infrastructure +works by defining a number of variables before calling the ++perl-package+ macro. + +First, all the package metadata information variables that exist in the +generic infrastructure also exist in the Perl/CPAN infrastructure: ++PERL_FOO_VERSION+, +PERL_FOO_SOURCE+, ++PERL_FOO_PATCH+, +PERL_FOO_SITE+, ++PERL_FOO_SUBDIR+, +PERL_FOO_DEPENDENCIES+, ++PERL_FOO_INSTALL_TARGET+. +
docs/manual/adding-packages-perl.txt line 94
Quoted 10 lines
docs/manual/adding-packages-perl.txt new file +10
-0+Note that setting +PERL_FOO_INSTALL_STAGING+ to +YES+ has no effect +unless a +PERL_FOO_INSTALL_STAGING_CMDS+ variable is defined. The perl +infrastructure doesn't define these commands since Perl modules generally +don't need to be installed to the +staging+ directory. + +A few additional variables, specific to the Perl/CPAN infrastructure, +can also be defined. Many of them are only useful in very specific +cases, typical packages will therefore only use a few of them. + +* +PERL_FOO_CONF_OPT+, to specify additional configure
I think +HOST_PERL_FOO_CONF_OPT+ should be mentioned explicitly here as
well, so it is clear that this is not "inherited" from PERL_FOO_CONF_OPT.
Regards,
Arnout
Quoted 28 lines
docs/manual/adding-packages-perl.txt new file +14
-0+ options to pass to the +perl Makefile.PL+ or +perl Build.PL+. + By default, empty. + +* +PERL_FOO_BUILD_OPT+, to specify additional options to + pass to +make pure_all+ or +perl Build build+ in the build step. + By default, empty. + +* +PERL_FOO_INSTALL_TARGET_OPT+, to specify additional options to + pass to +make pure_install+ or +perl Build install+ in the install step. + By default, empty. + +* +HOST_PERL_FOO_INSTALL_OPT+, to specify additional options to + pass to +make pure_install+ or +perl Build install+ in the install step. + By default, empty.docs/manual/adding-packages.txt +2
-0@@ -22,6 +22,8 @@ include::adding-packages-python.txt[] include::adding-packages-luarocks.txt[] +include::adding-packages-perl.txt[] + include::adding-packages-hooks.txt[] include::adding-packages-gettext.txt[]
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
[Buildroot] [UNSURE]Re: [V10 5/6] manual: adding packages perl
2014-02-20 8:11 GMT+01:00 Arnout Vandecappelle <[email protected]>:
Quoted 70 lines
Ah, documentation, always a big attractor of small corrections...
Quoted 54 lines · Francois Perrad
Signed-off-by Francois Perrad <[email protected]>--- docs/manual/adding-packages-perl.txt | 108 ++++++++++++++++++++++++++++++++++ docs/manual/adding-packages.txt | 2 + 2 files changed, 110 insertions(+) create mode 100644 docs/manual/adding-packages-perl.txtdocs/manual/adding-packages-perl.txt new file +41
-0@@ -0,0 +1,108 @@ +// -*- mode:doc; -*- +// vim: set syntax=asciidoc: + +Infrastructure for Perl/CPAN packages +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +[[perl-package-tutorial]] + ++perl-package+ tutorial +^^^^^^^^^^^^^^^^^^^^^^^ + +First, let's see how to write a +.mk+ file for a Perl/CPAN package, +with an example : + +------------------------ +01: ################################################################################ +02: # +03: # perl-foo-bar +04: # +05: ################################################################################ +06: +07: PERL_FOO_BAR_VERSION = 0.02 +08: PERL_FOO_BAR_SOURCE = Foo-Bar-$(PERL_FOO_BAR_VERSION).tar.gz +09: PERL_FOO_BAR_SITE = $(BR2_CPAN_MIRROR)/authors/id/M/MO/MONGER/ +10: PERL_FOO_BAR_DEPENDENCIES = perl-strictures +11: PERL_FOO_BAR_LICENSE = Artistic or GPLv1+ +12: PERL_FOO_BAR_LICENSE_FILES = LICENSE +13: +14: $(eval $(perl-package)) +------------------------ + +On line 7, we declare the version of the package. + +On line 8 and 9, we declare the name of the tarball and the location +of the tarball on a CPAN server. Buildroot will automatically download +the tarball from this location. + +On line 10, we declare our dependencies, so that they are built +before the build process of our package starts. + +On line 11 and 12, we give licensing details about the package (itsdocs/manual/adding-packages-perl.txt line 51
Quoted 10 lines
docs/manual/adding-packages-perl.txt new file +10
-0+license on line 11, and the file containing the license text on line +12). + +Finally, on line 14, we invoke the +perl-package+ macro that +generates all the Makefile rules that actually allow the package to be +built. + +Most of these data can be retrieved from https://metacpan.org/. +So, this file and the Config.in can be generated by running +the script +supports/scripts/scancpan Foo-Bar+ in the +TOPDIR+ directoryTOPDIR -> buildroot
Quoted 2 lines
(I have a feeling that the TOPDIR was actually inserted because of an earlier review comment, so maybe my feedback is not correct).
TOPDIR is here since V1, see
http://article.gmane.org/gmane.comp.lib.uclibc.buildroot/70565
Quoted 12 lines
docs/manual/adding-packages-perl.txt line 54
Quoted 4 lines
docs/manual/adding-packages-perl.txt new file +3
-0+(or in the +BR2_EXTERNAL+ directory). +This script recursively creates packages for all required Perl/CPAN +dependencies.How about:
This script creates a Config.in file and foo-bar.mk file for the
requested package, and also recursively for all dependencies specified by CPAN. You should still manually edit the result. In particular, the following things should be checked.
Quoted 10 lines
* The +PERL_FOO_BAR_LICENSE_FILES+ variable is not set, because metacpan doesn't have this information. Also, the name of the license file(s) varies between packages, and some don't even have a license file.
* If the perl module links with a shared library that is provided by another (non-perl) package, this dependency is not added automatically. It has to be added manually to +PERL_FOO_BAR_DEPENDENCIES+.
* The +package/Config.in+ file has to be updated manually to include the generated Config.in files. As a hint, the +scancpan+ script prints out the required +source "..."+ statements, sorted alphabetically.
Ok
Quoted 5 lines
Quoted 5 lines
docs/manual/adding-packages-perl.txt new file +5
-0+ +[[perl-package-reference]] + ++perl-package+ reference +^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 8 lines
docs/manual/adding-packages-perl.txt line 65
Quoted 6 lines
docs/manual/adding-packages-perl.txt new file +6
-0+ +As a policy, packages that provide Perl/CPAN modules should all be +named +perl-<something>+ in Buildroot. + +This infrastructure handles various Perl build systems : ++ExtUtils-MakeMaker+, +Module-Build+ and +Module-Build-Tiny+.Shouldn't that be
ExtUtils::MakeMakeretc?
ExtUtils::MakeMaker is a Perl module name. ExtUtils-MakeMaker is a CPAN distribution name (a distribution could contains several modules).
Remember that scancpan handles distribution name.
Quoted 25 lines
Quoted 25 lines
docs/manual/adding-packages-perl.txt new file +24
-0++Build.PL+ is always preferred when a package provides a +Makefile.PL+ +and a +Build.PL+. + +The main macro of the Perl/CPAN package infrastructure is ++perl-package+. It is similar to the +generic-package+ macro. The ability to +have target and host packages is also available, with the ++host-perl-package+ macro. + +Just like the generic infrastructure, the Perl/CPAN infrastructure +works by defining a number of variables before calling the ++perl-package+ macro. + +First, all the package metadata information variables that exist in the +generic infrastructure also exist in the Perl/CPAN infrastructure: ++PERL_FOO_VERSION+, +PERL_FOO_SOURCE+, ++PERL_FOO_PATCH+, +PERL_FOO_SITE+, ++PERL_FOO_SUBDIR+, +PERL_FOO_DEPENDENCIES+, ++PERL_FOO_INSTALL_TARGET+. + +Note that setting +PERL_FOO_INSTALL_STAGING+ to +YES+ has no effect +unless a +PERL_FOO_INSTALL_STAGING_CMDS+ variable is defined. The perl +infrastructure doesn't define these commands since Perl modules generally +don't need to be installed to the +staging+ directory. +
Quoted 9 lines
docs/manual/adding-packages-perl.txt line 94
Quoted 5 lines
docs/manual/adding-packages-perl.txt new file +5
-0+A few additional variables, specific to the Perl/CPAN infrastructure, +can also be defined. Many of them are only useful in very specific +cases, typical packages will therefore only use a few of them. + +* +PERL_FOO_CONF_OPT+, to specify additional configureI think +HOST_PERL_FOO_CONF_OPT+ should be mentioned explicitly here as
well, so it is clear that this is not "inherited" fromPERL_FOO_CONF_OPT.
Same thing for PERL_FOO_BUILD_OPT/HOST_PERL_FOO_BUILD_OPT.
Fran?ois
Quoted 45 lines
Regards,
ArnoutQuoted 20 lines
docs/manual/adding-packages-perl.txt new file +14
-0+ options to pass to the +perl Makefile.PL+ or +perl Build.PL+. + By default, empty. + +* +PERL_FOO_BUILD_OPT+, to specify additional options to + pass to +make pure_all+ or +perl Build build+ in the build step. + By default, empty. + +* +PERL_FOO_INSTALL_TARGET_OPT+, to specify additional options to + pass to +make pure_install+ or +perl Build install+ in the install step. + By default, empty. + +* +HOST_PERL_FOO_INSTALL_OPT+, to specify additional options to + pass to +make pure_install+ or +perl Build install+ in the install step. + By default, empty.docs/manual/adding-packages.txt +0
-0docs/manual/adding-packages.txt include::adding-packages-python.txt[] · line 29
Quoted 8 lines
docs/manual/adding-packages.txt +2
-0@@ -22,6 +22,8 @@ include::adding-packages-python.txt[] include::adding-packages-luarocks.txt[] +include::adding-packages-perl.txt[] + include::adding-packages-hooks.txt[] include::adding-packages-gettext.txt[]--
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH v10 6/6 scancpan: a new script
In reply to Francois Perradwhich creates Perl/CPAN package files
--- support/scripts/scancpan | 732 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 732 insertions(+) create mode 100755 support/scripts/scancpan
support/scripts/scancpan new file +732 -0
@@ -0,0 +1,732 @@ +#!/usr/bin/env perl + +# This chunk of stuff was generated by App::FatPacker. To find the original +# file's code, look for the end of this BEGIN block or the string 'FATPACK' +BEGIN { +my %fatpacked; + +$fatpacked{"MetaCPAN/API/Tiny.pm"} = <<'METACPAN_API_TINY'; + package MetaCPAN::API::Tiny; + { + $MetaCPAN::API::Tiny::VERSION = '1.131730'; + } + use strict; + use warnings; + # ABSTRACT: A Tiny API client for MetaCPAN + + use Carp; + use JSON::PP 'encode_json', 'decode_json'; + use HTTP::Tiny; + + + sub new { + my ($class, @args) = @_; + + $#_ % 2 == 0 + or croak 'Arguments must be provided as name/value pairs'; + + my %params = @args; + + die 'ua_args must be an array reference' + if $params{ua_args} && ref($params{ua_args}) ne 'ARRAY'; + + my $self = +{ + base_url => $params{base_url} || 'http://api.metacpan.org/v0', + ua => $params{ua} || HTTP::Tiny->new( + $params{ua_args} + ? @{$params{ua_args}} + : (agent => 'MetaCPAN::API::Tiny/' + . ($MetaCPAN::API::VERSION || 'xx'))), + }; + + return bless($self, $class); + } + + sub _build_extra_params { + my $self = shift; + + @_ % 2 == 0 + or croak 'Incorrect number of params, must be key/value'; + + my %extra = @_; + my $ua = $self->{ua}; + + foreach my $key (keys %extra) + { + # The implementation in HTTP::Tiny uses + instead of %20, fix that + $extra{$key} = $ua->_uri_escape($extra{$key}); + $extra{$key} =~ s/\+/%20/g; + } + + my $params = join '&', map { "$_=" . $extra{$_} } sort keys %extra; + + return $params; + } + + + # /source/{author}/{release}/{path} + sub source { + my $self = shift; + my %opts = @_ ? @_ : (); + my $url = ''; + my $error = "Provide 'author' and 'release' and 'path'"; + + %opts or croak $error; + + if ( + defined ( my $author = $opts{'author'} ) && + defined ( my $release = $opts{'release'} ) && + defined ( my $path = $opts{'path'} ) + ) { + $url = "source/$author/$release/$path"; + } else { + croak $error; + } + + $url = $self->{base_url} . "/$url"; + + my $result = $self->{ua}->get($url); + $result->{'success'} + or croak "Failed to fetch '$url': " . $result->{'reason'}; + + return $result->{'content'}; + } + + + # /release/{distribution} + # /release/{author}/{release} + sub release { + my $self = shift; + my %opts = @_ ? @_ : (); + my $url = ''; + my $error = "Either provide 'distribution', or 'author' and 'release', " . + "or 'search'"; + + %opts or croak $error; + + my %extra_opts = (); + + if ( defined ( my $dist = $opts{'distribution'} ) ) { + $url = "release/$dist"; + } elsif ( + defined ( my $author = $opts{'author'} ) && + defined ( my $release = $opts{'release'} ) + ) { + $url = "release/$author/$release"; + } elsif ( defined ( my $search_opts = $opts{'search'} ) ) { + ref $search_opts && ref $search_opts eq 'HASH' + or croak $error; + + %extra_opts = %{$search_opts}; + $url = 'release/_search'; + } else { + croak $error; + } + + return $self->fetch( $url, %extra_opts ); + } + + + # /pod/{module} + # /pod/{author}/{release}/{path} + sub pod { + my $self = shift; + my %opts = @_ ? @_ : (); + my $url = ''; + my $error = "Either provide 'module' or 'author and 'release' and 'path'"; + + %opts or croak $error; + + if ( defined ( my $module = $opts{'module'} ) ) { + $url = "pod/$module"; + } elsif ( + defined ( my $author = $opts{'author'} ) && + defined ( my $release = $opts{'release'} ) && + defined ( my $path = $opts{'path'} ) + ) { + $url = "pod/$author/$release/$path"; + } else { + croak $error; + } + + # check content-type + my %extra = (); + if ( defined ( my $type = $opts{'content-type'} ) ) { + $type =~ m{^ text/ (?: html|plain|x-pod|x-markdown ) $}x + or croak 'Incorrect content-type provided'; + + $extra{headers}{'content-type'} = $type; + } + + $url = $self->{base_url}. "/$url"; + + my $result = $self->{ua}->get( $url, \%extra ); + $result->{'success'} + or croak "Failed to fetch '$url': " . $result->{'reason'}; + + return $result->{'content'}; + } + + + # /module/{module} + sub module { + my $self = shift; + my $name = shift; + + $name or croak 'Please provide a module name'; + + return $self->fetch("module/$name"); + } + + + # file() is a synonym of module + sub file { goto &module } + + + # /author/{author} + sub author { + my $self = shift; + my ( $pause_id, $url, %extra_opts ); + + if ( @_ == 1 ) { + $url = 'author/' . shift; + } elsif ( @_ == 2 ) { + my %opts = @_; + + if ( defined $opts{'pauseid'} ) { + $url = "author/" . $opts{'pauseid'}; + } elsif ( defined $opts{'search'} ) { + my $search_opts = $opts{'search'}; + + ref $search_opts && ref $search_opts eq 'HASH' + or croak "'search' key must be hashref"; + + %extra_opts = %{$search_opts}; + $url = 'author/_search'; + } else { + croak 'Unknown option given'; + } + } else { + croak 'Please provide an author PAUSEID or a "search"'; + } + + return $self->fetch( $url, %extra_opts ); + } + + + + sub fetch { + my $self = shift; + my $url = shift; + my $extra = $self->_build_extra_params(@_); + my $base = $self->{base_url}; + my $req_url = $extra ? "$base/$url?$extra" : "$base/$url"; + + my $result = $self->{ua}->get($req_url); + return $self->_decode_result( $result, $req_url ); + } + + + sub post { + my $self = shift; + my $url = shift; + my $query = shift; + my $base = $self->{base_url}; + + defined $url + or croak 'First argument of URL must be provided'; + + ref $query and ref $query eq 'HASH' + or croak 'Second argument of query hashref must be provided'; + + my $query_json = encode_json( $query ); + my $result = $self->{ua}->request( + 'POST', + "$base/$url", + { + headers => { 'Content-Type' => 'application/json' }, + content => $query_json, + } + ); + + return $self->_decode_result( $result, $url, $query_json ); + } + + sub _decode_result { + my $self = shift; + my ( $result, $url, $original ) = @_; + my $decoded_result; + + ref $result and ref $result eq 'HASH' + or croak 'First argument must be hashref'; + + defined $url + or croak 'Second argument of a URL must be provided'; + + if ( defined ( my $success = $result->{'success'} ) ) { + my $reason = $result->{'reason'} || ''; + $reason .= ( defined $original ? " (request: $original)" : '' ); + + $success or croak "Failed to fetch '$url': $reason"; + } else { + croak 'Missing success in return value'; + } + + defined ( my $content = $result->{'content'} ) + or croak 'Missing content in return value'; + + eval { $decoded_result = decode_json $content; 1 } + or do { croak "Couldn't decode '$content': $@" }; + + return $decoded_result; + } + + 1; + + __END__ + + =pod + + =head1 NAME + + MetaCPAN::API::Tiny - A Tiny API client for MetaCPAN + + =head1 VERSION + + version 1.131730 + + =head1 DESCRIPTION + + This is the Tiny version of L<MetaCPAN::API>. It implements a compatible API + with a few notable exceptions: + + =over 4 + + =item Attributes are direct hash access + + The attributes defined using Mo(o|u)se are now accessed via the blessed hash + directly. There are no accessors defined to access this elements. + + =item Exception handling + + Instead of using Try::Tiny, raw evals are used. This could potentially cause + issues, so just be aware. + + =item Testing + + Test::Fatal was replaced with an eval implementation of exception(). + Test::TinyMocker usage is retained, but may be absorbed since it is pure perl + + =back + + =head1 CLASS_METHODS + + =head2 new + + new is the constructor for MetaCPAN::API::Tiny. In the non-tiny version of this + module, this is provided via Any::Moose built from the attributes defined. In + the tiny version, we define our own constructor. It takes the same arguments + and provides similar checks to MetaCPAN::API with regards to arguments passed. + + =head1 PUBLIC_METHODS + + =head2 source + + my $source = $mcpan->source( + author => 'DOY', + release => 'Moose-2.0201', + path => 'lib/Moose.pm', + ); + + Searches MetaCPAN for a module or a specific release and returns the plain source. + + =head2 release + + my $result = $mcpan->release( distribution => 'Moose' ); + + # or + my $result = $mcpan->release( author => 'DOY', release => 'Moose-2.0001' ); + + Searches MetaCPAN for a dist. + + You can do complex searches using 'search' parameter: + + # example lifted from MetaCPAN docs + my $result = $mcpan->release( + search => { + author => "OALDERS AND ", + filter => "status:latest", + fields => "name", + size => 1, + }, + ); + + =head2 pod + + my $result = $mcpan->pod( module => 'Moose' ); + + # or + my $result = $mcpan->pod( + author => 'DOY', + release => 'Moose-2.0201', + path => 'lib/Moose.pm', + ); + + Searches MetaCPAN for a module or a specific release and returns the POD. + + =head2 module + + my $result = $mcpan->module('MetaCPAN::API'); + + Searches MetaCPAN and returns a module's ".pm" file. + + =head2 file + + A synonym of L</module> + + =head2 author + + my $result1 = $mcpan->author('XSAWYERX'); + my $result2 = $mcpan->author( pauseid => 'XSAWYERX' ); + + Searches MetaCPAN for a specific author. + + You can do complex searches using 'search' parameter: + + # example lifted from MetaCPAN docs + my $result = $mcpan->author( + search => { + q => 'profile.name:twitter', + size => 1, + }, + ); + + =head2 fetch + + my $result = $mcpan->fetch('/release/distribution/Moose'); + + # with parameters + my $more = $mcpan->fetch( + '/release/distribution/Moose', + param => 'value', + ); + + This is a helper method for API implementations. It fetches a path from MetaCPAN, decodes the JSON from the content variable and returns it. + + You don't really need to use it, but you can in case you want to write your own extension implementation to MetaCPAN::API. + + It accepts an additional hash as "GET" parameters. + + =head2 post + + # /release&content={"query":{"match_all":{}},"filter":{"prefix":{"archive":"Cache-Cache-1.06"}}} + my $result = $mcpan->post( + 'release', + { + query => { match_all => {} }, + filter => { prefix => { archive => 'Cache-Cache-1.06' } }, + }, + ); + + The POST equivalent of the "fetch()" method. It gets the path and JSON request. + + =head1 THANKS + + Overall the tests and code were ripped directly from MetaCPAN::API and + tiny-fied. A big thanks to Sawyer X for writing the original module. + + =head1 AUTHOR + + Nicholas R. Perez <[email protected]> + + =head1 COPYRIGHT AND LICENSE + + This software is copyright (c) 2013 by Nicholas R. Perez <[email protected]>. + + This is free software; you can redistribute it and/or modify it under + the same terms as the Perl 5 programming language system itself. + + =cut +METACPAN_API_TINY + +s/^ //mg for values %fatpacked; + +unshift @INC, sub { + if (my $fat = $fatpacked{$_[1]}) { + if ($] < 5.008) { + return sub { + return 0 unless length $fat; + $fat =~ s/^([^\n]*\n?)//; + $_ = $1; + return 1; + }; + } + open my $fh, '<', \$fat + or die "FatPacker error loading $_[1] (could be a perl installation issue?)"; + return $fh; + } + return +}; + +} # END OF FATPACK CODE + + +use 5.018; # same major version as target perl +use strict; +use warnings; +use Fatal qw(open close); + +use Getopt::Long; +use Pod::Usage; +use File::Basename; +use Module::CoreList; +use MetaCPAN::API::Tiny; + +my ($help, $man, $quiet, $force, $recommend); +GetOptions( 'help|?' => \$help, + 'man' => \$man, + 'quiet|q' => \$quiet, + 'force|f' => \$force, + 'recommend' => \$recommend +) or pod2usage(-exitval => 1); +pod2usage(-exitval => 0) if $help; +pod2usage(-exitval => 0, -verbose => 2) if $man; +pod2usage(-exitval => 1) if scalar @ARGV == 0; + +my %dist; +my %need_target; +my %need_host; +my %deps_build; +my %deps_runtime; +my $mcpan = MetaCPAN::API::Tiny->new(); + +sub fetch { + my ($name, $need_target, $need_host) = @_; + $need_target{$name} = $need_target if $need_target; + $need_host{$name} = $need_host if $need_host; + unless ($dist{$name}) { + say qq{fetch ${name}} unless $quiet; + my $result = $mcpan->release( distribution => $name ); + $dist{$name} = $result; + my @deps_build = (); + my @deps_runtime = (); + my $mb; + foreach my $dep (@{$result->{dependency}}) { + my $modname = ${$dep}{module}; + $mb = 1 if $modname eq q{Module::Build}; + next if $modname eq q{perl}; + next if $modname =~ m|^Alien|; + next if $modname =~ m|^Win32|; + next if Module::CoreList::first_release( $modname ); + next if ${$dep}{phase} eq q{develop}; + next if ${$dep}{phase} eq q{test}; + next if !$recommend && ${$dep}{relationship} ne q{requires}; + my $distname = $mcpan->module( $modname )->{distribution}; + if (${$dep}{phase} eq q{runtime}) { + push @deps_runtime, $distname; + } + else { # configure, build + push @deps_build, $distname; + } + } + unshift @deps_build, q{Module-Build} if $mb; + $deps_build{$name} = \@deps_build; + $deps_runtime{$name} = \@deps_runtime; + } + foreach my $distname (@{$deps_build{$name}}) { + fetch( $distname, 0, 1 ); + } + foreach my $distname (@{$deps_runtime{$name}}) { + fetch( $distname, $need_target, $need_host ); + } + return; +} + +foreach my $distname (@ARGV) { + fetch( $distname, 1, 0 ); +} +say scalar keys %dist, q{ packages fetched.} unless $quiet; + +sub fsname { + my $name = shift; + return q{perl-} . lc $name; +} + +sub brname { + my $name = shift; + $name =~ s|-|_|g; + return uc $name; +} + +while (my ($distname, $dist) = each %dist) { + my $fsname = fsname( $distname ); + my $dirname = q{package/} . $fsname; + my $cfgname = $dirname . q{/Config.in}; + my $mkname = $dirname . q{/} . $fsname . q{.mk}; + my $brname = brname( $fsname ); + mkdir $dirname unless -d $dirname; + if ($need_target{$distname} && ($force || !-f $cfgname)) { + my $abstract = $dist->{abstract}; + say qq{write ${cfgname}} unless $quiet; + open my $fh, q{>}, $cfgname; + say {$fh} qq{config BR2_PACKAGE_${brname}}; + say {$fh} qq{\tbool "${fsname}"}; + foreach my $dep (@{$deps_runtime{$distname}}) { + my $brdep = brname( fsname( $dep ) ); + say {$fh} qq{\tselect BR2_PACKAGE_${brdep}}; + } + say {$fh} qq{\thelp} if $abstract; + say {$fh} qq{\t ${abstract}} if $abstract; + close $fh; + } + if ($force || !-f $mkname) { + my $version = $dist->{version}; + my $site = dirname( $dist->{download_url} ); + my($scheme, $auth, $path) = $dist->{download_url} =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)|; + my($filename, $directories, $suffix) = fileparse( $path, q{tar.gz}, q{tgz} ); + my $dependencies = join q{ }, map( { q{host-} . fsname( $_ ); } @{$deps_build{$distname}} ), + map( { fsname( $_ ); } @{$deps_runtime{$distname}} ); + my $host_dependencies = join q{ }, map { q{host-} . fsname( $_ ); } @{$deps_build{$distname}}, + @{$deps_runtime{$distname}}; + my $license = ref $dist->{license} eq 'ARRAY' + ? join q{ or }, @{$dist->{license}} + : $dist->{license}; + $license = q{Artistic or GPLv1+} if $license eq q{perl_5}; + say qq{write ${mkname}} unless $quiet; + open my $fh, q{>}, $mkname; + say {$fh} qq{################################################################################}; + say {$fh} qq{#}; + say {$fh} qq{# ${fsname}}; + say {$fh} qq{#}; + say {$fh} qq{################################################################################}; + say {$fh} qq{}; + say {$fh} qq{${brname}_VERSION = ${version}}; + say {$fh} qq{${brname}_SOURCE = ${distname}-\$(${brname}_VERSION).${suffix}}; + say {$fh} qq{${brname}_SITE = \$(BR2_CPAN_MIRROR)${directories}}; + say {$fh} qq{${brname}_DEPENDENCIES = perl ${dependencies}} if $need_target{$distname}; + say {$fh} qq{HOST_${brname}_DEPENDENCIES = ${host_dependencies}} if $need_host{$distname}; + say {$fh} qq{${brname}_LICENSE = ${license}} if $license && $license ne q{unknown}; + say {$fh} qq{}; + say {$fh} qq{\$(eval \$(perl-package))} if $need_target{$distname}; + say {$fh} qq{\$(eval \$(host-perl-package))} if $need_host{$distname}; + close $fh; + } +} + +my %pkg; +my $cfgname = q{package/Config.in}; +if (-f $cfgname) { + open my $fh, q{<}, $cfgname; + while (<$fh>) { + chomp; + $pkg{$_} = 1 if m|package/perl-|; + } + close $fh; +} + +foreach my $distname (keys %need_target) { + my $fsname = fsname( $distname ); + $pkg{qq{source "package/${fsname}/Config.in"}} = 1; +} + +say qq{${cfgname} must contain the following lines:}; +say join qq{\n}, sort keys %pkg; + +__END__ + +=head1 NAME + +support/scripts/scancpan Try-Tiny Moo + +=head1 SYNOPSIS + +curl -kL http://install.perlbrew.pl | bash + +perlbrew install perl-5.18.2 + +supports/scripts/scancpan [options] [distname ...] + + Options: + -help + -man + -quiet + -force + -recommend + +=head1 OPTIONS + +=over 8 + +=item B<-help> + +Prints a brief help message and exits. + +=item B<-man> + +Prints the manual page and exits. + +=item B<-quiet> + +Executes without output + +=item B<-force> + +Forces the overwriting of existing files. + +=item B<-recommend> + +Adds I<recommended> dependencies. + +=back + +=head1 DESCRIPTION + +This script creates templates of the Buildroot package files for all the +Perl/CPAN distributions required by the specified distnames. The +dependencies and metadata are fetched from https://metacpan.org/. + +After running this script, it is necessary to check the generated files. +You have to manually enable the host- version if you need it. You have to +manually add the license files (PERL_FOO_LICENSE_FILES variable). For +distributions that link against a target library, you have to add the +buildroot package name for that library to the DEPENDENCIES variable. + +See the Buildroot documentation for details on the usage of the Perl +infrastructure. + +The major version of the host perl must be aligned on the target one, +in order to work with the right CoreList data. + +=head1 LICENSE + +Copyright (C) 2013-2014 by Francois Perrad <[email protected]> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +This script is a part of Buildroot. + +This script requires the module C<MetaCPAN::API::Tiny> (version 1.131730) +which was included at the beginning of this file by the tool C<fatpack>. + +See L<http://search.cpan.org/~nperez/MetaCPAN-API-Tiny-1.131730/>. + +See L<http://search.cpan.org/search?query=App-FatPacker&mode=dist>. + +These both libraries are free software and may be distributed under the same +terms as perl itself. + +And perl may be distributed under the terms of Artistic v1 or GPL v1 license. + +=cut
Signature · 1 line
1.7.9.5
PATCH v10 6/6 scancpan: a new script
Quoted 3 lines · Francois Perrad
which creates Perl/CPAN package files
Signed-off-by Francois Perrad <[email protected]>
Looks good to me. I haven't tested it this time, but I assume that you have.
I have a few small suggestions for improvements still, but for me it's
OK to go in, so
Quoted 10 lines
--- support/scripts/scancpan | 732 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 732 insertions(+) create mode 100755 support/scripts/scancpansupport/scripts/scancpan new file +0
-0
[snip]
support/scripts/scancpan line 500
Quoted 5 lines
support/scripts/scancpan new file +5
-0+my %dist; +my %need_target; +my %need_host; +my %deps_build; +my %deps_runtime;
Even though I find the code quite readable and easy to follow
(especially for a perl script and given that I don't actually know perl), I think it would help if the contents of these variables would be explained. E.g.:
my %dist; # name -> metacpan data my %need_target; # name -> 1 if target package is needed my %need_host; # name -> 1 if host package is needed my %deps_build; # name -> list of host dependencies
my %deps_runtime; # name -> list of target dependencies
Quoted 6 lines
support/scripts/scancpan new file +6
-0+my $mcpan = MetaCPAN::API::Tiny->new(); + +sub fetch { + my ($name, $need_target, $need_host) = @_; + $need_target{$name} = $need_target if $need_target; + $need_host{$name} = $need_host if $need_host;
support/scripts/scancpan line 516
Quoted 10 lines
support/scripts/scancpan new file +10
-0+ unless ($dist{$name}) { + say qq{fetch ${name}} unless $quiet; + my $result = $mcpan->release( distribution => $name ); + $dist{$name} = $result; + my @deps_build = (); + my @deps_runtime = (); + my $mb; + foreach my $dep (@{$result->{dependency}}) { + my $modname = ${$dep}{module}; + $mb = 1 if $modname eq q{Module::Build};
I don't understand this one: why is Module-Build treated specially? Ah,
now I know: because we need the most recent one, even if Module::Build is in CoreList. Can you add a comment for that?
support/scripts/scancpan line 520
Quoted 4 lines
support/scripts/scancpan new file +4
-0+ next if $modname eq q{perl}; + next if $modname =~ m|^Alien|; + next if $modname =~ m|^Win32|; + next if Module::CoreList::first_release( $modname );
Also here, add a comment that since this script has 'use 5.018;' which
is equal to the target-perl, we can skip modules that are core in this release.
Quoted 15 lines
support/scripts/scancpan new file +15
-0+ next if ${$dep}{phase} eq q{develop}; + next if ${$dep}{phase} eq q{test}; + next if !$recommend && ${$dep}{relationship} ne q{requires}; + my $distname = $mcpan->module( $modname )->{distribution}; + if (${$dep}{phase} eq q{runtime}) { + push @deps_runtime, $distname; + } + else { # configure, build + push @deps_build, $distname; + } + } + unshift @deps_build, q{Module-Build} if $mb; + $deps_build{$name} = \@deps_build; + $deps_runtime{$name} = \@deps_runtime; + }
support/scripts/scancpan line 545
Quoted 10 lines
support/scripts/scancpan new file +10
-0+ foreach my $distname (@{$deps_build{$name}}) { + fetch( $distname, 0, 1 ); + } + foreach my $distname (@{$deps_runtime{$name}}) { + fetch( $distname, $need_target, $need_host ); + } + return; +} + +foreach my $distname (@ARGV) {
# Command-line's distributions are needed for target, not host
support/scripts/scancpan line 549
Quoted 4 lines
support/scripts/scancpan new file +4
-0+ fetch( $distname, 1, 0 ); +} +say scalar keys %dist, q{ packages fetched.} unless $quiet; +
# Buildroot package name: lowercase
support/scripts/scancpan line 554
Quoted 5 lines
support/scripts/scancpan new file +5
-0+sub fsname { + my $name = shift; + return q{perl-} . lc $name; +} +
# Buildroot variable name: uppercase
Quoted 21 lines
support/scripts/scancpan new file +21
-0+sub brname { + my $name = shift; + $name =~ s|-|_|g; + return uc $name; +} + +while (my ($distname, $dist) = each %dist) { + my $fsname = fsname( $distname ); + my $dirname = q{package/} . $fsname; + my $cfgname = $dirname . q{/Config.in}; + my $mkname = $dirname . q{/} . $fsname . q{.mk}; + my $brname = brname( $fsname ); + mkdir $dirname unless -d $dirname; + if ($need_target{$distname} && ($force || !-f $cfgname)) { + my $abstract = $dist->{abstract}; + say qq{write ${cfgname}} unless $quiet; + open my $fh, q{>}, $cfgname; + say {$fh} qq{config BR2_PACKAGE_${brname}}; + say {$fh} qq{\tbool "${fsname}"}; + foreach my $dep (@{$deps_runtime{$distname}}) { + my $brdep = brname( fsname( $dep ) );
support/scripts/scancpan line 585
Quoted 10 lines
support/scripts/scancpan new file +10
-0+ say {$fh} qq{\tselect BR2_PACKAGE_${brdep}}; + } + say {$fh} qq{\thelp} if $abstract; + say {$fh} qq{\t ${abstract}} if $abstract; + close $fh; + } + if ($force || !-f $mkname) { + my $version = $dist->{version}; + my $site = dirname( $dist->{download_url} ); + my($scheme, $auth, $path) = $dist->{download_url} =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)|;
This regexp cuts off any #-anchor or ?-arguments. This is OK because
buildroot doesn't support that kind of stuff anyway, but it would be good to add a comment to make that explicit.
Quoted 9 lines
support/scripts/scancpan new file +9
-0+ my($filename, $directories, $suffix) = fileparse( $path, q{tar.gz}, q{tgz} ); + my $dependencies = join q{ }, map( { q{host-} . fsname( $_ ); } @{$deps_build{$distname}} ), + map( { fsname( $_ ); } @{$deps_runtime{$distname}} ); + my $host_dependencies = join q{ }, map { q{host-} . fsname( $_ ); } @{$deps_build{$distname}}, + @{$deps_runtime{$distname}}; + my $license = ref $dist->{license} eq 'ARRAY' + ? join q{ or }, @{$dist->{license}} + : $dist->{license}; + $license = q{Artistic or GPLv1+} if $license eq q{perl_5};
support/scripts/scancpan line 604
Quoted 10 lines
support/scripts/scancpan new file +10
-0+ say qq{write ${mkname}} unless $quiet; + open my $fh, q{>}, $mkname; + say {$fh} qq{################################################################################}; + say {$fh} qq{#}; + say {$fh} qq{# ${fsname}}; + say {$fh} qq{#}; + say {$fh} qq{################################################################################}; + say {$fh} qq{}; + say {$fh} qq{${brname}_VERSION = ${version}}; + say {$fh} qq{${brname}_SOURCE = ${distname}-\$(${brname}_VERSION).${suffix}};
Maybe there should be a check that ${filename} is
${distname}-${version}, otherwise the above is incorrect.
Regards,
Arnout
Quoted 31 lines
support/scripts/scancpan new file +31
-0+ say {$fh} qq{${brname}_SITE = \$(BR2_CPAN_MIRROR)${directories}}; + say {$fh} qq{${brname}_DEPENDENCIES = perl ${dependencies}} if $need_target{$distname}; + say {$fh} qq{HOST_${brname}_DEPENDENCIES = ${host_dependencies}} if $need_host{$distname}; + say {$fh} qq{${brname}_LICENSE = ${license}} if $license && $license ne q{unknown}; + say {$fh} qq{}; + say {$fh} qq{\$(eval \$(perl-package))} if $need_target{$distname}; + say {$fh} qq{\$(eval \$(host-perl-package))} if $need_host{$distname}; + close $fh; + } +} + +my %pkg; +my $cfgname = q{package/Config.in}; +if (-f $cfgname) { + open my $fh, q{<}, $cfgname; + while (<$fh>) { + chomp; + $pkg{$_} = 1 if m|package/perl-|; + } + close $fh; +} + +foreach my $distname (keys %need_target) { + my $fsname = fsname( $distname ); + $pkg{qq{source "package/${fsname}/Config.in"}} = 1; +} + +say qq{${cfgname} must contain the following lines:}; +say join qq{\n}, sort keys %pkg; + +__END__
[snip]
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F