* RjY , 2015-10-28, 17:23:
debsnap seems to work perfectly well with JSON::PP, part of perl core
since 5.14, according to its manual page. So it might be nice to use it
instead of requiring the extra dependency?
I'd welcome this change too. Not that long ago I wanted to use debsnap
on a machine that didn't have libjson-perl installed, and it sucked.
I think running a bit slower (by using pure perl JSON implementation
instead of optimized C one) is preferable to not running at all :)
Yeah, I don't think we should be worried about JSON parser speed here.
I've attached a more complete patch. It gets rid of now unused error
handling code, and updates debian/control.
--
Jakub Wilk
diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -51,7 +51,6 @@
gnupg,
libdistro-info-perl,
libencode-locale-perl,
-libjson-perl,
libparse-debcontrol-perl,
liburi-perl,
libwww-perl,
@@ -135,8 +134,7 @@
the rest of the package to be present; can sign the pair remotely
or fetch the pair from a remote machine for signing [gnupg,
debian-keyring, ssh-client]
- - debsnap: grab packages from http://snapshot.debian.org [libwww-perl,
-libjson-perl]
+ - debsnap: grab packages from http://snapshot.debian.org [libwww-perl]
- debuild: wrapper to build a package without having to su or worry
about how to invoke dpkg to build using fakeroot. Also deals
with common environment problems, umask etc. [fakeroot, lintian, gnupg]
diff --git a/scripts/debsnap.pl b/scripts/debsnap.pl
--- a/scripts/debsnap.pl
+++ b/scripts/debsnap.pl
@@ -40,16 +40,7 @@
}
}
-eval {
-require JSON;
-};
-if ($@) {
-if ($@ =~ m/Can\'t locate JSON/) {
- die "$progname: Unable to run: the libjson-perl package is not installed";
-} else {
- die "$progname: Unable to run: Couldn't load JSON: $@";
-}
-}
+use JSON::PP;
my $modified_conf_msg = '';
my %config_vars = ();
@@ -113,7 +104,7 @@
verbose "Getting json $json_url\n";
my $content = LWP::Simple::get($json_url);
return unless defined $content;
-my $json = JSON->new();
+my $json = JSON::PP->new();
# these are some nice json options to relax restrictions a bit:
my $json_text = $json->allow_nonref->utf8->relaxed->decode($content);