diff --git a/Mk/Scripts/qa.sh b/Mk/Scripts/qa.sh index e7cf6dd12199..b214f42af396 100644 --- a/Mk/Scripts/qa.sh +++ b/Mk/Scripts/qa.sh @@ -1,216 +1,216 @@ #!/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 } shebangonefile() { local f interp rc f="$@" rc=0 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) ;; /usr/bin/nawk) ;; /bin/csh) ;; /bin/sh) ;; /bin/tcsh) ;; *) err "'${interp}' is an invalid shebang you need USES=shebangfix for '${f#${STAGEDIR}${PREFIX}/}'" rc=1 ;; esac return ${rc} } shebang() { local f l link rc rc=0 while read f; do # No results presents a blank line from heredoc. [ -z "${f}" ] && continue shebangonefile "${f}" || rc=1 # Use heredoc to avoid losing rc from find|while subshell done <<-EOF $(find ${STAGEDIR}${PREFIX}/bin ${STAGEDIR}${PREFIX}/sbin \ ${STAGEDIR}${PREFIX}/libexec -type f -perm +111 2>/dev/null) EOF # Split stat(1) result into 2 lines and read each line separately to # retain spaces in filenames. while read l; do # No results presents a blank line [ -z "${l}" ] && continue read link case "${link}" in /*) f="${STAGEDIR}${link}" ;; *) f="${l%/*}/${link}" ;; esac if [ -f "${f}" ]; then shebangonefile "${f}" || rc=1 fi # Use heredoc to avoid losing rc from find|while subshell done <<-EOF $(find ${STAGEDIR}${PREFIX}/bin ${STAGEDIR}${PREFIX}/sbin \ ${STAGEDIR}${PREFIX}/libexec -type l \ -exec stat -f "%N${LF}%Y" {} + 2>/dev/null) EOF return ${rc} } symlinks() { local rc rc=0 # Split stat(1) result into 2 lines and read each line separately to # retain spaces in filenames. while read l; do # No results presents a blank line from heredoc. [ -z "${l}" ] && continue read link case "${link}" in ${STAGEDIR}*) err "Bad symlink '${l#${STAGEDIR}${PREFIX}/}' pointing inside the stage directory" rc=1 ;; esac # Use heredoc to avoid losing rc from find|while subshell. done <<-EOF $(find ${STAGEDIR} -type l -exec stat -f "%N${LF}%Y" {} +) EOF return ${rc} } paths() { local rc rc=0 while read f; do # No results presents a blank line from heredoc. [ -z "${f}" ] && continue # Ignore false-positive/harmless files case "${f}" in */lib/ruby/gems/*/Makefile) continue ;; */lib/ruby/gems/*/Makefile.html) continue ;; */lib/ruby/gems/*/mkmf.log) continue ;; */share/texmf-var/web2c/*/*.fmt) continue ;; */share/texmf-var/web2c/*/*.log) continue ;; esac err "'${f#${STAGEDIR}${PREFIX}/}' is referring to ${STAGEDIR}" rc=1 # Use heredoc to avoid losing rc from find|while subshell done <<-EOF $(find ${TMPPLIST} ${STAGEDIR} -type f -exec grep -l "${STAGEDIR}" {} +) EOF return ${rc} } # For now do not raise an error, just warnings stripped() { [ -x /usr/bin/file ] || return # this is fatal [ -n "${STRIP}" ] || return 0 # Split file and result into 2 lines and read separately to ensure # files with spaces are kept intact. find ${STAGEDIR} -type f \ -exec /usr/bin/file -nNF "${LF}" {} + | while read f; do read output case "${output}" in ELF\ *\ executable,\ *FreeBSD*,\ not\ stripped*|ELF\ *\ shared\ object,\ *FreeBSD*,\ not\ stripped*) warn "'${f#${STAGEDIR}${PREFIX}/}' is not stripped consider trying INSTALL_TARGET=install-strip or 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() { local f found found=0 for f in ${STAGEDIR}${PREFIX}/share/mime/packages/*.xml; do [ "${f}" = "${STAGEDIR}${PREFIX}/share/mime/packages/*.xml" ] && break #no matches [ "${f}" = "${STAGEDIR}${PREFIX}/share/mime/packages/freedesktop.org.xml" ] && continue found=1 break done if [ -z "${USESSHAREDMIMEINFO}" -a ${found} -eq 1 ]; then warn "you need USES=shared-mime-info" elif [ -n "${USESSHAREDMIMEINFO}" -a ${found} -eq 0 ]; then warn "you may not need USES=shared-mime-info" fi return 0 } suidfiles() { local filelist 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 } libtool() { if [ -z "${USESLIBTOOL}" ]; then - find ${STAGEDIR} -type f -name '*.la' | while read f; do + find ${STAGEDIR} -name '*.la' | while read f; do grep -q 'libtool library' "${f}" && - warn ".la libraries found, port needs USES=libtool" && - return 0 || true + err ".la libraries found, port needs USES=libtool" && + return 1 || true done # The return above continues here. fi } checks="shebang symlinks paths stripped desktopfileutils sharedmimeinfo suidfiles libtool" ret=0 cd ${STAGEDIR} for check in ${checks}; do ${check} || ret=1 done exit $ret diff --git a/Mk/Uses/libtool.mk b/Mk/Uses/libtool.mk index 7d01d0ef1257..f8e928185931 100644 --- a/Mk/Uses/libtool.mk +++ b/Mk/Uses/libtool.mk @@ -1,87 +1,84 @@ # $FreeBSD$ # # Bring libtool scripts up to date. # # Feature: libtool # Usage: USES=libtool or USES=libtool:args -# Valid args: keepla Normally libtool libraries (*.la) are not installed. -# With this option they are. This is needed as long -# as there are dependent ports with .la libraries that -# refer to .la libraries in this port. As soon as all -# those dependent ports have some form of USES=libtool -# keepla can be removed. +# Valid args: keepla Don't remove libtool libraries (*.la) from the stage +# directory. Some ports need them at runtime (e.g. ports +# that call lt_dlopen from libltdl). # build Add a build dependency on devel/libtool. This can # be used when a port does not generate its own libtool # script and relies on the system to provide one. # # MAINTAINER: autotools@FreeBSD.org .if !defined(_INCLUDE_USES_LIBTOOL_MK) _INCLUDE_USES_LIBTOOL_MK= yes _USES_POST+= libtool libtool_ARGS:= ${libtool_ARGS:C/,/ /} .if ${libtool_ARGS:Mbuild} BUILD_DEPENDS+= libtool:${PORTSDIR}/devel/libtool .endif .endif .if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_LIBTOOL_POST_MK) _INCLUDE_USES_LIBTOOL_POST_MK= yes patch-libtool: @${FIND} ${WRKDIR} \( -name configure -or -name ltconfig \) \ -type f | while read i; do ${SED} -i.bak \ -e '/dragonfly\*/!s/^ *freebsd\*[ )]/dragonfly* | &/' \ -e '/gcc_dir=\\`/s/gcc /$$CC /' \ -e '/gcc_ver=\\`/s/gcc /$$CC /' \ -e '/link_all_deplibs[0-9A-Z_]*=/s/=unknown/=no/' \ -e '/objformat=/s/echo aout/echo elf/' \ -e "/freebsd-elf\\*)/,/;;/ { \ /deplibs_check_method=/s/=.*/=pass_all/; }" \ $${i} && ${TOUCH} -mr $${i}.bak $${i}; done @${FIND} ${WRKDIR} -type f -name ltmain.sh | \ ${XARGS} ${REINPLACE_CMD} \ -e '/if.*linkmode.*prog.*mode.*!= relink/s/if.*;/if :;/'\ -e '/if.*linkmode.*prog.*mode.* = relink/s/||.*;/;/' \ -e 's/|-p|-pg|/|-B*|-p|-pg|/' .if ! ${libtool_ARGS:Moldver} @${FIND} ${WRKDIR} \( -name configure -or -name ltconfig \) \ -type f | while read i; do ${SED} -i.bak \ -e "/freebsd-elf\\*)/,/;;/ { \ /library_names_spec=.*\\.so/ \ s/=.*/='\$$libname\$$release.so\$$versuffix \ \$$libname\$$release.so\$$major \$$libname.so' \ soname_spec='\$$libname\$$release.so\$$major'/; \ /library_names_spec=.*shared_ext/ \ s/=.*/='\$$libname\$$release\$$shared_ext\$$versuffix \ \$$libname\$$release\$$shared_ext\$$major \ \$$libname\$$shared_ext' \ soname_spec='\$$libname\$$release\$$shared_ext\$$major'/; \ }" $${i} && ${TOUCH} -mr $${i}.bak $${i}; done @${FIND} ${WRKDIR} -type f -name ltmain.sh | \ ${XARGS} ${REINPLACE_CMD} \ -e '/case $$version_type in/,+2 \ s/darwin|linux|/darwin|freebsd-elf|linux|/' \ -e '/freebsd-elf)/,+2 { \ /major=/s/=.*/=.$$(($$current - $$age))/; \ /versuffix=/s/=.*/="$$major.$$age.$$revision"/; }' .endif patch-lafiles: .if ${libtool_ARGS:Mkeepla} || ${libtool_ARGS:Moldver} @${FIND} ${STAGEDIR} -type f -name '*.la' | \ ${XARGS} ${SED} -i '' -e "/dependency_libs=/s/=.*/=''/" .else @${FIND} ${STAGEDIR} -type l -exec ${SH} -c \ 'case `${REALPATH} -q "{}"` in \ *.la) ${ECHO_CMD} "{}" ;; esac' \; | \ ${XARGS} ${GREP} -l 'libtool library' | ${XARGS} ${RM} @${FIND} ${STAGEDIR} -type f -name '*.la' | \ ${XARGS} ${GREP} -l 'libtool library' | ${XARGS} ${RM} .endif .endif