Attached is a set of patches to make rpm build cleanly on OS X.

Patches 0001, 0002, 0003 should be pretty straightforward and safe.

Patch 0004 looks like an outright bug.  Maybe it works on other
platforms because the rpm packaging of rpm fixes it up somehow.

Patch 0005 is more a hack to get it working, not something ready for
portable use yet.
From 025a521053982222fb6f0fcc7d6e24832b67226c Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 28 Sep 2015 23:49:23 -0400
Subject: [PATCH 1/5] Don't define htonll() if already defined

OS X already has it as a macro in the system headers.
---
 lib/header.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/header.c b/lib/header.c
index d497a3a..81f2038 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -107,6 +107,7 @@ static const size_t headerMaxbytes = (32*1024*1024);
 	(((_e)->info.tag >= RPMTAG_HEADERIMAGE) && ((_e)->info.tag < RPMTAG_HEADERREGIONS))
 #define	ENTRY_IN_REGION(_e)	((_e)->info.offset < 0)
 
+#ifndef htonll
 /* Convert a 64bit value to network byte order. */
 RPM_GNUC_CONST
 static uint64_t htonll(uint64_t n)
@@ -119,6 +120,7 @@ static uint64_t htonll(uint64_t n)
 #endif
     return n;
 }
+#endif
 
 Header headerLink(Header h)
 {
-- 
2.6.4

From 5e1b39fe48304ae3d0515280933fe4ba2d128264 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 28 Sep 2015 23:49:24 -0400
Subject: [PATCH 2/5] Supply declaration of fdatasync if missing

OS X has the function but doesn't have a declaration for it.
---
 configure.ac | 1 +
 system.h     | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/configure.ac b/configure.ac
index d6e8c0f..fd73b33 100644
--- a/configure.ac
+++ b/configure.ac
@@ -560,6 +560,7 @@ dnl Checks for library functions.
 AC_CHECK_FUNCS(putenv)
 AC_CHECK_FUNCS(mempcpy)
 AC_CHECK_FUNCS(fdatasync)
+AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
 AC_CHECK_FUNCS(lutimes)
 AC_CHECK_FUNCS(mergesort)
 AC_CHECK_FUNCS(getauxval)
diff --git a/system.h b/system.h
index 40b9933..99691f4 100644
--- a/system.h
+++ b/system.h
@@ -78,6 +78,10 @@ char * stpncpy(char * dest, const char * src, size_t n);
 #endif
 #endif
 
+#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
+extern int fdatasync(int fildes);
+#endif
+
 #include "rpmio/rpmutil.h"
 /* compatibility macros to avoid a mass-renaming all over the codebase */
 #define xmalloc(_size) rmalloc((_size))
-- 
2.6.4

From 87355a35cc5b42248a29e18639e12a4b65291a93 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 28 Sep 2015 23:49:24 -0400
Subject: [PATCH 3/5] Add missing header files

They are generating warnings.
---
 build/parsePrep.c | 1 +
 build/rpmfc.c     | 1 +
 lib/backend/db3.c | 1 +
 lib/transaction.c | 1 +
 misc/fnmatch.c    | 2 ++
 5 files changed, 6 insertions(+)

diff --git a/build/parsePrep.c b/build/parsePrep.c
index 7c862ed..b70aee2 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -6,6 +6,7 @@
 #include "system.h"
 
 #include <errno.h>
+#include <libgen.h>
 
 #include <rpm/header.h>
 #include <rpm/rpmlog.h>
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 3637f5c..7c61d9d 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -1,6 +1,7 @@
 #include "system.h"
 
 #include <errno.h>
+#include <libgen.h>
 #include <sys/select.h>
 #include <sys/wait.h>
 #include <signal.h>
diff --git a/lib/backend/db3.c b/lib/backend/db3.c
index 7f302a7..9262d04 100644
--- a/lib/backend/db3.c
+++ b/lib/backend/db3.c
@@ -10,6 +10,7 @@ static int _debug = 1;	/* XXX if < 0 debugging, > 0 unusual error returns */
 #include <sys/wait.h>
 #include <popt.h>
 #include <db.h>
+#include <signal.h>
 
 #include <rpm/rpmtypes.h>
 #include <rpm/rpmmacro.h>
diff --git a/lib/transaction.c b/lib/transaction.c
index 66888af..dd9972b 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -5,6 +5,7 @@
 #include "system.h"
 
 #include <inttypes.h>
+#include <libgen.h>
 
 #include <rpm/rpmlib.h>		/* rpmMachineScore, rpmReadPackageFile */
 #include <rpm/rpmmacro.h>	/* XXX for rpmExpand */
diff --git a/misc/fnmatch.c b/misc/fnmatch.c
index 77fbd93..8de22c8 100644
--- a/misc/fnmatch.c
+++ b/misc/fnmatch.c
@@ -17,7 +17,9 @@
    Boston, MA 02111-1307, USA.  */
 
 # include "system.h"
+# include <ctype.h>
 # include <stdlib.h>
+# include <string.h>
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
 static inline char *
-- 
2.6.4

From a65327700d6798ada18e8fedddf612b4380859d1 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Sat, 10 Oct 2015 22:31:12 -0400
Subject: [PATCH 4/5] Fix rpmquery and rpmverify symlinks

---
 Makefile.am | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 4b5d1d8..134ff55 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -230,9 +230,9 @@ rpmvar_DATA =
 
 install-exec-hook:
 	@rm -f $(DESTDIR)$(bindir)/rpmquery
-	@LN_S@ ../../bin/rpm $(DESTDIR)$(bindir)/rpmquery
+	@LN_S@ rpm $(DESTDIR)$(bindir)/rpmquery
 	@rm -f $(DESTDIR)$(bindir)/rpmverify
-	@LN_S@ ../../bin/rpm $(DESTDIR)$(bindir)/rpmverify
+	@LN_S@ rpm $(DESTDIR)$(bindir)/rpmverify
 
 install-data-local:
 	DESTDIR="$(DESTDIR)" pkglibdir="$(rpmconfigdir)" \
-- 
2.6.4

From 79cde6b6ffafa7af8a5b0dc02b484d6c6c6ea7a2 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 28 Sep 2015 23:49:23 -0400
Subject: [PATCH 5/5] Port getprogname()/setprogname() handling

These are provided by the system.
---
 lib/poptALL.c    |  7 -------
 rpm2archive.c    |  1 -
 rpm2cpio.c       |  1 -
 rpmbuild.c       |  1 -
 rpmqv.c          |  1 -
 rpmspec.c        |  1 -
 system.h         | 15 +--------------
 tools/rpmdeps.c  |  1 -
 tools/rpmgraph.c |  1 -
 9 files changed, 1 insertion(+), 28 deletions(-)

diff --git a/lib/poptALL.c b/lib/poptALL.c
index 2e894e0..a14c204 100644
--- a/lib/poptALL.c
+++ b/lib/poptALL.c
@@ -4,7 +4,6 @@
  */
 
 #include "system.h"
-const char *__progname;
 
 #include <rpm/rpmcli.h>
 #include <rpm/rpmlib.h>		/* rpmEVR, rpmReadConfigFiles etc */
@@ -262,12 +261,6 @@ rpmcliInit(int argc, char *const argv[], struct poptOption * optionsTable)
 
     setprogname(argv[0]);       /* Retrofit glibc __progname */
 
-    /* XXX glibc churn sanity */
-    if (__progname == NULL) {
-	if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
-	else __progname = argv[0];
-    }
-
 #if defined(ENABLE_NLS)
     (void) setlocale(LC_ALL, "" );
 
diff --git a/rpm2archive.c b/rpm2archive.c
index 63d64d9..6d55b24 100644
--- a/rpm2archive.c
+++ b/rpm2archive.c
@@ -1,7 +1,6 @@
 /* rpmarchive: spit out the main archive portion of a package */
 
 #include "system.h"
-const char *__progname;
 
 #include <rpm/rpmlib.h>		/* rpmReadPackageFile .. */
 #include <rpm/rpmfi.h>
diff --git a/rpm2cpio.c b/rpm2cpio.c
index 89ebdfa..a57f908 100644
--- a/rpm2cpio.c
+++ b/rpm2cpio.c
@@ -1,7 +1,6 @@
 /* rpmarchive: spit out the main archive portion of a package */
 
 #include "system.h"
-const char *__progname;
 
 #include <rpm/rpmlib.h>		/* rpmReadPackageFile .. */
 #include <rpm/rpmtag.h>
diff --git a/rpmbuild.c b/rpmbuild.c
index 5d4b207..214e0ee 100644
--- a/rpmbuild.c
+++ b/rpmbuild.c
@@ -1,5 +1,4 @@
 #include "system.h"
-const char *__progname;
 
 #include <errno.h>
 #include <libgen.h>
diff --git a/rpmqv.c b/rpmqv.c
index 3081ce3..de3ce05 100644
--- a/rpmqv.c
+++ b/rpmqv.c
@@ -1,5 +1,4 @@
 #include "system.h"
-const char *__progname;
 
 #include <rpm/rpmcli.h>
 #include <rpm/rpmlib.h>			/* RPMSIGTAG, rpmReadPackageFile .. */
diff --git a/rpmspec.c b/rpmspec.c
index 2027ffa..8baba77 100644
--- a/rpmspec.c
+++ b/rpmspec.c
@@ -1,5 +1,4 @@
 #include "system.h"
-const char *__progname;
 
 #include <rpm/rpmcli.h>
 #include <rpm/rpmbuild.h>
diff --git a/system.h b/system.h
index 99691f4..3a57f4c 100644
--- a/system.h
+++ b/system.h
@@ -90,20 +90,7 @@ extern int fdatasync(int fildes);
 #define xstrdup(_str) rstrdup((_str))
 #define _free(_ptr) rfree((_ptr))
 
-/* Retrofit glibc __progname */
-#if defined __GLIBC__ && __GLIBC__ >= 2
-#if __GLIBC_MINOR__ >= 1
-#define	__progname	__assert_program_name
-#endif
-#define	setprogname(pn)
-#else
-#define	__progname	program_name
-#define	setprogname(pn)	\
-  { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
-    else __progname = pn;		\
-  }
-#endif
-extern const char *__progname;
+#define __progname getprogname()
 
 /* Take care of NLS matters.  */
 #if ENABLE_NLS
diff --git a/tools/rpmdeps.c b/tools/rpmdeps.c
index ff785f0..9b0bfb5 100644
--- a/tools/rpmdeps.c
+++ b/tools/rpmdeps.c
@@ -1,5 +1,4 @@
 #include "system.h"
-const char *__progname;
 
 #include <rpm/rpmbuild.h>
 #include <rpm/argv.h>
diff --git a/tools/rpmgraph.c b/tools/rpmgraph.c
index 57d2eda..9576793 100644
--- a/tools/rpmgraph.c
+++ b/tools/rpmgraph.c
@@ -1,5 +1,4 @@
 #include "system.h"
-const char *__progname;
 
 #include <rpm/rpmcli.h>
 #include <rpm/rpmlib.h>		/* rpmReadPackageFile */
-- 
2.6.4

_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to