Hi
On Sat, Oct 10, 2015 at 01:52:12PM +0200, Jakub Wilk wrote:
> * Osamu Aoki <[email protected]>, 2015-10-10, 17:16:
> >>>Some time back licensecheck grew a dependency on Dpkg::IPC [1], which
> >>>on Fedora causes the "devscripts-minimal" package (which includes
> >>>licensecheck) to pull in dpkg. I'd like to propose the patch below to
> >>>reduce the dependency load:
>
[...]
> All these programs work work with Debian packages, so they are not very
[...]
> I think it would in spirit of SC§2 to avoid adding runtime dependencies that
> are unlikely to be satisfied on non-Debian systems to scripts that are
> generally useful on such systems.
Agreed.
> >If the wishlist bug comes with patch which enables either Dpkg::IPC or
> >IPC::Run after checking their availability, that may be implemented if
> >security concerns are not there.
>
> This would be my preferred option, too.
>
> I might write a patch implementing it later, but feel free to beat me to it.
> :)
Well, my understanding of perl is weak. Please check the validity of
attached patch or propose alternatives.
Osamu
diff --git a/scripts/licensecheck.pl b/scripts/licensecheck.pl
index 3d1ff2e..293186d 100755
--- a/scripts/licensecheck.pl
+++ b/scripts/licensecheck.pl
@@ -157,6 +157,14 @@ use warnings;
use warnings qw< FATAL utf8 >;
use Encode qw/decode/;
+my $dpkgipc = eval {require Dpkg::IPC;1});
+if ($dpkgipc) {
+ Dpkg::IPC->import(qw(spawn));
+} else {
+ # fallback for non-Debian system
+ require IPC::Run;
+ IPC::Run->import(qw(run));
+}
use Dpkg::IPC qw(spawn);
use Getopt::Long qw(:config gnu_getopt);
use File::Basename;
@@ -337,11 +345,16 @@ while (@files) {
# Encode::Guess does not work well, use good old file command to get file encoding
my $mime;
- spawn(exec => ['file', '--brief', '--mime', '--dereference', '--', $file],
- to_string => \$mime,
- error_to_file => '/dev/null',
- nocheck => 1,
- wait_child => 1);
+ if ($dpkgipc) {
+ spawn(exec => ['file', '--brief', '--mime', '--dereference', '--', $file],
+ to_string => \$mime,
+ error_to_file => '/dev/null',
+ nocheck => 1,
+ wait_child => 1);
+ } else {
+ # Fallback for the non-Debian system
+ run [qw(file --brief --mime --dereference), $file], \undef, \$mime;
+ }
my $charset ;
if ($mime =~ m/; charset=((?!binary)(?!unknown)[\w-]+)/) {
$charset = $1;
_______________________________________________
devscripts-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel