pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

mount-zip: Fix build on NetBSD 9.2



Module Name:	pkgsrc-wip
Committed By:	PHO <pho%cielonegro.org@localhost>
Pushed By:	pho
Date:		Fri Dec 3 01:16:09 2021 +0900
Changeset:	53f603b998ace97026e8216b84ae1ccc72a9d352

Modified Files:
	mount-zip/Makefile
	mount-zip/PLIST
	mount-zip/TODO
	mount-zip/distinfo
	mount-zip/patches/patch-main.cc
Added Files:
	mount-zip/patches/patch-Makefile

Log Message:
mount-zip: Fix build on NetBSD 9.2

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=53f603b998ace97026e8216b84ae1ccc72a9d352

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 mount-zip/Makefile               | 30 +++++++++++++++++
 mount-zip/PLIST                  |  5 ++-
 mount-zip/TODO                   | 43 +----------------------
 mount-zip/distinfo               |  3 +-
 mount-zip/patches/patch-Makefile | 15 +++++++++
 mount-zip/patches/patch-main.cc  | 73 +++++++++++++++++++++++++++++++++++++++-
 6 files changed, 122 insertions(+), 47 deletions(-)

diffs:
diff --git a/mount-zip/Makefile b/mount-zip/Makefile
index 2622f6f505..29a84c02cb 100644
--- a/mount-zip/Makefile
+++ b/mount-zip/Makefile
@@ -10,9 +10,39 @@ HOMEPAGE=	https://github.com/google/mount-zip/
 COMMENT=	Read-only FUSE file system for ZIP archives
 LICENSE=	gnu-gpl-v3
 
+# TODO: We should support c++20 in USE_LANGUAGES. Maybe we should do
+# GCC_REQD+=8 automatically too, because GCC 8.0 is the first version
+# supporting *some* part of C++20?
 USE_LANGUAGES=	c++
+# GCC 8.4.0 is not good enough for this particular package. But pho@
+# doesn't know which one is the exact minimum. It's somewhere between
+# 8.4 < x <= 9.
+GCC_REQD+=	9
 USE_TOOLS+=	gmake pkg-config
 
+# TODO: mk/fuse.buildlink3.mk does this for CFLAGS.NetBSD, but it's
+# actually a preprocessor flag so pho@ thinks it's wrong. pho@ just
+# doesn't want to touch any mk/* in the pre-freeze phase.
+CPPFLAGS.NetBSD+=	-D_KERNTYPES
+# TODO: The underlying problem is that our <puffs.h> #include's
+# <fs/puffs/puffs_msgif.h> and exposes kernel types, and thus
+# -D_KERNTYPES is required to use the header. This too needs to be
+# fixed.
+
+# GCC < 10 doesn't support -std=c++20. Use c++2a instead.
+BUILDLINK_TRANSFORM+=	opt:-std=c++20:-std=c++2a
+
+# Required for generating a man page.
+# TODO: Pandoc is not portable enough, because GHC isn't. We should
+# probably put a pre-generated man page in ${FILESDIR}.
+BUILD_DEPENDS+=	pandoc-[0-9]*:../../converters/pandoc
+
+INSTALLATION_DIRS+=	bin ${PKGMANDIR}/man1
+INSTALL_MAKE_FLAGS+=	bindir=${PREFIX:Q}/bin
+INSTALL_MAKE_FLAGS+=	INSTALL_PROGRAM=${INSTALL_PROGRAM:Q}
+INSTALL_MAKE_FLAGS+=	INSTALL_DATA=${INSTALL_DATA:Q}
+INSTALL_MAKE_FLAGS+=	MANDIR=${PREFIX:Q}/${PKGMANDIR:Q}/man1
+
 .include "../../archivers/libzip/buildlink3.mk"
 .include "../../devel/boost-headers/buildlink3.mk"
 .include "../../textproc/icu/buildlink3.mk"
diff --git a/mount-zip/PLIST b/mount-zip/PLIST
index 92ba51a2d7..122411a7e2 100644
--- a/mount-zip/PLIST
+++ b/mount-zip/PLIST
@@ -1,4 +1,3 @@
 @comment $NetBSD$
-@comment TODO: to fill this file with the file listing:
-@comment TODO: 1. run "/usr/bin/make package"
-@comment TODO: 2. run "/usr/bin/make print-PLIST"
+bin/mount-zip
+man/man1/mount-zip.1
diff --git a/mount-zip/TODO b/mount-zip/TODO
index 7c957ddff9..a515fc56a0 100644
--- a/mount-zip/TODO
+++ b/mount-zip/TODO
@@ -1,42 +1 @@
-Does not build on NetBSD:
-
-In file included from /usr/include/puffs.h:44,
-                 from /usr/include/fuse.h:41,
-                 from main.cc:30:
-/usr/include/fs/puffs/puffs_msgif.h:708:2: error: 'register_t' does not name a type; did you mean 'register'?
-  708 |  register_t  pvnr_retval;  /* IN */
-      |  ^~~~~~~~~~
-      |  register
-In file included from /usr/include/fuse.h:41,
-                 from main.cc:30:
-/usr/include/puffs.h:226:27: error: 'register_t' has not been declared
-  226 |      puffs_cookie_t, int, register_t *);
-      |                           ^~~~~~~~~~
-/usr/include/puffs.h:437:1: error: 'register_t' has not been declared
-  437 | PUFFSOP_PROTOS(puffs_null) /* XXX */
-      | ^~~~~~~~~~~~~~
-/usr/include/puffs.h:506:20: error: 'vsize_t' has not been declared
-  506 |        enum vtype, vsize_t, dev_t);
-      |                    ^~~~~~~
-main.cc: In function 'int main(int, char**)':
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-  384 |                            {nullptr, 0, 0}};
-      |                                           ^
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:384:43: error: narrowing conversion of '4294967295' from 'unsigned int' to 'int32_t' {aka 'int'} [-Wnarrowing]
-main.cc:451:7: error: 'fuse_setup' was not declared in this scope; did you mean 'fuse_opt'?
-  451 |       fuse_setup(args.argc, args.argv, &operations, sizeof(operations),
-      |       ^~~~~~~~~~
-      |       fuse_opt
-main.cc:469:3: error: 'fuse_teardown' was not declared in this scope
-  469 |   fuse_teardown(fuse, absolute_mount_point);
-      |   ^~~~~~~~~~~~~
+Eliminate BUILD_DEPENDS on pandoc (see Makefile).
diff --git a/mount-zip/distinfo b/mount-zip/distinfo
index 0aeda456d4..82ea9dfb33 100644
--- a/mount-zip/distinfo
+++ b/mount-zip/distinfo
@@ -3,5 +3,6 @@ $NetBSD$
 BLAKE2s (mount-zip-1.0.3.tar.gz) = d34c89835de46fa6761ba7869d27e1a6b837b91a413d3b23a179a7822378ca68
 SHA512 (mount-zip-1.0.3.tar.gz) = f18c24cedfb09edcf3b97d86e85fe8c3cd5d37fd024cfdff4c90fc7948e79fe719b6463c7bc35b8e1d582405c73f20ef6f6f4e05a67b5f07681a369a17ff6fa3
 Size (mount-zip-1.0.3.tar.gz) = 714641 bytes
+SHA1 (patch-Makefile) = e52cebe5be150433d1d6d197f3ebc61231aea520
 SHA1 (patch-lib_extra__field.cc) = 21158541a3d0521bae799a6cd61b508f596355f3
-SHA1 (patch-main.cc) = 8afd48d9dda938b8f8755dfea314b05bf674e0f6
+SHA1 (patch-main.cc) = e5df658a5b33936c0b339561457f4c4e593ce74e
diff --git a/mount-zip/patches/patch-Makefile b/mount-zip/patches/patch-Makefile
new file mode 100644
index 0000000000..5cc610e58a
--- /dev/null
+++ b/mount-zip/patches/patch-Makefile
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Honor CPPFLAGS; required on NetBSD.
+
+--- Makefile.orig	2021-12-02 15:21:15.664537142 +0000
++++ Makefile
+@@ -48,7 +48,7 @@ $(DEST): $(OBJECTS) $(LIB)
+ 	$(CXX) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
+ 
+ main.o: main.cc
+-	$(CXX) -Ilib -c $(CXXFLAGS) $< -o $@
++	$(CXX) -Ilib -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
+ 
+ $(LIB):
+ 	$(MAKE) -C lib
diff --git a/mount-zip/patches/patch-main.cc b/mount-zip/patches/patch-main.cc
index ea115d80de..09a84a3257 100644
--- a/mount-zip/patches/patch-main.cc
+++ b/mount-zip/patches/patch-main.cc
@@ -1,6 +1,26 @@
 $NetBSD$
 
-O_PATH does not exist on NetBSD.
+Hunk #0:
+    O_PATH does not exist on NetBSD.
+
+Hunk #1, #2:
+    Work around an issue in librefuse <fuse_opt.h>. It has been
+    incompatible with C++11 compilers. Fixed in HEAD:
+    * http://mail-index.netbsd.org/source-changes/2021/12/01/msg134169.html
+    * http://mail-index.netbsd.org/source-changes/2021/12/01/msg134170.html
+    ([pho@] It's me who broke it.)
+
+Hunk #3:
+    fuse_setup() and fuse_teardown() are obsolete functions and has been
+    (wrongly) removed from librefuse. Use fuse_main() instead, especially when
+    nothing special needs to be done while mounting a filesystem and entering a
+    main loop.
+
+    TODO: These two functions should be added back to librefuse, along with
+    proper FUSE_USE_VERSION checks. Old applications are everywhere and it's
+    clear we still need to support the decades old API given the amount of
+    patches we ended up with for filesystems/fuse-*.
+    ([pho@] I must admit it's me who removed them.)
 
 --- main.cc.orig	2021-11-28 04:14:07.000000000 +0000
 +++ main.cc
@@ -15,3 +35,54 @@ O_PATH does not exist on NetBSD.
  // Prints usage information.
  void print_usage() {
    fprintf(
+@@ -364,6 +368,8 @@ int main(int argc, char* argv[]) try {
+   Cleanup cleanup{.args = &args};
+   Param param;
+ 
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wnarrowing"
+   const fuse_opt opts[] = {FUSE_OPT_KEY("--help", KEY_HELP),
+                            FUSE_OPT_KEY("-h", KEY_HELP),
+                            FUSE_OPT_KEY("--version", KEY_VERSION),
+@@ -378,6 +384,7 @@ int main(int argc, char* argv[]) try {
+                            FUSE_OPT_KEY("nohardlinks", KEY_NO_HARDLINKS),
+                            {"encoding=%s", offsetof(Param, opts.encoding), 0},
+                            {nullptr, 0, 0}};
++#pragma GCC diagnostic pop
+ 
+   if (fuse_opt_parse(&args, &param, opts, ProcessArg))
+     return EXIT_FAILURE;
+@@ -440,32 +447,7 @@ int main(int argc, char* argv[]) try {
+   // Single-threaded operation.
+   fuse_opt_add_arg(&args, "-s");
+ 
+-  char* absolute_mount_point;
+-  int multithreaded;
+-  timer.Reset();
+-  struct fuse* const fuse =
+-      fuse_setup(args.argc, args.argv, &operations, sizeof(operations),
+-                 &absolute_mount_point, &multithreaded, tree.get());
+-
+-  if (!fuse)
+-    throw std::runtime_error(StrCat("Cannot mount ", Path(param.filename),
+-                                    " on ", Path(param.mount_point)));
+-
+-  Log(LOG_DEBUG, "Mounted ", Path(param.filename), " on ",
+-      Path(param.mount_point), " in ", timer);
+-  Log(LOG_DEBUG, "When finished, run: fusermount -u ",
+-      Path(absolute_mount_point));
+-
+-  assert(!multithreaded);
+-  const int res = fuse_loop(fuse);
+-
+-  Log(LOG_DEBUG, "Unmounting ", Path(param.filename), " from ",
+-      Path(param.mount_point), "...");
+-  timer.Reset();
+-  fuse_teardown(fuse, absolute_mount_point);
+-  Log(LOG_DEBUG, "Unmounted ", Path(param.filename), " in ", timer);
+-
+-  return res;
++  return fuse_main(args.argc, args.argv, &operations, tree.get());
+ } catch (const ZipError& e) {
+   Log(LOG_ERR, e.what());
+   // Shift libzip error codes in order to avoid collision with FUSE errors.


Home | Main Index | Thread Index | Old Index