From nobody@FreeBSD.org  Sun Jul  1 19:18:15 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 94BDE37B403
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  1 Jul 2001 19:18:15 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.3/8.11.3) id f622IFv42084;
	Sun, 1 Jul 2001 19:18:15 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200107020218.f622IFv42084@freefall.freebsd.org>
Date: Sun, 1 Jul 2001 19:18:15 -0700 (PDT)
From: Rob Braun <rbraun@apple.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: xinstall has no way to pass options to strip
X-Send-Pr-Version: www-1.0

>Number:         28620
>Category:       bin
>Synopsis:       [patch] install(1) has no way to pass options to strip
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 01 19:20:01 PDT 2001
>Closed-Date:    Mon Sep 26 23:15:52 UTC 2011
>Last-Modified:  Mon Sep 26 23:15:52 UTC 2011
>Originator:     Rob Braun
>Release:        top of tree
>Organization:
Apple Computer, Inc.
>Environment:
>Description:
FreeBSD's xinstall [install(1)] lacks a way to pass arguments to strip.  In non-ELF systems this can be important.  Below is a patch to FreeBSD's xinstall TOT that adds a -Z flag that takes an argument that can be passed to strip(1) when it is exec'd.  It also lets the user specify an alternate strip program with the STRIP environment variable.  This functionality is based on NetBSD's xinstall -S flag.  Unfortunately, -S is already used by FreeBSD's xinstall as a "safe copy".
>How-To-Repeat:

>Fix:
Here's the patch.  The note at the bottom of this page says not to submit code here, but provides no mechanism to do so.  If this is non functional, this patch was also submitted to the hackers list on Friday.


Index: install.1
===================================================================
RCS file: /cvs/Darwin/Commands/BSD/file_cmds/install/install.1,v
retrieving revision 1.1.1.3
diff -u -d -r1.1.1.3 install.1
--- install.1   2001/06/28 00:35:04     1.1.1.3
+++ install.1   2001/06/30 19:45:52
@@ -46,6 +46,7 @@
 .Op Fl g Ar group
 .Op Fl m Ar mode
 .Op Fl o Ar owner
+.Op Fl Z Ar stripflags
 .Ar file1 file2
 .Nm
 .Op Fl bCcMpSsv
@@ -54,6 +55,7 @@
 .Op Fl g Ar group
 .Op Fl m Ar mode
 .Op Fl o Ar owner
+.Op Fl Z Ar stripflag
 .Ar file1 ... fileN directory
 .Nm
 .Fl d
@@ -61,6 +63,7 @@
 .Op Fl g Ar group
 .Op Fl m Ar mode
 .Op Fl o Ar owner
+.Op Fl Z Ar stripflag
 .Ar directory ...
 .Sh DESCRIPTION
 The file(s) are copied
@@ -155,6 +158,23 @@
 .Nm
 can be portable over a large
 number of systems and binary types.
+.It Fl Z Ar stripflags
+.Nm
+pases
+.Ar stripflags
+as option arguments to
+.Xr strip 1 .
+When -Z is used,
+.Xr strip 1
+is invoked via the
+.Xr sh 1
+shell, allowing a single -Z argument to be specified to
+.Nm
+which the shell can then tokenize.  Normally,
+.Nm
+invokes
+.Xr strip 1
+directly.  This flag implies -s
 .It Fl v
 Causes
 .Nm
Index: xinstall.c
===================================================================
RCS file: /cvs/Darwin/Commands/BSD/file_cmds/install/xinstall.c,v
retrieving revision 1.2
diff -u -d -r1.2 xinstall.c
--- xinstall.c  2001/06/28 00:38:03     1.2
+++ xinstall.c  2001/06/30 19:45:52
@@ -84,6 +84,7 @@
 int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy, verbose;
 mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
 char *suffix = BACKUP_SUFFIX;
+char *stripArgs=NULL;

 #ifdef __APPLE__
 u_long  string_to_flags __P((char **, u_long *, u_long *));
@@ -165,6 +166,12 @@
                case 'v':
                        verbose = 1;
                        break;
+               case 'Z':
+                       stripArgs = (char*)malloc(sizeof(char)*(strlen(optarg)+1
+));
+                       strcpy(stripArgs,optarg);
+                       dostrip = 1;
+                       break;
                case '?':
                default:
                        usage();
@@ -704,6 +711,7 @@
        char *to_name;
 {
        int serrno, status;
+       char *stripprog;

        switch (fork()) {
        case -1:
@@ -712,8 +720,19 @@
                errno = serrno;
                err(EX_TEMPFAIL, "fork");
        case 0:
-               execlp("strip", "strip", to_name, NULL);
-               err(EX_OSERR, "exec(strip)");
+               stripprog = getenv("STRIP");
+               if (stripprog == NULL)
+                       stripprog = _PATH_STRIP;
+               if (stripArgs) {
+                       char *cmd = (char*)malloc(sizeof(char)*
+                                               (3+strlen(stripprog)+
+                                               strlen(stripArgs)+
+                                               strlen(to_name)));
+                       sprintf(cmd, "%s %s %s", stripprog, stripArgs, to_name);
+                       execl(_PATH_BSHELL, "sh", "-c", cmd, NULL);
+               } else
+               execlp(stripprog, "strip", to_name, NULL);
+               err(EX_OSERR, "exec(%s)", stripprog);
        default:
                if (wait(&status) == -1 || status) {
                        (void)unlink(to_name);

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: mikeh 
Responsible-Changed-When: Sun Jul 1 21:36:10 PDT 2001 
Responsible-Changed-Why:  
Ruslan did the latest work on xinstall 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28620 
Responsible-Changed-From-To: ru->marcel 
Responsible-Changed-By: ru 
Responsible-Changed-When: Fri Jun 11 13:56:54 GMT 2004 
Responsible-Changed-Why:  
Marcel, could you please document the STRIPBIN envariable 
in the manpage, and then close this PR? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=28620 
State-Changed-From-To: open->closed 
State-Changed-By: marcel 
State-Changed-When: Fri Jun 11 17:26:01 GMT 2004 
State-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=28620 
State-Changed-From-To: closed->open 
State-Changed-By: marcel 
State-Changed-When: Fri Jun 11 17:28:30 GMT 2004 
State-Changed-Why:  
Grrr. Apparently GNATS doesn'y reject empty comments in an attempt 
to abort changing the state. Anyway: 
o  The STRIPBIN environment variable is documented, 
o  The PR is reassigned back to ru@ and kept open (well, is reopened 
again to be precise). 
The reason for not closing the PR is that we didn't implement a -Z 
option and there might actually be use for it. 



Responsible-Changed-From-To: marcel->ru 
Responsible-Changed-By: marcel 
Responsible-Changed-When: Fri Jun 11 17:28:30 GMT 2004 
Responsible-Changed-Why:  
Grrr. Apparently GNATS doesn'y reject empty comments in an attempt 
to abort changing the state. Anyway: 
o  The STRIPBIN environment variable is documented, 
o  The PR is reassigned back to ru@ and kept open (well, is reopened 
again to be precise). 
The reason for not closing the PR is that we didn't implement a -Z 
option and there might actually be use for it. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=28620 
State-Changed-From-To: open->closed 
State-Changed-By: eadler 
State-Changed-When: Mon Sep 26 23:15:51 UTC 2011 
State-Changed-Why:  
this is unlikely to happen 

http://www.freebsd.org/cgi/query-pr.cgi?pr=28620 
>Unformatted:
