"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: convert imsg->fd to imsg_get_fd()
To:
Omar Polo <op@omarpolo.com>, gameoftrees@openbsd.org
Date:
Wed, 17 Jan 2024 13:10:39 +0100

Download raw body.

Thread
On Wed, Jan 17, 2024 at 12:58:01PM +0100, Stefan Sperling wrote:
> On Wed, Jan 17, 2024 at 12:01:06PM +0100, Omar Polo wrote:
> > Oh, this also means that got can't be built on the latest release.
> 
> The main branch already fails to build on 7.4 now.
> 
> I would like to preserve our ability to provide -stable packages on 7.4.
> Is the hack below too horrible or can we use this until 7.5?

New diff which also fixes the build of gotd, gotsh, and gotwebd
on 7.4 by adding imsg_get_fd() stubs in additional places.

-----------------------------------------------
 provide imsg_get_fd in case libutil does not provide it
 
 This hack is needed to keep providing -stable packages for OpenBSD 7.4.
 It can be dropped once the 7.5 release is out.
 
diff cfcfb026c8c94bb60b400f6b21b89bce7b698873 94dbe89b44627b2e86f0ea897504c2c234ace1e1
commit - cfcfb026c8c94bb60b400f6b21b89bce7b698873
commit + 94dbe89b44627b2e86f0ea897504c2c234ace1e1
blob - 495bc5a1d44efc6d760792f0976a4cbf808e0b8a
blob + 9445083e58321d06a302cdb23136923329e029fd
--- Makefile.inc
+++ Makefile.inc
@@ -6,6 +6,12 @@ CPPFLAGS += -DGOT_LIBEXECDIR=${LIBEXECDIR} -DGOT_VERSI
 #CFLAGS += -DGOT_DELTA_CACHE_DEBUG
 #CFLAGS += -DGOT_DIFF_NO_MMAP
 
+# Compat hack for OpenBSD 7.4. Can be removed once 7.5 has been released.
+GOT_NEED_IMSG_GET_FD != if nm /usr/lib/libutil.a | grep -q imsg_get_fd; then echo 'No'; else echo 'Yes'; fi
+.if "${GOT_NEED_IMSG_GET_FD}" == "Yes"
+CFLAGS += -DGOT_NEED_IMSG_GET_FD
+.endif
+
 .if "${GOT_RELEASE}" == "Yes"
 PREFIX ?= /usr/local
 BINDIR ?= ${PREFIX}/bin
blob - acb40dee8cd351b48669c3c3247c42ed5f44501b
blob + 34081b10b9161250367a2264982566ede394c6e7
--- gotd/gotd.h
+++ gotd/gotd.h
@@ -470,3 +470,7 @@ void gotd_imsg_send_ack(struct got_object_id *, struct
     uint32_t, pid_t);
 void gotd_imsg_send_nak(struct got_object_id *, struct imsgbuf *,
     uint32_t, pid_t);
+
+#ifdef GOT_NEED_IMSG_GET_FD
+int imsg_get_fd(struct imsg *);
+#endif
blob - e5c21b47893334094185748ac154995dee4065d6
blob + 62cea717faf701d1308a2a415374c1d63ac003a6
--- gotd/privsep_stub.c
+++ gotd/privsep_stub.c
@@ -64,3 +64,12 @@ got_privsep_init_pack_child(struct imsgbuf *ibuf, stru
 {
 	return got_error(GOT_ERR_NOT_IMPL);
 }
+
+/* backwards compat for OpenBSD 7.4 release */
+#ifdef GOT_NEED_IMSG_GET_FD
+int
+imsg_get_fd(struct imsg *imsg)
+{
+	return (imsg->fd);
+}
+#endif
blob - 2523b2c27285f8b883a18bfa1d16fb268ff9cd5c
blob + 507eab6db8a334acfe32f41319c79f9dd47fb8e0
--- gotsh/gotsh.c
+++ gotsh/gotsh.c
@@ -132,3 +132,12 @@ done:
 
 	return 0;
 }
+
+/* backwards compat for OpenBSD 7.4 release */
+#ifdef GOT_NEED_IMSG_GET_FD
+int
+imsg_get_fd(struct imsg *imsg)
+{
+	return (imsg->fd);
+}
+#endif
blob - 9adea01286908db58bde811ebffe397078853fe3
blob + 7777424d01e97420aaae98cdaf7aabe3781d3eb2
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
@@ -554,3 +554,7 @@ __dead void fatal(const char *, ...)
 	    __attribute__((__format__ (printf, 1, 2)));
 __dead void fatalx(const char *, ...)
 	    __attribute__((__format__ (printf, 1, 2)));
+
+#ifdef GOT_NEED_IMSG_GET_FD
+int imsg_get_fd(struct imsg *);
+#endif
blob - d517f36f2ccbda4c48348016a20e6d6e87fbd1a4
blob + 26d623ff4b67f9c7e13bd0a0f8dd4178d57687f9
--- lib/got_lib_privsep.h
+++ lib/got_lib_privsep.h
@@ -839,3 +839,7 @@ const struct got_error *got_privsep_recv_painted_commi
     struct imsgbuf *);
 
 void got_privsep_exec_child(int[2], const char *, const char *);
+
+#ifdef GOT_NEED_IMSG_GET_FD
+int imsg_get_fd(struct imsg *);
+#endif
blob - f0f625ddad473f4c65fabd04e165b109d87dacb7
blob + edd86a7772bb2102629d74a5f25ca2850c24d315
--- lib/privsep.c
+++ lib/privsep.c
@@ -3615,3 +3615,12 @@ got_privsep_exec_child(int imsg_fds[2], const char *pa
 		_exit(1);
 	}
 }
+
+/* backwards compat for OpenBSD 7.4 release */
+#ifdef GOT_NEED_IMSG_GET_FD
+int
+imsg_get_fd(struct imsg *imsg)
+{
+	return (imsg->fd);
+}
+#endif