From d89cffce88b1c4da4944fa85951166e4f5cbbbad Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 24 Jan 2024 10:58:07 +0000 Subject: [PATCH] Temporary workaround for binutils bug https://sourceware.org/bugzilla/show_bug.cgi?id=31283 Use git to apply the patches since patch 0004 contains a binary patch. --- ...tmaps-Fix-tests-when-srcdir-builddir.patch | 2 +- ...x-tests-to-work-with-srcdir-builddir.patch | 2 +- ...nts-win32-Only-build-nbdkit-cat.mc-d.patch | 2 +- ...ents-win32-Make-windmc-tool-optional.patch | 192 ++++++++++++++++++ nbdkit.spec | 12 +- 5 files changed, 205 insertions(+), 5 deletions(-) create mode 100644 0004-common-replacements-win32-Make-windmc-tool-optional.patch diff --git a/0001-common-bitmaps-Fix-tests-when-srcdir-builddir.patch b/0001-common-bitmaps-Fix-tests-when-srcdir-builddir.patch index ea7acc2..4f98f9b 100644 --- a/0001-common-bitmaps-Fix-tests-when-srcdir-builddir.patch +++ b/0001-common-bitmaps-Fix-tests-when-srcdir-builddir.patch @@ -1,7 +1,7 @@ From 93a1538808ac7f9788336a7e35168d851e8b2c72 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 23 Jan 2024 13:24:48 +0000 -Subject: [PATCH 1/3] common/bitmaps: Fix tests when srcdir != builddir +Subject: [PATCH 1/4] common/bitmaps: Fix tests when srcdir != builddir --- common/bitmap/Makefile.am | 1 + diff --git a/0002-tests-Fix-tests-to-work-with-srcdir-builddir.patch b/0002-tests-Fix-tests-to-work-with-srcdir-builddir.patch index 93d28f8..7461254 100644 --- a/0002-tests-Fix-tests-to-work-with-srcdir-builddir.patch +++ b/0002-tests-Fix-tests-to-work-with-srcdir-builddir.patch @@ -1,7 +1,7 @@ From ac60163ceba1b951e1d2f0625552e6a45d85f666 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 23 Jan 2024 13:35:02 +0000 -Subject: [PATCH 2/3] tests: Fix tests to work with srcdir != builddir +Subject: [PATCH 2/4] tests: Fix tests to work with srcdir != builddir --- tests/test-cc-cpp.sh | 2 +- diff --git a/0003-common-replacements-win32-Only-build-nbdkit-cat.mc-d.patch b/0003-common-replacements-win32-Only-build-nbdkit-cat.mc-d.patch index b9f8ae0..28c0ccb 100644 --- a/0003-common-replacements-win32-Only-build-nbdkit-cat.mc-d.patch +++ b/0003-common-replacements-win32-Only-build-nbdkit-cat.mc-d.patch @@ -1,7 +1,7 @@ From 774465bb9e3444f23709deabeb39cc91490001a5 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 23 Jan 2024 18:08:12 +0000 -Subject: [PATCH 3/3] common/replacements/win32: Only build nbdkit-cat.mc +Subject: [PATCH 3/4] common/replacements/win32: Only build nbdkit-cat.mc derived files once Previously parallel builds caused multiple instances of windmc to run. diff --git a/0004-common-replacements-win32-Make-windmc-tool-optional.patch b/0004-common-replacements-win32-Make-windmc-tool-optional.patch new file mode 100644 index 0000000..de45bd0 --- /dev/null +++ b/0004-common-replacements-win32-Make-windmc-tool-optional.patch @@ -0,0 +1,192 @@ +From 617f950de1d18d5ddd146c32d700afd81470a284 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 24 Jan 2024 10:46:26 +0000 +Subject: [PATCH 4/4] common/replacements/win32: Make windmc tool optional + +Make the windmc (mc.exe) tool option even on Windows. + +Distribute the generated message catalogs, but regenerate them if +windmc is found at compile time. + +I also changed mc -> mc.exe since "mc" on Linux is a program called +Midnight Commander and mc.exe would only be the name when compiling on +Windows. (If there's any confusion here, you can always define the +right binary to use by doing: ./configure MC=/path/to/mc.exe) +--- + configure.ac | 10 ++-- + common/replacements/win32/Makefile.am | 13 +++-- + common/replacements/win32/nbdkit-cat.h | 68 ++++++++++++++++++++++++ + common/replacements/win32/MSG00001.bin | Bin 0 -> 28 bytes + common/replacements/win32/nbdkit-cat.rc | 9 ++++ + .gitignore | 3 -- + 6 files changed, 89 insertions(+), 14 deletions(-) + create mode 100644 common/replacements/win32/nbdkit-cat.h + create mode 100644 common/replacements/win32/MSG00001.bin + create mode 100644 common/replacements/win32/nbdkit-cat.rc + +diff --git a/configure.ac b/configure.ac +index 08ba6287c..03c655638 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -584,13 +584,11 @@ AC_DEFINE_UNQUOTED([DIR_SEPARATOR_STR],["$DIR_SEPARATOR_STR"], + [String that separates path elements.]) + AM_CONDITIONAL([IS_WINDOWS],[test "x$is_windows" = "xyes"]) + ++dnl Look for the mc/windmc utility (optional). ++AC_CHECK_TOOLS([MC],[windmc mc.exe],[no]) ++AM_CONDITIONAL([HAVE_MC],[test "x$MC" != "xno"]) ++ + AS_IF([test "x$is_windows" = "xyes"],[ +- dnl For Windows, look for the mc/windmc utility. +- dnl XXX Do we need to check for mc.exe as well? +- AC_CHECK_TOOLS([MC],[windmc mc],[no]) +- AS_IF([test "x$MC" = "xno"], +- [AC_MSG_ERROR([mc/windmc utility must be available when compiling for Windows])]) +- + dnl On Windows look for dlltool. + AC_CHECK_TOOLS([DLLTOOL],[dlltool],[no]) + AS_IF([test "x$DLLTOOL" = "xno"], +diff --git a/common/replacements/win32/Makefile.am b/common/replacements/win32/Makefile.am +index b8c7c639e..45dcd6ac2 100644 +--- a/common/replacements/win32/Makefile.am ++++ b/common/replacements/win32/Makefile.am +@@ -29,15 +29,18 @@ + # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + # SUCH DAMAGE. + ++# The Windows message catalog. ++ + include $(top_srcdir)/common-rules.mk + +-EXTRA_DIST = nbdkit-cat.mc +- +-if IS_WINDOWS +- +-# Build the message catalog. + noinst_DATA = MSG00001.bin nbdkit-cat.h nbdkit-cat.rc + ++# We distribute the generated message catalog files to save people ++# needing to install the windmc tool, but they are regenerated (below) ++# if windmc is found at configure time. ++EXTRA_DIST = nbdkit-cat.mc $(noinst_DATA) ++ ++if HAVE_MC + CLEANFILES += stamp-data + + $(noinst_DATA): stamp-data +diff --git a/common/replacements/win32/nbdkit-cat.h b/common/replacements/win32/nbdkit-cat.h +new file mode 100644 +index 000000000..8081e453d +--- /dev/null ++++ b/common/replacements/win32/nbdkit-cat.h +@@ -0,0 +1,68 @@ ++/* Do not edit this file manually. ++ This file is autogenerated by windmc. */ ++ ++// ++// The values are 32 bit layed out as follows: ++// ++// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 ++// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 ++// +---+-+-+-----------------------+-------------------------------+ ++// |Sev|C|R| Facility | Code | ++// +---+-+-+-----------------------+-------------------------------+ ++// ++// where ++// ++// C - is the Customer code flag ++// ++// R - is a reserved bit ++// ++// Code - is the facility's status code ++// ++// Sev - is the severity code ++// ++// Success - 00 ++// Informational - 01 ++// Warning - 02 ++// Error - 03 ++// ++// Facility - is the facility code ++// ++// System - 00ff ++// Application - 0fff ++// ++ ++// nbdkit ++// Copyright Red Hat ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions are ++// met: ++// ++// * Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// ++// * Redistributions in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// ++// * Neither the name of Red Hat nor the names of its contributors may be ++// used to endorse or promote products derived from this software without ++// specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ++// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ++// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A ++// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR ++// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ++// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ++// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ++// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ++// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ++// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ++// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++// SUCH DAMAGE. ++// ++// MessageId: NBDKIT_SYSLOG_ERROR ++// ++#define NBDKIT_SYSLOG_ERROR 0xc0000001 ++ +diff --git a/common/replacements/win32/MSG00001.bin b/common/replacements/win32/MSG00001.bin +new file mode 100644 +index 0000000000000000000000000000000000000000..f642ff3a4079b4b8b3b60b9ecefebe7c136a404b +GIT binary patch +literal 28 +dcmZQ%U|?WmU^oE60zftokf+LE$iM|;0{|fO0s#O3 + +literal 0 +HcmV?d00001 + +diff --git a/common/replacements/win32/nbdkit-cat.rc b/common/replacements/win32/nbdkit-cat.rc +new file mode 100644 +index 000000000..6f6ce3344 +--- /dev/null ++++ b/common/replacements/win32/nbdkit-cat.rc +@@ -0,0 +1,9 @@ ++/* Do not edit this file manually. ++ This file is autogenerated by windmc. */ ++ ++ ++// Country: United States ++// Language: English ++#pragma code_page(1252) ++LANGUAGE 0x9, 0x1 ++1 MESSAGETABLE "MSG00001.bin" +diff --git a/.gitignore b/.gitignore +index 14f816c93..cce2de79b 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -52,9 +52,6 @@ plugins/*/*.3 + /common/protocol/protostrings.c + /common/replacements/libcompat.a + /common/replacements/test-current-dir-name +-/common/replacements/win32/MSG00001.bin +-/common/replacements/win32/nbdkit-cat.h +-/common/replacements/win32/nbdkit-cat.rc + /common/replacements/win32/stamp-data + /common/utils/test-quotes + /common/utils/test-vector +-- +2.43.0 + diff --git a/nbdkit.spec b/nbdkit.spec index 019f681..a8d25ae 100644 --- a/nbdkit.spec +++ b/nbdkit.spec @@ -92,13 +92,18 @@ Source8: %{modulename}.fc # Upstream patches to fix srcdir != builddir Patch: 0001-common-bitmaps-Fix-tests-when-srcdir-builddir.patch Patch: 0002-tests-Fix-tests-to-work-with-srcdir-builddir.patch +# Upstream patches to fix mingw builds Patch: 0003-common-replacements-win32-Only-build-nbdkit-cat.mc-d.patch +Patch: 0004-common-replacements-win32-Make-windmc-tool-optional.patch + +# For applying the patches: +BuildRequires: git -BuildRequires: make %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool %endif +BuildRequires: make BuildRequires: gcc, gcc-c++ BuildRequires: %{_bindir}/pod2man BuildRequires: gnutls-devel @@ -755,7 +760,7 @@ development kit for 64 bit versions of Windows. %if 0%{verify_tarball_signature} %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}' %endif -%autosetup -p1 +%autosetup -p1 -S git %if 0%{patches_touch_autotools} autoreconf -i %endif @@ -860,7 +865,10 @@ bzip2 -9 %{modulename}.pp popd %if 0%{?have_mingw} +# MC=no is a temporary hack until this bug is fixed in binutils: +# https://sourceware.org/bugzilla/show_bug.cgi?id=31283 %mingw_configure \ + MC=no \ --disable-static \ --enable-shared \ --with-extra='%{name}-%{version}-%{release}' \