debian: Use the dh_* tools from the GST debian package to add proper dependencies
This commit is contained in:
parent
ae98bc0a1e
commit
a02827966d
|
@ -1,3 +1,9 @@
|
|||
osmo-smalltalk (1-2) unstable; urgency=low
|
||||
|
||||
* Fix the dependencies between star files by using script from gst.
|
||||
|
||||
-- Holger Freyther <holger@freyther.de> Fri, 12 Oct 2012 13:15:38 +0200
|
||||
|
||||
osmo-smalltalk (1-1) unstable; urgency=low
|
||||
|
||||
* Package all of the Smalltalk for Osmocom.
|
||||
|
|
|
@ -10,61 +10,61 @@ Homepage: http://osmocom.org
|
|||
|
||||
Package: osmo-st-asn1
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: osmo-st-core
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: osmo-st-gsm
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: osmo-st-logging
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: osmo-st-mgcp
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: osmo-st-msc
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: osmo-st-network
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: osmo-st-sip
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: osmo-st-testphone
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: petitparser
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: petitparser-tests
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
Package: soapopera
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Depends: ${misc:Depends} ${gst:Depends}
|
||||
Description: TODO
|
||||
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dh_fixstars - fixes GNU Smalltalk archives (.star)
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use File::Find;
|
||||
use Debian::Debhelper::Dh_Lib;
|
||||
#use Dpkg::Arch qw(get_raw_host_arch debarch_to_multiarch);
|
||||
use Dpkg::Arch qw(get_raw_host_arch);
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<dh_fixstars> [S<I<debhelper options>>]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
dh_fixstars is a debhelper program that is responsible for fixing
|
||||
things when using .star files.
|
||||
|
||||
Today, it creates missing symlinks for dlopen()'ed shared libraries
|
||||
so that the .star file work without the associated -dev package.
|
||||
|
||||
For instance, NCurses.star loads libncurses.so
|
||||
|
||||
=cut
|
||||
|
||||
init();
|
||||
|
||||
my $pwd = `pwd`;
|
||||
chomp $pwd;
|
||||
|
||||
verbose_print("Loading shlibs...");
|
||||
my %shlibdata;
|
||||
|
||||
open(SHLIBS, "cat /var/lib/dpkg/info/*.shlibs debian/shlibs.local debian/*/DEBIAN/shlibs 2> /dev/null |");
|
||||
|
||||
while (<SHLIBS>) {
|
||||
/(\S+)\s+(\S+)\s+(\w.*)\n?/;
|
||||
$shlibdata{$1} = "$1.so.$2";
|
||||
}
|
||||
|
||||
close(SHLIBS);
|
||||
|
||||
foreach my $package (@{$dh{DOPACKAGES}}) {
|
||||
my $tmp = tmpdir($package);
|
||||
|
||||
find(sub {
|
||||
return unless -f && !-l && /\.star$/;
|
||||
add_symlinks($tmp, $_);
|
||||
}, $tmp
|
||||
);
|
||||
}
|
||||
|
||||
sub path_to_shlib {
|
||||
my $lib = shift;
|
||||
#my $multiarch_dir = debarch_to_multiarch(get_raw_host_arch());
|
||||
my %dirs = (
|
||||
"/lib/$lib" => "/lib/$lib",
|
||||
"/usr/lib/$lib" => "../$lib",
|
||||
# "/usr/lib/$multiarch_dir/$lib" => "../$multiarch_dir/$lib",
|
||||
# "/lib/$multiarch_dir/$lib" => "/lib/$multiarch_dir/$lib"
|
||||
);
|
||||
|
||||
# Found path; can be empty.
|
||||
my $path;
|
||||
|
||||
while (my ($k, $v) = each(%dirs)) {
|
||||
if (-e "$k") {
|
||||
$path = "$v";
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
sub add_symlinks {
|
||||
my $tmp = shift;
|
||||
my $star_file = shift;
|
||||
|
||||
open(PACKAGEXML, "unzip -p $star_file package.xml |");
|
||||
|
||||
while(<PACKAGEXML>) {
|
||||
chomp;
|
||||
|
||||
# Package that loads a library at runtime, with dlopen()
|
||||
if (/<library>(\S+)<\/library>/) {
|
||||
my $sym = "$pwd/$tmp/usr/lib/gnu-smalltalk/$1.so";
|
||||
my $lib = $shlibdata{$1};
|
||||
|
||||
if ($lib) {
|
||||
my $target = path_to_shlib($lib);
|
||||
if ($target) {
|
||||
doit("rm", "-f", "$sym");
|
||||
doit("mkdir", "-p", "$pwd/$tmp/usr/lib/gnu-smalltalk");
|
||||
doit("ln", "-s", "$target", "$sym");
|
||||
doit("chown", "--no-dereference", "0:0", "$sym");
|
||||
} else {
|
||||
error("Can't find \"$lib\" (\"$1\" in \"$star_file\")!");
|
||||
}
|
||||
|
||||
} else {
|
||||
error("Unknown library \"$1\" in \"$star_file\"!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(PACKAGEXML);
|
||||
}
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<debhelper(7)>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Thomas Girard <thomas.g.girard@free.fr>, heavily based on code from
|
||||
Mirco Bauer <meebey@meebey.net> and Eduard Bloch <blade@debian.org>
|
||||
for dh_clideps.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,117 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dh_makestarlibs - creates starlibs files for GNU Smalltalk archives
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use Debian::Debhelper::Dh_Lib;
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<dh_makestarlibs> [S<I<debhelper options>>]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
dh_makestarlibs is a debhelper script that is responsible for generating
|
||||
starlibs files that will be used to compute GNU SmallTalk ARchives
|
||||
(.star files) dependencies.
|
||||
|
||||
=cut
|
||||
|
||||
init();
|
||||
|
||||
foreach my $package (@{$dh{DOPACKAGES}}) {
|
||||
next if is_udeb($package);
|
||||
|
||||
my $tmp = tmpdir($package);
|
||||
my %seen;
|
||||
|
||||
doit("rm", "-f", "$tmp/DEBIAN/starlibs");
|
||||
|
||||
if (-e "debian/$package.starlibs") {
|
||||
complex_doit("cat debian/$package.starlibs > $tmp/DEBIAN/starlibs");
|
||||
} else {
|
||||
open(FIND, "find $tmp -type f -name '*.star' |");
|
||||
|
||||
while (<FIND>) {
|
||||
chomp;
|
||||
my $starchive = $_;
|
||||
$starchive =~ s,.*/([^/]+)\.star$,$1,;
|
||||
|
||||
if (!-d "$tmp/DEBIAN") {
|
||||
doit("install", "-d", "$tmp/DEBIAN");
|
||||
}
|
||||
|
||||
my $deps = depends($package);
|
||||
my $line = "$starchive $deps";
|
||||
|
||||
if (!$seen{$line}) {
|
||||
$seen{$line} = 1;
|
||||
complex_doit("echo '$line' >> $tmp/DEBIAN/starlibs");
|
||||
}
|
||||
}
|
||||
|
||||
close FIND;
|
||||
|
||||
# Support packages.xml
|
||||
if (open(META, "$tmp/usr/share/gnu-smalltalk/packages.xml")) {
|
||||
my @lines = <META>;
|
||||
my $content = join("", @lines);
|
||||
|
||||
if (my @pkgs = $content =~ m,<package>\s*<name>(\w+)</name>,gi) {
|
||||
foreach my $p (@pkgs) {
|
||||
verbose_print("adding virtual package $p");
|
||||
my $deps = depends($package);
|
||||
complex_doit("echo '$p $deps' >> $tmp/DEBIAN/starlibs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (-e "$tmp/DEBIAN/starlibs") {
|
||||
doit("chmod", 644, "$tmp/DEBIAN/starlibs");
|
||||
doit("chown", "0:0", "$tmp/DEBIAN/starlibs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub depends {
|
||||
my $package = shift;
|
||||
my $deps = $package;
|
||||
|
||||
# Call isnative because it sets $dh{VERSION}
|
||||
# as a side effect.
|
||||
isnative($package);
|
||||
my $version = $dh{VERSION};
|
||||
|
||||
# Old compatibility levels include the
|
||||
# debian revision, while new do not.
|
||||
if (!compat(3)) {
|
||||
# Remove debian version, if any.
|
||||
$version =~ s/-[^-]+$//;
|
||||
}
|
||||
|
||||
if ($dh{V_FLAG_SET}) {
|
||||
if ($dh{V_FLAG} ne '') {
|
||||
$deps = $dh{V_FLAG};
|
||||
} else {
|
||||
$deps = "$package (>= $version)";
|
||||
}
|
||||
}
|
||||
|
||||
return $deps;
|
||||
}
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<debhelper(7)>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Thomas Girard <thomas.g.girard@free.fr>, heavily based on code from
|
||||
Mirco Bauer <meebey@meebey.net> and Eduard Bloch <blade@debian.org>
|
||||
for dh_makeclilibs.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,146 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dh_stardeps - calculates GNU Smalltalk archives (.star) dependencies
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use File::Find;
|
||||
use Debian::Debhelper::Dh_Lib;
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<dh_stardeps> [S<I<debhelper options>>]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
dh_stardeps is a debhelper program that is responsible for generating the
|
||||
${gst:Depends} substitutions and adding them to substvars files.
|
||||
|
||||
The program wil look at .star files in your package, and will use the
|
||||
dependency information generated by dh_makestarlibs to compute the
|
||||
${gst:Depends} variable.
|
||||
|
||||
=cut
|
||||
|
||||
init();
|
||||
|
||||
verbose_print("Loading starlibs...");
|
||||
my %starlibdata;
|
||||
|
||||
open(STARLIBS, "cat /var/lib/dpkg/info/*.starlibs debian/*/DEBIAN/starlibs 2> /dev/null |");
|
||||
|
||||
while (<STARLIBS>) {
|
||||
/(\S+)\s+(\w.*)\n?/;
|
||||
$starlibdata{$1} = $2;
|
||||
}
|
||||
|
||||
close(STARLIBS);
|
||||
|
||||
verbose_print("Loading shlibs...");
|
||||
my %shlibdata;
|
||||
|
||||
open(SHLIBS, "cat /var/lib/dpkg/info/*.shlibs debian/shlibs.local debian/*/DEBIAN/shlibs 2> /dev/null |");
|
||||
|
||||
while (<SHLIBS>) {
|
||||
/(\S+)\s+(\S+)\s+(\w.*)\n?/;
|
||||
$shlibdata{$1} = $3;
|
||||
}
|
||||
|
||||
close(SHLIBS);
|
||||
|
||||
foreach my $package (@{$dh{DOPACKAGES}}) {
|
||||
my $tmp = tmpdir($package);
|
||||
my @depends = ();
|
||||
|
||||
# for idempotency
|
||||
delsubstvar($package, "gst:Depends");
|
||||
|
||||
find(sub {
|
||||
return unless -f && !-l && /\.star$/;
|
||||
my $file = $_;
|
||||
push(@depends, resolve_starlib_ref($package, $file));
|
||||
}, $tmp
|
||||
);
|
||||
|
||||
@depends = unique(@depends);
|
||||
|
||||
addsubstvar($package, "gst:Depends", join(", ", @depends));
|
||||
}
|
||||
|
||||
sub resolve_starlib_ref {
|
||||
my $package = shift;
|
||||
my $star_file = shift;
|
||||
my @deps = ();
|
||||
my $in_test = 0;
|
||||
|
||||
open(PACKAGEXML, "unzip -p $star_file package.xml |");
|
||||
|
||||
while(<PACKAGEXML>) {
|
||||
chomp;
|
||||
|
||||
if (/<test>/) {
|
||||
$in_test = 1;
|
||||
} elsif (/<\/test>/) {
|
||||
$in_test = 0;
|
||||
}
|
||||
|
||||
# Handle prereq packages -- but not for tests
|
||||
elsif (/<prereq>(\S+)<\/prereq>/ and not $in_test) {
|
||||
my $dep = $starlibdata{$1};
|
||||
|
||||
if ($dep) {
|
||||
if ($dep !~ m/^$package(?:\s+.+)?$/) {
|
||||
push(@deps, $dep);
|
||||
}
|
||||
} else {
|
||||
error("Unknown dependency \"$1\" in \"$star_file\"!");
|
||||
}
|
||||
|
||||
# Package with unit tests; depends on SUnit. This dependency might
|
||||
# already be captured, but we'll remove duplicates later.
|
||||
} elsif (/<sunit>/) {
|
||||
if (exists($starlibdata{"SUnit"})) {
|
||||
# Only if this is not the package containing SUnit already
|
||||
if ($starlibdata{"SUnit"} !~ m/^$package(?:\s+.+)?$/) {
|
||||
push(@deps, $starlibdata{"SUnit"});
|
||||
}
|
||||
} else {
|
||||
warning("Unable to store SUnit dependency for \"$star_file\"");
|
||||
}
|
||||
|
||||
# Package that loads a library at runtime, with dlopen()
|
||||
} elsif (/<library>(\S+)<\/library>/) {
|
||||
my $lib = $shlibdata{$1};
|
||||
|
||||
if ($lib) {
|
||||
push(@deps, $lib);
|
||||
} else {
|
||||
error("Unknown library dependency \"$1\" in \"$star_file\"!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(PACKAGEXML);
|
||||
|
||||
return @deps;
|
||||
}
|
||||
|
||||
sub unique {
|
||||
my %seen = ();
|
||||
return grep(!$seen{$_}++, @_);
|
||||
}
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<debhelper(7)>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Thomas Girard <thomas.g.girard@free.fr>, heavily based on code from
|
||||
Mirco Bauer <meebey@meebey.net> and Eduard Bloch <blade@debian.org>
|
||||
for dh_clideps.
|
||||
|
||||
=cut
|
|
@ -27,3 +27,11 @@ override_dh_auto_install: build
|
|||
$(MAKE) GST_PACKAGE_ARGS="--destdir $(CURDIR)/debian/tmp" install
|
||||
|
||||
|
||||
override_dh_installdeb:
|
||||
perl -w debian/dh_makestarlibs -i -V
|
||||
dh_installdeb -i
|
||||
|
||||
override_dh_gencontrol:
|
||||
perl -w debian/dh_stardeps -i
|
||||
perl -w debian/dh_fixstars -i
|
||||
dh_gencontrol -i
|
||||
|
|
Reference in New Issue