Subject: Re: pkg/29152: pkgfind patch for linux and openbsd
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Peter Postma <peter@pointless.nl>
List: pkgsrc-bugs
Date: 01/30/2005 13:22:01
The following reply was made to PR pkg/29152; it has been noted by GNATS.
From: Peter Postma <peter@pointless.nl>
To: "Julio M. Merino Vidal" <jmmv84@gmail.com>
Cc: gnats-bugs@netbsd.org, jschauma@netbsd.org
Subject: Re: pkg/29152: pkgfind patch for linux and openbsd
Date: Sun, 30 Jan 2005 14:21:12 +0100
--Q68bSM7Ycu6FN28Q
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Sun, Jan 30, 2005 at 01:07:57PM +0100, Peter Postma wrote:
>
> I've attached a diff that attempts to make it more portable, I would
> appreciate if you could test it on a non-NetBSD system.
>
emh, now with attachment.
--
Peter Postma
--Q68bSM7Ycu6FN28Q
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pkgfind.diff"
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkgfind/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- Makefile 27 Jan 2005 20:42:23 -0000 1.8
+++ Makefile 30 Jan 2005 12:04:19 -0000
@@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.8 2005/01/27 20:42:23 jschauma Exp $
-DISTNAME= pkgfind-20050127
+DISTNAME= pkgfind-20050130
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
@@ -32,12 +32,4 @@
SUBST_SED.path= -e "s,/usr/pkgsrc,${PKGSRCDIR},g"
SUBST_MESSAGE.path= "Adjusting pkgsrc directory."
-.include "../../mk/bsd.prefs.mk"
-
-.if ${OPSYS} == "IRIX"
-CFLAGS+= -DNEED_LIBNBCOMPAT
-LDFLAGS+= -lnbcompat
-. include "../../pkgtools/libnbcompat/buildlink3.mk" # need err(1), warn(1)
-.endif
-
.include "../../mk/bsd.pkg.mk"
Index: files/pkgfind.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkgfind/files/pkgfind.c,v
retrieving revision 1.5
diff -u -r1.5 pkgfind.c
--- files/pkgfind.c 27 Jan 2005 20:42:23 -0000 1.5
+++ files/pkgfind.c 30 Jan 2005 12:04:19 -0000
@@ -38,14 +38,9 @@
#include <sys/param.h>
#include <sys/stat.h>
-#ifdef NEED_LIBNBCOMPAT
-#include <nbcompat.h>
-#else
-#include <err.h>
-#endif
-
#include <ctype.h>
#include <dirent.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -76,8 +71,6 @@
const char *path;
int ch;
- setprogname("pkgfind");
-
/* default searches have partial matches */
search = partialmatch;
@@ -126,25 +119,27 @@
char *text, *comment = NULL;
struct stat sb;
- if ((ncat = scandir(path, &cat, checkskip, alphasort)) < 0)
- err(EXIT_FAILURE, "%s", path);
+ if ((ncat = scandir(path, &cat, checkskip, alphasort)) < 0) {
+ fprintf(stderr, "%s: %s", path, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
for (i = 0; i < ncat; i++) {
if (snprintf(tmp, sizeof(tmp), "%s/%s", path, cat[i]->d_name)
>= sizeof(tmp)) {
- warnx("filename too long");
+ fprintf(stderr, "filename too long");
continue;
}
if (stat(tmp, &sb) < 0 || !S_ISDIR(sb.st_mode))
continue;
if ((nlist = scandir(tmp, &list, checkskip, alphasort)) < 0) {
- warn("%s", tmp);
+ fprintf(stderr, "%s: %s", tmp, strerror(errno));
continue;
}
for (j = 0; j < nlist; j++) {
if (snprintf(tmp, sizeof(tmp), "%s/%s/%s", path,
cat[i]->d_name, list[j]->d_name) >= sizeof(tmp)) {
- warnx("filename too long");
+ fprintf(stderr, "filename too long");
continue;
}
if (stat(tmp, &sb) < 0 || !S_ISDIR(sb.st_mode))
@@ -177,13 +172,17 @@
len = strlen(path) + strlen(cat) + strlen(pkg) + strlen("Makefile") + 3 + 1;
if (!qflag) {
- if ((mk = malloc(len)) == NULL)
- err(EXIT_FAILURE, "malloc");
+ if ((mk = malloc(len)) == NULL) {
+ fprintf(stderr, "malloc: %s", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
(void)snprintf(mk, len, "%s/%s/%s/Makefile", path, cat, pkg);
if (getcomment(mk, &comment) == 0) {
- if ((mk = realloc(mk, len + 7)) == NULL)
- err(EXIT_FAILURE, "malloc");
+ if ((mk = realloc(mk, len + 7)) == NULL) {
+ fprintf(stderr, "malloc: %s", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
(void)snprintf(mk, len+7, "%s/%s/%s/Makefile.common",
path, cat, pkg);
(void)getcomment(mk, &comment);
@@ -268,6 +267,8 @@
static void
usage(void)
{
- (void)fprintf(stderr, "Usage: %s [-Ccqx] keyword [...]\n", getprogname());
+ extern char *__progname;
+
+ (void)fprintf(stderr, "Usage: %s [-Ccqx] keyword [...]\n", __progname);
exit(EXIT_FAILURE);
}
--Q68bSM7Ycu6FN28Q--