Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Jun 2001 12:55:21 -0700
From:      Rob Braun <rbraun@apple.com>
To:        freebsd-hackers@freebsd.org
Subject:   xinstall args to strip
Message-ID:  <D6E1C9DE-6D91-11D5-A64B-003065BADC60@brauro.apple.com.synack.net>

next in thread | raw e-mail | index | archive | help
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".

Rob

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);

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D6E1C9DE-6D91-11D5-A64B-003065BADC60>