From 924c69c62a553578df53b781ef02bf0ece5519c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Mairb=C3=B6ck?= Date: Tue, 31 Dec 2024 14:29:00 +0100 Subject: [PATCH] xml_sax: new perl module recipe This includes a patch to install the ParserDetails.ini configuration file into site_perl (i.e. the non-packaged hierarchy) instead of vendor_perl because it should be editable by other perl module packages that provide an XML SAX parser (whether installed as HPKG or manually). The config file is created and modified using post-install and pre-uninstall scripts. --- .../install_xml_sax_pureperl.pl | 5 ++ .../uninstall_xml_sax_pureperl.pl | 5 ++ .../xml_sax/patches/xml_sax-1.02.patchset | 49 +++++++++++++ dev-perl/xml_sax/xml_sax-1.02.recipe | 73 +++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100755 dev-perl/xml_sax/additional-files/install_xml_sax_pureperl.pl create mode 100755 dev-perl/xml_sax/additional-files/uninstall_xml_sax_pureperl.pl create mode 100644 dev-perl/xml_sax/patches/xml_sax-1.02.patchset create mode 100644 dev-perl/xml_sax/xml_sax-1.02.recipe diff --git a/dev-perl/xml_sax/additional-files/install_xml_sax_pureperl.pl b/dev-perl/xml_sax/additional-files/install_xml_sax_pureperl.pl new file mode 100755 index 000000000..74c9e4938 --- /dev/null +++ b/dev-perl/xml_sax/additional-files/install_xml_sax_pureperl.pl @@ -0,0 +1,5 @@ +#!perl + +use XML::SAX; + +XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers(); diff --git a/dev-perl/xml_sax/additional-files/uninstall_xml_sax_pureperl.pl b/dev-perl/xml_sax/additional-files/uninstall_xml_sax_pureperl.pl new file mode 100755 index 000000000..d9816ff87 --- /dev/null +++ b/dev-perl/xml_sax/additional-files/uninstall_xml_sax_pureperl.pl @@ -0,0 +1,5 @@ +#!perl + +use XML::SAX; + +XML::SAX->remove_parser(q(XML::SAX::PurePerl))->save_parsers(); diff --git a/dev-perl/xml_sax/patches/xml_sax-1.02.patchset b/dev-perl/xml_sax/patches/xml_sax-1.02.patchset new file mode 100644 index 000000000..e17fde837 --- /dev/null +++ b/dev-perl/xml_sax/patches/xml_sax-1.02.patchset @@ -0,0 +1,49 @@ +From bb777002f24040802543de8e9ae6716365c04898 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joachim=20Mairb=C3=B6ck?= +Date: Sun, 8 Dec 2024 21:52:07 +0100 +Subject: put ParserDetails.ini into site_perl in non-packaged + + +diff --git a/lib/XML/SAX.pm b/lib/XML/SAX.pm +index 7cd93d2..b04b3e8 100644 +--- a/lib/XML/SAX.pm ++++ b/lib/XML/SAX.pm +@@ -12,7 +12,9 @@ use Exporter (); + + @EXPORT_OK = qw(Namespaces Validation); + ++use Config; + use File::Basename qw(dirname); ++use File::Path qw(make_path); + use File::Spec (); + use Symbol qw(gensym); + use XML::SAX::ParserFactory (); # loaded for simplicity +@@ -53,8 +55,8 @@ sub load_parsers { + + # get directory from wherever XML::SAX is installed + if (!$dir) { +- $dir = $INC{'XML/SAX.pm'}; +- $dir = dirname($dir); ++ $dir = $Config{'sitelib'}; ++ $dir = File::Spec->catdir($dir, "XML"); + } + + my $fh = gensym(); +@@ -180,10 +182,11 @@ sub save_parsers { + my $class = shift; + + # get directory from wherever XML::SAX is installed +- my $dir = $INC{'XML/SAX.pm'}; +- $dir = dirname($dir); ++ my $dir = $Config{'sitelib'}; ++ $dir = File::Spec->catdir($dir, "XML", "SAX"); ++ make_path($dir); + +- my $file = File::Spec->catfile($dir, "SAX", PARSER_DETAILS); ++ my $file = File::Spec->catfile($dir, PARSER_DETAILS); + chmod 0644, $file; + unlink($file); + +-- +2.45.2 + diff --git a/dev-perl/xml_sax/xml_sax-1.02.recipe b/dev-perl/xml_sax/xml_sax-1.02.recipe new file mode 100644 index 000000000..870225952 --- /dev/null +++ b/dev-perl/xml_sax/xml_sax-1.02.recipe @@ -0,0 +1,73 @@ +SUMMARY="Simple API for XML" +DESCRIPTION="XML::SAX is a SAX parser access API for Perl. It includes classes and APIs required \ +for implementing SAX drivers, along with a factory class for returning any SAX parser installed \ +on the user's system." +HOMEPAGE="https://metacpan.org/pod/XML::SAX::Base" +COPYRIGHT="Grant McLean" +LICENSE="Artistic" +REVISION="1" +SOURCE_URI="https://cpan.metacpan.org/authors/id/G/GR/GRANTM/XML-SAX-$portVersion.tar.gz" +CHECKSUM_SHA256="4506c387043aa6a77b455f00f57409f3720aa7e553495ab2535263b4ed1ea12a" +SOURCE_DIR="XML-SAX-$portVersion" +PATCHES="xml_sax-$portVersion.patchset" +ADDITIONAL_FILES=" + install_xml_sax_pureperl.pl + uninstall_xml_sax_pureperl.pl + " + +ARCHITECTURES="any" + +POST_INSTALL_SCRIPTS="$relativePostInstallDir/install_xml_sax_pureperl.pl" +PRE_UNINSTALL_SCRIPTS="$relativePreUninstallDir/uninstall_xml_sax_pureperl.pl" + +PROVIDES=" + xml_sax = $portVersion + " +REQUIRES=" + haiku + vendor_perl + xml_namespacesupport + xml_sax_base + " + +BUILD_REQUIRES=" + haiku_devel + " +BUILD_PREREQUIRES=" + cmd:make + cmd:perl + " + +TEST_REQUIRES=" + xml_namespacesupport + xml_sax_base + " + +BUILD() +{ + perl Makefile.PL PREFIX=$prefix + make +} + +INSTALL() +{ + make pure_install + + # remove architecture-specific files + cd $prefix + rm -r $(perl -V:vendorarch | cut -d\' -f2 | cut -d/ -f5-) + # cut extracts the quoted string and strips the prefix (which is perl's and not ours) + + mkdir -p $postInstallDir $preUninstallDir + cp $portDir/additional-files/install_xml_sax_pureperl.pl $postInstallDir + cp $portDir/additional-files/uninstall_xml_sax_pureperl.pl $preUninstallDir +} + +TEST() +{ + # The patch to install the configuration into site_perl in non-packaged causes two tests to + # fail because it can't create the configuration directory and save a configuration there. + # The path uses perl Config and therefore perl's prefix which is read-only and non-packaged + # doesn't exist inside the haikuporter chroot. + make test +}