Date: Mon, 11 Sep 2000 14:41:34 -0300 From: "Mario Sergio Fujikawa Ferreira" <lioux@uol.com.br> To: freebsd-ports@freebsd.org Subject: bsd.port.mk addition STRIP_PROGRAM Message-ID: <20000911144133.A8211@Fedaykin.here>
next in thread | raw e-mail | index | archive | help
--vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Reading the USE_LINUX thread, I thought about contributing a little token of my appreciation. The patch is bit crude. (/me apologizes) I added a -P flag to the install program, so that it is possible to specify alternate stripping programs. However, a sanity checking on the -P paramater is in order to avoid any future problems. Besides, I added a little logic to bsd.port.mk to allow automatic change of the strip program, e.g., when USE_LINUX is in use (the appropriate linux ABI strip should be used). Unfortunaly, for compability purposes, the patch is rather ugly. I tried to keep with the old "STRIP= " behavior, stripping does not occur when STRIP is empty. I hope this gets commited since it is useful and a very simple patch (if you do not consider the missing sanity path checking before the execlp on xinstall.c). :) Regards, Mario Ferreira --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="xinstall.patch" diff -ruN /usr/src/usr.bin/xinstall/install.1 xinstall/install.1 --- /usr/src/usr.bin/xinstall/install.1 Thu Mar 2 00:46:57 2000 +++ xinstall/install.1 Mon Sep 11 14:33:33 2000 @@ -41,20 +41,22 @@ .Sh SYNOPSIS .Nm install .Op Fl CcDMpsv +.Op Fl P Ar strip program .Op Fl f Ar flags .Op Fl g Ar group .Op Fl m Ar mode +\&... .Op Fl o Ar owner .Ar file1 file2 .Nm install .Op Fl CcDMpsv +.Op Fl P Ar strip program .Op Fl f Ar flags .Op Fl g Ar group .Op Fl m Ar mode -.Op Fl o Ar owner -.Ar file1 \&... -.Ar fileN directory +.Op Fl o Ar owner +.Ar file1 fileN directory .Nm install .Fl d .Op Fl v @@ -121,6 +123,11 @@ .It Fl o Specify an owner. A numeric UID is allowed. +.It Fl P +Specify an alternate program to use when stripping binaries. Stripping occurs with +.Fl s . +Default is +.Xr strip 1 . .It Fl p Preserve the modification time. Copy the file, as if the diff -ruN /usr/src/usr.bin/xinstall/xinstall.c xinstall/xinstall.c --- /usr/src/usr.bin/xinstall/xinstall.c Wed Jun 28 04:42:40 2000 +++ xinstall/xinstall.c Mon Sep 11 14:29:42 2000 @@ -92,6 +92,8 @@ char *group, *owner, pathbuf[MAXPATHLEN]; char pathbuf2[MAXPATHLEN]; +#define DEFAULT_STRIP_PROGRAM "strip" + #define DIRECTORY 0x01 /* Tell install it's a directory. */ #define SETFLAGS 0x02 /* Tell install to set flags. */ #define NOCHANGEBITS (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND) @@ -99,9 +101,9 @@ void copy __P((int, char *, int, char *, off_t)); int compare __P((int, const char *, int, const char *, const struct stat *, const struct stat *)); -void install __P((char *, char *, u_long, u_int)); +void install __P((char *, char *, char *, u_long, u_int)); void install_dir __P((char *)); -void strip __P((char *)); +void strip __P((char*, char *)); void usage __P((void)); int trymmap __P((int)); @@ -132,10 +134,10 @@ u_long fset; u_int iflags; int ch, no_target; - char *flags, *to_name; + char *flags, *to_name, *strip_path = NULL; iflags = 0; - while ((ch = getopt(argc, argv, "CcdDf:g:m:Mo:psv")) != -1) + while ((ch = getopt(argc, argv, "CcdDf:g:m:Mo:P:psv")) != -1) switch((char)ch) { case 'C': docompare = docopy = 1; @@ -171,6 +173,9 @@ case 'o': owner = optarg; break; + case 'P': + strip_path = optarg; + break; case 'p': docompare = docopy = dopreserve = 1; break; @@ -222,7 +227,7 @@ no_target = stat(to_name = argv[argc - 1], &to_sb); if (!no_target && (to_sb.st_mode & S_IFMT) == S_IFDIR) { for (; *argv != to_name; ++argv) - install(*argv, to_name, fset, iflags | DIRECTORY); + install(*argv, to_name, strip_path, fset, iflags | DIRECTORY); exit(EX_OK); /* NOTREACHED */ } @@ -259,7 +264,7 @@ (void)unlink(to_name); #endif } - install(*argv, to_name, fset, iflags); + install(*argv, to_name, strip_path, fset, iflags); exit(EX_OK); /* NOTREACHED */ } @@ -313,8 +318,8 @@ * build a path name and install the file */ void -install(from_name, to_name, fset, flags) - char *from_name, *to_name; +install(from_name, to_name, strip_path, fset, flags) + char *from_name, *to_name, *strip_path; u_long fset; u_int flags; { @@ -394,7 +399,7 @@ if (dostrip) { (void)close(to_fd); - strip(to_name); + strip(strip_path, to_name); /* Reopen target. */ to_fd = open(to_name, O_RDWR, 0); @@ -641,8 +646,8 @@ * use strip(1) to strip the target file */ void -strip(to_name) - char *to_name; +strip(strip_path, to_name) + char *strip_path, *to_name; { int serrno, status; @@ -653,8 +658,15 @@ errno = serrno; err(EX_TEMPFAIL, "fork"); case 0: - execlp("strip", "strip", to_name, NULL); - err(EX_OSERR, "exec(strip)"); + if (strip_path) { + + execlp(strip_path, strip_path, to_name, NULL); + err(EX_OSERR, "exec(%s)", strip_path); + } else { + execlp(DEFAULT_STRIP_PROGRAM, DEFAULT_STRIP_PROGRAM, to_name, NULL); + err(EX_OSERR, "exec(%s)", DEFAULT_STRIP_PROGRAM); + } + default: if (wait(&status) == -1 || status) { (void)unlink(to_name); @@ -705,9 +717,10 @@ usage() { (void)fprintf(stderr,"\ -usage: install [-CcDpsv] [-f flags] [-g group] [-m mode] [-o owner] file1 file2\n\ - install [-CcDpsv] [-f flags] [-g group] [-m mode] [-o owner] file1 ...\n\ - fileN directory\n\ +usage: install [-CcDpsv] [-P strip program] [-f flags] [-g group] [-m mode] ... + [-o owner] file1 file2\n\ + install [-CcDpsv] [-P strip program] [-f flags] [-g group] [-m mode] ... + [-o owner] file1 fileN directory\n\ install -d [-v] [-g group] [-m mode] [-o owner] directory ...\n"); exit(EX_USAGE); /* NOTREACHED */ --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="bsd.port.mk.patch" --- /tmp/bsd.port.mk Mon Sep 11 14:15:11 2000 +++ bsd.port.mk Mon Sep 11 14:23:24 2000 @@ -937,6 +937,12 @@ TOUCH?= /usr/bin/touch TOUCH_FLAGS?= -f +.if defined(USE_LINUX) +STRIP_PROGRAM?= ${LINUXBASE}/usr/bin/strip +.else +STRIP_PROGRAM?= /usr/bin/strip +.endif + PATCH?= /usr/bin/patch PATCH_STRIP?= -p0 PATCH_DIST_STRIP?= -p0 @@ -996,8 +1002,12 @@ MTREE_ARGS?= -U -f ${MTREE_FILE} -d -e -p # A few aliases for *-install targets +.if defined(STRIP) INSTALL_PROGRAM= \ - ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} + ${INSTALL} ${COPY} ${STRIP} -P ${STRIP_PROGRAM} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} +.else + ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} +.endif INSTALL_SCRIPT= \ ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} INSTALL_DATA= \ --vtzGhvizbBRQ85DL-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000911144133.A8211>