Bug#803315: debsnap: use JSON::PP

2015-11-01 Thread Jakub Wilk

* 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);


Bug#803315: debsnap: use JSON::PP

2015-10-28 Thread RjY
Package: devscripts
Version: 2.15.9
Severity: wishlist
Tags: patch

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 think running a bit slower
(by using pure perl JSON implementation instead of optimized C one) is
preferable to not running at all :)

---8<---

--- /usr/bin/debsnap2015-10-06 02:29:12.0 +0100
+++ ./debsnap   2015-10-28 16:54:21.239450648 +
@@ -42,7 +42,7 @@
 }
 
 eval {
-require JSON;
+require JSON::PP;
 };
 if ($@) {
 if ($@ =~ m/Can\'t locate JSON/) {
@@ -114,7 +114,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);

--->8---

-- 
http://rjy.org.uk/