Date: Sun, 1 Jul 2001 19:18:15 -0700 (PDT) From: Rob Braun <rbraun@apple.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/28620: xinstall has no way to pass options to strip Message-ID: <200107020218.f622IFv42084@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 28620 >Category: bin >Synopsis: xinstall has no way to pass options to strip >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Jul 01 19:20:01 PDT 2001 >Closed-Date: >Last-Modified: >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: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200107020218.f622IFv42084>