From a4465087c8cf200ea45bc61d4522da226e42bb0c Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Fri, 12 Aug 2005 08:48:16 +0000 Subject: [PATCH] various ocaml-md5sums related fixes --- debian/changelog | 13 +++++- debian/control | 2 +- debian/ocaml-compiler-libs.postrm | 4 +- debian/ocaml-nox.postrm | 4 +- debian/ocaml.postrm | 4 +- debian/patches/ocaml-md5sums.dpatch | 68 +++++++++++++++-------------- 6 files changed, 58 insertions(+), 37 deletions(-) diff --git a/debian/changelog b/debian/changelog index adf55364..d58c11a1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,7 +4,18 @@ ocaml (3.08.3-7) UNRELEASED; urgency=low * debian/patches/byterun_interp_ia64_fix.dpatch - Removed spurious ia64 cast which broke builds with gcc 4.0 - -- Sven Luther Tue, 9 Aug 2005 20:06:13 +0200 + Changes by Stefano Zacchiroli: + * debian/control + - added versioned dep from ocaml-compiler-libs to ocaml-base-nox to + ensure ocaml-md5sums exists at postinst invocation time + * debian/{ocaml-compiler-libs,ocaml-nox,ocaml}.postrm + - invoke ocaml-md5sums update only if it is available, if not + md5sums database will be updated next time ocaml-base-nox will be + installed (Closes: Bug#322210) + * debian/patches/ocaml-md5sums + - avoid failure on update if /var/lib/ocaml/md5sums does not exists + + -- Debian OCaml Maintainers Fri, 12 Aug 2005 10:47:30 +0200 ocaml (3.08.3-6) unstable; urgency=low diff --git a/debian/control b/debian/control index f0d387f4..cc24b6fc 100644 --- a/debian/control +++ b/debian/control @@ -138,7 +138,7 @@ Description: Ocaml interpreter and standard libraries Package: ocaml-compiler-libs Architecture: any Provides: ocaml-compiler-libs-3.08.3 -Depends: ocaml-nox-3.08.3 +Depends: ocaml-nox-3.08.3, ocaml-base-nox (>= 3.08.3-6) Description: Ocaml interpreter and standard libraries Objective Caml is an implementation of the ML language, based on the Caml Light dialect extended with a complete class-based object system diff --git a/debian/ocaml-compiler-libs.postrm b/debian/ocaml-compiler-libs.postrm index 80fcec69..0fb414e4 100644 --- a/debian/ocaml-compiler-libs.postrm +++ b/debian/ocaml-compiler-libs.postrm @@ -1,7 +1,9 @@ #!/bin/sh -e if [ "$1" = "remove" ]; then - ocaml-md5sums update + if [ -x /usr/bin/ocaml-md5sums ]; then + /usr/bin/ocaml-md5sums update + fi fi #DEBHELPER# diff --git a/debian/ocaml-nox.postrm b/debian/ocaml-nox.postrm index 3fec175a..6b337769 100644 --- a/debian/ocaml-nox.postrm +++ b/debian/ocaml-nox.postrm @@ -3,7 +3,9 @@ rm -f /usr/include/caml if [ "$1" = "remove" ]; then - ocaml-md5sums update + if [ -x /usr/bin/ocaml-md5sums ]; then + /usr/bin/ocaml-md5sums update + fi fi #DEBHELPER# diff --git a/debian/ocaml.postrm b/debian/ocaml.postrm index 80fcec69..0fb414e4 100644 --- a/debian/ocaml.postrm +++ b/debian/ocaml.postrm @@ -1,7 +1,9 @@ #!/bin/sh -e if [ "$1" = "remove" ]; then - ocaml-md5sums update + if [ -x /usr/bin/ocaml-md5sums ]; then + /usr/bin/ocaml-md5sums update + fi fi #DEBHELPER# diff --git a/debian/patches/ocaml-md5sums.dpatch b/debian/patches/ocaml-md5sums.dpatch index 90c02a1c..637f7055 100755 --- a/debian/patches/ocaml-md5sums.dpatch +++ b/debian/patches/ocaml-md5sums.dpatch @@ -5,9 +5,9 @@ ## DP: No description. @DPATCH@ -diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/configure /tmp/dpep-work.c7Vvzd/trunk/ocaml-md5sums/configure +diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/configure /tmp/dpep-work.YsUxwk/trunk/ocaml-md5sums/configure --- ./ocaml-md5sums/configure 1970-01-01 01:00:00.000000000 +0100 -+++ /tmp/dpep-work.c7Vvzd/trunk/ocaml-md5sums/configure 2005-07-31 11:02:49.000000000 +0200 ++++ /tmp/dpep-work.YsUxwk/trunk/ocaml-md5sums/configure 2005-08-12 10:19:10.000000000 +0200 @@ -0,0 +1,12 @@ +#!/bin/sh +DEFAULT="/var/lib/ocaml/3.08.3/md5sums" @@ -21,9 +21,9 @@ diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/configure /tmp/dpep-wor +echo -n "Creating ocaml-md5sums.ml ... " +sed "s:@MD5SUMS_DIR@:$MD5SUMS_DIR:" < ocaml-md5sums.ml.in > ocaml-md5sums.ml +echo "done." -diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/feeding.sh /tmp/dpep-work.c7Vvzd/trunk/ocaml-md5sums/feeding.sh +diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/feeding.sh /tmp/dpep-work.YsUxwk/trunk/ocaml-md5sums/feeding.sh --- ./ocaml-md5sums/feeding.sh 1970-01-01 01:00:00.000000000 +0100 -+++ /tmp/dpep-work.c7Vvzd/trunk/ocaml-md5sums/feeding.sh 2005-07-31 11:03:53.000000000 +0200 ++++ /tmp/dpep-work.YsUxwk/trunk/ocaml-md5sums/feeding.sh 2005-08-12 10:19:10.000000000 +0200 @@ -0,0 +1,40 @@ +#!/bin/sh +# Copyright (C) 2005, Stefano Zacchiroli @@ -65,9 +65,9 @@ diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/feeding.sh /tmp/dpep-wo + ;; +esac + -diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/Makefile /tmp/dpep-work.c7Vvzd/trunk/ocaml-md5sums/Makefile +diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/Makefile /tmp/dpep-work.YsUxwk/trunk/ocaml-md5sums/Makefile --- ./ocaml-md5sums/Makefile 1970-01-01 01:00:00.000000000 +0100 -+++ /tmp/dpep-work.c7Vvzd/trunk/ocaml-md5sums/Makefile 2005-07-31 11:02:49.000000000 +0200 ++++ /tmp/dpep-work.YsUxwk/trunk/ocaml-md5sums/Makefile 2005-08-12 10:19:10.000000000 +0200 @@ -0,0 +1,30 @@ + +DESTDIR = /usr/local/bin @@ -99,17 +99,17 @@ diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/Makefile /tmp/dpep-work +clean: + rm -f ocaml-md5sums ocaml-md5sums.opt *.cm[aiox] *.cmxa *.[ao] + -diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/ocaml-md5sums.ml.in /tmp/dpep-work.c7Vvzd/trunk/ocaml-md5sums/ocaml-md5sums.ml.in +diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/ocaml-md5sums.ml.in /tmp/dpep-work.YsUxwk/trunk/ocaml-md5sums/ocaml-md5sums.ml.in --- ./ocaml-md5sums/ocaml-md5sums.ml.in 1970-01-01 01:00:00.000000000 +0100 -+++ /tmp/dpep-work.c7Vvzd/trunk/ocaml-md5sums/ocaml-md5sums.ml.in 2005-07-31 11:02:49.000000000 +0200 -@@ -0,0 +1,310 @@ ++++ /tmp/dpep-work.YsUxwk/trunk/ocaml-md5sums/ocaml-md5sums.ml.in 2005-08-12 10:28:16.000000000 +0200 +@@ -0,0 +1,314 @@ +(* + * ocaml-md5sums - use and maintain debian registry of ocaml md5sums + * + * Copyright (C) 2005, Stefano Zacchiroli + * + * Created: Wed, 06 Apr 2005 16:55:39 +0200 zack -+ * Last-Modified: Sun, 31 Jul 2005 00:48:15 +0200 zack ++ * Last-Modified: Fri, 12 Aug 2005 10:28:10 +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 @@ -210,6 +210,8 @@ diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/ocaml-md5sums.ml.in /tm + List.rev !lines + +let is_empty fname = (Unix.stat fname).Unix.st_size = 0 ++let is_regular fname = (Unix.stat fname).Unix.st_kind = Unix.S_REG ++let is_dir fname = (Unix.stat fname).Unix.st_kind = Unix.S_DIR + +(** {2 Auxiliary functions} *) + @@ -361,28 +363,30 @@ diff -urNad --exclude=CVS --exclude=.svn ./ocaml-md5sums/ocaml-md5sums.ml.in /tm + info (sprintf "updating registry %s using info from %s/" + registry_file md5sums_dir); + let keys = Hashtbl.create 1024 in (* history of seen registry keys *) -+ let dir = Unix.opendir md5sums_dir in -+ let registry = open_out registry_file in -+ try -+ while true do -+ let fname = sprintf "%s/%s" md5sums_dir (Unix.readdir dir) in -+ if (Str.string_match md5sums_ext_RE fname 0) -+ && ((Unix.stat fname).Unix.st_kind = Unix.S_REG) -+ then -+ iter_registry -+ (fun ~md5sum ~unit_name ~dev_dep ~runtime_dep ~dep_version -> -+ if Hashtbl.mem keys (unit_name, md5sum) then -+ error (sprintf "duplicate entry %s %s in registry" unit_name -+ md5sum); -+ Hashtbl.replace keys (unit_name, md5sum) (); -+ pp_entry registry ~md5sum ~unit_name ~dev_dep ~runtime_dep -+ ~dep_version) -+ fname -+ done -+ with End_of_file -> -+ Unix.closedir dir; -+ close_out registry; -+ if is_empty registry_file then Sys.remove registry_file ++ if Sys.file_exists md5sums_dir && is_dir md5sums_dir then begin ++ let dir = Unix.opendir md5sums_dir in ++ let registry = open_out registry_file in ++ try ++ while true do ++ let fname = sprintf "%s/%s" md5sums_dir (Unix.readdir dir) in ++ if (Str.string_match md5sums_ext_RE fname 0) && is_regular fname then ++ iter_registry ++ (fun ~md5sum ~unit_name ~dev_dep ~runtime_dep ~dep_version -> ++ if Hashtbl.mem keys (unit_name, md5sum) then ++ error (sprintf "duplicate entry %s %s in registry" unit_name ++ md5sum); ++ Hashtbl.replace keys (unit_name, md5sum) (); ++ pp_entry registry ~md5sum ~unit_name ~dev_dep ~runtime_dep ++ ~dep_version) ++ fname ++ done ++ with End_of_file -> ++ Unix.closedir dir; ++ close_out registry; ++ if is_empty registry_file then Sys.remove registry_file ++ end else ++ warning (sprintf "%s/ does not exist or is not a directory, not updating" ++ md5sums_dir) + +(** {2 Main} *) + -- 2.30.2