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.
This commit is contained in:
Joachim Mairböck
2024-12-31 14:29:00 +01:00
parent a49be5166d
commit 924c69c62a
4 changed files with 132 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
#!perl
use XML::SAX;
XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers();

View File

@@ -0,0 +1,5 @@
#!perl
use XML::SAX;
XML::SAX->remove_parser(q(XML::SAX::PurePerl))->save_parsers();

View File

@@ -0,0 +1,49 @@
From bb777002f24040802543de8e9ae6716365c04898 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joachim=20Mairb=C3=B6ck?= <j.mairboeck@gmail.com>
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

View File

@@ -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
}