From owner-freebsd-ports Sun Apr 30 8:17: 2 2000 Delivered-To: freebsd-ports@freebsd.org Received: from air.web.us.uu.net (air.web.us.uu.net [208.212.208.1]) by hub.freebsd.org (Postfix) with ESMTP id DE71F37B749 for ; Sun, 30 Apr 2000 08:16:45 -0700 (PDT) (envelope-from djm@air.web.us.uu.net) Received: (from djm@localhost) by air.web.us.uu.net (8.9.3/8.9.3) id LAA10995; Sun, 30 Apr 2000 11:16:37 -0400 X-Authentication-Warning: air.web.us.uu.net: djm set sender to djm@air.web.us.uu.net using -f From: "David J. MacKenzie" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14604.20052.950286.273870@air.web.us.uu.net> Date: Sun, 30 Apr 2000 11:16:36 -0400 (EDT) To: rpm-list@redhat.com, mycroft@netbsd.org, ports@freebsd.org Subject: port of rpm 3.0.x to BSD X-Mailer: VM 6.72 under Emacs 20.5.1 Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The NetBSD and FreeBSD packages for rpm still seem to be a 2.x version. Here is a port of the 3.0.4 version. Most or all of it applies as well to OpenBSD and BSD/OS. Problems fixed by this patch: 1. The RPM sources didn't support getmntinfo(), and tried to open the nonexistent /etc/mnttab and died. NetBSD, FreeBSD, and BSD/OS have the same function and problem. 2. The macros file got installed without _vendor and _host_vendor defined, and rpm refused to run until they were defined. This is because the NetBSD (and FreeBSD similarly) package system passes the configure option "--host=sparc--netbsd", with an (illegal) empty vendor. I suggest "sun" as the vendor on sparcs, and "pc" on pc's... "unknown" if you want to be lazy. 3. The RPM build process used the BSD libc glob() but the included GNU glob.h, resulting in a bus error when trying to expand a wildcard in the %files section while making a package with "rpm -bi" (or -bb). The 4.4BSD glob.h does define a gl_stat member, which configure tests for as a GNU extension. I removed the check for glob.h from configure.in, because whether to use the system glob.h is completely determined by whether we're using the one that comes with RPM. The places that include glob.h were changed to use USE_GNU_GLOB instead of HAVE_GLOB_H. Both system.h and rpmio.h don't need to include glob.h, and they were doing it in different ways. Also, some of the subdirectories compile with -I../misc, thus forcing them to get the wrong version of the file. So I renamed misc/glob.h to misc/gnuglob.h to avoid any possibililty of accidentally getting it when intending to get the libc version. That renaming looks like this in misc/rpm3/Makefile: pre-configure: @(cd ${WRKSRC} && autoreconf --force) @(cd ${WRKSRC} && mv -f misc/glob.h misc/gnuglob.h) The cache variable name rpm_cv_glob is confusingly vague; rpm_cv_glob_gnu would be clearer. I didn't change it, though. 4. The external symbol "timezone" is assumed by RPM to be an integer, as it is on Linux and Solaris, but on 4.4BSD it is a function that returns a char *. Also, configure sets HAS_TIMEZONE, but doesn't use it. acconfig.h and system.h use NEED_TIMEZONE, which configure doesn't set. On BSD (and Linux with its BSD compatibility), you want -time.tm_gmtoff. The warning sign you see on BSD is: parseChangelog.c: In function `dateToTimet': parseChangelog.c:88: warning: pointer to a function used in arithmetic parseChangelog.c:88: warning: assignment makes integer from pointer without a cast 5. NetBSD has sys/mount.h and struct statfs, but it needs sys/param.h to be included first. 6. The find-provides script for FreeBSD doesn't quite work on 4.0 (x86). A small change to the regexp was all that's needed, to get rid of the word "shared". bash-2.03# file -L libc.so libc.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (FreeBSD), stripped Also fixed: files.c: In function `initSourceHeader': files.c:1344: warning: assignment makes pointer from integer without a cast files.c:1378: warning: assignment makes pointer from integer without a cast parsePrep.c: In function `doPatch': parsePrep.c:109: warning: implicit declaration of function `basename' oldheader.c: In function `oldhdrReadFromStream': oldheader.c:48: warning: return discards `const' from pointer target type oldheader.c:93: warning: return discards `const' from pointer target type oldheader.c:112: warning: return discards `const' from pointer target type oldheader.c:122: warning: return discards `const' from pointer target type oldheader.c:129: warning: return discards `const' from pointer target type oldheader.c:136: warning: return discards `const' from pointer target type rpmchecksig.c: In function `rpmCheckSig': rpmchecksig.c:283: warning: assignment makes pointer from integer without a cast rpm.c: In function `main': rpm.c:577: warning: assignment discards `const' from pointer target type rpmgettext.c: At top level: rpmgettext.c:96: warning: `getTypeString' defined but not used Not fixed: creating perl/Makefile sed: ./perl/Makefile.in: No such file or directory creating perl/Makefile.PL sed: ./perl/Makefile.PL.in: No such file or directory creating config.h linking ./intl/libgettext.h to intl/libintl.h configuring in popt dcgettext.c:102: warning: function declaration isn't a prototype rpmio.c: In function `fdSeek': rpmio.c:595: warning: long int format, different type arg (arg 4) rpmio.c: In function `gzdSeek': rpmio.c:2285: warning: long int format, different type arg (arg 4) rpmgettext.c: In function `gettextfile': rpmgettext.c:323: warning: implicit declaration of function `basename' rpmgettext.c:323: warning: format argument is not a pointer (arg 3) rpmgettext.c:334: warning: passing arg 2 of `strcpy' makes pointer from integer without a cast rpmgettext.c: In function `rpmgettext': rpmgettext.c:827: warning: assignment makes pointer from integer without a cast Also, after installing rpm, I think the ports Makefiles should do: rpm --initdb And on systems with shared libraries, also: rm -f /etc/rpmrc for x in /usr/lib /usr/*/lib; do cd $x && \ls -1 | /usr/local/lib/rpm/find-provides | sed 's/^/provides: /' >> /etc/rpmrc done --- ../../rpm-3.0.4/acconfig.h Thu Mar 9 13:13:03 2000 +++ ./acconfig.h Sun Apr 30 03:11:29 2000 @@ -53,14 +53,20 @@ /* Define as 1 if defines S_ISSOCK */ #undef HAVE_S_ISSOCK -/* Define as 1 if we need timezone */ -#undef NEED_TIMEZONE +/* Define as 1 if we have tm_gmtoff */ +#undef HAVE_TM_GMTOFF + +/* Define as 1 if we have int timezone */ +#undef HAVE_TIMEZONE /* Define as 1 if we need myrealloc */ #undef NEED_MYREALLOC /* Define as one if we need to include (along with ) */ #undef NEED_STRINGS_H + +/* Define as 1 if you have getmntinfo() (4.4BSD) */ +#undef HAVE_GETMNTINFO /* Define as 1 if you have getmntinfo_r() (only osf?) */ #undef HAVE_GETMNTINFO_R --- ../../rpm-3.0.4/build/files.c Mon Feb 21 22:09:53 2000 +++ ./build/files.c Sun Apr 30 02:39:58 2000 @@ -1338,10 +1338,8 @@ spec->sourceHeader = headerNew(); /* Only specific tags are added to the source package header */ - for (hi = headerInitIterator(spec->packages->header); - headerNextIterator(hi, &tag, &type, &ptr, &count); - ptr = ((type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE) - ? xfree(ptr), NULL : NULL)) + hi = headerInitIterator(spec->packages->header); + while (headerNextIterator(hi, &tag, &type, &ptr, &count)) { switch (tag) { case RPMTAG_NAME: @@ -1368,16 +1366,20 @@ /* do not copy */ break; } + if (type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE) + xfree(ptr); + ptr = NULL; } headerFreeIterator(hi); /* Add the build restrictions */ - for (hi = headerInitIterator(spec->buildRestrictions); - headerNextIterator(hi, &tag, &type, &ptr, &count); - ptr = ((type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE) - ? xfree(ptr), NULL : NULL)) + hi = headerInitIterator(spec->buildRestrictions); + while (headerNextIterator(hi, &tag, &type, &ptr, &count)) { headerAddEntry(spec->sourceHeader, tag, type, ptr, count); + if (type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE) + xfree(ptr); + ptr = NULL; } headerFreeIterator(hi); --- ../../rpm-3.0.4/build/parseChangelog.c Mon Jan 24 15:02:32 2000 +++ ./build/parseChangelog.c Sun Apr 30 03:17:09 2000 @@ -85,7 +85,11 @@ if (*secs == -1) return -1; /* adjust to GMT */ +#ifdef HAVE_TM_GMTOFF + *secs -= time.tm_gmtoff; +#elif HAVE_TIMEZONE *secs += timezone; +#endif return 0; } --- ../../rpm-3.0.4/build/parsePrep.c Sun Feb 27 15:50:52 2000 +++ ./build/parsePrep.c Sun Apr 30 03:26:14 2000 @@ -7,6 +7,10 @@ #include #include +#if !defined(HAVE_BASENAME) +extern char *basename (const char *__filename); +#endif + /* These have to be global to make up for stupid compilers */ static int leaveDirs, skipDefaultAction; static int createDir, quietly; --- ../../rpm-3.0.4/config.h.in Wed Mar 15 07:33:33 2000 +++ ./config.h.in Sun Apr 30 02:39:57 2000 @@ -120,6 +120,9 @@ /* Define as one if we need to include (along with ) */ #undef NEED_STRINGS_H +/* Define as 1 if you have getmntinfo() (4.4BSD) */ +#undef HAVE_GETMNTINFO + /* Define as 1 if you have getmntinfo_r() (only osf?) */ #undef HAVE_GETMNTINFO_R @@ -315,9 +318,6 @@ /* Define if you have the header file. */ #undef HAVE_GETOPT_H - -/* Define if you have the header file. */ -#undef HAVE_GLOB_H /* Define if you have the header file. */ #undef HAVE_GRP_H --- ../../rpm-3.0.4/configure.in Wed Mar 15 07:29:09 2000 +++ ./configure.in Sun Apr 30 03:20:44 2000 @@ -411,8 +411,6 @@ fi AC_SUBST(BUILD_RPMNLSTOOLS) -AC_CHECK_HEADERS(glob.h) - dnl statfs portability fiddles. dnl dnl We should really emulate/steal sections of the statfs and struct statfs @@ -458,6 +456,7 @@ #ifdef HAVE_SYS_TYPES_H #include #endif +#include #include ], [struct statfs sfs;], [AC_MSG_RESULT(in sys/mount.h) @@ -583,10 +582,29 @@ AC_DEFINE(HAVE_S_ISSOCK) fi -AC_MSG_CHECKING(if timezone is defined) -AC_TRY_LINK([#include ],printf("%ld", timezone), - HAS_TIMEZONE=yes,HAS_TIMEZONE=no) -AC_MSG_RESULT($HAS_TIMEZONE) +# BSD has tm_gmtoff. +AC_CACHE_CHECK([for tm_gmtoff in struct tm],rpm_cv_struct_tm_gmtoff, +[AC_TRY_LINK([#include ],[struct tm t; t.tm_gmtoff = 0;], + rpm_cv_struct_tm_gmtoff=yes,rpm_cv_struct_tm_gmtoff=no)]) +if test "$rpm_cv_struct_tm_gmtoff" = yes; then + AC_DEFINE(HAVE_TM_GMTOFF) +else + # BSD has char *timezone(). + AC_CACHE_CHECK([if timezone is defined as a function],rpm_cv_func_timezone, + [AC_TRY_LINK([#include ],[char *s = timezone();], + rpm_cv_func_timezone=yes,rpm_cv_func_timezone=no)]) + if test "$rpm_cv_func_timezone" = no; then + # Linux has extern long timezone. + AC_CACHE_CHECK([if timezone is defined as an integer],rpm_cv_int_timezone, + [AC_TRY_LINK([#include ],[long t = timezone], + rpm_cv_int_timezone=yes,rpm_cv_int_timezone=no)]) + if test "$rpm_cv_int_timezone" = yes; then + AC_DEFINE(HAVE_TIMEZONE) + else + AC_MSG_ERROR([neither tm_gmtoff nor int timezone found]) + fi + fi +fi dnl Check for missing typedefs AC_TYPE_MODE_T @@ -685,10 +703,11 @@ AC_CHECK_FUNC(getmntent, AC_DEFINE(HAVE_GETMNTENT), [ AC_CHECK_FUNC(mntctl, AC_DEFINE(HAVE_MNTCTL),[ + AC_CHECK_FUNC(getmntinfo, AC_DEFINE(HAVE_GETMNTINFO),[ AC_CHECK_FUNC(getmntinfo_r, AC_DEFINE(HAVE_GETMNTINFO_R), [ AC_CHECK_LIB(c_r, getmntinfo_r, [LIBS="$LIBS -lc_r"; AC_DEFINE(HAVE_GETMNTINFO_R)], - LIBOBJS="$LIBOBJS getmntent.o")])])]) + LIBOBJS="$LIBOBJS getmntent.o")])])])]) AC_CHECK_FUNC(lchown, [__CHOWN_RHF="%{__chown} -Rhf" --- ../../rpm-3.0.4/lib/oldheader.c Wed Nov 10 17:09:49 1999 +++ ./lib/oldheader.c Sun Apr 30 03:28:04 2000 @@ -45,7 +45,7 @@ unsigned int groupLength; if (timedRead(fd, (char *)&lit, sizeof(lit)) != sizeof(lit)) { - return Fstrerror(fd); + return (char *) Fstrerror(fd); } bytesRead = sizeof(lit); @@ -90,7 +90,7 @@ if (timedRead(fd, header->group, groupLength) != groupLength) { oldhdrFree(header); - return Fstrerror(fd); + return (char *) Fstrerror(fd); } header->group[groupLength] = '\0'; bytesRead += groupLength; @@ -109,7 +109,7 @@ if (timedRead(fd, header->icon, header->iconLength) != header->iconLength) { oldhdrFree(header); - return Fstrerror(fd); + return (char *) Fstrerror(fd); } bytesRead += header->iconLength; } else { @@ -119,21 +119,21 @@ while (bytesRead < specOffset) { if (timedRead(fd, &ch, 1) != 1) { oldhdrFree(header); - return Fstrerror(fd); + return (char *) Fstrerror(fd); } bytesRead++; } if (timedRead(fd, header->spec, header->specLength) != header->specLength) { oldhdrFree(header); - return Fstrerror(fd); + return (char *) Fstrerror(fd); } bytesRead += header->specLength; while (bytesRead < archiveOffset) { if (timedRead(fd, &ch, 1) != 1) { oldhdrFree(header); - return Fstrerror(fd); + return (char *) Fstrerror(fd); } bytesRead++; } --- ../../rpm-3.0.4/lib/rpmchecksig.c Tue Jan 4 08:12:08 2000 +++ ./lib/rpmchecksig.c Sun Apr 30 03:29:23 2000 @@ -277,10 +277,8 @@ untrustedKeys[0] = '\0'; sprintf(buffer, "%s:%c", rpm, (rpmIsVerbose() ? '\n' : ' ') ); - for (sigIter = headerInitIterator(sig); - headerNextIterator(sigIter, &tag, &type, &ptr, &count); - ptr = ((type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE) - ? xfree(ptr), NULL : NULL)) + sigIter = headerInitIterator(sig); + while (headerNextIterator(sigIter, &tag, &type, &ptr, &count)) { switch (tag) { case RPMSIGTAG_PGP5: /* XXX legacy */ @@ -398,6 +396,9 @@ } } } + if (type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE) + xfree(ptr); + ptr = NULL; } headerFreeIterator(sigIter); res += res2; --- ../../rpm-3.0.4/lib/rpmio.h Thu Dec 16 16:58:20 1999 +++ ./lib/rpmio.h Sun Apr 30 02:39:57 2000 @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include --- ../../rpm-3.0.4/lib/transaction.c Tue Feb 22 07:05:13 2000 +++ ./lib/transaction.c Sun Apr 30 02:39:57 2000 @@ -21,6 +21,7 @@ # include # else # if STATFS_IN_SYS_MOUNT +# include # include # else # if STATFS_IN_SYS_STATFS --- ../../rpm-3.0.4/python/rpmmodule.c Mon Feb 28 15:00:31 2000 +++ ./python/rpmmodule.c Sun Apr 30 02:39:57 2000 @@ -4,7 +4,11 @@ #include #include #include -#include /* XXX rpmio.h */ +#if !defined(USE_GNU_GLOB) +#include +#else +#include "misc/gnuglob.h" +#endif #include /* XXX rpmio.h */ #include "Python.h" --- ../../rpm-3.0.4/python/upgrade.c Mon Jan 31 11:42:12 2000 +++ ./python/upgrade.c Sun Apr 30 02:39:58 2000 @@ -4,7 +4,11 @@ #include #include -#include /* XXX rpmio.h */ +#if !defined(USE_GNU_GLOB) +#include +#else +#include "misc/gnuglob.h" +#endif #include /* XXX rpmio.h */ #include --- ../../rpm-3.0.4/rpm.c Wed Mar 15 07:31:44 2000 +++ ./rpm.c Sun Apr 30 03:33:43 2000 @@ -574,7 +574,7 @@ #if HAVE_MCHECK_H && HAVE_MTRACE mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */ #endif - setprogname(argv[0]); /* Retrofit glibc __progname */ + setprogname((char *) argv[0]); /* Retrofit glibc __progname */ /* set the defaults for the various command line options */ allFiles = 0; --- ../../rpm-3.0.4/system.h Sat Mar 11 15:14:07 2000 +++ ./system.h Sun Apr 30 03:14:58 2000 @@ -47,11 +47,6 @@ # endif #endif -#if NEED_TIMEZONE -extern time_t timezone; -#endif - - /* Since major is a function on SVR4, we can't use `ifndef major'. */ #if MAJOR_IN_MKDEV #include @@ -272,11 +267,10 @@ #include #endif -#if HAVE_GLOB_H +/* You'd better have glob.h if you're not using our glob! */ #include -#endif #else -#include "misc/glob.h" +#include "misc/gnuglob.h" #include "misc/fnmatch.h" #endif @@ -330,7 +324,7 @@ #define lchown chown #endif -#if HAVE_GETMNTINFO_R || HAVE_MNTCTL +#if HAVE_GETMNTINFO_R || HAVE_GETMNTINFO || HAVE_MNTCTL # define GETMNTENT_ONE 0 # define GETMNTENT_TWO 0 # if HAVE_SYS_MNTCTL_H --- ../../rpm-3.0.4/tools/rpmgettext.c Sun Nov 14 14:15:18 1999 +++ ./tools/rpmgettext.c Sun Apr 30 03:38:01 2000 @@ -91,6 +91,7 @@ {NULL, 0} }; +#if 0 static char * getTypeString(int tval) { @@ -104,6 +105,7 @@ sprintf(buf, "", tval); return buf; } +#endif /* ================================================================== */ --- ../../rpm-3.0.4/misc/Makefile.am Thu Mar 9 13:13:03 2000 +++ ./misc/Makefile.am Sun Apr 30 04:08:10 2000 @@ -18,7 +18,7 @@ noinst_HEADERS = \ err.h error.h fnmatch.h fstrcmp.h \ - glob.h libgettext.h message.h po-lex.h \ + gnuglob.h libgettext.h message.h po-lex.h \ str-list.h fstrcmp.h noinst_LIBRARIES = libmisc.a --- ../../rpm-3.0.4/lib/fs.c Sun Feb 27 15:50:52 2000 +++ ./lib/fs.c Sun Apr 30 04:19:04 2000 @@ -118,7 +118,7 @@ # if GETMNTENT_ONE || GETMNTENT_TWO our_mntent item; FILE * mtab; -# elif HAVE_GETMNTINFO_R +# elif HAVE_GETMNTINFO_R || HAVE_GETMNTINFO struct statfs * mounts = NULL; int mntCount = 0, bufSize = 0, flags = MNT_NOWAIT; int nextMount = 0; @@ -133,6 +133,8 @@ strerror(errno)); return 1; } +# elif HAVE_GETMNTINFO + mntCount = getmntinfo(&mounts, flags); # elif HAVE_GETMNTINFO_R getmntinfo_r(&mounts, flags, &mntCount, &bufSize); # endif @@ -151,7 +153,7 @@ /* Solaris, maybe others */ if (getmntent(mtab, &item)) break; mntdir = item.our_mntdir; -# elif HAVE_GETMNTINFO_R +# elif HAVE_GETMNTINFO_R || HAVE_GETMNTINFO if (nextMount == mntCount) break; mntdir = mounts[nextMount++].f_mntonname; # endif --- ../../rpm-3.0.4/autodeps/freebsd.prov Sun Feb 6 14:05:36 2000 +++ ./autodeps/freebsd.prov Sun Apr 30 04:56:48 2000 @@ -2,7 +2,7 @@ # ---------------------------------------------------------- # find-provides for FreeBSD-2.2.x # ---------------------------------------------------------- -filelist=$(grep "\\.so" | grep -v "^/lib/ld.so" | xargs file -L 2>/dev/null | grep "FreeBSD.*shared" | cut -d: -f1) +filelist=$(grep "\\.so" | grep -v "^/lib/ld.so" | xargs file -L 2>/dev/null | grep "FreeBSD" | cut -d: -f1) for f in $filelist; do echo ${f##*/} To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message