[Pkg-ocaml-maint-commits] [SCM] dh-ocaml packaging branch, master, updated. debian/0.5.0-9-g2e8a3e9
Mehdi Dogguy
dogguy at pps.jussieu.fr
Tue Jul 21 13:59:16 UTC 2009
The following commit has been merged in the master branch:
commit 2e8a3e9aba7bd96f089f524cda84d8e117651e86
Author: Mehdi Dogguy <dogguy at pps.jussieu.fr>
Date: Tue Jul 21 15:59:07 2009 +0200
Partial rewrite of dh_ocaml
diff --git a/debhelper/dh_ocaml b/debhelper/dh_ocaml
index 7e7a26c..7ebd922 100755
--- a/debhelper/dh_ocaml
+++ b/debhelper/dh_ocaml
@@ -4,8 +4,9 @@
# dh_ocaml - debhelper which computes OCaml md5sums and calculates OCaml
# dependencies
#
-# Copyright (C) 2005-2006, Stefano Zacchiroli <zack at debian.org>
-# Samuel Mimram <smimram at debian.org>
+# Copyright © 2005-2006 Stefano Zacchiroli <zack at debian.org>
+# Samuel Mimram <smimram at debian.org>
+# Copyright © 2009 Mehdi Dogguy <mehdi at dogguy.org>
#
# Created: Fri, 01 Apr 2005 19:50:48 +0200 zack
# Last-Modified: $Id: dh_ocaml 3180 2006-09-18 17:25:50Z smimram $
@@ -120,13 +121,15 @@ non-custom OCaml executables.
=item B<-m> I<filename>
-By default, the list of OCaml objects shipped by your package which should be
-analyzed for retrieving dependency information is guessed by dh_ocaml.
+By default, the list of OCaml objects or bytecode binaries shipped by your
+package which should be analyzed for retrieving dependency information is
+guessed by dh_ocaml.
-The -m option permit to specify a file which lists, one per line, that OCaml
-objects. They should be in one of the format understandable by ocamlobjinfo
-(*.cma, *.cmi, *.cmo) and are considered relative to the package build
-directory.
+The -m option permit to specify a file which lists, one per line, that
+OCaml objects or bytecode binaries. Objects should be in one of the
+format understandable by ocamlobjinfo (*.cma, *.cmi, *.cmo) and
+binaries understandable by ocamlbyteinfo. Files are considered
+relative to the package build directory.
=item B<-l> I<dev1:runtime1,dev2:runtime2,...>
@@ -143,12 +146,10 @@ corresponds to the development part of a library) or two package names separated
by a colon (stating that the first corresponds to the development part of a
library, while the second to its accompanying runtime part).
-=item B<-d>
+=item B<-v>, B<--verbose>
-By default, dependency on findlib is generated for development parts of
-libraries which ship any META file. Using -d you can disable the generation of
-such dependency (even if this is discouraged and is very likely to violate the
-OCaml packaging policy)
+Verbose mode: show all commands that modify the package build
+directory and pass verbose option to ocaml-md5sums.
=back
@@ -160,20 +161,6 @@ OCaml packaging policy, version 1.0.0
=cut
-# find ocaml bytecode executables contained in a given directory
-# (i.e. executables whose first line is #!/usr/bin/ocamlrun)
-sub find_ocaml_bc_binaries($) {
- my ($dir) = @_;
- my @binaries = split /\n/, `find $dir -type f -perm -0100`;
- my @bc_binaries;
- foreach my $bin (@binaries) {
- my $line = `head -1 $bin` or next;
- chomp $line;
- push @bc_binaries, $bin if $line eq $ocaml_magic_line;
- }
- return @bc_binaries;
-}
-
# add an entry to the ocaml:Depends substvar, filter out dummy "-" values
sub add_ocaml_dep($$$) {
my ($package, $dep, $version) = @_;
@@ -198,10 +185,6 @@ sub fill_ocaml_depends($$$$$) {
if ($is_library) {
add_ocaml_dep $package, $1, ">= $3";
add_ocaml_dep $package, $runtime, "= $dh{VERSION}" if $runtime;
- if (`find $tmp -type f -name "META*"` ne "" and not $dh{D_FLAG}) {
- # package has META and findlib dependency has not been forbidden
- add_ocaml_dep $package, "ocaml-findlib", "-"
- }
add_ocaml_dep $runtime, $2, ">= $3";
} else {
add_ocaml_dep $package, $2, ">= $3";
@@ -269,56 +252,83 @@ sub runtime_of_library($$) {
return (package_exists $runtime ? $runtime : "");
}
+sub get_omd5_params($) {
+ my ($package) = @_;
+ my %omd5_params;
+ isnative($package); # sets $dh{VERSION}
+ $omd5_params{"tmp"} = tmpdir $package;
+ $omd5_params{"ext"} = pkgext $package;
+ $omd5_params{"oinfo"} = "debian/".$omd5_params{"ext"} . "oinfo.debhelper"; # ocaml objects info
+ $omd5_params{"olist"} = "debian/".$omd5_params{"ext"} . "olist.debhelper"; # ocaml object list
+ $omd5_params{"oprovides"} = "debian/".$omd5_params{"ext"} . "oprovides.debhelper"; # provided package
+ $omd5_params{"olist"} = $dh{M_PARAMS} if $dh{M_PARAMS}; # override object list with -m
+ $omd5_params{"odeps"} = "debian/".$omd5_params{"ext"} . "odeps.debhelper"; # ocaml dependencies
+ $omd5_params{"runtime"} = runtime_of_library $package, $dh{L_PARAMS};
+ return %omd5_params;
+}
+
# main
exit 0 if $dh{NO_ACT};
+complex_doit "mkdir -p debian/dh_ocaml_md5sums";
foreach my $package (@{$dh{DOPACKAGES}}) {
- my $tmp = tmpdir $package;
- my $ext = pkgext $package;
- isnative($package); # sets $dh{VERSION}
- my $oinfo = "debian/$ext" . "oinfo.debhelper"; # ocaml objects info
- my $olist = "debian/$ext" . "olist.debhelper"; # ocaml object list
- my $oprovides = "debian/$ext" . "oprovides.debhelper"; # provided package
- $olist = $dh{M_PARAMS} if $dh{M_PARAMS}; # override object list with -m
- my $odeps = "debian/$ext" . "odeps.debhelper"; # ocaml dependencies
- if (is_library $package, $dh{L_PARAMS}) { # ocaml library package
- my $runtime = runtime_of_library $package, $dh{L_PARAMS};
- my $flags = "--package $package --version $dh{VERSION}";
- $flags .= " --runtime $runtime" if $runtime;
- # create md5sum registry entry and post.* scripts
- complex_doit "find $tmp$ocaml_lib_dir -type f -name '*.cm[ao]' > $olist"
- unless $dh{M_PARAMS};
- complex_doit "mkdir -p $tmp$md5dir";
- complex_doit("$omd5 $flags --dump-info $oinfo --dump-provides $oprovides compute < $olist"
- . " | sort -k 2" # optional pass, just for "pretty" printing
- . " > $tmp$md5dir/$package$md5ext");
- autoscript $package, "postinst", "postinst-ocaml";
- autoscript $package, "postrm", "postrm-ocaml";
- complex_doit "$omd5 --load-info $oinfo dep < $olist > $odeps"; # compute deps
- fill_ocaml_depends $package, $tmp, $odeps, 1, $runtime;
- fill_ocaml_provides $package, $tmp, $oprovides, 1;
- } elsif (is_binary $package, $dh{L_PARAMS}) { # ocaml binary package
- my @binaries = find_ocaml_bc_binaries $tmp;
- next unless @binaries; # nothing to do if no bytecode binary has been found
- complex_doit "> $odeps";
- if (not $dh{M_PARAMS}) {
- foreach my $bin (@binaries) { # try to find .cmo of bc binaries
- my $guess = basename $bin . ".cm[ao]";
- complex_doit "find . -type f -name '$guess' >> $olist"
- }
+ my %omd5_params = get_omd5_params($package);
+ my $flags = "--package $package --version $dh{VERSION}";
+ $flags .= " --runtime ".$omd5_params{"runtime"} if $omd5_params{"runtime"};
+ $flags .= " -v" if $dh{VERBOSE};
+
+ # search for OCaml objects
+ unless ($dh{M_PARAMS}) {
+ complex_doit " > $omd5_params{'olist'}";
+ complex_doit "find $omd5_params{'tmp'}$ocaml_lib_dir -type f "
+ . "-name '*.cm[ao]' >> $omd5_params{'olist'}"
+ unless (not -e "$omd5_params{'tmp'}$ocaml_lib_dir");
+
+ # search for OCaml bc binaries
+ my @binaries = split /\n/, `find $omd5_params{"tmp"} -type f -perm -0100`;
+ open(OLIST, ">> $omd5_params{'olist'}");
+ foreach my $bin (@binaries) {
+ my $line = `head -1 $bin` or next;
+ chomp $line;
+ print OLIST "$bin\n" if $line eq $ocaml_magic_line;
}
- complex_doit "$omd5 dep < $olist > $odeps"; # compute deps
- fill_ocaml_depends $package, $tmp, $odeps, 0, "";
+ close(OLIST);
+ }
+
+ # compute md5sums files
+ complex_doit "mkdir -p $omd5_params{'tmp'}$md5dir";
+ complex_doit("$omd5 $flags --dump-info $omd5_params{'oinfo'}"
+ . " compute < $omd5_params{'olist'}"
+ . " | sort -k 2" # optional pass, just for "pretty" printing
+ . " > $omd5_params{'tmp'}$md5dir/$package$md5ext");
+ complex_doit "cp $omd5_params{'tmp'}$md5dir/$package$md5ext debian/dh_ocaml_md5sums";
+}
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+ my %omd5_params = get_omd5_params($package);
+ my $library_bit=0;
+ if (is_library $package, $dh{L_PARAMS}) {
+ $library_bit=1;
}
+
+ # compute deps
+ complex_doit "$omd5 --load-info $omd5_params{'oinfo'}"
+ . " --md5sums-dir debian/dh_ocaml_md5sums"
+ . " dep < $omd5_params{'olist'} > $omd5_params{'odeps'}";
+
+ # fill depends and provides fields
+ fill_ocaml_depends $package, $omd5_params{"tmp"}, $omd5_params{"odeps"}, $library_bit, $omd5_params{"runtime"};
+ fill_ocaml_provides $package, $omd5_params{"tmp"}, $omd5_params{"oprovides"}, $library_bit;
}
+complex_doit "rm -Rf debian/dh_ocaml_md5sums";
=head1 SEE ALSO
-L<ocamlobjinfo(1)>, L<debhelper(7)>, L<ocaml-md5sums(1)>
+L<ocamlobjinfo(1)>, L<ocamlbyteinfo(1)>, L<debhelper(7)>, L<ocaml-md5sums(1)>
This program is a part of debhelper.
=head1 AUTHORS
-Stefano Zacchiroli <zack at debian.org>, Samuel Mimram <smimram at debian.org>
+Stefano Zacchiroli <zack at debian.org>, Samuel Mimram <smimram at debian.org>, Mehdi Dogguy <mehdi at dogguy.org>
=cut
--
dh-ocaml packaging
More information about the Pkg-ocaml-maint-commits
mailing list