[Pkg-ocaml-maint-commits] [SCM] dh-ocaml packaging branch, master, updated. debian/0.5.0-51-gba85137

Sylvain Le Gall gildor at debian.org
Mon Jul 27 22:11:36 UTC 2009


The following commit has been merged in the master branch:
commit eae9dc261dd761e11aea4c78e3a47f2b78ca63f6
Author: Sylvain Le Gall <gildor at debian.org>
Date:   Mon Jul 27 21:47:24 2009 +0000

    Add ocaml-lintian and use it in dh_ocaml to dump information for lintian check

diff --git a/debhelper/dh_ocaml b/debhelper/dh_ocaml
index 76e465e..99d526e 100755
--- a/debhelper/dh_ocaml
+++ b/debhelper/dh_ocaml
@@ -186,11 +186,20 @@ OCaml packaging policy, version 1.0.0
 
 =cut
 
-my $omd5 = $ENV{OCAML_MD5SUMS};
-$omd5 = "/usr/bin/ocaml-md5sums" unless $omd5;
-error "$omd5 does not exists or is not executable" unless -x $omd5;
+sub exec_default ($$)
+{
+  my ($env_var, $default) = @_;
+  my $res = $default;
+  $res = $ENV{$env_var} if defined($ENV{$env_var});
+  error "$res does not exists or is not executable" unless -x $res;
+  return $res;
+}
+
+my $omd5 = exec_default("OCAML_MD5SUMS", "/usr/bin/ocaml-md5sums");
+my $olintian = exec_default("OCAML_LINTIAN", "/usr/bin/ocaml-lintian");
 
 my $md5dir = "/var/lib/ocaml/md5sums";
+my $lintiandir = "/var/lib/ocaml/lintian";
 my $md5ext = ".md5sums";
 my $ocaml_magic_line = "#!/usr/bin/ocamlrun";
 
@@ -364,12 +373,13 @@ foreach my $package (keys(%dev_packages), @binary_packages)
   };
 };
 
-verbose_print "+++ Compute .md5sums files for dev packages +++";
+verbose_print "+++ Compute .md5sums and lintian files for dev packages +++";
 my %oinfo;
 foreach my $package (keys(%dev_packages)) {
   my $runtime = $dev_packages{$package};
   $runtime = undef if $runtime && $runtime eq "-";
   my $md5sums_fn = (tmpdir $package)."/$md5dir/$package$md5ext";
+  my $lintian_fn = (tmpdir $package)."/$lintiandir/$package";
   my $oinfo_fn = "debian/".(pkgext $package)."oinfo.debhelper";
   $oinfo{$package} = $oinfo_fn;
   my $oprovides_fn = "debian/".(pkgext $package)."oprovides.debhelper";
@@ -386,7 +396,30 @@ foreach my $package (keys(%dev_packages)) {
     . " --dump-info $oinfo_fn"
     . " --dump-provides $oprovides_fn"
     . " compute < ".$olist{$package}
-    . " > $md5sums_fn") || die "Cannot compute $md5sums_fn";
+    . " > $md5sums_fn");
+
+  # compute lintian informations
+  doit(qw/mkdir -p/, dirname $lintian_fn);
+  complex_doit("$olintian $local_flags < $olist{$package} > $lintian_fn.info");
+  if (defined($runtime))
+  {
+    my @META = ();
+    my $obj_dir = (tmpdir $runtime)."/usr/lib";
+    find(sub {push (@META, $File::Find::name) if $_ =~ /META(\..+)?/}, 
+         $obj_dir) 
+      if -d $obj_dir;
+    foreach (@META)
+    {
+      if (/META\.(.*)/)
+      {
+        doit("cp", $_, "$lintian_fn.META.$1");
+      }
+      else
+      {
+        doit("cp", $_, "$lintian_fn.META.".(basename (dirname $_)));
+      };
+    }
+  };
 
   if (!$dh{NO_ACT})
   {
diff --git a/debhelper/ocaml-lintian b/debhelper/ocaml-lintian
new file mode 100755
index 0000000..63210b2
--- /dev/null
+++ b/debhelper/ocaml-lintian
@@ -0,0 +1,111 @@
+#!/usr/bin/perl
+
+use Getopt::Long;
+use Pod::Usage;
+use warnings;
+use strict;
+
+# Executable called
+my $ocamlobjinfo=$ENV{OCAMLOBJINFO};
+$ocamlobjinfo="ocamlobjinfo" unless defined($ocamlobjinfo);
+
+my $man = 0;
+my $help = 0;
+my @objects;
+my $package_dev;
+my $package_runtime;
+my $package_version;
+my $checksum;
+
+sub process_not_option
+{
+  push @objects, @_;
+}
+
+sub get_objects
+{
+  return <STDIN> unless @objects > 0;
+  return @objects;
+}
+
+GetOptions(
+  "package=s"  => \$package_dev,
+  "runtime=s"  => \$package_runtime,
+  "version=s"  => \$package_version,
+  "checksum=s" => \$checksum,
+  "<>"         => \&process_not_option,
+  "help|?"     => \$help,
+  "man"        => \$man) or pod2usage(2);
+pod2usage(1) if $help;
+pod2usage(-exitstatus => 0, -verbose => 2) if $man;
+
+ at objects = get_objects();
+
+print "Package: $package_dev\n" if $package_dev;
+print "Runtime: $package_runtime\n" if $package_runtime;
+print "Version: $package_version\n" if $package_version;
+print "ForcedChecksum: $checksum\n" if $checksum;
+
+foreach my $obj_file (get_objects())
+{
+  chomp $obj_file;
+  if ($obj_file =~ /.*\.cma$/)
+  {
+    print "\nFile: $obj_file\n";
+    foreach (`$ocamlobjinfo $obj_file`)
+    {
+      chomp $_;
+      if (/.*(Force custom|Extra C object files|Extra C options):(.*)/)
+      {
+        print "$1:$2\n"
+      };
+    };
+    die "Error running $ocamlobjinfo" if $?;
+  }
+};
+
+__END__
+
+=head1 NAME
+
+ocaml-lintian - Dump OCaml object information for lintian test
+
+=head1 SYNOPSIS
+
+ocaml-lintian [option ...] file ...
+
+Extract information from various OCaml object and dump them. This information
+should be reused by lintian OCaml test, without dependency to ocaml tools to
+extract information.
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--package> pkg
+
+Set package name for development dependency.
+
+=item B<--runtime> pkg
+
+Set package name for runtime dependency.
+
+=item B<--version> ver
+
+Set package version for dependencies.
+
+=item B<--checksum> str
+
+Checksum to use.
+
+=item B<-help>
+
+Print a brief help message and exits.
+
+=item B<-man>
+
+Prints the manual page and exits.
+
+=back
+
+=cut
diff --git a/debian/changelog b/debian/changelog
index d7d0ad5..0979715 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,8 @@ dh-ocaml (0.9.0) UNRELEASED; urgency=low
   * dh_ocaml now computes automatically dependencies (Closes: #522831)
   * Add dh-ocaml (>= 0.9) build dependency when generating debian/control
     through CDBS
+  * Add ocaml-lintian and use it in dh_ocaml to dump information for
+    lintian check
 
   [ Mehdi Dogguy ]
   * Install ocaml.pm to enable: dh --with ocaml

-- 
dh-ocaml packaging



More information about the Pkg-ocaml-maint-commits mailing list