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
|
#!/usr/bin/perl
#
# Copyright (C) 2015-2020 Michael Gilbert <mgilbert@debian.org>
#
# Return the library packages associated with all of the -dev packages
# found via regex of the build-deps in the local control file.
#
# License: LGPL-2+
use strict;
use warnings;
use Dpkg::Deps;
use Dpkg::Arch;
use Dpkg::Control::Info;
if ($#ARGV < 0) {
print "usage: $0 <regex to find in the control file's Build-Depends field>\n";
} else {
my $arch = Dpkg::Arch::get_host_arch();
my $triplet = Dpkg::Arch::debarch_to_multiarch($arch);
my $control = Dpkg::Control::Info->new()->get_source();
my $depends = deps_parse($control->{'Build-Depends'});
foreach (split /,\s+/,$depends) {
if ($_ =~ /$ARGV[0]/) {
$_ =~ s/-dev//;
my @array = split ' ', $_;
my $name = shift @array;
my $version = readlink "/usr/lib/$triplet/$name.so";
$version =~ s/\.so\.//;
print "$version @array\n";
}
}
}
|