From 0da9aef77a63c5b250c50a34895ced8d835d588a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 13 Feb 2018 08:22:36 +0000 Subject: [PATCH] Fix bytes/string problems. --- 0001-Fix-Bytes-String-for-OCaml-4.06.patch | 58 ++++++++++++++++++++++ supermin.spec | 8 ++- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 0001-Fix-Bytes-String-for-OCaml-4.06.patch diff --git a/0001-Fix-Bytes-String-for-OCaml-4.06.patch b/0001-Fix-Bytes-String-for-OCaml-4.06.patch new file mode 100644 index 0000000..4d1408a --- /dev/null +++ b/0001-Fix-Bytes-String-for-OCaml-4.06.patch @@ -0,0 +1,58 @@ +From 5c5eff66dfaccb212b8906e769e40633d8b8f5e4 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 13 Feb 2018 08:20:52 +0000 +Subject: [PATCH] Fix Bytes/String for OCaml 4.06. + +--- + src/format_ext2_kernel.ml | 4 ++-- + src/mode_build.ml | 10 ++++++---- + 2 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/src/format_ext2_kernel.ml b/src/format_ext2_kernel.ml +index d5d529d..98bff3a 100644 +--- a/src/format_ext2_kernel.ml ++++ b/src/format_ext2_kernel.ml +@@ -290,9 +290,9 @@ and read_leshort chan offset = + + and read_string chan offset len = + seek_in chan offset; +- let buf = String.create len in ++ let buf = Bytes.create len in + really_input chan buf 0 len; +- buf ++ Bytes.to_string buf + + and copy_or_symlink_file copy_kernel src dest = + if not copy_kernel then +diff --git a/src/mode_build.ml b/src/mode_build.ml +index 95869cb..b5f5fa6 100644 +--- a/src/mode_build.ml ++++ b/src/mode_build.ml +@@ -299,9 +299,10 @@ and update_appliance appliance lines = function + (* Determine the [file_type] of [file], or exit with an error. *) + and get_file_type file = + let chan = open_in file in +- let buf = String.create 512 in +- let len = input chan buf 0 (String.length buf) in ++ let buf = Bytes.create 512 in ++ let len = input chan buf 0 (Bytes.length buf) in + close_in chan; ++ let buf = Bytes.to_string buf in + + if len >= 3 && buf.[0] = '\x1f' && buf.[1] = '\x8b' && buf.[2] = '\x08' + then (* gzip-compressed file *) +@@ -335,8 +336,9 @@ and get_file_content file buf len = + and get_compressed_file_content zcat file = + let cmd = sprintf "%s %s" zcat (quote file) in + let chan_out, chan_in, chan_err = open_process_full cmd [||] in +- let buf = String.create 512 in +- let len = input chan_out buf 0 (String.length buf) in ++ let buf = Bytes.create 512 in ++ let len = input chan_out buf 0 (Bytes.length buf) in ++ let buf = Bytes.to_string buf in + (* We're expecting the subprocess to fail because we close the pipe + * early, so: + *) +-- +2.15.1 + diff --git a/supermin.spec b/supermin.spec index a34e85e..c4dec25 100644 --- a/supermin.spec +++ b/supermin.spec @@ -31,7 +31,7 @@ Summary: Tool for creating supermin appliances Name: supermin Version: 5.1.19 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2+ %if 0%{?rhel} >= 7 @@ -49,6 +49,9 @@ Source1: http://libguestfs.org/download/supermin/%{name}-%{version}.tar.gz Source2: libguestfs.keyring %endif +# Upstream patch which fixes byte/string problems. +Patch1: 0001-Fix-Bytes-String-for-OCaml-4.06.patch + BuildRequires: /usr/bin/pod2man BuildRequires: /usr/bin/pod2html BuildRequires: rpm @@ -170,6 +173,9 @@ make check || { %changelog +* Tue Feb 13 2018 Richard W.M. Jones - 5.1.19-3 +- Fix bytes/string problems. + * Fri Feb 09 2018 Fedora Release Engineering - 5.1.19-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild