NetBSD Problem Report #45047

From www@NetBSD.org  Fri Jun 10 15:53:56 2011
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 47BD663BEFB
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 10 Jun 2011 15:53:56 +0000 (UTC)
Message-Id: <20110610155354.E4D1563B970@www.NetBSD.org>
Date: Fri, 10 Jun 2011 15:53:54 +0000 (UTC)
From: tcort@minix3.org
Reply-To: tcort@minix3.org
To: gnats-bugs@NetBSD.org
Subject: pkgtools/pkg_install minix support
X-Send-Pr-Version: www-1.0

>Number:         45047
>Category:       pkg
>Synopsis:       pkgtools/pkg_install minix support
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    agc
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 10 15:55:00 +0000 2011
>Last-Modified:  Tue Jul 19 13:10:03 +0000 2011
>Originator:     Thomas Cort
>Release:        N/A
>Organization:
Minix3
>Environment:
Minix 192.168.122.210 3.2.0 i686
>Description:
Some changes need to be made to pkg_install for it to work properly on Minix. The release and version info returned in struct utsname is slightly different than on most systems. For Minix 3.2.0, release is "3" and version is "2.0". However, most other operating systems would store the whole thing ("3.2.0") in release. Also, some Minix systems use GNU ar (gar) instead of ar, so configure should also check for gar. Additionally, a few header files need to be included in some C source files. Lastly, the dependency checking should prevent endless recursion for circular dependencies.
>How-To-Repeat:
Try using pkg_install on Minix
>Fix:
diff --git a/pkgtools/pkg_install/Makefile b/pkgtools/pkg_install/Makefile
index 392093c..b262265 100644
--- a/pkgtools/pkg_install/Makefile
+++ b/pkgtools/pkg_install/Makefile
@@ -142,6 +142,10 @@ LIBS+=		-larchive
 CPPFLAGS+=	-I${WRKDIR}/libfetch
 LDFLAGS+=	-L${WRKDIR}/libfetch

+.  if ${OPSYS} == "Minix"
+LIBS+=		-larchive -lbz2 -lz
+.  endif
+
 CONFIGURE_ENV+=	LIBS=${LIBS:Q}

 do-extract:
diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c
index aa3dff3..cf7a5c5 100644
--- a/pkgtools/pkg_install/files/add/perform.c
+++ b/pkgtools/pkg_install/files/add/perform.c
@@ -52,6 +52,7 @@ __RCSID("$NetBSD: perform.c,v 1.98 2010/09/14 22:26:18 gdt Exp $");
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <assert.h>

 #include <archive.h>
 #include <archive_entry.h>
@@ -126,7 +127,12 @@ static const struct pkg_meta_desc {
 	{ 0, NULL, 0, 0 },
 };

-static int pkg_do(const char *, int, int);
+struct dependency_stack {
+	struct dependency_stack *prev;
+	const char *pkgpath;
+};
+
+static int pkg_do(const char *, int, int, struct dependency_stack *);

 static int
 end_of_version(const char *opsys, const char *version_end)
@@ -738,7 +744,7 @@ extract_files(struct pkg_task *pkg)
 			continue;

 		case PLIST_CMD:
-			if (format_cmd(cmd, sizeof(cmd), p->name, pkg->prefix, last_file))
+			if (format_cmd(cmd, sizeof(cmd), p->name, pkg->install_prefix, last_file))
 				return -1;
 			printf("Executing '%s'\n", cmd);
 			if (!Fake && system(cmd))
@@ -858,6 +864,35 @@ pkg_register_depends(struct pkg_task *pkg)
 	free(text);
 }

+#ifdef __minix
+static void
+normalise_version(char *release, char *version)
+{
+	char actual_version[50];
+	int l1, l2;
+
+	assert(release && version);
+
+	l1 = strlen(release);
+	l2 = strlen(version);
+
+	assert(l1 + l2 + 2 < sizeof(actual_version));
+
+	if(l1 > 0 && l2 > 0)
+		snprintf(actual_version, sizeof(actual_version),
+			"%s.%s", release, version);
+        else if(strlen(release) > 0)
+		strncpy(actual_version, release, sizeof(actual_version)-1);
+	else if(strlen(version) > 0)
+		strncpy(actual_version, version, sizeof(actual_version)-1);
+	else
+		errx(EXIT_FAILURE, "no version info");
+
+	strcpy(release, actual_version);
+	version[0] = '\0';
+}
+#endif
+
 /*
  * Reduce the result from uname(3) to a canonical form.
  */
@@ -870,6 +905,9 @@ normalise_platform(struct utsname *host_name)
 	span = strspn(host_name->release, "0123456789.");
 	host_name->release[span] = '\0';
 #endif
+#ifdef __minix
+	normalise_version(host_name->release, host_name->version);
+#endif
 }

 /*
@@ -880,7 +918,7 @@ check_platform(struct pkg_task *pkg)
 {
 	struct utsname host_uname;
 	const char *effective_arch;
-	int fatal;
+	int fatal = 0;

 	if (uname(&host_uname) < 0) {
 		if (Force) {
@@ -906,6 +944,10 @@ check_platform(struct pkg_task *pkg)
 	else
 		fatal = 0;

+#ifdef __minix
+	normalise_version(host_uname.release, host_uname.version);
+#endif
+
 	if (fatal ||
 	    compatible_platform(OPSYS_NAME, host_uname.release,
 				pkg->buildinfo[BI_OS_VERSION]) != 1) {
@@ -1093,7 +1135,7 @@ check_implicit_conflict(struct pkg_task *pkg)
 }

 static int
-check_dependencies(struct pkg_task *pkg)
+check_dependencies(struct pkg_task *pkg, struct dependency_stack *dependency_stack)
 {
 	plist_t *p;
 	char *best_installed;
@@ -1124,7 +1166,7 @@ check_dependencies(struct pkg_task *pkg)
 				    p->name);
 				continue;
 			}
-			if (pkg_do(p->name, 1, 0)) {
+			if (pkg_do(p->name, 1, 0, dependency_stack)) {
 				if (ForceDepends) {
 					warnx("Can't install dependency %s, "
 					    "continuing", p->name);
@@ -1373,12 +1415,33 @@ check_license(struct pkg_task *pkg)
  * Install a single package.
  */
 static int
-pkg_do(const char *pkgpath, int mark_automatic, int top_level)
+pkg_do(const char *pkgpath, int mark_automatic, int top_level, 
+	struct dependency_stack *dependency_stack)
 {
 	char *archive_name;
 	int status, invalid_sig;
 	struct pkg_task *pkg;

+	/* workaround 2010-12-10: prevent endless recursion for circular dependencies */
+	struct dependency_stack dependency_stack_top;
+
+	dependency_stack_top.prev = dependency_stack;
+	dependency_stack_top.pkgpath = pkgpath;
+
+	while (dependency_stack) {
+		if (strcmp(dependency_stack->pkgpath, pkgpath) == 0) {
+			fprintf(stderr, "warning: ignoring circular dependency:\n");
+			dependency_stack = &dependency_stack_top;
+			while (dependency_stack) {
+				fprintf(stderr, "- %s\n", dependency_stack->pkgpath);
+				dependency_stack = dependency_stack->prev;
+			}
+			return 0;
+		}
+		dependency_stack = dependency_stack->prev;
+	}
+	/* end workaround */
+	
 	pkg = xcalloc(1, sizeof(*pkg));

 	status = -1;
@@ -1490,7 +1553,7 @@ pkg_do(const char *pkgpath, int mark_automatic, int top_level)
 			pkg->install_logdir_real = NULL;
 		}

-		if (check_dependencies(pkg))
+		if (check_dependencies(pkg, &dependency_stack_top))
 			goto nuke_pkgdb;
 	} else {
 		/*
@@ -1498,7 +1561,7 @@ pkg_do(const char *pkgpath, int mark_automatic, int top_level)
 		 * Install/update dependencies first and
 		 * write the current package to disk afterwards.
 		 */ 
-		if (check_dependencies(pkg))
+		if (check_dependencies(pkg, &dependency_stack_top))
 			goto clean_memory;

 		if (write_meta_data(pkg))
@@ -1582,7 +1645,7 @@ pkg_perform(lpkg_head_t *pkgs)
 	lpkg_t *lpp;

 	while ((lpp = TAILQ_FIRST(pkgs)) != NULL) {
-		if (pkg_do(lpp->lp_name, Automatic, 1))
+		if (pkg_do(lpp->lp_name, Automatic, 1, NULL))
 			++errors;
 		TAILQ_REMOVE(pkgs, lpp, lp_link);
 		free_lpkg(lpp);
diff --git a/pkgtools/pkg_install/files/configure b/pkgtools/pkg_install/files/configure
index 0be4828..232aaf1 100755
--- a/pkgtools/pkg_install/files/configure
+++ b/pkgtools/pkg_install/files/configure
@@ -3431,8 +3431,10 @@ else
   RANLIB="$ac_cv_prog_RANLIB"
 fi

-# Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
+for ac_prog in gar ar
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if ${ac_cv_prog_AR+:} false; then :
@@ -3448,7 +3450,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_AR="ar"
+    ac_cv_prog_AR="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -3468,6 +3470,9 @@ $as_echo "no" >&6; }
 fi


+  test -n "$AR" && break
+done
+

 # Extract the first word of "chmod", so it can be a program name with args.
 set dummy chmod; ac_word=$2
diff --git a/pkgtools/pkg_install/files/configure.ac b/pkgtools/pkg_install/files/configure.ac
index ece6517..74da9ff 100644
--- a/pkgtools/pkg_install/files/configure.ac
+++ b/pkgtools/pkg_install/files/configure.ac
@@ -16,7 +16,7 @@ AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_RANLIB
-AC_CHECK_PROG(AR, ar, ar)
+AC_CHECK_PROGS(AR, [gar ar])

 AC_PATH_PROG(CHMOD, chmod)
 AC_PATH_PROG(CMP, cmp)
diff --git a/pkgtools/pkg_install/files/info/show.c b/pkgtools/pkg_install/files/info/show.c
index e44a6c9..89940e3 100644
--- a/pkgtools/pkg_install/files/info/show.c
+++ b/pkgtools/pkg_install/files/info/show.c
@@ -60,6 +60,9 @@ __RCSID("$NetBSD: show.c,v 1.31 2010/11/22 09:00:12 joerg Exp $");
 #if HAVE_ERR_H
 #include <err.h>
 #endif
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif

 #include "defs.h"
 #include "lib.h"
diff --git a/pkgtools/pkg_install/files/lib/plist.c b/pkgtools/pkg_install/files/lib/plist.c
index f1b6c6d..d171ad4 100644
--- a/pkgtools/pkg_install/files/lib/plist.c
+++ b/pkgtools/pkg_install/files/lib/plist.c
@@ -514,6 +514,7 @@ delete_package(Boolean ign_err, package_t *pkg, Boolean NoDeleteFiles,
 	int     fail = SUCCESS;
 	Boolean preserve;
 	char    tmp[MaxPathSize];
+	char 	cmd[MaxPathSize];
 	const char *prefix = NULL, *name = NULL;

 	if (!pkgdb_open(ReadWrite)) {
@@ -580,10 +581,12 @@ delete_package(Boolean ign_err, package_t *pkg, Boolean NoDeleteFiles,
 		case PLIST_UNEXEC:
 			if (NoDeleteFiles)
 				break;
-			format_cmd(tmp, sizeof(tmp), p->name, prefix, last_file);
-			printf("Executing `%s'\n", tmp);
-			if (!Fake && system(tmp)) {
-				warnx("unexec command for `%s' failed", tmp);
+			(void) snprintf(tmp, sizeof(tmp), "%s%s%s",
+					destdir ? destdir : "", destdir ? "/" : "", prefix);
+			format_cmd(cmd, sizeof(cmd), p->name, tmp, last_file);
+			printf("Executing `%s'\n", cmd);
+			if (!Fake && system(cmd)) {
+				warnx("unexec command for `%s' failed", cmd);
 				fail = FAIL;
 			}
 			break;

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->agc
Responsible-Changed-By: obache@NetBSD.org
Responsible-Changed-When: Fri, 10 Jun 2011 23:43:44 +0000
Responsible-Changed-Why:
Over to maintainer.


From: Alistair Crooks <agc@pkgsrc.org>
To: gnats-bugs@NetBSD.org
Cc: pkg-manager@NetBSD.org, gnats-admin@NetBSD.org, pkgsrc-bugs@NetBSD.org
Subject: Re: pkg/45047: pkgtools/pkg_install minix support
Date: Sat, 11 Jun 2011 19:34:30 +0200

 On Fri, Jun 10, 2011 at 03:55:00PM +0000, tcort@minix3.org wrote:
 > >Description:
 > Some changes need to be made to pkg_install for it to work properly
 > on Minix.  The release and version info returned in struct utsname
 > is slightly different than on most systems.  For Minix 3.2.0,
 > release is "3" and version is "2.0".  However, most other operating
 > systems would store the whole thing ("3.2.0") in release.  Also,
 > some Minix systems use GNU ar (gar) instead of ar, so configure
 > should also check for gar.  Additionally, a few header files need to
 > be included in some C source files.  Lastly, the dependency checking
 > should prevent endless recursion for circular dependencies.

 Thanks for the diffs - great to see Minix support coming along!

 I'd like to see this make it into pkgsrc-2011Q2, but there are a
 number of changes here that are lumped together, and I feel that we'd
 be better off separating them out and considering them individually.

 Personally, I don't like to use assertions in production code.  We
 have seen too many failures at inopportune moments from systems like
 bind for me to believe that it's a good thing.  I'd like to replace
 the assertions with a check, and return a sane error to the calling
 function.

 I'd like to split out the dependency stack checks for recursive
 dependencies - it's not that it's the wrong thing or that we don't
 want it, simply that it's not related to Minix3 support per se.

 Can we use the dewey dependency functions for the Minix version
 number, or cons up a standard version number as expected from the two
 constituent parts?

 Many thanks,
 Alistair

From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/45047: pkgtools/pkg_install minix support
Date: Sat, 11 Jun 2011 19:57:58 +0200

 On Fri, Jun 10, 2011 at 03:55:00PM +0000, tcort@minix3.org wrote:
 > diff --git a/pkgtools/pkg_install/Makefile b/pkgtools/pkg_install/Makefile
 > index 392093c..b262265 100644
 > --- a/pkgtools/pkg_install/Makefile
 > +++ b/pkgtools/pkg_install/Makefile
 > @@ -142,6 +142,10 @@ LIBS+=		-larchive
 >  CPPFLAGS+=	-I${WRKDIR}/libfetch
 >  LDFLAGS+=	-L${WRKDIR}/libfetch
 >  
 > +.  if ${OPSYS} == "Minix"
 > +LIBS+=		-larchive -lbz2 -lz
 > +.  endif
 > +
 >  CONFIGURE_ENV+=	LIBS=${LIBS:Q}
 >  
 >  do-extract:

 This is wrong, it shouldn't be needed.

 > diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c
 > index aa3dff3..cf7a5c5 100644
 > --- a/pkgtools/pkg_install/files/add/perform.c
 > +++ b/pkgtools/pkg_install/files/add/perform.c
 > @@ -52,6 +52,7 @@ __RCSID("$NetBSD: perform.c,v 1.98 2010/09/14 22:26:18 gdt Exp $");
 >  #include <stdlib.h>
 >  #include <string.h>
 >  #include <unistd.h>
 > +#include <assert.h>
 >  
 >  #include <archive.h>
 >  #include <archive_entry.h>
 > @@ -126,7 +127,12 @@ static const struct pkg_meta_desc {
 >  	{ 0, NULL, 0, 0 },
 >  };
 >  
 > -static int pkg_do(const char *, int, int);
 > +struct dependency_stack {
 > +	struct dependency_stack *prev;
 > +	const char *pkgpath;
 > +};
 > +
 > +static int pkg_do(const char *, int, int, struct dependency_stack *);
 >  
 >  static int
 >  end_of_version(const char *opsys, const char *version_end)
 > @@ -738,7 +744,7 @@ extract_files(struct pkg_task *pkg)
 >  			continue;
 >  
 >  		case PLIST_CMD:
 > -			if (format_cmd(cmd, sizeof(cmd), p->name, pkg->prefix, last_file))
 > +			if (format_cmd(cmd, sizeof(cmd), p->name, pkg->install_prefix, last_file))
 >  				return -1;
 >  			printf("Executing '%s'\n", cmd);
 >  			if (!Fake && system(cmd))

 What are you trying to do here?

 > @@ -858,6 +864,35 @@ pkg_register_depends(struct pkg_task *pkg)
 >  	free(text);
 >  }
 >  
 > +#ifdef __minix
 > +static void
 > +normalise_version(char *release, char *version)
 > +{
 > +	char actual_version[50];
 > +	int l1, l2;
 > +
 > +	assert(release && version);
 > +
 > +	l1 = strlen(release);
 > +	l2 = strlen(version);
 > +
 > +	assert(l1 + l2 + 2 < sizeof(actual_version));
 > +
 > +	if(l1 > 0 && l2 > 0)
 > +		snprintf(actual_version, sizeof(actual_version),
 > +			"%s.%s", release, version);
 > +        else if(strlen(release) > 0)
 > +		strncpy(actual_version, release, sizeof(actual_version)-1);
 > +	else if(strlen(version) > 0)
 > +		strncpy(actual_version, version, sizeof(actual_version)-1);
 > +	else
 > +		errx(EXIT_FAILURE, "no version info");
 > +
 > +	strcpy(release, actual_version);
 > +	version[0] = '\0';
 > +}
 > +#endif
 > +
 >  /*
 >   * Reduce the result from uname(3) to a canonical form.
 >   */
 > @@ -870,6 +905,9 @@ normalise_platform(struct utsname *host_name)
 >  	span = strspn(host_name->release, "0123456789.");
 >  	host_name->release[span] = '\0';
 >  #endif
 > +#ifdef __minix
 > +	normalise_version(host_name->release, host_name->version);
 > +#endif
 >  }
 >  
 >  /*
 > @@ -880,7 +918,7 @@ check_platform(struct pkg_task *pkg)
 >  {
 >  	struct utsname host_uname;
 >  	const char *effective_arch;
 > -	int fatal;
 > +	int fatal = 0;
 >  
 >  	if (uname(&host_uname) < 0) {
 >  		if (Force) {
 > @@ -906,6 +944,10 @@ check_platform(struct pkg_task *pkg)
 >  	else
 >  		fatal = 0;
 >  
 > +#ifdef __minix
 > +	normalise_version(host_uname.release, host_uname.version);
 > +#endif
 > +
 >  	if (fatal ||
 >  	    compatible_platform(OPSYS_NAME, host_uname.release,
 >  				pkg->buildinfo[BI_OS_VERSION]) != 1) {
 > @@ -1093,7 +1135,7 @@ check_implicit_conflict(struct pkg_task *pkg)
 >  }
 >  
 >  static int
 > -check_dependencies(struct pkg_task *pkg)
 > +check_dependencies(struct pkg_task *pkg, struct dependency_stack *dependency_stack)
 >  {
 >  	plist_t *p;
 >  	char *best_installed;
 > @@ -1124,7 +1166,7 @@ check_dependencies(struct pkg_task *pkg)
 >  				    p->name);
 >  				continue;
 >  			}
 > -			if (pkg_do(p->name, 1, 0)) {
 > +			if (pkg_do(p->name, 1, 0, dependency_stack)) {
 >  				if (ForceDepends) {
 >  					warnx("Can't install dependency %s, "
 >  					    "continuing", p->name);
 > @@ -1373,12 +1415,33 @@ check_license(struct pkg_task *pkg)
 >   * Install a single package.
 >   */
 >  static int
 > -pkg_do(const char *pkgpath, int mark_automatic, int top_level)
 > +pkg_do(const char *pkgpath, int mark_automatic, int top_level, 
 > +	struct dependency_stack *dependency_stack)
 >  {
 >  	char *archive_name;
 >  	int status, invalid_sig;
 >  	struct pkg_task *pkg;
 >  
 > +	/* workaround 2010-12-10: prevent endless recursion for circular dependencies */
 > +	struct dependency_stack dependency_stack_top;

 Please don't. If you want to catch circular dependencies, just use a
 counter. Bigger question of course is, why you ended up here in first
 place...

 > +
 > +	dependency_stack_top.prev = dependency_stack;
 > +	dependency_stack_top.pkgpath = pkgpath;
 > +
 > +	while (dependency_stack) {
 > +		if (strcmp(dependency_stack->pkgpath, pkgpath) == 0) {
 > +			fprintf(stderr, "warning: ignoring circular dependency:\n");
 > +			dependency_stack = &dependency_stack_top;
 > +			while (dependency_stack) {
 > +				fprintf(stderr, "- %s\n", dependency_stack->pkgpath);
 > +				dependency_stack = dependency_stack->prev;
 > +			}
 > +			return 0;
 > +		}
 > +		dependency_stack = dependency_stack->prev;
 > +	}
 > +	/* end workaround */
 > +	
 >  	pkg = xcalloc(1, sizeof(*pkg));
 >  
 >  	status = -1;
 > @@ -1490,7 +1553,7 @@ pkg_do(const char *pkgpath, int mark_automatic, int top_level)
 >  			pkg->install_logdir_real = NULL;
 >  		}
 >  
 > -		if (check_dependencies(pkg))
 > +		if (check_dependencies(pkg, &dependency_stack_top))
 >  			goto nuke_pkgdb;
 >  	} else {
 >  		/*
 > @@ -1498,7 +1561,7 @@ pkg_do(const char *pkgpath, int mark_automatic, int top_level)
 >  		 * Install/update dependencies first and
 >  		 * write the current package to disk afterwards.
 >  		 */ 
 > -		if (check_dependencies(pkg))
 > +		if (check_dependencies(pkg, &dependency_stack_top))
 >  			goto clean_memory;
 >  
 >  		if (write_meta_data(pkg))
 > @@ -1582,7 +1645,7 @@ pkg_perform(lpkg_head_t *pkgs)
 >  	lpkg_t *lpp;
 >  
 >  	while ((lpp = TAILQ_FIRST(pkgs)) != NULL) {
 > -		if (pkg_do(lpp->lp_name, Automatic, 1))
 > +		if (pkg_do(lpp->lp_name, Automatic, 1, NULL))
 >  			++errors;
 >  		TAILQ_REMOVE(pkgs, lpp, lp_link);
 >  		free_lpkg(lpp);
 > diff --git a/pkgtools/pkg_install/files/configure b/pkgtools/pkg_install/files/configure

 Please don't include generated files in diffs, they just provide noise.

 > diff --git a/pkgtools/pkg_install/files/info/show.c b/pkgtools/pkg_install/files/info/show.c
 > index e44a6c9..89940e3 100644
 > --- a/pkgtools/pkg_install/files/info/show.c
 > +++ b/pkgtools/pkg_install/files/info/show.c
 > @@ -60,6 +60,9 @@ __RCSID("$NetBSD: show.c,v 1.31 2010/11/22 09:00:12 joerg Exp $");
 >  #if HAVE_ERR_H
 >  #include <err.h>
 >  #endif
 > +#if HAVE_SYS_PARAM_H
 > +#include <sys/param.h>
 > +#endif
 >  
 >  #include "defs.h"
 >  #include "lib.h"

 Why?

 > diff --git a/pkgtools/pkg_install/files/lib/plist.c b/pkgtools/pkg_install/files/lib/plist.c
 > index f1b6c6d..d171ad4 100644
 > --- a/pkgtools/pkg_install/files/lib/plist.c
 > +++ b/pkgtools/pkg_install/files/lib/plist.c
 > @@ -514,6 +514,7 @@ delete_package(Boolean ign_err, package_t *pkg, Boolean NoDeleteFiles,
 >  	int     fail = SUCCESS;
 >  	Boolean preserve;
 >  	char    tmp[MaxPathSize];
 > +	char 	cmd[MaxPathSize];
 >  	const char *prefix = NULL, *name = NULL;
 >  
 >  	if (!pkgdb_open(ReadWrite)) {
 > @@ -580,10 +581,12 @@ delete_package(Boolean ign_err, package_t *pkg, Boolean NoDeleteFiles,
 >  		case PLIST_UNEXEC:
 >  			if (NoDeleteFiles)
 >  				break;
 > -			format_cmd(tmp, sizeof(tmp), p->name, prefix, last_file);
 > -			printf("Executing `%s'\n", tmp);
 > -			if (!Fake && system(tmp)) {
 > -				warnx("unexec command for `%s' failed", tmp);
 > +			(void) snprintf(tmp, sizeof(tmp), "%s%s%s",
 > +					destdir ? destdir : "", destdir ? "/" : "", prefix);
 > +			format_cmd(cmd, sizeof(cmd), p->name, tmp, last_file);
 > +			printf("Executing `%s'\n", cmd);
 > +			if (!Fake && system(cmd)) {
 > +				warnx("unexec command for `%s' failed", cmd);
 >  				fail = FAIL;
 >  			}
 >  			break;
 > 

 Why?

 Joerg

From: Thomas Cort <tcort@minix3.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/45047: pkgtools/pkg_install minix support
Date: Mon, 13 Jun 2011 13:43:24 -0400

 >> +. =A0if ${OPSYS} =3D=3D "Minix"
 >> +LIBS+=3D =A0 =A0 =A0 =A0 =A0 =A0 =A0-larchive -lbz2 -lz
 >> +. =A0endif
 >
 > This is wrong, it shouldn't be needed.

 Without it, I get this:

 gcc -L/usr/tmp/work/pkgtools/pkg_install/work/libfetch
 -L/usr/tmp/work/pkgtools/pkg_install/work/libnbcompat
 -Wl,-R/usr/pkg/lib -L../lib -o pkg_add main.o perform.o -linstall
 -lfetch -larchive -lnbcompat
 /usr/lib/libarchive.a(archive_read_support_compression_bzip2.o): In
 function `bzip2_filter_read':
 /usr/src/lib/libarchive/archive_read_support_compression_bzip2.c:(.text+0x2=
 74):
 undefined reference to `BZ2_bzDecompress'
 /usr/src/lib/libarchive/archive_read_support_compression_bzip2.c:(.text+0x2=
 a2):
 undefined reference to `BZ2_bzDecompressEnd'
 /usr/src/lib/libarchive/archive_read_support_compression_bzip2.c:(.text+0x2=
 fc):
 undefined reference to `BZ2_bzDecompressInit'
 /usr/src/lib/libarchive/archive_read_support_compression_bzip2.c:(.text+0x3=
 1c):
 undefined reference to `BZ2_bzDecompressInit'
 /usr/lib/libarchive.a(archive_read_support_compression_bzip2.o): In
 function `bzip2_filter_close':
 /usr/src/lib/libarchive/archive_read_support_compression_bzip2.c:(.text+0x3=
 cd):
 undefined reference to `BZ2_bzDecompressEnd'
 /usr/lib/libarchive.a(archive_read_support_compression_gzip.o): In
 function `gzip_filter_read':
 /usr/src/lib/libarchive/archive_read_support_compression_gzip.c:(.text+0x1c=
 8):
 undefined reference to `crc32'
 /usr/src/lib/libarchive/archive_read_support_compression_gzip.c:(.text+0x20=
 d):
 undefined reference to `inflateInit2_'
 /usr/src/lib/libarchive/archive_read_support_compression_gzip.c:(.text+0x2c=
 0):
 undefined reference to `inflate'
 /usr/src/lib/libarchive/archive_read_support_compression_gzip.c:(.text+0x2e=
 d):
 undefined reference to `inflateEnd'
 /usr/lib/libarchive.a(archive_read_support_compression_gzip.o): In
 function `gzip_filter_close':
 /usr/src/lib/libarchive/archive_read_support_compression_gzip.c:(.text+0x3a=
 d):
 undefined reference to `inflateEnd'
 /usr/lib/libarchive.a(archive_read_support_format_zip.o): In function
 `archive_read_format_zip_read_header':
 /usr/src/lib/libarchive/archive_read_support_format_zip.c:(.text+0x23c):
 undefined reference to `crc32'
 /usr/lib/libarchive.a(archive_read_support_format_zip.o): In function
 `archive_read_format_zip_read_data':
 /usr/src/lib/libarchive/archive_read_support_format_zip.c:(.text+0xb0c):
 undefined reference to `crc32'
 /usr/src/lib/libarchive/archive_read_support_format_zip.c:(.text+0xc1c):
 undefined reference to `inflateReset'
 /usr/src/lib/libarchive/archive_read_support_format_zip.c:(.text+0xc3e):
 undefined reference to `inflateInit2_'
 /usr/src/lib/libarchive/archive_read_support_format_zip.c:(.text+0xcc6):
 undefined reference to `inflate'
 /usr/lib/libarchive.a(archive_read_support_format_zip.o): In function
 `archive_read_format_zip_cleanup':
 /usr/src/lib/libarchive/archive_read_support_format_zip.c:(.text+0xf43):
 undefined reference to `inflateEnd'
 collect2: ld returned 1 exit status
 *** Error code 1


 > =A0> =A0 =A0 =A0 =A0 =A0 =A0 =A0case PLIST_CMD:
 > =A0> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (format_cmd(cmd, sizeof(=
 cmd), p->name, pkg->prefix, last_file))
 > =A0> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (format_cmd(cmd, sizeof(=
 cmd), p->name, pkg->install_prefix, last_file))
 > =A0> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -1=
 ;
 > =A0> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("Executing '%s'\n"=
 , cmd);
 > =A0> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!Fake && system(cmd))
 >
 > =A0What are you trying to do here?

 I'll check with the original author, but AFAIK it is a DESTDIR related
 change. Again, I'll move those changes into a separate patch/PR and
 give a better explanation of the changes.

 > If you want to catch circular dependencies, just use a
 > counter.

 Okay. I'll re-implement the circular dependency checker using a counter.

 > Bigger question of course is, why you ended up here in first
 >=A0place...

 AFAIK it was because of an inconsistent set of binary packages (built
 from different pkgsrc tree versions) causing circular dependencies.

 > Please don't include generated files in diffs, they just provide noise.

 Sorry, it won't happen again.

 >> +#if HAVE_SYS_PARAM_H
 >> +#include <sys/param.h>
 >> +#endif
 >
 > Why?

 There was some shuffling around of macros in the Minix headers and
 according to the commit message include <sys/param.h> was needed for
 MIN()/MAX(). However, I just tried it without the include and it works
 just fine. In the next revision of the patch I'll remove that hunk.

 >> diff --git a/pkgtools/pkg_install/files/lib/plist.c b/pkgtools/pkg_insta=
 ll/files/lib/plist.c
 >> index f1b6c6d..d171ad4 100644
 >> --- a/pkgtools/pkg_install/files/lib/plist.c
 >> +++ b/pkgtools/pkg_install/files/lib/plist.c
 >> @@ -580,10 +581,12 @@ delete_package(Boolean ign_err, package_t *pkg, Bo=
 olean NoDeleteFiles,
 >> =A0 =A0 =A0 =A0 =A0 =A0 =A0case PLIST_UNEXEC:
 >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (NoDeleteFiles)
 >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;
 >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0format_cmd(tmp, sizeof(tmp), p-=
 >name, prefix, last_file);
 >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("Executing `%s'\n", tmp)=
 ;
 >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!Fake && system(tmp)) {
 >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0warnx("unexec c=
 ommand for `%s' failed", tmp);
 >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(void) snprintf(tmp, sizeof(tmp=
 ), "%s%s%s",
 >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
 =A0destdir ? destdir : "", destdir ? "/" : "", prefix);
 >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0format_cmd(cmd, sizeof(cmd), p-=
 >name, tmp, last_file);
 >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("Executing `%s'\n", cmd)=
 ;
 >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!Fake && system(cmd)) {
 >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0warnx("unexec c=
 ommand for `%s' failed", cmd);
 >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fail =3D FAIL=
 ;
 >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
 >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;
 >>
 >
 > Why?

 Again, DESTDIR related. PLIST files can have commands to be executed
 using the @exec directive. Pkgin for instance uses "@exec ${MKDIR}
 %D/etc/pkgin". The %D is supposed to be expanded to pkgsrc root.
 Earlier pkg_add would ignore the destdir when expanding the %D. We
 changed pkg_add to expand %D to destdir/pkgsrc_root.

From: Thomas Cort <tcort@minix3.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/45047: pkgtools/pkg_install minix support
Date: Mon, 13 Jun 2011 13:26:58 -0400

 > =A0I'd like to see this make it into pkgsrc-2011Q2, but there are a
 > =A0number of changes here that are lumped together, and I feel that we'd
 > =A0be better off separating them out and considering them individually.

 Agreed. I'll split up the patch and create additional PRs where needed.

 > =A0Personally, I don't like to use assertions in production code.

 No problem. I'll clean things up and attach an updated patch.

 > =A0Can we use the dewey dependency functions for the Minix version
 > =A0number, or cons up a standard version number as expected from the two
 > =A0constituent parts?

 I'll look into it.

From: Thomas Cort <tcort@minix3.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/45047: pkgtools/pkg_install minix support
Date: Fri, 17 Jun 2011 10:50:48 -0400

 Based on the feedback, I've updated the patch. The assert() statements
 were removed, the code cleaned up slightly, and non-Minix specific
 changes were moved into their own problem reports.

 The circular dependency detection patch was moved to pkg/45077.
 The destdir patch was moved to pkg/45078.

 --- a/pkg_install/files/configure.ac	Thu Jun 16 19:34:17 2011
 +++ b/pkg_install/files/configure.ac	Thu Jun 16 19:34:31 2011
 @@ -16,7 +16,7 @@
  AC_PROG_INSTALL
  AC_PROG_LN_S
  AC_PROG_RANLIB
 -AC_CHECK_PROG(AR, ar, ar)
 +AC_CHECK_PROGS(AR, [gar ar])

  AC_PATH_PROG(CHMOD, chmod)
  AC_PATH_PROG(CMP, cmp)
 --- a/pkg_install/files/add/perform.c	Thu Jun 16 19:34:17 2011
 +++ b/pkg_install/files/add/perform.c	Thu Jun 16 19:34:31 2011
 @@ -858,18 +858,63 @@
  	free(text);
  }

 +#ifdef __minix
 +static int
 +normalise_version(char *release, char *version)
 +{
 +	char actual_version[50];
 +	int l1, l2;
 +
 +	if (release == NULL || version == NULL) {
 +		warnx("release or version information not present");
 +		return -1;
 +	}
 +
 +	l1 = strlen(release);
 +	l2 = strlen(version);
 +
 +	if (l1 + l2 + 2 >= sizeof(actual_version)) {
 +		warnx("not enough space to normalise version");
 +		return -1;
 +	}
 +
 +	if (l1 > 0 && l2 > 0) {
 +		snprintf(actual_version, sizeof(actual_version),
 +			"%s.%s", release, version);
 +	} else if (strlen(release) > 0) {
 +		strncpy(actual_version, release, sizeof(actual_version)-1);
 +	} else if (strlen(version) > 0) {
 +		strncpy(actual_version, version, sizeof(actual_version)-1);
 +	} else {
 +		warnx("cannot determine version information");
 +		return -1;
 +	}
 +
 +	strcpy(release, actual_version);
 +	version[0] = '\0';
 +
 +	return 0;
 +}
 +#endif
 +
  /*
   * Reduce the result from uname(3) to a canonical form.
   */
 -static void
 +static int
  normalise_platform(struct utsname *host_name)
  {
 +	int rc = 0;
 +
  #ifdef NUMERIC_VERSION_ONLY
  	size_t span;

  	span = strspn(host_name->release, "0123456789.");
  	host_name->release[span] = '\0';
  #endif
 +#ifdef __minix
 +	rc = normalise_version(host_name->release, host_name->version);
 +#endif
 +	return rc;
  }

  /*
 @@ -892,7 +937,9 @@
  		}
  	}

 -	normalise_platform(&host_uname);
 +	if (normalise_platform(&host_uname)) {
 +		return -1;
 +	}

  	if (OverrideMachine != NULL)
  		effective_arch = OverrideMachine;
 --- a/pkg_install/Makefile	Thu Jun 16 19:34:17 2011
 +++ b/pkg_install/Makefile	Thu Jun 16 19:34:31 2011
 @@ -142,6 +142,10 @@
  CPPFLAGS+=	-I${WRKDIR}/libfetch
  LDFLAGS+=	-L${WRKDIR}/libfetch

 +.  if ${OPSYS} == "Minix"
 +LIBS+=		-larchive -lbz2 -lz
 +.  endif
 +
  CONFIGURE_ENV+=	LIBS=${LIBS:Q}

  do-extract:

From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/45047: pkgtools/pkg_install minix support
Date: Fri, 17 Jun 2011 19:05:14 +0200

 On Fri, Jun 17, 2011 at 02:55:02PM +0000, Thomas Cort wrote:
 > The following reply was made to PR pkg/45047; it has been noted by GNATS.
 > 
 > From: Thomas Cort <tcort@minix3.org>
 > To: gnats-bugs@netbsd.org
 > Cc: 
 > Subject: Re: pkg/45047: pkgtools/pkg_install minix support
 > Date: Fri, 17 Jun 2011 10:50:48 -0400
 > 
 >  Based on the feedback, I've updated the patch. The assert() statements
 >  were removed, the code cleaned up slightly, and non-Minix specific
 >  changes were moved into their own problem reports.
 >  
 >  The circular dependency detection patch was moved to pkg/45077.
 >  The destdir patch was moved to pkg/45078.
 >  
 >  --- a/pkg_install/files/configure.ac	Thu Jun 16 19:34:17 2011
 >  +++ b/pkg_install/files/configure.ac	Thu Jun 16 19:34:31 2011
 >  @@ -16,7 +16,7 @@
 >   AC_PROG_INSTALL
 >   AC_PROG_LN_S
 >   AC_PROG_RANLIB
 >  -AC_CHECK_PROG(AR, ar, ar)
 >  +AC_CHECK_PROGS(AR, [gar ar])
 >   
 >   AC_PATH_PROG(CHMOD, chmod)
 >   AC_PATH_PROG(CMP, cmp)
 >  --- a/pkg_install/files/add/perform.c	Thu Jun 16 19:34:17 2011
 >  +++ b/pkg_install/files/add/perform.c	Thu Jun 16 19:34:31 2011
 >  @@ -858,18 +858,63 @@
 >   	free(text);
 >   }
 >   
 >  +#ifdef __minix
 >  +static int
 >  +normalise_version(char *release, char *version)
 >  +{
 >  +	char actual_version[50];
 >  +	int l1, l2;
 >  +
 >  +	if (release == NULL || version == NULL) {
 >  +		warnx("release or version information not present");
 >  +		return -1;
 >  +	}
 >  +
 >  +	l1 = strlen(release);
 >  +	l2 = strlen(version);
 >  +
 >  +	if (l1 + l2 + 2 >= sizeof(actual_version)) {
 >  +		warnx("not enough space to normalise version");
 >  +		return -1;
 >  +	}
 >  +
 >  +	if (l1 > 0 && l2 > 0) {
 >  +		snprintf(actual_version, sizeof(actual_version),
 >  +			"%s.%s", release, version);
 >  +	} else if (strlen(release) > 0) {
 >  +		strncpy(actual_version, release, sizeof(actual_version)-1);
 >  +	} else if (strlen(version) > 0) {
 >  +		strncpy(actual_version, version, sizeof(actual_version)-1);
 >  +	} else {
 >  +		warnx("cannot determine version information");
 >  +		return -1;
 >  +	}
 >  +
 >  +	strcpy(release, actual_version);
 >  +	version[0] = '\0';
 >  +
 >  +	return 0;
 >  +}
 >  +#endif

 Why aren't the checks here fatal?

 Joerg

From: Thomas Cort <tcort@minix3.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/45047: pkgtools/pkg_install minix support
Date: Fri, 17 Jun 2011 13:54:45 -0400

 > > +normalise_version(char *release, char *version)
 >
 > Why aren't the checks here fatal?

 They are, in a way. The function returns an error to check_platform(),
 which returns the error to pkg_do(), which returns the error to
 pkg_perform(), which returns the error to main(), which calls exit(1).

 I chose that method instead of just exiting at the point of the error
 because Alistair suggested returning an error to the calling function...

 > Personally, I don't like to use assertions in production code.  We
 > have seen too many failures at inopportune moments from systems like
 > bind for me to believe that it's a good thing.  I'd like to replace
 > the assertions with a check, and return a sane error to the calling
 > function.

From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/45047: pkgtools/pkg_install minix support
Date: Fri, 17 Jun 2011 20:19:50 +0200

 On Fri, Jun 17, 2011 at 05:55:02PM +0000, Thomas Cort wrote:
 > The following reply was made to PR pkg/45047; it has been noted by GNATS.
 > 
 > From: Thomas Cort <tcort@minix3.org>
 > To: gnats-bugs@netbsd.org
 > Cc: 
 > Subject: Re: pkg/45047: pkgtools/pkg_install minix support
 > Date: Fri, 17 Jun 2011 13:54:45 -0400
 > 
 >  > > +normalise_version(char *release, char *version)
 >  >
 >  > Why aren't the checks here fatal?
 >  
 >  They are, in a way. The function returns an error to check_platform(),
 >  which returns the error to pkg_do(), which returns the error to
 >  pkg_perform(), which returns the error to main(), which calls exit(1).
 >  
 >  I chose that method instead of just exiting at the point of the error
 >  because Alistair suggested returning an error to the calling function...
 >  
 >  > Personally, I don't like to use assertions in production code.  We
 >  > have seen too many failures at inopportune moments from systems like
 >  > bind for me to believe that it's a good thing.  I'd like to replace
 >  > the assertions with a check, and return a sane error to the calling
 >  > function.
 >  

 Assertions are conditionally disabled. That's slightly different. Also
 at the time of calling, nothing permanent should have been done.

 Joerg

From: Thomas Cort <tcort@minix3.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/45047: pkgtools/pkg_install minix support
Date: Tue, 19 Jul 2011 09:07:03 -0400

 After submitting the original patch, Minix got a new C library and headers.
 The C library and headers were ported from NetBSD. The caused us to make a
 change (disabling db in libnbcompat). An updated patch follows.

 Patch Summary:

  * Since Minix's new NetBSD-based C library has the db stuff, we pass
    the --disable-db parameter to libnbcompat's configure script. Other
    systems still pass --enable-db.

  * When ${OPSYS} = Minix, add "-larchive -lbz2 -lz" to LIBS. Without
    explicitly listing the libraries, linking fails with undefined
    reference errors.

  * Add a normalisation function to build a proper release string. On
    Minix, the "3.2.0" release is represented as release "3" version "2.0".

  * Check for gar and ar since some Minix systems use GNU ar (gar) instead
    of ar.

 diff --git a/pkgtools/pkg_install/Makefile b/pkgtools/pkg_install/Makefile
 index 392093c..ace0688 100644
 --- a/pkgtools/pkg_install/Makefile
 +++ b/pkgtools/pkg_install/Makefile
 @@ -28,7 +28,7 @@ CONFIGURE_ARGS+=	--with-pkgdbdir=${PKG_DBDIR:Q}

  USE_FEATURES=		nbcompat

 -NBCOMPAT_CONFIGURE_ARGS+=	--enable-bsd-getopt --enable-db
 +NBCOMPAT_CONFIGURE_ARGS+=	--enable-bsd-getopt

  SKIP_AUDIT_PACKAGES=	yes
  NO_PKGTOOLS_REQD_CHECK=	yes
 @@ -86,6 +86,12 @@ VERSION!=		${AWK} '/PKGTOOLS_VERSION/ {print $$3}' \
  # raw format appeared in libarchive 2.8.
  BUILDLINK_API_DEPENDS.libarchive+=	libarchive>=2.8.0

 +.if ${OPSYS} == "Minix"
 +NBCOMPAT_CONFIGURE_ARGS+=	--disable-db
 +.else
 +NBCOMPAT_CONFIGURE_ARGS+=	--enable-db
 +.endif
 +
  .include "../../archivers/bzip2/builtin.mk"
  .include "../../archivers/libarchive/builtin.mk"
  .include "../../devel/zlib/builtin.mk"
 @@ -142,6 +148,10 @@ LIBS+=		-larchive
  CPPFLAGS+=	-I${WRKDIR}/libfetch
  LDFLAGS+=	-L${WRKDIR}/libfetch

 +.  if ${OPSYS} == "Minix"
 +LIBS+=		-larchive -lbz2 -lz
 +.  endif
 +
  CONFIGURE_ENV+=	LIBS=${LIBS:Q}

  do-extract:
 diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c
 index aa3dff3..c87aa5b 100644
 --- a/pkgtools/pkg_install/files/add/perform.c
 +++ b/pkgtools/pkg_install/files/add/perform.c
 @@ -858,18 +860,63 @@ pkg_register_depends(struct pkg_task *pkg)
  	free(text);
  }

 +#ifdef __minix
 +static int
 +normalise_version(char *release, char *version)
 +{
 +	char actual_version[50];
 +	int l1, l2;
 +
 +	if (release == NULL || version == NULL) {
 +		warnx("release or version information not present");
 +		return -1;
 +	}
 +
 +	l1 = strlen(release);
 +	l2 = strlen(version);
 +
 +	if (l1 + l2 + 2 >= sizeof(actual_version)) {
 +		warnx("not enough space to normalise version");
 +		return -1;
 +	}
 +
 +	if (l1 > 0 && l2 > 0) {
 +		snprintf(actual_version, sizeof(actual_version),
 +			"%s.%s", release, version);
 +	} else if (strlen(release) > 0) {
 +		strncpy(actual_version, release, sizeof(actual_version)-1);
 +	} else if (strlen(version) > 0) {
 +		strncpy(actual_version, version, sizeof(actual_version)-1);
 +	} else {
 +		warnx("cannot determine version information");
 +		return -1;
 +	}
 +
 +	strcpy(release, actual_version);
 +	version[0] = '\0';
 +
 +	return 0;
 +}
 +#endif
 +
  /*
   * Reduce the result from uname(3) to a canonical form.
   */
 -static void
 +static int
  normalise_platform(struct utsname *host_name)
  {
 +	int rc = 0;
 +
  #ifdef NUMERIC_VERSION_ONLY
  	size_t span;

  	span = strspn(host_name->release, "0123456789.");
  	host_name->release[span] = '\0';
  #endif
 +#ifdef __minix
 +	rc = normalise_version(host_name->release, host_name->version);
 +#endif
 +	return rc;
  }

  /*
 @@ -892,7 +939,9 @@ check_platform(struct pkg_task *pkg)
  		}
  	}

 -	normalise_platform(&host_uname);
 +	if (normalise_platform(&host_uname)) {
 +		return -1;
 +	}

  	if (OverrideMachine != NULL)
  		effective_arch = OverrideMachine;
 diff --git a/pkgtools/pkg_install/files/configure.ac b/pkgtools/pkg_install/files/configure.ac
 index ece6517..74da9ff 100644
 --- a/pkgtools/pkg_install/files/configure.ac
 +++ b/pkgtools/pkg_install/files/configure.ac
 @@ -16,7 +16,7 @@ AC_PROG_CC
  AC_PROG_INSTALL
  AC_PROG_LN_S
  AC_PROG_RANLIB
 -AC_CHECK_PROG(AR, ar, ar)
 +AC_CHECK_PROGS(AR, [gar ar])

  AC_PATH_PROG(CHMOD, chmod)
  AC_PATH_PROG(CMP, cmp)

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.