pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/check Added a new check for binaries, so that they ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b446195f5fd7
branches:  trunk
changeset: 538595:b446195f5fd7
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Feb 13 15:02:20 2008 +0000

description:
Added a new check for binaries, so that they are installed according to
the INSTALL_UNSTRIPPED variable. By default, this check is disabled, so
that it does not cause any breakage.

NB: The file(1) command needs the explicit locale to prevent translated
messages. This file is copied from check-interpreter.mk.

diffstat:

 mk/check/bsd.check.mk      |   3 +-
 mk/check/check-stripped.mk |  58 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletions(-)

diffs (79 lines):

diff -r 53778b5472b7 -r b446195f5fd7 mk/check/bsd.check.mk
--- a/mk/check/bsd.check.mk     Wed Feb 13 15:00:51 2008 +0000
+++ b/mk/check/bsd.check.mk     Wed Feb 13 15:02:20 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.check.mk,v 1.7 2008/02/10 11:44:48 tnn Exp $
+# $NetBSD: bsd.check.mk,v 1.8 2008/02/13 15:02:20 rillig Exp $
 #
 # This Makefile fragment is included by bsd.pkg.mk and provides all
 # variables and targets related to build and install checks.
@@ -31,6 +31,7 @@
 .include "check-perms.mk"
 .include "check-portability.mk"
 .include "check-shlibs.mk"
+.include "check-stripped.mk"
 .include "check-vulnerable.mk"
 .include "check-wrkref.mk"
 .include "check-fakehome.mk"
diff -r 53778b5472b7 -r b446195f5fd7 mk/check/check-stripped.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/check/check-stripped.mk        Wed Feb 13 15:02:20 2008 +0000
@@ -0,0 +1,58 @@
+# $NetBSD: check-stripped.mk,v 1.1 2008/02/13 15:02:20 rillig Exp $
+#
+# This file checks that after installation, all binaries conform to the
+# setting of INSTALL_UNSTRIPPED.
+#
+# User-settable variables:
+#
+# CHECK_STRIPPED
+#      Whether this check should be enabled or not.
+#
+#      Default value: "no".
+#
+# Package-settable variables:
+#
+# CHECK_STRIPPED_SKIP
+#      The list of file patterns that are skipped by the check.
+#
+#      Default value: (empty)
+#
+#      Example: bin/* sbin/foo
+#
+
+.if defined(PKG_DEVELOPER)
+CHECK_STRIPPED?=               no      # XXX: change to "yes" later
+.else
+CHECK_STRIPPED?=               no
+.endif
+CHECK_STRIPPED_SKIP?=          # empty
+
+_CHECK_STRIPPED_FILELIST_CMD?= ${SED} -e '/^@/d' ${PLIST}
+
+.if !empty(CHECK_STRIPPED:M[Yy][Ee][Ss])
+privileged-install-hook: _check-stripped
+.endif
+
+_check-stripped: error-check .PHONY
+       @${STEP_MSG} "Checking whether binaries are ${_INSTALL_UNSTRIPPED:Dun:U}stripped."
+       ${RUN} cd ${DESTDIR}${PREFIX};                                  \
+       want_stripped=${_INSTALL_UNSTRIPPED:Dno:Uyes};                  \
+       ${_CHECK_STRIPPED_FILELIST_CMD} | ${SORT} | ${SED} 's,\\,\\\\,g'\
+       | while read file; do                                           \
+               case "$$file" in                                        \
+               ${CHECK_STRIPPED_SKIP:@p@${p}) continue ;;@}            \
+               *) ;;                                                   \
+               esac;                                                   \
+               test -x "$$file" || continue;                           \
+               if [ ! -r "$$file" ]; then                              \
+                       ${DELAYED_WARNING_MSG} "[check-stripped.mk] File \"${DESTDIR}${PREFIX}/$$file\" cannot be read."; \
+                       continue;                                       \
+               fi;                                                     \
+               ftype=`LANG=C LC_ALL=C ${FILE_CMD} ./$$file`;           \
+               case $$want_stripped,$$ftype in                         \
+               yes,*:*\ ELF\ *,\ not\ stripped*) ${DELAYED_ERROR_MSG} "[check-stripped.mk] ${DESTDIR}${PREFIX}/$$file should be stripped, but is not.";; \
+               no,*:*\ ELF\ *,\ stripped*) ${DELAYED_ERROR_MSG} "[check-stripped.mk] ${DESTDIR}${PREFIX}/$$file should NOT be stripped, but it is.";; \
+               no,*:*\ ELF\ *,\ not\ stripped*) ${INFO_MSG} "[check-stripped.mk] ${DESTDIR}${PREFIX}/$$file is not stripped (ok).";; \
+               yes,*:*\ ELF\ *,\ stripped*) ${INFO_MSG} "[check-stripped.mk] ${DESTDIR}${PREFIX}/$$file is stripped (ok).";; \
+               esac;                                                   \
+       done



Home | Main Index | Thread Index | Old Index