svn commit: r329902 - in head/Mk: . Scripts
Baptiste Daroussin
bapt at FreeBSD.org
Wed Oct 9 15:11:33 UTC 2013
Author: bapt
Date: Wed Oct 9 15:11:32 2013
New Revision: 329902
URL: http://svnweb.freebsd.org/changeset/ports/329902
Log:
First set of Q/A for staged ports.
A couple of Q/A tests are done if the DEVELOPER macros is set in make.conf
Right now the tests are:
- Check if the symlinks are properly created
- Check if the binaries are stripped (just warn)
- Check if the STAGEDIR or the WORKDIR are referenced in the final files
- Check if the ports provide script with bad shebangs.
Added:
head/Mk/Scripts/qa.sh (contents, props changed)
Directory Properties:
head/Mk/Scripts/ (props changed)
Modified:
head/Mk/bsd.port.mk
head/Mk/bsd.stage.mk
Added: head/Mk/Scripts/qa.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/Mk/Scripts/qa.sh Wed Oct 9 15:11:32 2013 (r329902)
@@ -0,0 +1,82 @@
+#!/bin/sh
+# MAINTAINER: portmgr at FreeBSD.org
+# $FreeBSD$
+
+if [ -z "${STAGEDIR}" -o -z "${PREFIX}" -o -z "${LOCALBASE}" ]; then
+ echo "STAGEDIR, PREFIX, LOCALBASE required in environment." >&2
+ exit 1
+fi
+
+warn() {
+ echo "Warning: $@" >&2
+}
+
+err() {
+ echo "Error: $@" >&2
+}
+
+shebang() {
+ rc=0
+ for f in `find ${STAGEDIR} -type f`; do
+ interp=$(sed -n -e '1s/^#![[:space:]]*\([^[:space:]]*\).*/\1/p' $f)
+ case "$interp" in
+ "") ;;
+ /usr/bin/env) ;;
+ ${LOCALBASE}/*) ;;
+ ${PREFIX}/*) ;;
+ /usr/bin/awk) ;;
+ /usr/bin/sed) ;;
+ /bin/sh) ;;
+ *)
+ err "${interp} is an invalid shebang you need USES=shebangfix for ${f#${STAGEDIR}${PREFIX}/}"
+ rc=1
+ ;;
+ esac
+ done
+}
+
+symlinks() {
+ rc=0
+ for l in `find ${STAGEDIR} -type l`; do
+ link=$(readlink ${l})
+ case "${link}" in
+ ${STAGEDIR}*) err "Bad symlinks ${l} pointing inside the stage directory"
+ rc=1
+ ;;
+ esac
+ done
+}
+
+paths() {
+ rc=0
+ dirs="${STAGEDIR} ${WRKDIR}"
+ for f in `find ${STAGEDIR} -type f`;do
+ for d in ${dirs}; do
+ if grep -q ${d} ${f} ; then
+ err "${f} is referring to ${d}"
+ rc=1
+ fi
+ done
+ done
+}
+
+# For now do not raise an error, just warnings
+stripped() {
+ [ -x /usr/bin/file ] || return
+ for f in `find ${STAGEDIR} -type f`; do
+ output=`/usr/bin/file ${f}`
+ case "${output}" in
+ *:*\ ELF\ *,\ not\ stripped*) warn "${f} is not stripped";;
+ esac
+ done
+}
+
+checks="shebang symlinks paths stripped"
+
+ret=0
+cd ${STAGEDIR}
+for check in ${checks}; do
+ ${check} || ret=1
+done
+
+exit $ret
Modified: head/Mk/bsd.port.mk
==============================================================================
--- head/Mk/bsd.port.mk Wed Oct 9 14:14:59 2013 (r329901)
+++ head/Mk/bsd.port.mk Wed Oct 9 15:11:32 2013 (r329902)
@@ -1129,6 +1129,7 @@ _DISTDIR?= ${DISTDIR}/${DIST_SUBDIR}
INDEXDIR?= ${PORTSDIR}
SRC_BASE?= /usr/src
USESDIR?= ${PORTSDIR}/Mk/Uses
+SCRIPTSDIR?= ${PORTSDIR}/Mk/Scripts
LIB_DIRS?= /lib /usr/lib ${LOCALBASE}/lib
.if defined(FORCE_STAGE)
@@ -4341,11 +4342,17 @@ _STAGE_SUSEQ= create-users-groups do-ins
install-rc-script install-ldconfig-file install-license \
install-desktop-entries add-plist-info add-plist-docs add-plist-examples \
add-plist-data add-plist-post fix-plist-sequence
+.if defined(DEVELOPER)
+_STAGE_SUSEQ+= stage-qa
+.endif
.else
_STAGE_SEQ+= create-users-groups do-install post-install post-stage compress-man \
install-rc-script install-ldconfig-file install-license \
install-desktop-entries add-plist-info add-plist-docs add-plist-examples \
add-plist-data add-plist-post fix-plist-sequence
+.if defined(DEVELOPER)
+_STAGE_SEQ+= stage-qa
+.endif
.endif
.if defined(WITH_PKGNG)
_INSTALL_DEP= stage
Modified: head/Mk/bsd.stage.mk
==============================================================================
--- head/Mk/bsd.stage.mk Wed Oct 9 14:14:59 2013 (r329901)
+++ head/Mk/bsd.stage.mk Wed Oct 9 15:11:32 2013 (r329902)
@@ -6,6 +6,8 @@ STAGEDIR?= ${WRKDIR}/stage
DESTDIRNAME?= DESTDIR
MAKE_ARGS+= ${DESTDIRNAME}=${STAGEDIR}
+QA_ENV+= STAGEDIR=${STAGEDIR} PREFIX=${PREFIX} \
+ LOCALBASE=${LOCALBASE}
.if !target(stage-dir)
stage-dir:
@@ -153,3 +155,9 @@ check-orphans: stage
-e "s,${DATADIR},%%DATADIR%%,g" \
-e "s,${PREFIX}/,,g" | ${GREP} -v "^@dirrmtry share/licenses" || ${TRUE}
.endif
+
+.if !target(stage-qa)
+stage-qa:
+ @${ECHO_CMD} "====> Running Q/A tests" ; \
+ ${SETENV} ${QA_ENV} ${SH} ${SCRIPTSDIR}/qa.sh
+.endif
More information about the svn-ports-head
mailing list