diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | doc/coreutils.texi | 5 | ||||
-rw-r--r-- | src/install.c | 21 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rwxr-xr-x | tests/install/strip-program | 41 |
6 files changed, 68 insertions, 6 deletions
@@ -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 @@ -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 be59ae9aa..7b7e47a1f 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. +@itemx --strip-program=@var{program} +@opindex --strip-program +@cindex symbol table information, stripping, program +Program used to strip binaries. + @optBackupSuffix @optTargetDirectory diff --git a/src/install.c b/src/install.c index 0d3927df4..a7c3b3d88 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 59d1e489c..8a5835624 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 000000000..57597fcd3 --- /dev/null +++ b/tests/install/strip-program @@ -0,0 +1,41 @@ +#!/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 + ginstall --version +fi + +. $srcdir/test-lib.sh + +working_umask_or_skip_ + +cat <<EOF > b || framework_failure +#!$POSIX_SHELL +sed s/b/B/ \$1 > \$1.t && mv \$1.t \$1 +EOF +chmod a+x b || framework_failure + +fail=0 + +echo abc > src || fail=1 +echo aBc > exp || fail=1 +ginstall src dest -s --strip-program=./b || fail=1 +compare dest exp || fail=1 + +(exit $fail); exit $fail |