Subject: pkg/23921: pkgtools/rpm2pkg won't compile on systems missing cpio.h; trival fix included
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <dotz@irc.pl>
List: netbsd-bugs
Date: 12/29/2003 03:01:44
>Number:         23921
>Category:       pkg
>Synopsis:       pkgtools/rpm2pkg won't compile on systems missing cpio.h; trival fix included
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 29 03:02:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Michal Pasternak
>Release:        N/A
>Organization:
>Environment:
FreeBSD mainframe.w.lub.pl 4.9-STABLE FreeBSD 4.9-STABLE #0: Thu Dec 25 12:02:15 CET 2003     doc@mainframe.w.lub.pl:/usr/obj/usr/src/sys/MP-UX  i386

>Description:

rpm2pkg won't compile on systems missing cpio.h

some of such systems include widely-used FreeBSD-4-STABLE

emulators/suse_* packages depend on rpm2pkg

I have commited a FreeBSD PR about this:
http://www.freebsd.org/cgi/query-pr.cgi?pr=60597
and IMO this is the prefered way to fix this (make OS conformant to 
POSIX and XRG standards and not clobber rpm2pkg sources) But, in 
discussion about
http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=23900
Frederick Bruckman insisted on providing a fix for rpm2pkg, so here it is.

>How-To-Repeat:
Obvious.
>Fix:
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/rpm2pkg/Makefile,v
retrieving revision 1.19
diff -u -r1.19 Makefile
--- Makefile    17 Jul 2003 22:52:19 -0000      1.19
+++ Makefile    29 Dec 2003 02:58:45 -0000
@@ -19,6 +19,10 @@
 CFLAGS+=       ${BUILDLINK_CPPFLAGS.rpm}
 LIBS=          -lrpm -lintl -lz
 
+.if !exists(/usr/include/cpio.h)
+CFLAGS+=       -DMISSING_CPIO_H
+.endif
+
 do-build:
        ${BUILDLINK_CC} ${CFLAGS} ${LDFLAGS} -o ${WRKSRC}/rpm2pkg \
                ${FILESDIR}/rpm2pkg.c ${LIBS}
Index: files/rpm2pkg.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/rpm2pkg/files/rpm2pkg.c,v
retrieving revision 1.3
diff -u -r1.3 rpm2pkg.c
--- files/rpm2pkg.c     9 Dec 2002 15:16:27 -0000       1.3
+++ files/rpm2pkg.c     29 Dec 2003 02:58:45 -0000
@@ -13,8 +13,31 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-
+#ifndef MISSING_CPIO_H
 #include <cpio.h>
+#else
+#define C_IRUSR                0000400
+#define C_IWUSR                0000200
+#define C_IXUSR                0000100
+#define C_IRGRP                0000040
+#define C_IWGRP                0000020
+#define C_IXGRP                0000010
+#define C_IROTH                0000004
+#define C_IWOTH                0000002
+#define C_IXOTH                0000001
+#define C_ISUID                0004000
+#define C_ISGID                0002000
+#define C_ISVTX                0001000
+#define C_ISDIR                0040000
+#define C_ISFIFO       0010000
+#define C_ISREG                0100000
+#define C_ISBLK                0060000
+#define C_ISCHR                0020000
+#define C_ISCTG                0110000
+#define C_ISLNK                0120000
+#define C_ISSOCK       0140000
+#define MAGIC          "070707"
+#endif
 #include <rpmlib.h>
 #include <zlib.h>
 

>Release-Note:
>Audit-Trail:
>Unformatted: