From owner-svn-ports-head@FreeBSD.ORG Wed Oct 9 15:11:33 2013 Return-Path: Delivered-To: svn-ports-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 45F5BE4F; Wed, 9 Oct 2013 15:11:33 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 335882DFE; Wed, 9 Oct 2013 15:11:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r99FBXj0041927; Wed, 9 Oct 2013 15:11:33 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r99FBWH9041923; Wed, 9 Oct 2013 15:11:32 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201310091511.r99FBWH9041923@svn.freebsd.org> From: Baptiste Daroussin Date: Wed, 9 Oct 2013 15:11:32 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r329902 - in head/Mk: . Scripts X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Oct 2013 15:11:33 -0000 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@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