Index: head/Mk/Scripts/check-stagedir.sh =================================================================== --- head/Mk/Scripts/check-stagedir.sh (revision 334662) +++ head/Mk/Scripts/check-stagedir.sh (revision 334663) @@ -1,113 +1,115 @@ #!/bin/sh # ports/Mk/Scripts/check-stagedir.sh - called from ports/Mk/bsd.stage.mk +# $FreeBSD$ set -e export LC_ALL=C # lists an mtree file's contents, prefixed to dir. listmtree() { # mtreefile prefix { echo '#mtree' sed 's/nochange$//;' $1 } | tar -tf- | sed "s,^,$2/,;s,^$2/\.$,$2,;s,^$,/," } # obtain operating mode from command line makeplist=0 case "$1" in orphans) ;; makeplist) makeplist=1 ;; *) echo >&2 "Usage: $0 {orphans|makelist}" ; exit 1 ;; esac # validate environment -envfault=0 +envfault= for i in STAGEDIR PREFIX LOCALBASE WRKDIR WRKSRC MTREE_FILE \ TMPPLIST DATADIR DOCSDIR EXAMPLESDIR do - if eval test -z "\$$i" ; then - echo >&2 "Environment variable $i undefined. Aborting." - envfault=1 + if ! ( eval ": \${${i}?}" ) 2>/dev/null ; then + envfault="${envfault}${envfault:+" "}${i}" fi done -if [ $envfault -ne 0 ] ; then +if [ -n "$envfault" ] ; then + echo "Environment variables $envfault undefined. Aborting." \ + | fmt >&2 exit 1 fi set -u #### EXPAND TMPPLIST TO ABSOLUTE PATHS, SPLITTING FILES AND DIRS TO # Use file descriptors 1 and 3 so that the while loop can write # files to the pipe and dirs to a separate file. if [ $makeplist = 0 ] ; then # check for orphans cwd=${PREFIX} while read line; do case $line in @dirrm*|'@unexec rmdir'*) line="$(printf %s "$line" \ | sed -Ee 's/\|\|.*//;s|[0-9]*[[:space:]]*>[&]?[[:space:]]*[^[:space:]]+||g' \ -e "/^@unexec[[:space:]]+rmdir/s|([^%])%D([^%])|\1${PREFIX}\2|g" \ -e '/^@unexec[[:space:]]+rmdir/s|"(.*)"[[:space:]]+|\1|g' \ -e 's/@unexec[[:space:]]+rmdir[[:space:]]+//' \ -e 's/@dirrm(try)?[[:space:]]+//' \ -e 's/[[:space:]]+$//')" case "$line" in /*) echo >&3 "$line" ;; *) echo >&3 "$cwd/$line" ;; esac ;; # order matters here - we must check @cwd first because # otherwise the @cwd* would also match it first, shadowing the # @cwd) line. @cwd|@cd) cwd=${PREFIX} ;; @cwd*|@cd*) set -- $line ; cwd=$2 ;; @*) ;; /*) echo "$line" ;; *) echo "$cwd/$line" ;; esac done < ${TMPPLIST} 3>${WRKDIR}/.plist-dirs-unsorted | sort >${WRKDIR}/.plist-files else # generate plist - pretend the plist had been empty : >${WRKDIR}/.plist-dirs-unsorted : >${WRKDIR}/.plist-files fi ### PRODUCE MTREE FILE { listmtree /etc/mtree/BSD.root.dist "" #listmtree /etc/mtree/BSD.usr.dist /usr listmtree /etc/mtree/BSD.var.dist /var if [ -n "${MTREE_FILE}" ]; then listmtree "${MTREE_FILE}" "${PREFIX}" fi a=${PREFIX} while :; do + echo ${a} a=${a%/*} [ -z "${a}" ] && break - echo ${a} done } > ${WRKDIR}/.mtree ### HANDLE FILES find ${STAGEDIR} -type f -o -type l | sort | sed -e "s,${STAGEDIR},," >${WRKDIR}/.staged-files comm -13 ${WRKDIR}/.plist-files ${WRKDIR}/.staged-files \ | sed \ -e "s,${DOCSDIR},%%PORTDOCS%%%%DOCSDIR%%,g" \ -e "s,${EXAMPLESDIR},%%PORTEXAMPLES%%%%EXAMPLESDIR%%,g" \ -e "s,${DATADIR},%%DATADIR%%,g" \ -e "s,${PREFIX}/,,g" | grep -v "^share/licenses" || [ $? = 1 ] ### HANDLE DIRS cat ${WRKDIR}/.plist-dirs-unsorted ${WRKDIR}/.mtree | sort -u >${WRKDIR}/.traced-dirs find ${STAGEDIR} -type d | sed -e "s,^${STAGEDIR},,;/^$/d" | sort >${WRKDIR}/.staged-dirs comm -13 ${WRKDIR}/.traced-dirs ${WRKDIR}/.staged-dirs \ | sort -r | sed \ -e "s,\(.*\)${DOCSDIR},%%PORTDOCS%%\1%%DOCSDIR%%,g" \ -e "s,\(.*\)${EXAMPLESDIR},%%PORTEXAMPLES%%\1%%EXAMPLESDIR%%,g" \ -e "s,${DATADIR},%%DATADIR%%,g" \ -e "s,${PREFIX}/,,g" \ -e 's,^,@dirrmtry ,' \ -e 's,@dirrmtry \(/.*\),@unexec rmdir >/dev/null 2>\&1 \1 || :,' | grep -v "^@dirrmtry share/licenses" || [ $? = 1 ] Property changes on: head/Mk/Scripts/check-stagedir.sh ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/Mk/Scripts/qa.sh =================================================================== --- head/Mk/Scripts/qa.sh (revision 334662) +++ head/Mk/Scripts/qa.sh (revision 334663) @@ -1,116 +1,119 @@ #!/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 +LF=$(printf '\nX') +LF=${LF%X} + warn() { echo "Warning: $@" >&2 } err() { echo "Error: $@" >&2 } shebang() { rc=0 - for f in `find ${STAGEDIR} -type f`; do + IFS="$LF" ; for f in `find ${STAGEDIR} -type f`; do interp=$(sed -n -e '1s/^#![[:space:]]*\([^[:space:]]*\).*/\1/p;2q' $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 + IFS="$LF" ; 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 + IFS="$LF" ; 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 # this is fatal [ -n "${STRIP}" ] || return 0 - for f in `find ${STAGEDIR} -type f`; do + IFS="$LF" ; for f in `find ${STAGEDIR} -type f`; do output=`/usr/bin/file ${f}` case "${output}" in *:*\ ELF\ *,\ not\ stripped*) warn "${f} is not stripped consider using \${STRIP_CMD}";; esac done } desktopfileutils() { if [ -z "${USESDESKTOPFILEUTILS}" ]; then grep -q MimeType= ${STAGEDIR}${PREFIX}/share/applications/*.desktop 2>/dev/null && warn "you need USES=desktop-file-utils" else grep -q MimeType= ${STAGEDIR}${PREFIX}/share/applications/*.desktop 2>/dev/null || warn "you may not need USES=desktop-file-utils" fi return 0 } sharedmimeinfo() { if [ -z "${USESSHAREDMIMEINFO}" ]; then find ${STAGEDIR}${PREFIX}/share/mime/packages/*.xml ! -name "freedesktop\.org\.xml" -quit 2>/dev/null && warn "you need USES=shared-mime-info" else find ${STAGEDIR}${PREFIX}/share/mime/packages/*.xml ! -name "freedesktop\.org\.xml" -quit 2>/dev/null || warn "you may not need USES=shared-mime-info" fi return 0 } suidfiles() { filelist=`find ${STAGEDIR} -type f \ \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ \( -perm -u+s -or -perm -g+s \)` if [ -n "${filelist}" ]; then warn "setuid files in the stage directory (are these necessary?):" ls -liTd ${filelist} fi return 0 } checks="shebang symlinks paths stripped desktopfileutils sharedmimeinfo suidfiles" ret=0 cd ${STAGEDIR} for check in ${checks}; do ${check} || ret=1 done exit $ret