[Pkg-ocaml-maint-commits] r1443 - trunk/tools/dh_ocaml

Stefano Zacchiroli zack@costa.debian.org
Sat, 09 Jul 2005 15:58:09 +0000


Author: zack
Date: 2005-07-09 15:58:08 +0000 (Sat, 09 Jul 2005)
New Revision: 1443

Added:
   trunk/tools/dh_ocaml/prerm-ocaml
Removed:
   trunk/tools/dh_ocaml/postrm-ocaml
Modified:
   trunk/tools/dh_ocaml/Makefile
   trunk/tools/dh_ocaml/dh_ocaml
   trunk/tools/dh_ocaml/ocaml-md5sums.ml.in
Log:
- ocaml-md5sums will now delete the registry file if, after an update,
  it no longer contains any entry (actually if it is empty)
- on removal update registry in prerm script instead of postrm one so
  that registry dir could be deleted by dpkg if empty
- bugfix in Makefile: scripts are installed again when creating
  debhelper package


Modified: trunk/tools/dh_ocaml/Makefile
===================================================================
--- trunk/tools/dh_ocaml/Makefile	2005-07-09 14:56:27 UTC (rev 1442)
+++ trunk/tools/dh_ocaml/Makefile	2005-07-09 15:58:08 UTC (rev 1443)
@@ -11,6 +11,7 @@
 OCAMLC = ocamlc
 OCAMLOPT = ocamlopt
 OCAML_LIBS = unix str
+SCRIPTS = postinst-ocaml prerm-ocaml
 
 all: ocaml-md5sums
 opt: ocaml-md5sums.opt

Modified: trunk/tools/dh_ocaml/dh_ocaml
===================================================================
--- trunk/tools/dh_ocaml/dh_ocaml	2005-07-09 14:56:27 UTC (rev 1442)
+++ trunk/tools/dh_ocaml/dh_ocaml	2005-07-09 15:58:08 UTC (rev 1443)
@@ -72,9 +72,9 @@
 retrieving dependency information for the package. Those information will then
 be used to fill the "${ocaml:Depends}" substvar.
 
-dh_ocaml takes also care of creating postinst and postrm autoscripts which
-update the global system registry (/var/lib/ocaml/md5sums/MD5SUMS) with the
-registry entry shipped by your package.
+dh_ocaml takes also care of creating postinst and prerm autoscripts which update
+the global system registry (/var/lib/ocaml/md5sums/MD5SUMS) with the registry
+entry shipped by your package.
 
 On non-library packages, dh_ocaml tries to guess the OCaml objects corresponding
 to shipped bytecode binaries and extract from them information about imported
@@ -250,7 +250,7 @@
       . " | sort -k 2"  # optional pass, just for "pretty" printing
       . " > $tmp$md5dir/$package$md5ext");
     autoscript $package, "postinst", "postinst-ocaml";
-    autoscript $package, "postrm", "postrm-ocaml";
+    autoscript $package, "prerm", "prerm-ocaml";
     complex_doit "$omd5 --load-info $oinfo dep < $olist > $odeps"; #compute deps
     fill_ocaml_depends $package, $tmp, $odeps, 1, $runtime;
   } elsif (is_binary $package, $dh{L_PARAMS}) {  # ocaml binary package

Modified: trunk/tools/dh_ocaml/ocaml-md5sums.ml.in
===================================================================
--- trunk/tools/dh_ocaml/ocaml-md5sums.ml.in	2005-07-09 14:56:27 UTC (rev 1442)
+++ trunk/tools/dh_ocaml/ocaml-md5sums.ml.in	2005-07-09 15:58:08 UTC (rev 1443)
@@ -4,7 +4,7 @@
  * Copyright (C) 2005, Stefano Zacchiroli <zack@debian.org>
  *
  * Created:        Wed, 06 Apr 2005 16:55:39 +0200 zack
- * Last-Modified:  Mon, 11 Apr 2005 10:39:58 +0200 zack
+ * Last-Modified:  Sat, 09 Jul 2005 17:40:44 +0200 zack
  *
  * This is free software, you can redistribute it and/or modify it under the
  * terms of the GNU General Public License version 2 as published by the Free
@@ -98,6 +98,8 @@
   iter_in (fun s -> lines := s :: !lines) stdin;
   List.rev !lines
 
+let is_empty fname = (Unix.stat fname).Unix.st_size = 0
+
 (** {2 Auxiliary functions} *)
 
 (** loads info previously stored in a file using --dump-info and stores them in
@@ -200,17 +202,19 @@
             fname !lineno)))
     fname
 
-(** @param fname file name of the registry file
+(** @param fname file name of the registry file, if fname does not exists an
+ * empty registry will be returned
  * @return an hashtbl mapping pairs <unit_name, md5sum> to pairs <package_name,
  * version_info>. E.g. ("Foo_bar", "74be7fa4320ebd9415f1c7cfc04c2d7b") ->
  * ("libfoo-ocaml-dev", ">= 1.2.3-4") *)
 let parse_registry fname =
   let registry = Hashtbl.create 1024 in
-  iter_registry
-    (fun ~md5sum ~unit_name ~dev_dep ~runtime_dep ~dep_version ->
-      Hashtbl.replace registry (unit_name, md5sum)
-        (dev_dep, runtime_dep, dep_version))
-    fname;
+  if Sys.file_exists fname then
+    iter_registry
+      (fun ~md5sum ~unit_name ~dev_dep ~runtime_dep ~dep_version ->
+        Hashtbl.replace registry (unit_name, md5sum)
+          (dev_dep, runtime_dep, dep_version))
+      fname;
   registry
 
 (** {2 Main functions, one for each command line action} *)
@@ -266,7 +270,8 @@
     done
   with End_of_file ->
     Unix.closedir dir;
-    close_out registry
+    close_out registry;
+    if is_empty registry_file then Sys.remove registry_file
 
 (** {2 Main} *)
 

Deleted: trunk/tools/dh_ocaml/postrm-ocaml
===================================================================
--- trunk/tools/dh_ocaml/postrm-ocaml	2005-07-09 14:56:27 UTC (rev 1442)
+++ trunk/tools/dh_ocaml/postrm-ocaml	2005-07-09 15:58:08 UTC (rev 1443)
@@ -1,3 +0,0 @@
-if [ "$1" = "remove" ]; then
-  ocaml-md5sums update
-fi

Copied: trunk/tools/dh_ocaml/prerm-ocaml (from rev 1442, trunk/tools/dh_ocaml/postrm-ocaml)