[Pkg-ocaml-maint-commits] [ocaml] 02/05: Enable ocamldoc to build reproducible manpages (Closes: #794586)
Stéphane Glondu
glondu at moszumanska.debian.org
Thu Aug 13 17:37:21 UTC 2015
This is an automated email from the git hooks/post-receive script.
glondu pushed a commit to branch experimental/master
in repository ocaml.
commit 9ec4337bcee69c54abc100a72c4195bbdd34254f
Author: Stephane Glondu <steph at glondu.net>
Date: Thu Aug 13 13:19:55 2015 +0200
Enable ocamldoc to build reproducible manpages (Closes: #794586)
Patch by Valentin Lorentz.
---
...e-ocamldoc-to-build-reproducible-manpages.patch | 145 +++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 146 insertions(+)
diff --git a/debian/patches/0010-Enable-ocamldoc-to-build-reproducible-manpages.patch b/debian/patches/0010-Enable-ocamldoc-to-build-reproducible-manpages.patch
new file mode 100644
index 0000000..d7c255d
--- /dev/null
+++ b/debian/patches/0010-Enable-ocamldoc-to-build-reproducible-manpages.patch
@@ -0,0 +1,145 @@
+From: Valentin Lorentz <progval at progval.net>
+Date: Thu, 13 Aug 2015 11:59:04 +0200
+Subject: Enable ocamldoc to build reproducible manpages
+
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=794586
+Signed-off-by: Stephane Glondu <steph at glondu.net>
+---
+ ocamldoc/odoc_man.ml | 15 +++++----------
+ ocamldoc/odoc_misc.ml | 12 ++++++++++--
+ ocamldoc/odoc_misc.mli | 7 ++++++-
+ 3 files changed, 21 insertions(+), 13 deletions(-)
+
+diff --git a/ocamldoc/odoc_man.ml b/ocamldoc/odoc_man.ml
+index e97db4b..2170fc9 100644
+--- a/ocamldoc/odoc_man.ml
++++ b/ocamldoc/odoc_man.ml
+@@ -857,14 +857,13 @@ class man =
+ (** Generate the man page for the given class.*)
+ method generate_for_class cl =
+ Odoc_info.reset_type_names () ;
+- let date = Unix.time () in
+ let file = self#file_name cl.cl_name in
+ try
+ let chanout = self#open_out file in
+ let b = new_buf () in
+ bs b (".TH \""^cl.cl_name^"\" ");
+ bs b !man_section ;
+- bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
++ bs b (" source: "^Odoc_misc.current_date^" ");
+ bs b "OCamldoc ";
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
+
+@@ -916,14 +915,13 @@ class man =
+ (** Generate the man page for the given class type.*)
+ method generate_for_class_type ct =
+ Odoc_info.reset_type_names () ;
+- let date = Unix.time () in
+ let file = self#file_name ct.clt_name in
+ try
+ let chanout = self#open_out file in
+ let b = new_buf () in
+ bs b (".TH \""^ct.clt_name^"\" ");
+ bs b !man_section ;
+- bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
++ bs b (" source: "^Odoc_misc.current_date^" ");
+ bs b "OCamldoc ";
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
+
+@@ -1009,14 +1007,13 @@ class man =
+ (** Generate the man file for the given module type.
+ @raise Failure if an error occurs.*)
+ method generate_for_module_type mt =
+- let date = Unix.time () in
+ let file = self#file_name mt.mt_name in
+ try
+ let chanout = self#open_out file in
+ let b = new_buf () in
+ bs b (".TH \""^mt.mt_name^"\" ");
+ bs b !man_section ;
+- bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
++ bs b (" source: "^Odoc_misc.current_date^" ");
+ bs b "OCamldoc ";
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
+
+@@ -1092,14 +1089,13 @@ class man =
+ (** Generate the man file for the given module.
+ @raise Failure if an error occurs.*)
+ method generate_for_module m =
+- let date = Unix.time () in
+ let file = self#file_name m.m_name in
+ try
+ let chanout = self#open_out file in
+ let b = new_buf () in
+ bs b (".TH \""^m.m_name^"\" ");
+ bs b !man_section ;
+- bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
++ bs b (" source: "^Odoc_misc.current_date^" ");
+ bs b "OCamldoc ";
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
+
+@@ -1199,14 +1195,13 @@ class man =
+ | Res_const (_,f) -> f.vc_name
+ )
+ in
+- let date = Unix.time () in
+ let file = self#file_name name in
+ try
+ let chanout = self#open_out file in
+ let b = new_buf () in
+ bs b (".TH \""^name^"\" ");
+ bs b !man_section ;
+- bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
++ bs b (" source: "^Odoc_misc.current_date^" ");
+ bs b "OCamldoc ";
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
+ bs b ".SH NAME\n";
+diff --git a/ocamldoc/odoc_misc.ml b/ocamldoc/odoc_misc.ml
+index e938dbe..79bb713 100644
+--- a/ocamldoc/odoc_misc.ml
++++ b/ocamldoc/odoc_misc.ml
+@@ -223,9 +223,9 @@ let apply_opt f v_opt =
+ None -> None
+ | Some v -> Some (f v)
+
+-let string_of_date ?(hour=true) d =
++let string_of_date ?(absolute=false) ?(hour=true) d =
+ let add_0 s = if String.length s < 2 then "0"^s else s in
+- let t = Unix.localtime d in
++ let t = (if absolute then Unix.gmtime else Unix.localtime) d in
+ (string_of_int (t.Unix.tm_year + 1900))^"-"^
+ (add_0 (string_of_int (t.Unix.tm_mon + 1)))^"-"^
+ (add_0 (string_of_int t.Unix.tm_mday))^
+@@ -238,6 +238,14 @@ let string_of_date ?(hour=true) d =
+ ""
+ )
+
++let current_date =
++ let time =
++ try
++ float_of_string (Sys.getenv "SOURCE_DATE_EPOCH")
++ with
++ Not_found -> Unix.time ()
++ in string_of_date ~absolute: true ~hour: false time
++
+
+ let rec text_list_concat sep l =
+ match l with
+diff --git a/ocamldoc/odoc_misc.mli b/ocamldoc/odoc_misc.mli
+index 5958be9..4fe2647 100644
+--- a/ocamldoc/odoc_misc.mli
++++ b/ocamldoc/odoc_misc.mli
+@@ -62,7 +62,12 @@ val apply_opt : ('a -> 'b) -> 'a option -> 'b option
+
+ (** Return a string representing a date given as a number of seconds
+ since 1970. The hour is optionnaly displayed. *)
+-val string_of_date : ?hour:bool -> float -> string
++val string_of_date : ?absolute:bool -> ?hour:bool -> float -> string
++
++(* Value returned by string_of_date for current time.
++ * Uses environment variable SOURCE_DATE_EPOCH if set; falls back to
++ * current timestamp otherwise. *)
++val current_date : string
+
+ (** Return the first sentence (until the first dot) of a text.
+ Don't stop in the middle of [Code], [Verbatim], [List], [Lnum],
diff --git a/debian/patches/series b/debian/patches/series
index 70f532e..631b36f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -6,3 +6,4 @@
0006-Embed-bytecode-in-C-object-when-using-custom.patch
0007-Tune-resource-usage-of-some-tests.patch
0008-Native-backtraces-don-t-work-on-powerpc-and-sparc.patch
+0010-Enable-ocamldoc-to-build-reproducible-manpages.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/ocaml.git
More information about the Pkg-ocaml-maint-commits
mailing list