Bug#944592: FTBFS with OCaml 4.08.1 (safe strings)

2020-04-01 Thread Gianfranco Costamagna
control: tags -1 patch pending

diff uploaded

G.

On Tue, 12 Nov 2019 10:22:55 +0100 =?utf-8?q?St=C3=A9phane_Glondu?= 
 wrote:
> Package: src:ocaml-deriving-ocsigen
> Version: 0.7.1-1
> Severity: serious
> Tags: ftbfs
> User: debian-ocaml-ma...@lists.debian.org
> Usertags: ocaml-4.08-transition
> 
> Dear Maintainer,
> 
> ocaml-deriving-ocsigen FTBFS with OCaml 4.08.1 because -safe-string is
> the default now:
> 
>   https://buildd.debian.org/status/package.php?p=ocaml-deriving-ocsigen
> 
> 
> Cheers,
> 
> -- 
> Stéphane
> 
> -- System Information:
> Debian Release: bullseye/sid
>   APT prefers testing
>   APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
> Architecture: amd64 (x86_64)
> 
> Kernel: Linux 5.2.0-3-amd64 (SMP w/4 CPU cores)
> Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), 
> LANGUAGE=fr_FR.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /usr/bin/dash
> Init: systemd (via /run/systemd/system)
> LSM: AppArmor: enabled
diff -Nru ocaml-deriving-ocsigen-0.7.1/debian/changelog 
ocaml-deriving-ocsigen-0.7.1/debian/changelog
--- ocaml-deriving-ocsigen-0.7.1/debian/changelog   2016-08-03 
16:27:18.0 +0200
+++ ocaml-deriving-ocsigen-0.7.1/debian/changelog   2020-04-01 
16:30:46.0 +0200
@@ -1,3 +1,13 @@
+ocaml-deriving-ocsigen (0.7.1-1.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+
+  [ Dimitri John Ledkov  ]
+  * Cherrypick upstream patch to fix ftbfs with new ocaml (Closes: #944592).
+  * Add libnum-ocaml-dev dependency
+
+ -- Gianfranco Costamagna   Wed, 01 Apr 2020 
16:30:46 +0200
+
 ocaml-deriving-ocsigen (0.7.1-1) unstable; urgency=medium
 
   * New upstream release
diff -Nru ocaml-deriving-ocsigen-0.7.1/debian/control 
ocaml-deriving-ocsigen-0.7.1/debian/control
--- ocaml-deriving-ocsigen-0.7.1/debian/control 2016-08-03 16:26:27.0 
+0200
+++ ocaml-deriving-ocsigen-0.7.1/debian/control 2020-04-01 16:30:43.0 
+0200
@@ -11,6 +11,7 @@
   debhelper (>= 9),
   libtype-conv-camlp4-dev (>= 108),
   liboptcomp-camlp4-dev,
+  libnum-ocaml-dev,
   oasis (>= 0.4.5),
   camlp4-extra
 Standards-Version: 3.9.8
diff -Nru 
ocaml-deriving-ocsigen-0.7.1/debian/patches/df07e7150f4d196720fa6b44a289783ae9168810.patch
 
ocaml-deriving-ocsigen-0.7.1/debian/patches/df07e7150f4d196720fa6b44a289783ae9168810.patch
--- 
ocaml-deriving-ocsigen-0.7.1/debian/patches/df07e7150f4d196720fa6b44a289783ae9168810.patch
  1970-01-01 01:00:00.0 +0100
+++ 
ocaml-deriving-ocsigen-0.7.1/debian/patches/df07e7150f4d196720fa6b44a289783ae9168810.patch
  2020-04-01 16:30:43.0 +0200
@@ -0,0 +1,82 @@
+From df07e7150f4d196720fa6b44a289783ae9168810 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20Hillerstr=C3=B6m?= 
+Date: Tue, 14 Nov 2017 19:56:45 +
+Subject: [PATCH] Since OCaml 4.06.0 (-safe-string option) bytes and strings
+ cannot be used interchangeably. This patch fixes the code base such that the
+ modules Bytes and String (and hence types bytes and string) are no longer
+ used interchangeably.
+
+---
+ lib/deriving_Dump.ml | 7 ---
+ lib/deriving_interned.ml | 9 +
+ syntax/common/utils.ml   | 2 +-
+ 3 files changed, 10 insertions(+), 8 deletions(-)
+
+diff --git a/lib/deriving_Dump.ml b/lib/deriving_Dump.ml
+index 13e356f..9bafe3d 100644
+--- a/lib/deriving_Dump.ml
 b/lib/deriving_Dump.ml
+@@ -142,7 +142,7 @@ module Dump_string = Defaults (
+ for i = 0 to len - 1 do
+   Bytes.unsafe_set s i (Stream.next stream)
+ done;
+-s
++Bytes.to_string s
+   end
+ )
+ 
+@@ -241,7 +241,8 @@ module Dump_via_marshal (P : sig type a end) = Defaults (
+   struct
+ include P
+ let to_buffer buffer obj = Buffer.add_string buffer (Marshal.to_string 
obj [Marshal.Closures])
+-let from_stream stream = 
++let from_stream stream =
++  let to_string bs = Bytes.to_string bs in
+   let readn n = 
+ let s = Bytes.create n in
+ for i = 0 to n - 1 do
+@@ -252,5 +253,5 @@ module Dump_via_marshal (P : sig type a end) = Defaults (
+   let header = readn Marshal.header_size in
+   let datasize = Marshal.data_size header 0 in
+   let datapart = readn datasize in
+-Marshal.from_string (header ^ datapart) 0
++Marshal.from_string ((to_string header) ^ (to_string datapart)) 0
+   end)
+diff --git a/lib/deriving_interned.ml b/lib/deriving_interned.ml
+index d53bcc7..88aad8f 100644
+--- a/lib/deriving_interned.ml
 b/lib/deriving_interned.ml
+@@ -14,15 +14,16 @@ type t = int * string
+ deriving (Show)
+ 
+ let intern s =
+-  try BytesMap.find s !map
++  let bs = Bytes.of_string s in
++  try BytesMap.find bs !map
+   with Not_found ->
+-let fresh = (!counter, Bytes.of_string s) in begin
+-  map := BytesMap.add s fresh !map;
++let fresh = (!counter, s) in begin
++  map := BytesMap.add bs fresh !map;
+   incr counter;
+   fresh
+ end
+ 
+-let to_string (_,s) = Bytes.to_string s
++let to_string (_,s) = s
+ let name 

Bug#944592: FTBFS with OCaml 4.08.1 (safe strings)

2019-11-12 Thread Stéphane Glondu
Package: src:ocaml-deriving-ocsigen
Version: 0.7.1-1
Severity: serious
Tags: ftbfs
User: debian-ocaml-ma...@lists.debian.org
Usertags: ocaml-4.08-transition

Dear Maintainer,

ocaml-deriving-ocsigen FTBFS with OCaml 4.08.1 because -safe-string is
the default now:

  https://buildd.debian.org/status/package.php?p=ocaml-deriving-ocsigen


Cheers,

-- 
Stéphane

-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.2.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), 
LANGUAGE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled