Hello,
as requested in TODO, new option --strip-program was added to install to
specify the program used to strip binaries. Proposed patch in attachment.
Kamil
From abf2ded806353d83594683af45838661e5f817d2 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <[EMAIL PROTECTED]>
Date: Fri, 5 Sep 2008 13:12:06 +0200
Subject: [PATCH] install: new option: --strip-program to specify the program used to strip binaries
* src/install.c (main): Handle new option --strip-program.
(strip): Use strip program from global variable strip_program.
(usage): Mention new option --strip-program in --help.
* tests/tests/strip-program: Test case for new option --strip-program.
* tests/Makefile.am: Add new test case to test set.
* doc/coreutils.texi: Mention new option --strip-program.
* NEWS: Mention the change.
* TODO: Remove completed task.
---
NEWS | 3 +++
TODO | 3 ---
doc/coreutils.texi | 5 +++++
src/install.c | 21 ++++++++++++++++++---
tests/Makefile.am | 1 +
tests/install/strip-program | 36 ++++++++++++++++++++++++++++++++++++
6 files changed, 63 insertions(+), 6 deletions(-)
create mode 100755 tests/install/strip-program
diff --git a/NEWS b/NEWS
index a774d1a..2549d41 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,9 @@ GNU coreutils NEWS -*- outline -*-
expr support arbitrarily large numbers. Pollard's rho algorithm is
used to factor large numbers.
+ install accepts a new option --strip-program to specify the program used to
+ strip binaries.
+
ls now colorizes files with capabilities if libcap is available
md5sum now accepts the new option, --quiet, to suppress the printing of
diff --git a/TODO b/TODO
index da5e0ac..7eaa157 100644
--- a/TODO
+++ b/TODO
@@ -42,9 +42,6 @@ renice: POSIX utility, needs implementing.
suggestion from Karl Berry (among others).
Bob Proulx is working on this.
-install: add an option to specify the program used to strip binaries.
- suggestion from Karl Berry
-
doc/coreutils.texi:
Address this comment: FIXME: mv's behavior in this case is system-dependent
Better still: fix the code so it's *not* system-dependent.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index be59ae9..7b7e47a 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7923,6 +7923,11 @@ to when they were last installed.
@cindex stripping symbol table information
Strip the symbol tables from installed binary executables.
[EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED] --strip-program
[EMAIL PROTECTED] symbol table information, stripping, program
+Program used to strip binaries.
+
@optBackupSuffix
@optTargetDirectory
diff --git a/src/install.c b/src/install.c
index 0d3927d..a7c3b3d 100644
--- a/src/install.c
+++ b/src/install.c
@@ -131,11 +131,15 @@ static bool strip_files;
/* If true, install a directory instead of a regular file. */
static bool dir_arg;
+/* Program used to strip binaries, "strip" is default */
+static char *strip_program = "strip";
+
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
- PRESERVE_CONTEXT_OPTION = CHAR_MAX + 1
+ PRESERVE_CONTEXT_OPTION = CHAR_MAX + 1,
+ STRIP_PROGRAM_OPTION
};
static struct option const long_options[] =
@@ -154,6 +158,7 @@ static struct option const long_options[] =
a year or two later. */
{"preserve_context", no_argument, NULL, PRESERVE_CONTEXT_OPTION},
{"strip", no_argument, NULL, 's'},
+ {"strip-program", required_argument, NULL, STRIP_PROGRAM_OPTION},
{"suffix", required_argument, NULL, 'S'},
{"target-directory", required_argument, NULL, 't'},
{"verbose", no_argument, NULL, 'v'},
@@ -330,6 +335,7 @@ main (int argc, char **argv)
bool no_target_directory = false;
int n_files;
char **file;
+ bool strip_program_specified = false;
security_context_t scontext = NULL;
/* set iff kernel has extra selinux system calls */
selinux_enabled = (0 < is_selinux_enabled ());
@@ -373,6 +379,10 @@ main (int argc, char **argv)
signal (SIGCHLD, SIG_DFL);
#endif
break;
+ case STRIP_PROGRAM_OPTION:
+ strip_program = xstrdup (optarg);
+ strip_program_specified = true;
+ break;
case 'd':
dir_arg = true;
break;
@@ -514,6 +524,10 @@ main (int argc, char **argv)
free (change);
}
+ if (strip_program_specified && !strip_files)
+ error (0, 0, _("WARNING: ignoring --strip-program option as -s option was "
+ "not specified"));
+
get_ids ();
if (dir_arg)
@@ -708,8 +722,8 @@ strip (char const *name)
error (EXIT_FAILURE, errno, _("fork system call failed"));
break;
case 0: /* Child. */
- execlp ("strip", "strip", name, NULL);
- error (EXIT_FAILURE, errno, _("cannot run strip"));
+ execlp (strip_program, strip_program, name, NULL);
+ error (EXIT_FAILURE, errno, _("cannot run %s"), strip_program);
break;
default: /* Parent. */
if (waitpid (pid, &status, 0) < 0)
@@ -828,6 +842,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-p, --preserve-timestamps apply access/modification times of SOURCE files\n\
to corresponding destination files\n\
-s, --strip strip symbol tables\n\
+ --strip-program=PROGRAM program used to strip binaries\n\
-S, --suffix=SUFFIX override the usual backup suffix\n\
-t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY\n\
-T, --no-target-directory treat DEST as a normal file\n\
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 59d1e48..8a58356 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -311,6 +311,7 @@ TESTS = \
install/basic-1 \
install/create-leading \
install/d-slashdot \
+ install/strip-program \
install/trap \
ln/backup-1 \
ln/hard-backup \
diff --git a/tests/install/strip-program b/tests/install/strip-program
new file mode 100755
index 0000000..01a7753
--- /dev/null
+++ b/tests/install/strip-program
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Ensure "install -s --strip-program=PROGRAM" uses the program to strip
+
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ ls --version
+fi
+
+. $srcdir/test-lib.sh
+
+fail=0
+
+# Don't let a different umask perturb the results.
+umask 22
+
+echo test > src || fail=1
+echo dest > out1 || fail=1
+ginstall src dest -s --strip-program=echo > out2 || fail=1
+compare out1 out2 || fail=1
+
+(exit $fail); exit $fail
--
1.5.4.1
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils