1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
The Debian way of handling ParserDetails.ini: use
update-perl-sax-parsers(8) instead.
* SAX.pm: the meat of the modifications
+ add XML::SAX->save_parsers_debian(), used by update-perl-sax-parsers
+ disable XML::SAX->save_parsers() with a helpful error message for
users trying to install SAX parsers manually from CPAN
* Makefile.PL: Don't try to modify ParserDetails.ini when building the package
* t/01known.t, t/99cleanup.t: Skip tests related to XML::SAX->save_parsers()
Originally by Ardo van Rangelrooij <ardo@debian.org>
Cleanups and quilt conversion by Niko Tyni <ntyni@iki.fi>
--- libxml-sax-perl-0.16.orig/t/01known.t
+++ libxml-sax-perl-0.16/t/01known.t
@@ -1,6 +1,9 @@
-use Test;
+use Test::More;
BEGIN { plan tests => 3 }
+SKIP: {
+skip 'Tests skipped due to Debian modifications', 3;
use XML::SAX;
ok(XML::SAX->save_parsers);
ok(XML::SAX->load_parsers);
ok(@{XML::SAX->parsers}, 0);
+}
--- libxml-sax-perl-0.16.orig/t/99cleanup.t
+++ libxml-sax-perl-0.16/t/99cleanup.t
@@ -1,7 +1,7 @@
use Test;
BEGIN { plan tests => 1 }
use File::Spec;
-ok(unlink(
+skip('Test skipped due to Debian modifications', unlink(
File::Spec->catdir(qw(blib lib XML SAX ParserDetails.ini))),
1,
'delete ParserDetails.ini'
--- libxml-sax-perl-0.16.orig/Makefile.PL
+++ libxml-sax-perl-0.16/Makefile.PL
@@ -16,6 +16,10 @@
package MY;
my $script = shift->SUPER::install(@_);
+ print STDERR "Debian build: won't modify ParserDetails.ini when installing.\n";
+ print STDERR " (use update-perl-sax-parsers(8) instead.)\n";
+ return $script;
+
# Only modify existing ParserDetails.ini if user agrees
my $write_ini_ok = 0;
--- libxml-sax-perl-0.16.orig/SAX.pm
+++ libxml-sax-perl-0.16/SAX.pm
@@ -179,6 +179,15 @@
sub save_parsers {
my $class = shift;
+ ### DEBIAN MODIFICATION
+ print "\n";
+ print "Please use 'update-perl-sax-parsers(8) to register this parser.'\n";
+ print "See /usr/share/doc/libxml-sax-perl/README.Debian.gz for more info.\n";
+ print "\n";
+
+ return $class; # rest of the function is disabled on Debian.
+ ### END DEBIAN MODIFICATION
+
# get directory from wherever XML::SAX is installed
my $dir = $INC{'XML/SAX.pm'};
$dir = dirname($dir);
@@ -206,6 +215,40 @@
return $class;
}
+sub save_parsers_debian {
+ my $class = shift;
+ my ($parser_module,$directory, $priority) = @_;
+
+ # add parser
+ $known_parsers = [];
+ $class->add_parser($parser_module);
+
+ # get parser's ParserDetails file
+ my $file = $parser_module;
+ $file = "${priority}-$file" if $priority != 0;
+ $file = File::Spec->catfile($directory, $file);
+ chmod 0644, $file;
+ unlink($file);
+
+ my $fh = gensym();
+ open($fh, ">$file") ||
+ die "Cannot write to $file: $!";
+
+ foreach my $p (@$known_parsers) {
+ print $fh "[$p->{Name}]\n";
+ foreach my $key (keys %{$p->{Features}}) {
+ print $fh "$key = $p->{Features}{$key}\n";
+ }
+ print $fh "\n";
+ }
+
+ print $fh "\n";
+
+ close $fh;
+
+ return $class;
+}
+
sub do_warn {
my $class = shift;
# Don't output warnings if running under Test::Harness
|