Subject: gensolpkg: relax 9-character package name length limit.
To: None <tech-pkg@netbsd.org>
From: Bill Sommerfeld <sommerfeld@orchard.arlington.ma.us>
List: tech-pkg
Date: 10/20/2005 11:48:02
--=-+Jn//BTrv5cpLZ2zZd5Q
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

There have been updates to the solaris package tools (including binary
patches for all currently supported releases) which relax the
9-character package name limit to 32 characters.  The driving factor for
this turned out to be GNOME, which, well, has a lot of packages with
similar names which would be hell to condense into SUNWxxxxx format.

It's time to take advantage of this in gensolpkg.

I've attached a diff to gensolpkg/patches/patch-ac for review.  
unless anyone objects, I'll commit this in a few days.

					- Bill




--=-+Jn//BTrv5cpLZ2zZd5Q
Content-Description: 
Content-Disposition: inline; filename=gensolpkg-patch-ac.diff
Content-Type: text/x-patch; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Index: patch-ac
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/gensolpkg/patches/patch-ac,v
retrieving revision 1.2
diff -u -u -r1.2 patch-ac
--- patch-ac	5 Nov 2004 16:44:46 -0000	1.2
+++ patch-ac	20 Oct 2005 15:45:03 -0000
@@ -1,8 +1,24 @@
-$NetBSD: patch-ac,v 1.2 2004/11/05 16:44:46 agc Exp $
+$NetBSD$
 
---- 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 @@
+--- gensolpkg.c.in.orig	2001-05-05 10:44:31.000000000 -0400
++++ gensolpkg.c.in
+@@ -59,6 +59,8 @@ static strv_t	dirs;
+ #define MIN(a, b)	(((a) < (b)) ? (a) : (b))
+ #endif
+ 
++#define SOLPKGNAMELEN		32
++
+ #ifndef PACKAGE_DEPENDS_TARGET
+ #define PACKAGE_DEPENDS_TARGET	"run-depends-list PACKAGE_DEPENDS_WITH_PATTERNS=false PACKAGE_NAME_TYPE=svr4"
+ #endif
+@@ -73,15 +75,17 @@ static char	bmake[MAXPATHLEN];		/* path 
+ static char	pkgdir[MAXPATHLEN];		/* package device - default "/var/spool/pkg" */
+ 
+ static char	pkgname[256 + 1];		/* PKGNAME from pkgsrc */
+-static char	abbrev[9 + 1];			/* Solaris package abbreviation */
++static char	abbrev[SOLPKGNAMELEN + 1];			/* Solaris package abbreviation */
+ static char	pkgarch[16 + 1];		/* Solaris arch name - default "sparc" */
+ static char	pkgversion[256 + 1];		/* version number for this package */
  static char	comment[256 + 1];		/* one line descr of pkg */
  
  static char	prefix[MAXPATHLEN];		/* current prefix */
@@ -10,8 +26,32 @@
 +static char	workdir[MAXPATHLEN];		/* name of working directory */
  static char	*category;			/* category of package - default "application" */
  static int	transform;			/* transform the package - default "disabled" */
++static int	solpkgnamlen = SOLPKGNAMELEN;	/* Package name limit */
++static int	oldflag = 0;			/* Old name conversion */
  
-@@ -357,9 +357,9 @@
+ /* save `n' chars of `s' in malloc'd memory */
+ char *
+@@ -122,8 +126,8 @@ make_abbrev(char *pkg, char *out)
+ 	if ((lastminus = strrchr(pkg, '-')) == (char *) NULL) {
+ 		lastminus = &pkg[strlen(pkg)];
+ 	}
+-	for (cp = pkg ; (int)(out - ret) < 9 && cp < lastminus ; cp++) {
+-		if (isalnum(*cp)) {
++	for (cp = pkg ; (int)(out - ret) < solpkgnamlen && cp < lastminus ; cp++) {
++		if (isalnum(*cp) || (!oldflag && (*cp == '-'))) {
+ 			*out++ = tolower(*cp);
+ 		}
+ 	}
+@@ -170,7 +174,7 @@ do_depend(char *pkg, char *prefix)
+ 	FILE	*pp;
+ 	FILE	*fp;
+ 	char	buf[BUFSIZ];
+-	char	pa[9 + 1];
++	char	pa[SOLPKGNAMELEN + 1];
+ 	
+ 	if ((fp = fopen(dependfile, "w")) == (FILE *) NULL) {
+ 		(void) fprintf(stderr, "can't open `%s'\n", dependfile);
+@@ -357,9 +361,9 @@ do_prototype(char *pkg, char *prefix, si
  	}
  	(void) fprintf(fp, "!PKG=%s\n", pkg);
  	(void) fprintf(fp, "!PREFIX=%s\n", prefix);
@@ -24,7 +64,7 @@
  	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 @@
+@@ -463,7 +467,7 @@ do_prototype(char *pkg, char *prefix, si
  			(void) fputc('\n', fp2);
  		}
  		(void) fclose(fp2);
@@ -33,7 +73,7 @@
  	}
  	if (remove.s_c > 0) {
  		(void) snprintf(f, sizeof(f), "%s/.postremove", workdir);
-@@ -493,7 +493,7 @@
+@@ -493,7 +497,7 @@ do_prototype(char *pkg, char *prefix, si
  			(void) fputc('\n', fp2);
  		}
  		(void) fclose(fp2);
@@ -42,7 +82,22 @@
  	}
  	(void) fclose(fp);
  	(void) fclose(plist);
-@@ -572,13 +572,17 @@
+@@ -530,7 +534,7 @@ pkgmk(char *name, char *prefix)
+ 		if (!vsystem("/usr/bin/pkgtrans -s %s %s/%s %s", pkgdir, output, name, name)) {
+ 			return 0;
+ 		}
+-		if (!vsystem("/usr/bin/compress %s/%s", output, name)) {
++		if (!vsystem("/usr/bin/compress -f %s/%s", output, name)) {
+ 			return 0;
+ 		}
+ 		if (!vsystem("/bin/rm -rf %s/%s", pkgdir, name)) {
+@@ -567,18 +571,22 @@ int
+ main(int argc, char **argv)
+ {
+ 	char	cmd[MAXPATHLEN * 2];
+-	char	tmp[9 + 1];
++	char	tmp[SOLPKGNAMELEN + 1];
+ 	char	*pkg;
  	int	i;
  
  	(void) strcpy(prefix, "@PREFIX@");
@@ -62,12 +117,25 @@
  	(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 @@
+@@ -609,7 +617,7 @@ main(int argc, char **argv)
+ 		exit(1);
+ 	}
+ 	pkg = make_abbrev(tmp, abbrev);
+-	while ((i = getopt(argc, argv, "a:c:d:n:o:p:tw:")) != -1) {
++	while ((i = getopt(argc, argv, "a:c:d:n:o:p:tw:O")) != -1) {
+ 		switch(i) {
+ 		case 'a':
+ 			(void) strnncpy(pkgarch, sizeof(pkgarch), optarg, strlen(optarg));
+@@ -633,7 +641,11 @@ main(int argc, char **argv)
  			transform = 1;
  			break;
  		case 'w':
 -			workdir = optarg;
 +			(void) strnncpy(workdir, sizeof(workdir), optarg, strlen(optarg));
++			break;
++		case 'O':
++			oldflag = 1;
++			solpkgnamlen = 9;
  			break;
  		default:
  			fprintf(stderr, "Usage:\n");

--=-+Jn//BTrv5cpLZ2zZd5Q--