Subject: pkg/18786: Fix for bootstrap-pkgsrc version of mtree(8) on Solaris
To: None <gnats-bugs@gnats.netbsd.org>
From: None <sketch@rd.bbc.co.uk>
List: netbsd-bugs
Date: 10/23/2002 12:18:59
>Number:         18786
>Category:       pkg
>Synopsis:       Fix for bootstrap-pkgsrc version of mtree(8) on Solaris
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 23 12:19:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jonathan Perkin
>Release:        1.6
>Organization:
British Broadcasting Corporation
>Environment:
SunOS desk06 5.9 Generic_112233-01 sun4u sparc SUNW,Ultra-5_10
>Description:
The bootstrap-pkgsrc version of mtree running on Solaris currently
doesn't work, due to a specfile parsing issue:

-% mtree -U -f SunOS.pkg.dist -d -e -p /cache/npkg/;
unknown keyword `/set'<unset_progname>: failed at line 5 of the specification

I *think* this is related to the built-in version of strsep() used on
hosts which don't have a version in their libc, and using verbatim the
libc version means it works.

However I haven't dug into the source that deep, so don't know if this
is the correct fix or not.

The "unset_progname" issue I will look into further too, as it seems
the supplied setprogname() isn't working neither.  I will hopefully
have a patch for that in a later pr.
>How-To-Repeat:

>Fix:
Index: misc.c
===================================================================
RCS file: /cache/ncvs/othersrc/bootstrap-pkgsrc/mtree/misc.c,v
retrieving revision 1.3
diff -u -r1.3 misc.c
--- misc.c      2002/10/10 16:56:05     1.3
+++ misc.c      2002/10/23 18:59:35
@@ -298,8 +298,29 @@
 
 #ifndef HAVE_STRSEP
 char *
-strsep(char **str, const char *delim)
+strsep(char **stringp, const char *delim)
 {
-       return strtok(*str, delim);
+        char *s;
+        const char *spanp;
+        int c, sc;
+        char *tok;
+
+        if ((s = *stringp) == NULL)
+                return (NULL);
+        for (tok = s;;) {
+                c = *s++;
+                spanp = delim;
+                do {
+                        if ((sc = *spanp++) == c) {
+                                if (c == 0)
+                                        s = NULL;
+                                else
+                                        s[-1] = 0;
+                                *stringp = s;
+                                return (tok);
+                        }
+                } while (sc != 0);
+        }
+        /* NOTREACHED */
 }
 #endif
>Release-Note:
>Audit-Trail:
>Unformatted: