$NetBSD: patch-ac,v 1.2 2004/11/05 16:44:46 agc Exp $ --- gensolpkg.c.in.orig Sat May 5 15:44:31 2001 +++ gensolpkg.c.in Fri Nov 5 16:19:24 2004 @@ -79,7 +79,7 @@ static char comment[256 + 1]; /* one line descr of pkg */ static char prefix[MAXPATHLEN]; /* current prefix */ -static char *workdir; /* name of working directory */ +static char workdir[MAXPATHLEN]; /* name of working directory */ static char *category; /* category of package - default "application" */ static int transform; /* transform the package - default "disabled" */ @@ -357,9 +357,9 @@ } (void) fprintf(fp, "!PKG=%s\n", pkg); (void) fprintf(fp, "!PREFIX=%s\n", prefix); - (void) fprintf(fp, "i pkginfo=%s/%s\n", getcwd(buf, sizeof(buf)), pkginfofile); - (void) fprintf(fp, "i version=%s/%s\n", getcwd(buf, sizeof(buf)), versionfile); - (void) fprintf(fp, "i depend=%s/%s\n", getcwd(buf, sizeof(buf)), dependfile); + (void) fprintf(fp, "i pkginfo=%s\n", pkginfofile); + (void) fprintf(fp, "i version=%s\n", versionfile); + (void) fprintf(fp, "i depend=%s\n", dependfile); for (linec = 1 ; fgets(buf, sizeof(buf), plist) != (char *) NULL ; linec++) { /* trim leading whitespace from PLIST entries */ for (cp = buf ; isspace(*cp) ; cp++) { @@ -463,7 +463,7 @@ (void) fputc('\n', fp2); } (void) fclose(fp2); - (void) fprintf(fp, "i postinstall=%s/%s/.postinstall\n", getcwd(buf, sizeof(buf)), workdir); + (void) fprintf(fp, "i postinstall=%s/.postinstall\n", workdir); } if (remove.s_c > 0) { (void) snprintf(f, sizeof(f), "%s/.postremove", workdir); @@ -493,7 +493,7 @@ (void) fputc('\n', fp2); } (void) fclose(fp2); - (void) fprintf(fp, "i postremove=%s/%s/.postremove\n", getcwd(buf, sizeof(buf)), workdir); + (void) fprintf(fp, "i postremove=%s/.postremove\n", workdir); } (void) fclose(fp); (void) fclose(plist); @@ -572,13 +572,17 @@ int i; (void) strcpy(prefix, "@PREFIX@"); - (void) strcpy(bmake, "@PREFIX@/bsd/bin/bmake"); + (void) strcpy(bmake, "@PREFIX@/bin/bmake"); (void) strcpy(output, "/tmp"); (void) strcpy(pkgdir, "@SPOOLDIR@"); transform = 0; - workdir = "work"; category = "application"; pkg = (char *) NULL; + (void) snprintf(cmd, sizeof(cmd), "%s show-var VARNAME=WRKDIR", bmake); + if (!pipeit(workdir, sizeof(workdir), cmd, "r")) { + (void) fprintf(stderr, "Warning: can't find package workdir\n"); + exit(1); + } (void) snprintf(cmd, sizeof(cmd), "%s show-var VARNAME=PREFIX", bmake); if (!pipeit(prefix, sizeof(prefix), cmd, "r")) { (void) fprintf(stderr, "Can't find package prefix\n"); @@ -633,7 +637,7 @@ transform = 1; break; case 'w': - workdir = optarg; + (void) strnncpy(workdir, sizeof(workdir), optarg, strlen(optarg)); break; default: fprintf(stderr, "Usage:\n");