Index: Mk/Scripts/actual-package-depends.sh =================================================================== --- Mk/Scripts/actual-package-depends.sh +++ Mk/Scripts/actual-package-depends.sh @@ -12,21 +12,21 @@ resolv_symlink() { local file tgt file=${1} - if [ ! -L ${file} ] ; then - echo ${file} + if [ ! -L "${file}" ] ; then + echo "${file}" return fi - tgt=`readlink ${file}` + tgt=$(readlink "${file}") case $tgt in /*) - echo $tgt + echo "$tgt" return ;; esac file=${file%/*}/${tgt} - absolute_path ${file} + absolute_path "${file}" } absolute_path() { @@ -35,6 +35,8 @@ myifs=${IFS} IFS='/' + # shellcheck disable=SC2086 + # we want splitting here. set -- ${file} IFS=${myifs} for el; do @@ -45,7 +47,7 @@ *) target="${target}/${el}" ;; esac done - echo ${target} + echo "${target}" } find_dep() { @@ -60,15 +62,15 @@ searchfile=$pattern ;; *) - searchfile=$(/usr/bin/which ${pattern} 2>/dev/null) + searchfile=$(/usr/bin/which "${pattern}" 2>/dev/null) ;; esac if [ -n "${searchfile}" ]; then - ${PKG_BIN} which -q ${searchfile} || ${PKG_BIN} which -q "$(resolv_symlink ${searchfile} 2>/dev/null)" || + ${PKG_BIN} which -q "${searchfile}" || ${PKG_BIN} which -q "$(resolv_symlink "${searchfile}" 2>/dev/null)" || echo "actual-package-depends: dependency on ${searchfile} not registered (normal if it belongs to base)" >&2 fi } for lookup; do - ${PKG_BIN} query "\"%n\": {origin: \"%o\", version: \"%v\"}" "$(find_dep ${lookup})" || : + ${PKG_BIN} query "\"%n\": {origin: \"%o\", version: \"%v\"}" "$(find_dep "${lookup}")" || : done Index: Mk/Scripts/check-stagedir.sh =================================================================== --- Mk/Scripts/check-stagedir.sh +++ Mk/Scripts/check-stagedir.sh @@ -13,14 +13,14 @@ set -e -. ${SCRIPTSDIR}/functions.sh +. "${SCRIPTSDIR}"/functions.sh # 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,^$,/," + sed 's/nochange$//;' "$1" + } | tar -tf- | sed "s,^,$2/,;s,^$2/\\.$,$2,;s,^$,/," } ### PRODUCE MTREE FILE @@ -45,27 +45,27 @@ # Add LOCALBASE a=${LOCALBASE} while :; do - echo ${a} + echo "${a}" a=${a%/*} [ -z "${a}" ] && break done # Add in PREFIX if this port wants it - if [ ${NO_PREFIX_RMDIR} -eq 0 ]; then + if [ "${NO_PREFIX_RMDIR}" -eq 0 ]; then a=${PREFIX} while :; do - echo ${a} + echo "${a}" a=${a%/*} [ -z "${a}" ] && break done fi - } >${WRKDIR}/.mtree + } >"${WRKDIR}"/.mtree } -# Sort a directory list by the order of the dfs-sorted file (from find -ds) +# Sort a directory list by the order of the dfs-sorted file (from find -d -s) sort_dfs() { - while read dir; do - grep "^[0-9]* ${dir}$" ${WRKDIR}/.staged-dirs-dfs-sorted + while read -r dir; do + grep "^[0-9]* ${dir}$" "${WRKDIR}"/.staged-dirs-dfs-sorted done | sort -n | cut -d ' ' -f2- } @@ -73,7 +73,7 @@ setup_plist_seds() { ### HANDLE PORTDOCS/PORTEXAMPLES sed_portdocsexamples="/%%DOCSDIR%%/s!^!%%PORTDOCS%%!g; /%%EXAMPLESDIR%%/s!^!%%PORTEXAMPLES%%!g;" - if [ ${makeplist} -eq 0 ]; then + if [ "${makeplist}" -eq 0 ]; then # echo "=====> Using OPTIONS: ${PORT_OPTIONS}" | /usr/bin/fmt -w 79 | \ # sed -e '2,$s/^/ /' # Handle magical PORT* features @@ -88,51 +88,51 @@ unset PORT_OPTIONS fi - sed_plist_sub=$(echo "${PLIST_SUB_SED}" | /bin/sh ${SCRIPTSDIR}/plist_sub_sed_sort.sh) + sed_plist_sub=$(echo "${PLIST_SUB_SED}" | /bin/sh "${SCRIPTSDIR}"/plist_sub_sed_sort.sh) unset PLIST_SUB_SED # Used for generate_plist sed_files_gen="s!^${PREFIX}/!!g; ${sed_plist_sub} \ - ${sed_portdocsexamples} /^share\/licenses/d; \ - \#${LOCALBASE}/lib/debug#d;" + ${sed_portdocsexamples} /^share\\/licenses/d; \ + \\#${LOCALBASE}/lib/debug#d;" sed_dirs_gen="s!^${PREFIX}/!!g; ${sed_plist_sub} s,^,@dir ,; \ ${sed_portdocsexamples} \ - /^@dir share\/licenses/d;" + /^@dir share\\/licenses/d;" # These prevent ignoring DOCS/EXAMPLES dirs with sed_portdocsexamples - sed_files="s!^${PREFIX}/!!g; ${sed_plist_sub} /^share\/licenses/d; \ - \#${LOCALBASE}/lib/debug#d;" + sed_files="s!^${PREFIX}/!!g; ${sed_plist_sub} /^share\\/licenses/d; \ + \\#${LOCALBASE}/lib/debug#d;" sed_dirs="s!^${PREFIX}/!!g; ${sed_plist_sub} s,^,@dir ,; \ - /^@dir share\/licenses/d;" + /^@dir share\\/licenses/d;" } # Generate plist from staged files generate_plist() { - : >${WRKDIR}/.staged-plist + : >"${WRKDIR}"/.staged-plist ### 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 | \ + 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 "${sed_files_gen}" \ - >>${WRKDIR}/.staged-plist || : + >>"${WRKDIR}"/.staged-plist || : ### 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-dirrms-sorted - find -sd ${STAGEDIR}${PREFIX} -type d -empty | sed -e "s,^${STAGEDIR},,;\,^${PREFIX}$,d;/^$/d" \ - >${WRKDIR}/.staged-dirs-dfs - find -sd ${STAGEDIR} -type d ! -path "${STAGEDIR}${PREFIX}/*" | sed -e "s,^${STAGEDIR},,;\,^${PREFIX}$,d;/^$/d" \ - >>${WRKDIR}/.staged-dirs-dfs - sort ${WRKDIR}/.staged-dirs-dfs >${WRKDIR}/.staged-dirs-sorted - awk '{print FNR, $0}' ${WRKDIR}/.staged-dirs-dfs \ - >${WRKDIR}/.staged-dirs-dfs-sorted - # Find all staged dirs and then sort them by depth-first (find -ds) - comm -13 ${WRKDIR}/.traced-dirs ${WRKDIR}/.staged-dirs-sorted \ + cat "${WRKDIR}"/.plist-dirs-unsorted "${WRKDIR}"/.mtree \ + | sort -u >"${WRKDIR}"/.traced-dirs + find "${STAGEDIR}" -type d | sed -e "s,^${STAGEDIR},,;/^$/d" | sort \ + >"${WRKDIR}"/.staged-dirrms-sorted + find -s -d "${STAGEDIR}${PREFIX}" -type d -empty | sed -e "s,^${STAGEDIR},,;\\,^${PREFIX}$,d;/^$/d" \ + >"${WRKDIR}"/.staged-dirs-dfs + find -s -d "${STAGEDIR}" -type d ! -path "${STAGEDIR}${PREFIX}/*" | sed -e "s,^${STAGEDIR},,;\\,^${PREFIX}$,d;/^$/d" \ + >>"${WRKDIR}"/.staged-dirs-dfs + sort "${WRKDIR}"/.staged-dirs-dfs >"${WRKDIR}"/.staged-dirs-sorted + awk '{print FNR, $0}' "${WRKDIR}"/.staged-dirs-dfs \ + >"${WRKDIR}"/.staged-dirs-dfs-sorted + # Find all staged dirs and then sort them by depth-first (find -d -s) + comm -13 "${WRKDIR}"/.traced-dirs "${WRKDIR}"/.staged-dirs-sorted \ | sort_dfs | sed "${sed_dirs_gen}" \ - >>${WRKDIR}/.staged-plist || : + >>"${WRKDIR}"/.staged-plist || : } # Check for files in STAGEDIR missing from plist @@ -141,7 +141,7 @@ echo "===> Checking for items in STAGEDIR missing from pkg-plist" # Handle whitelisting - while read path; do + while read -r path; do case "${path}" in *.bak) ;; *.orig) ;; @@ -175,7 +175,7 @@ echo "Error: Orphaned: ${path}" >&2 ;; esac - done < ${WRKDIR}/.staged-plist + done < "${WRKDIR}"/.staged-plist return ${ret} } @@ -183,34 +183,34 @@ check_missing_plist_items() { local ret=0 echo "===> Checking for items in pkg-plist which are not in STAGEDIR" - : >${WRKDIR}/.invalid-plist-missing - comm -23 ${WRKDIR}/.plist-files-no-comments ${WRKDIR}/.staged-files | \ + : >"${WRKDIR}"/.invalid-plist-missing + comm -23 "${WRKDIR}"/.plist-files-no-comments "${WRKDIR}"/.staged-files | \ sed -e "${sed_files}" \ - >>${WRKDIR}/.invalid-plist-missing || : + >>"${WRKDIR}"/.invalid-plist-missing || : # Look for directories, then sort them by DFS. Must create the dirs # so find -ds can be used to sort them. - rm -rf ${WRKDIR}/.missing-dirs > /dev/null 2>&1 || : - mkdir ${WRKDIR}/.missing-dirs - comm -23 ${WRKDIR}/.plist-dirs-sorted-no-comments \ - ${WRKDIR}/.staged-dirrms-sorted > ${WRKDIR}/.missing-plist-dirs + rm -rf "${WRKDIR}"/.missing-dirs > /dev/null 2>&1 || : + mkdir "${WRKDIR}"/.missing-dirs + comm -23 "${WRKDIR}"/.plist-dirs-sorted-no-comments \ + "${WRKDIR}"/.staged-dirrms-sorted > "${WRKDIR}"/.missing-plist-dirs # Creates the dirs in WRKDIR/.missing-dirs and ensure spaces are # quoted. sed -e "s,^,${WRKDIR}/.missing-dirs," \ -e 's,^\(.*\)$,"\1",' \ - ${WRKDIR}/.missing-plist-dirs | xargs mkdir -p - find -ds ${WRKDIR}/.missing-dirs | \ + "${WRKDIR}"/.missing-plist-dirs | xargs mkdir -p + find -d -s "${WRKDIR}"/.missing-dirs | \ sed -e "s,^${WRKDIR}/.missing-dirs,," | \ - while read dir; do \ - grep -x "${dir}" ${WRKDIR}/.missing-plist-dirs || :; done | \ + while read -r dir; do \ + grep -x "${dir}" "${WRKDIR}"/.missing-plist-dirs || :; done | \ sed "${sed_dirs}" \ - >>${WRKDIR}/.invalid-plist-missing || : - rm -rf ${WRKDIR}/.missing-dirs + >>"${WRKDIR}"/.invalid-plist-missing || : + rm -rf "${WRKDIR}"/.missing-dirs if [ -s "${WRKDIR}/.invalid-plist-missing" ]; then ret=1 - while read line; do + while read -r line; do echo "Error: Missing: ${line}" >&2 - done < ${WRKDIR}/.invalid-plist-missing + done < "${WRKDIR}"/.invalid-plist-missing fi return ${ret} } @@ -234,23 +234,23 @@ if [ $makeplist = 0 ] ; then echo "===> Parsing plist" - parse_plist "${PREFIX}" 1 < ${TMPPLIST} \ - 3>${WRKDIR}/.plist-dirs-unsorted \ - >${WRKDIR}/.plist-files-unsorted + parse_plist "${PREFIX}" 1 < "${TMPPLIST}" \ + 3>"${WRKDIR}"/.plist-dirs-unsorted \ + >"${WRKDIR}"/.plist-files-unsorted unset TMPPLIST # Create the -no-comments files and trim out @comment from the plists. # This is used for various tests later. - sed -e '/^@comment/d' ${WRKDIR}/.plist-dirs-unsorted \ - >${WRKDIR}/.plist-dirs-unsorted-no-comments - sed -i '' -e 's/^@comment //' ${WRKDIR}/.plist-dirs-unsorted - sed -e '/^@comment/d' ${WRKDIR}/.plist-files-unsorted | sort \ - >${WRKDIR}/.plist-files-no-comments - sed -e 's/^@comment //' ${WRKDIR}/.plist-files-unsorted | sort \ - >${WRKDIR}/.plist-files + sed -e '/^@comment/d' "${WRKDIR}"/.plist-dirs-unsorted \ + >"${WRKDIR}"/.plist-dirs-unsorted-no-comments + sed -i '' -e 's/^@comment //' "${WRKDIR}"/.plist-dirs-unsorted + sed -e '/^@comment/d' "${WRKDIR}"/.plist-files-unsorted | sort \ + >"${WRKDIR}"/.plist-files-no-comments + sed -e 's/^@comment //' "${WRKDIR}"/.plist-files-unsorted | sort \ + >"${WRKDIR}"/.plist-files else # generate plist - pretend the plist had been empty - : >${WRKDIR}/.plist-dirs-unsorted - : >${WRKDIR}/.plist-files + : >"${WRKDIR}"/.plist-dirs-unsorted + : >"${WRKDIR}"/.plist-files echo '/you/have/to/check/what/makeplist/gives/you' fi @@ -261,15 +261,15 @@ # If just making plist, show results and exit successfully. if [ ${makeplist} -eq 1 ]; then - cat ${WRKDIR}/.staged-plist + cat "${WRKDIR}"/.staged-plist exit 0 fi check_orphans_from_plist || ret=1 # Prepare plist-dirs for directory checks -sort -u ${WRKDIR}/.plist-dirs-unsorted-no-comments \ - >${WRKDIR}/.plist-dirs-sorted-no-comments +sort -u "${WRKDIR}"/.plist-dirs-unsorted-no-comments \ + >"${WRKDIR}"/.plist-dirs-sorted-no-comments check_missing_plist_items || ret=1 Index: Mk/Scripts/check_leftovers.sh =================================================================== --- Mk/Scripts/check_leftovers.sh +++ Mk/Scripts/check_leftovers.sh @@ -35,21 +35,21 @@ if [ -n "${PREFIX}" ]; then PORT_FLAGS="${PORT_FLAGS} PREFIX=${PREFIX}" else - PREFIX=$(make -C ${portdir} -VPREFIX) + PREFIX=$(make -C "${portdir}" -VPREFIX) fi if [ -n "${LOCALBASE}" ]; then PORT_FLAGS="${PORT_FLAGS} LOCALBASE=${LOCALBASE}" else - LOCALBASE=$(make -C ${portdir} -VLOCALBASE) + LOCALBASE=$(make -C "${portdir}" -VLOCALBASE) fi if [ -z "${CCACHE_DIR}" ]; then - CCACHE_DIR=$(make -C ${portdir} -VCCACHE_DIR) + CCACHE_DIR=$(make -C "${portdir}" -VCCACHE_DIR) fi -homedirs=$(awk -F: -v users=$(make -C ${portdir} -V USERS|sed -e 's, ,|,g;/^$/d;s,^,^(,;s,$,)$,') 'users && $1 ~ users {print $9}' ${PORTSDIR}/UIDs|sort -u|sed -e "s|/usr/local|${PREFIX}|"|tr "\n" " ") -plistsub_sed=$(make -C ${portdir} -VPLIST_SUB_SED | /bin/sh ${PORTSDIR}/Mk/Scripts/plist_sub_sed_sort.sh) -tmpplist=$(make -C ${portdir} -VTMPPLIST) +homedirs=$(awk -F: -v users="$(make -C "${portdir}" -V USERS|sed -e 's, ,|,g;/^$/d;s,^,^(,;s,$,)$,')" 'users && $1 ~ users {print $9}' "${PORTSDIR}"/UIDs|sort -u|sed -e "s|/usr/local|${PREFIX}|"|tr "\\n" " ") +plistsub_sed=$(make -C "${portdir}" -VPLIST_SUB_SED | /bin/sh "${PORTSDIR}"/Mk/Scripts/plist_sub_sed_sort.sh) +tmpplist=$(make -C "${portdir}" -VTMPPLIST) -while read modtype path extra; do +while read -r modtype path extra; do # Ignore everything from these files/directories case "${path}" in ${CCACHE_DIR}/*|\ @@ -95,7 +95,7 @@ # Don't show dirs already in plist (due to parents) grep -qE \ "^@(unexec rmdir \"?(%D/|${PREFIX})?${path#${PREFIX}/}[ \"]|dir(rm|rmtry)? ${path#${PREFIX}/}\$)" \ - ${tmpplist} && continue + "${tmpplist}" && continue fi # Check absolute paths @@ -152,10 +152,8 @@ share/xml/catalog.ports) ;; # Ignore ghc's doc index share/doc/ghc-%%GHC_VERSION%%/*) ;; - share/doc/ghc-%%GHC_VERSION%%/html/libraries/%%PORTNAME%%-%%PORTVERSION%%/html) ;; # Ignore ghc's package conf lib/ghc-%%GHC_VERSION%%/package.conf.d/*) ;; - lib/ghc-%%GHC_VERSION%%/package.conf.d/%%PORTNAME%%-%%PORTVERSION%%.conf) ;; # Ignore common system config files /etc/group|\ /etc/make.conf|\ Index: Mk/Scripts/checksum.sh =================================================================== --- Mk/Scripts/checksum.sh +++ Mk/Scripts/checksum.sh @@ -70,6 +70,8 @@ if [ "${OK:=true}" = "retry" ] && [ "${dp_FETCH_REGET}" -gt 0 ]; then ${dp_ECHO_MSG} "===> Refetch for ${dp_FETCH_REGET} more times files: $refetchlist" + # shellcheck disable=SC2086 + # dp_MAKEFLAGS contains arguments, needs splitting. if ${dp_MAKE} -C "${dp_CURDIR}" ${dp_MAKEFLAGS} FORCE_FETCH_LIST="$refetchlist" FETCH_REGET="$((dp_FETCH_REGET - 1))" fetch; then if ${dp_MAKE} -C "${dp_CURDIR}" ${dp_MAKEFLAGS} FETCH_REGET="$((dp_FETCH_REGET - 1))" checksum ; then OK="true" @@ -87,7 +89,7 @@ if [ "$OK" != "true" ]; then exit 1 fi -elif [ -n "${@}" ]; then +elif [ -n "${*}" ]; then ${dp_ECHO_MSG} "=> No checksum file (${dp_DISTINFO_FILE})." exit 1 fi Index: Mk/Scripts/create-manifest.sh =================================================================== --- Mk/Scripts/create-manifest.sh +++ Mk/Scripts/create-manifest.sh @@ -26,17 +26,17 @@ lst=$2 for elt in ${lst} ; do - if [ ${elt} = ${str} ]; then + if [ "${elt}" = "${str}" ]; then return 0 fi done return 1 } -mkdir -p ${dp_METADIR} +mkdir -p "${dp_METADIR}" # Save stdout and redirect it to the manifest file. -exec 3>&1 >${dp_METADIR}/+MANIFEST +exec 3>&1 >"${dp_METADIR}"/+MANIFEST # First, all the required bits cat <> ${output} + [ -f "${input}" ] && cat "${input}" >> "${output}" done done done # *** STARTING NOW, STDOUT is +DISPLAY *** -exec >${dp_METADIR}/+DISPLAY +exec >"${dp_METADIR}/+DISPLAY" for message in ${dp_PKGMESSAGES}; do [ -f "${message}" ] && cat "${message}" done # Try and keep these messages in sync with check-deprecated -if [ ${dp_MAINTAINER} = "ports@FreeBSD.org" ]; then +if [ "${dp_MAINTAINER}" = "ports@FreeBSD.org" ]; then if [ -f "${dp_METADIR}/+DISPLAY" ]; then echo; fi cat <<-EOT ===> NOTICE: @@ -153,6 +153,6 @@ fi fi -if [ ! -s ${dp_METADIR}/+DISPLAY ]; then - rm -f ${dp_METADIR}/+DISPLAY +if [ ! -s "${dp_METADIR}/+DISPLAY" ]; then + rm -f "${dp_METADIR}/+DISPLAY" fi Index: Mk/Scripts/depends-list.sh =================================================================== --- Mk/Scripts/depends-list.sh +++ Mk/Scripts/depends-list.sh @@ -4,7 +4,7 @@ set -e -. ${dp_SCRIPTSDIR}/functions.sh +. "${dp_SCRIPTSDIR}"/functions.sh recursive=0 missing=0 @@ -56,6 +56,8 @@ unset FLAVOR myifs=${IFS} IFS=: + # shellcheck disable=SC2086 + # we need splitting here. set -- ${_dep} IFS=${myifs} @@ -77,7 +79,7 @@ esac checked="${checked} ${d}" # Check if the dependency actually exists or skip otherwise. - if [ ! -d ${d} ]; then + if [ ! -d "${d}" ]; then echo "${dp_PKGNAME}: \"${d}\" non-existent -- dependency list incomplete" >&2 continue fi @@ -92,11 +94,15 @@ # Grab any needed vars from the port. if [ ${requires_wrkdir} -eq 1 ]; then - set -- $(${dp_MAKE} -C ${d} -VWRKDIR -V_UNIFIED_DEPENDS) + # shellcheck disable=SC2046 + # We want word splitting here. + set -- $(${dp_MAKE} -C "${d}" -VWRKDIR -V_UNIFIED_DEPENDS) wrkdir="$1" shift elif [ ${recursive} -eq 1 ]; then - set -- $(${dp_MAKE} -C ${d} -V_UNIFIED_DEPENDS) + # shellcheck disable=SC2046 + # We want word splitting here. + set -- $(${dp_MAKE} -C "${d}" -V_UNIFIED_DEPENDS) fi # If a WRKDIR is required to show the dependency, check for it. @@ -104,12 +110,16 @@ if [ ${requires_wrkdir} -eq 1 ] && ! [ -d "${wrkdir}" ]; then show_dep=0 fi - [ ${show_dep} -eq 1 ] && echo ${d} + [ ${show_dep} -eq 1 ] && echo "${d}" if [ ${recursive} -eq 1 -o ${requires_wrkdir} -eq 1 -a ${show_dep} -eq 1 ]; then + # shellcheck disable=SC2068 + # Do not add quotes, we want to split the string here. check_dep $@ fi done } checked= +# shellcheck disable=SC2068 +# Do not add quotes, we want to split the string here. check_dep $@ Index: Mk/Scripts/dialog4ports.sh =================================================================== --- Mk/Scripts/dialog4ports.sh +++ Mk/Scripts/dialog4ports.sh @@ -10,12 +10,12 @@ exit 1 fi -: ${DIALOGPORT:=ports-mgmt/dialog4ports} -: ${DIALOGNAME:=dialog4ports} +: "${DIALOGPORT:=ports-mgmt/dialog4ports}" +: "${DIALOGNAME:=dialog4ports}" OPTIONSFILE="$1" -if ! [ -e $DIALOG4PORTS ]; then +if ! [ -e "$DIALOG4PORTS" ]; then # If INSTALL_AS_USER is set then just build and use the WRKDIR version # Also do this if PREFIX!=LOCALBASE to avoid missing file or double # installs @@ -24,27 +24,27 @@ echo "===> Skipping 'config' as ${DIALOGPORT} is not checked out" >&2 exit 1 fi - DIALOG4PORTS=$(${MAKE} -C ${PORTSDIR}/${DIALOGPORT} -V DIALOG4PORTS) + DIALOG4PORTS=$(${MAKE} -C "${PORTSDIR}/${DIALOGPORT}" -V DIALOG4PORTS) if ! [ -e "${DIALOG4PORTS}" ]; then echo "===> Building ${DIALOGNAME} as it is required for the config dialog" - ${MAKE} -C ${PORTSDIR}/${DIALOGPORT} -D NO_DIALOG clean build + ${MAKE} -C "${PORTSDIR}/${DIALOGPORT}" -D NO_DIALOG clean build fi else # Build+install through su-install as normal echo "===> Building/installing ${DIALOGNAME} as it is required for the config dialog" - ${MAKE} -C ${PORTSDIR}/${DIALOGPORT} -D NO_DIALOG clean install + ${MAKE} -C "${PORTSDIR}/${DIALOGPORT}" -D NO_DIALOG clean install # Need to clean again as it can't run twice in 1 call above - ${MAKE} -C ${PORTSDIR}/${DIALOGPORT} -D NO_DIALOG clean + ${MAKE} -C "${PORTSDIR}/${DIALOGPORT}" -D NO_DIALOG clean fi fi # Backwards compat with older version which used stdout [<= 0.1.1] (or stderr [0.1.2]). # Clear environment of PKGNAME or the dialog will show on older versions # that do not understand -v. -if ! env -u PKGNAME ${DIALOG4PORTS} -v > /dev/null 2>&1; then - exec $DIALOG4PORTS > $OPTIONSFILE 2>&1 +if ! env -u PKGNAME "${DIALOG4PORTS}" -v > /dev/null 2>&1; then + exec "$DIALOG4PORTS" > "$OPTIONSFILE" 2>&1 fi # Newer versions use stderr to work around a jail issue # http://lists.freebsd.org/pipermail/freebsd-ports/2013-March/082383.html -exec $DIALOG4PORTS 2> $OPTIONSFILE +exec "$DIALOG4PORTS" 2> "$OPTIONSFILE" Index: Mk/Scripts/do-depends.sh =================================================================== --- Mk/Scripts/do-depends.sh +++ Mk/Scripts/do-depends.sh @@ -5,7 +5,7 @@ set -e -. ${dp_SCRIPTSDIR}/functions.sh +. "${dp_SCRIPTSDIR}"/functions.sh validate_env dp_RAWDEPENDS dp_DEPTYPE dp_DEPENDS_TARGET dp_DEPENDS_PRECLEAN \ dp_DEPENDS_CLEAN dp_DEPENDS_ARGS dp_USE_PACKAGE_DEPENDS \ @@ -23,7 +23,9 @@ target=$2 depends_args=$3 if [ -z "${dp_USE_PACKAGE_DEPENDS}" -a -z "${dp_USE_PACKAGE_DEPENDS_ONLY}" ]; then - MAKEFLAGS="${dp_MAKEFLAGS}" ${dp_MAKE} -C ${origin} -DINSTALLS_DEPENDS ${target} ${depends_args} + # shellcheck disable=SC2086 + # depends_args contains arguments, needs splitting. + MAKEFLAGS="${dp_MAKEFLAGS}" ${dp_MAKE} -C "${origin}" -DINSTALLS_DEPENDS "${target}" ${depends_args} return 0 fi @@ -34,19 +36,21 @@ if [ -r "${pkgfile}" -a "${target}" = "${dp_DEPENDS_TARGET}" ]; then echo "===> Installing existing package ${pkgfile}" if [ "${pkgbase}" = "pkg" ]; then - [ -d ${dp_WRKDIR} ] || mkdir -p ${dp_WRKDIR} - tar xf ${pkgfile} -C ${dp_WRKDIR} -s ",/.*/,,g" "*/pkg-static" - ${dp_WRKDIR}/pkg-static add ${pkgfile} - rm -f ${dp_WRKDIR}/pkg-static + [ -d "${dp_WRKDIR}" ] || mkdir -p "${dp_WRKDIR}" + tar xf "${pkgfile}" -C "${dp_WRKDIR}" -s ",/.*/,,g" "*/pkg-static" + "${dp_WRKDIR}"/pkg-static add "${pkgfile}" + rm -f "${dp_WRKDIR}"/pkg-static else - ${dp_PKG_ADD} -A ${pkgfile} + ${dp_PKG_ADD} -A "${pkgfile}" fi elif [ -n "${dp_USE_PACKAGE_DEPENDS_ONLY}" -a "${target}" = "${dp_DEPENDS_TARGET}" ]; then echo "===> ${dp_PKGNAME} depends on package: ${pkgfile} - not found" >&2 echo "===> USE_PACKAGE_DEPENDS_ONLY set - not building missing dependency from source" >&2 exit 1 else - MAKEFLAGS="${dp_MAKEFLAGS}" ${dp_MAKE} -C ${origin} -DINSTALLS_DEPENDS ${target} ${depends_args} + # shellcheck disable=SC2086 + # depends_args contains arguments, needs splitting. + MAKEFLAGS="${dp_MAKEFLAGS}" ${dp_MAKE} -C "${origin}" -DINSTALLS_DEPENDS "${target}" ${depends_args} fi } @@ -72,7 +76,7 @@ find_file_path() { - if which -s $1 ; then + if which -s "$1" ; then echo "===> ${dp_PKGNAME} depends on executable: $1 - found" return 0 fi @@ -83,7 +87,7 @@ find_lib() { echo -n "===> ${dp_PKGNAME} depends on shared library: $1" - libfile=$(env -i PATH="${PATH}" LIB_DIRS="${dp_LIB_DIRS}" LOCALBASE="${dp_LOCALBASE}" ${dp_SH} ${dp_SCRIPTSDIR}/find-lib.sh $1) + libfile=$(env -i PATH="${PATH}" LIB_DIRS="${dp_LIB_DIRS}" LOCALBASE="${dp_LOCALBASE}" "${dp_SH}" "${dp_SCRIPTSDIR}"/find-lib.sh "$1") if [ -z "${libfile}" ]; then echo " - not found" return 1 @@ -98,6 +102,8 @@ unset FLAVOR myifs=${IFS} IFS=: + # shellcheck disable=SC2086 + # we want splitting here. set -- ${_line} IFS=${myifs} if [ $# -lt 2 -o $# -gt 3 ]; then @@ -170,7 +176,7 @@ if ${fct} "${pattern}" ; then continue fi - [ ${pattern} = "/nonexistent" ] || anynotfound=1 + [ "${pattern}" = "/nonexistent" ] || anynotfound=1 if [ ! -f "${origin}/Makefile" ]; then echo "Error a dependency refers to a non existing origin: ${origin} in ${dp_DEPTYPE}" >&2 Index: Mk/Scripts/do-fetch.sh =================================================================== --- Mk/Scripts/do-fetch.sh +++ Mk/Scripts/do-fetch.sh @@ -112,6 +112,8 @@ ;; esac sites_remaining=0 + # shellcheck disable=SC2086 + # dp_RANDOMIZE_SITES contains arguments, with spaces, needs to be split. sites="$(${SORTED_MASTER_SITES_CMD_TMP} ${dp_RANDOMIZE_SITES})" for site in ${sites}; do sites_remaining=$((sites_remaining + 1)) @@ -137,6 +139,8 @@ case ${dp_TARGET} in do-fetch|makesum) ${dp_ECHO_MSG} "=> Attempting to fetch ${site}${file}" + # shellcheck disable=SC2086 + # _fetch_cmd contains arguments, with spaces, needs to be split. if env -S "${dp_FETCH_ENV}" ${_fetch_cmd}; then actual_size=$(stat -f %z "${file}") if [ -n "${dp_DISABLE_SIZE}" ] || [ -z "${CKSIZE}" ] || [ "${actual_size}" -eq "${CKSIZE}" ]; then @@ -154,7 +158,7 @@ echo -n "env $(escape "${_fetch_cmd}") || " ;; fetch-url-list-int) - echo ${args} + echo "${args}" ;; esac done Index: Mk/Scripts/do-patch.sh =================================================================== --- Mk/Scripts/do-patch.sh +++ Mk/Scripts/do-patch.sh @@ -50,7 +50,7 @@ *) ${dp_CAT} "${file}" ;; - esac | do_patch "$@" ${patch_strip} + esac | do_patch "$@" "${patch_strip}" } do_patch() { @@ -79,7 +79,9 @@ if [ -n "${dp_PATCH_DEBUG_TMP}" ]; then ${dp_ECHO_MSG} "===> Applying ${msg} patch ${i}" fi - if do_patch ${dp_PATCH_ARGS} < ${i}; then + # shellcheck disable=SC2086 + # dp_PATCH_ARGS contains arguments, with spaces, needs to be split. + if do_patch ${dp_PATCH_ARGS} < "${i}"; then PATCHES_APPLIED="${PATCHES_APPLIED} ${i}" else ${dp_ECHO_MSG} "=> ${msg} patch ${i} failed to apply cleanly." @@ -99,6 +101,8 @@ ${dp_ECHO_MSG} "===> Applying distribution patches for ${dp_PKGNAME}" cd "${dp_DISTDIR}" for i in ${dp_PATCHFILES}; do + # shellcheck disable=SC2086 + # dp_PATCH_DIST_ARGS contains arguments, with spaces, needs to be split. apply_one_patch "${i}" \ "${dp_PATCH_DEBUG_TMP:+ Applying distribution patch}" \ ${dp_PATCH_DIST_ARGS} @@ -107,6 +111,8 @@ if [ -n "${dp_EXTRA_PATCHES}" ]; then for i in ${dp_EXTRA_PATCHES}; do + # shellcheck disable=SC2086 + # dp_PATCH_ARGS contains arguments, with spaces, needs to be split. apply_one_patch "${i}" \ "Applying extra patch" \ ${dp_PATCH_ARGS} Index: Mk/Scripts/do-users-groups.sh =================================================================== --- Mk/Scripts/do-users-groups.sh +++ Mk/Scripts/do-users-groups.sh @@ -56,15 +56,21 @@ echo "echo \"===> Creating groups.\"" >> "${dp_UG_INSTALL}" for group in ${GROUPS}; do # _bgpd:*:130: + # shellcheck disable=SC2086 + # We need splitting. if ! grep -q "^${group}:" ${dp_GID_FILES}; then \ error "** Cannot find any information about group \`${group}' in ${dp_GID_FILES}." fi + # shellcheck disable=SC2086 + # We need splitting in the heredoc. while read -r line; do # Do not change IFS for more than one command, if we # changed IFS around the while read, it would mess up # the string splitting in the heredoc command. o_IFS=${IFS} IFS=":" + # shellcheck disable=SC2086 + # We want splitting. set -- ${line} IFS=${o_IFS} group=$1 @@ -99,15 +105,21 @@ for user in ${USERS}; do # _bgpd:*:130:130:BGP Daemon:/var/empty:/sbin/nologin + # shellcheck disable=SC2086 + # We need splitting. if ! grep -q "^${user}:" ${dp_UID_FILES} ; then error "** Cannot find any information about user \`${user}' in ${dp_UID_FILES}." fi + # shellcheck disable=SC2086 + # We need splitting in the heredoc. while read -r line; do # Do not change IFS for more than one command, if we # changed IFS around the while read, it would mess up # the string splitting in the heredoc command. o_IFS=${IFS} IFS=":" + # shellcheck disable=SC2086 + # We want splitting. set -- ${line} IFS=${o_IFS} login=$1 @@ -151,6 +163,8 @@ if [ -n "${GROUPS}" ]; then for group in ${GROUPS}; do # mail:*:6:postfix,clamav + # shellcheck disable=SC2086 + # We need splitting in the heredoc. while read -r line; do # Do not change IFS for more than one command, if we # changed IFS around the while read, it would mess up @@ -159,6 +173,8 @@ IFS=":" # As some lines do not have a fourth argument, provide # one so $4 always exists. + # shellcheck disable=SC2086 + # We need splitting. set -- ${line} "" IFS=${o_IFS} group=$1 @@ -167,6 +183,8 @@ gid=$((gid+dp_GID_OFFSET)) o_IFS=${IFS} IFS="," + # shellcheck disable=SC2086 + # We need splitting. set -- ${members} IFS=${o_IFS} for login in "$@"; do Index: Mk/Scripts/find-lib.sh =================================================================== --- Mk/Scripts/find-lib.sh +++ Mk/Scripts/find-lib.sh @@ -22,12 +22,12 @@ fi lib=$1 -dirs="${LIB_DIRS} `cat ${LOCALBASE}/libdata/ldconfig/* 2>/dev/null || :`" +dirs="${LIB_DIRS} $(cat "${LOCALBASE}"/libdata/ldconfig/* 2>/dev/null || :)" for libdir in ${dirs} ; do - test -f ${libdir}/${lib} || continue + test -f "${libdir}/${lib}" || continue libfile=${libdir}/${lib} - [ `file -b -L --mime-type ${libfile}` = "application/x-sharedlib" ] || continue - echo $libfile + [ "$(file -b -L --mime-type "${libfile}")" = "application/x-sharedlib" ] || continue + echo "$libfile" break done Index: Mk/Scripts/functions.sh =================================================================== --- Mk/Scripts/functions.sh +++ Mk/Scripts/functions.sh @@ -30,7 +30,7 @@ # the plist so it does not show up as an orphan. PLIST_SUB uses # a @comment to deactive files. XXX: It would be better to # make all ports use @ignore instead of @comment. - if [ ${parse_comments} -eq 1 -a -z "${line%%@comment *}" ]; then + if [ "${parse_comments}" -eq 1 -a -z "${line%%@comment *}" ]; then line="${line##*@comment }" # Remove @comment so it can be parsed as a file, # but later prepend it again to create a list of @@ -60,7 +60,7 @@ @dir*|'@unexec rmdir'*|'@unexec /bin/rmdir'*) line="$(printf %s "$line" \ | sed -Ee 's/\|\|.*//;s|[[:space:]]+[0-9]*[[:space:]]*>[&]?[[:space:]]*[^[:space:]]+||g' \ - -e "/^@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?/s|([^%])%D([^%])|\1${cwd}\2|g" \ + -e "/^@unexec[[:space:]]+(\\/bin\\/)?rmdir( -p)?/s|([^%])%D([^%])|\\1${cwd}\\2|g" \ -e '/^@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?/s|"(.*)"[[:space:]]*|\1|g' \ -e 's/@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?[[:space:]]+//' \ -e 's/@dir(rm|rmtry)?[[:space:]]+//' \ @@ -72,14 +72,18 @@ ;; # Handle [file] Keywords @info\ *|@shell\ *|@xmlcatmgr\ *) + # shellcheck disable=SC2086 + # We want splitting. set -- $line shift - case "$@" in - /*) echo "${comment}$@" ;; - *) echo "${comment}${cwd}/$@" ;; + case "$*" in + /*) echo "${comment}$*" ;; + *) echo "${comment}${cwd}/$*" ;; esac ;; @sample\ *) + # shellcheck disable=SC2086 + # We want splitting. set -- $line shift sample_file=$1 @@ -101,14 +105,16 @@ ;; # Handle [dir] Keywords @fc\ *|@fcfontsdir\ *|@fontsdir\ *) + # shellcheck disable=SC2086 + # We want splitting. set -- $line shift - case "$@" in + case "$*" in /*) - echo >&3 "${comment}$@" + echo >&3 "${comment}$*" ;; *) - echo >&3 "${comment}${cwd}/$@" + echo >&3 "${comment}${cwd}/$*" ;; esac ;; @@ -125,6 +131,8 @@ fi ;; @cwd*|@cd*) + # shellcheck disable=SC2086 + # We want splitting. set -- $line newcwd=$2 # Don't set cwd=/ as it causes // in plist and @@ -160,7 +168,7 @@ } export_ports_env() { - local export_vars make_cmd make_env var results value uses + local export_vars make_cmd make_env var value uses validate_env MAKE PORTSDIR @@ -201,16 +209,18 @@ done # Bring in all the vars, but not empty ones. - eval $(${MAKE} -f ${PORTSDIR}/Mk/bsd.port.mk ${make_cmd} \ - USES="${uses}" | grep -v '=$' | sed -e 's,\\ $,,') + eval "$(${MAKE} -f "${PORTSDIR}/Mk/bsd.port.mk" "${make_cmd}" \ + USES="${uses}" | grep -v '=$' | sed -e 's,\\ $,,')" for var in ${export_vars}; do # Export and display non-empty ones. This is not redundant # with above since we're looping on all vars here; do not # export a var we didn't eval in. - value="$(eval echo \$${var})" + value="$(eval echo \$"${var}")" if [ -n "${value}" ]; then - export ${var} + # shellcheck disable=SC2163 + # We want to export the variable which name is in var. + export "${var}" echo "export ${var}=\"${value}\"" fi done @@ -270,7 +280,11 @@ _vars="${_vars}${_vars:+ }${_var}" shift 2 done + # shellcheck disable=SC2086 + # We want splitting. set -- ${_vars} + # shellcheck disable=SC2086 + # We want splitting in the heredoc. while read -r _line; do setvar "$1" "${_line}" shift Index: Mk/Scripts/generate-symbols.sh =================================================================== --- Mk/Scripts/generate-symbols.sh +++ Mk/Scripts/generate-symbols.sh @@ -3,7 +3,7 @@ # Maintainer: portmgr@FreeBSD.org msg() { - echo "====> $@" + echo "====> $*" } msg "Finding symbols" @@ -12,23 +12,23 @@ ELF_FILES=$(mktemp -t elf_files) LF=$(printf '\nX') LF=${LF%X} -find ${STAGEDIR} -type f \ - -exec /usr/bin/file -nNF "${LF}" {} + | while read f; do - read output +find "${STAGEDIR}" -type f \ + -exec /usr/bin/file -nNF "${LF}" {} + | while read -r f; do + read -r output case "${output}" in ELF\ *\ executable,\ *FreeBSD*,\ not\ stripped*|\ ELF\ *\ shared\ object,\ *FreeBSD*,\ not\ stripped*) echo "${f}" ;; esac -done > ${ELF_FILES} +done > "${ELF_FILES}" # Create all of the /usr/local/lib/* dirs lib_dir="${STAGEDIR}.debug${PREFIX}/lib/debug" sed -e "s,^${STAGEDIR}${PREFIX}/,${lib_dir}/," -e 's,/[^/]*$,,' \ - ${ELF_FILES} | sort -u | xargs mkdir -p + "${ELF_FILES}" | sort -u | xargs mkdir -p -while read staged_elf_file; do +while read -r staged_elf_file; do elf_file_name="${staged_elf_file##*/}" lib_dir_dest="${lib_dir}/${staged_elf_file#${STAGEDIR}${PREFIX}/}" # Strip off filename @@ -41,6 +41,6 @@ --add-gnu-debuglink="${lib_dir_dest}/${elf_file_name}.debug" \ "${staged_elf_file}" msg "Saved symbols for ${staged_elf_file}" -done < ${ELF_FILES} +done < "${ELF_FILES}" -rm -f ${ELF_FILES} +rm -f "${ELF_FILES}" Index: Mk/Scripts/makesum.sh =================================================================== --- Mk/Scripts/makesum.sh +++ Mk/Scripts/makesum.sh @@ -27,8 +27,8 @@ # the first run. # So, we extract the content of the distinfo file minus the TIMESTAMP, if it # contains a TIMESTAMP. -if [ -f "${dp_DISTINFO_FILE}" ] && grep -q "^TIMESTAMP " ${dp_DISTINFO_FILE}; then - grep -v "^TIMESTAMP " ${dp_DISTINFO_FILE} > ${DISTINFO_OLD} +if [ -f "${dp_DISTINFO_FILE}" ] && grep -q "^TIMESTAMP " "${dp_DISTINFO_FILE}"; then + grep -v "^TIMESTAMP " "${dp_DISTINFO_FILE}" > "${DISTINFO_OLD}" fi for file in ${dp_CKSUMFILES}; do @@ -47,7 +47,7 @@ # need to add one. # - If the old and new distinfo content minus the TIMESTAMP differ, it means # something was updated or changed, it is time to generate a new timestamp. -if [ ! -s ${DISTINFO_OLD} ] || ! cmp -s ${DISTINFO_OLD} ${DISTINFO_NEW}; then - echo "TIMESTAMP = $(date '+%s')" > ${dp_DISTINFO_FILE} - cat ${DISTINFO_NEW} >> ${dp_DISTINFO_FILE} +if [ ! -s "${DISTINFO_OLD}" ] || ! cmp -s "${DISTINFO_OLD}" "${DISTINFO_NEW}"; then + echo "TIMESTAMP = $(date '+%s')" > "${dp_DISTINFO_FILE}" + cat "${DISTINFO_NEW}" >> "${dp_DISTINFO_FILE}" fi Index: Mk/Scripts/plist_sub_sed_sort.sh =================================================================== --- Mk/Scripts/plist_sub_sed_sort.sh +++ Mk/Scripts/plist_sub_sed_sort.sh @@ -5,7 +5,7 @@ # # PLIST_SUB_SED helper to sort by longest value first. -exec awk '{ +awk '{ while (match($0, /s![^!]*![^!]*!g;/)) { sedp=substr($0, RSTART, RLENGTH) $0=substr($0, RSTART+RLENGTH) Index: Mk/Scripts/ports_env.sh =================================================================== --- Mk/Scripts/ports_env.sh +++ Mk/Scripts/ports_env.sh @@ -8,6 +8,6 @@ exit 1 fi -. ${SCRIPTSDIR}/functions.sh +. "${SCRIPTSDIR}"/functions.sh export_ports_env Index: Mk/Scripts/qa.sh =================================================================== --- Mk/Scripts/qa.sh +++ Mk/Scripts/qa.sh @@ -13,25 +13,25 @@ LF=${LF%X} notice() { - echo "Notice: $@" >&2 + echo "Notice: $*" >&2 } warn() { - echo "Warning: $@" >&2 + echo "Warning: $*" >&2 } err() { - echo "Error: $@" >&2 + echo "Error: $*" >&2 } list_stagedir_elfs() { - cd ${STAGEDIR} && find -s . -type f \( -perm +111 -o -name '*.so*' \) "$@" + cd "${STAGEDIR}" && find -s . -type f \( -perm +111 -o -name '*.so*' \) "$@" } shebangonefile() { local f interp interparg badinterp rc - f="$@" + f="$*" rc=0 # whitelist some files @@ -54,7 +54,7 @@ ${LINUXBASE}/*) ;; ${LOCALBASE}/bin/perl5.* | ${PREFIX}/bin/perl5.*) # lang/perl5* are allowed to have these shebangs. - if ! expr ${PKGORIGIN} : '^lang/perl5.*' > /dev/null; then + if ! expr "${PKGORIGIN}" : '^lang/perl5.*' > /dev/null; then err "'${interp}' is an invalid shebang for '${f#${STAGEDIR}${PREFIX}/}' you must use ${LOCALBASE}/bin/perl." err "Either pass \${PERL} to the build or use USES=shebangfix" rc=1 @@ -95,13 +95,13 @@ rc=0 - while read f; do + while read -r 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} \ + $(find "${STAGEDIR}${PREFIX}" \ -type f -perm +111 2>/dev/null) EOF @@ -113,7 +113,7 @@ local found_openssl local file [ "${PKGBASE}" = "pkg" -o "${PKGBASE}" = "pkg-devel" ] && return - while read f; do + while read -r f; do case ${f} in File:\ .*) file=${f#File: .} @@ -148,10 +148,10 @@ # Split stat(1) result into 2 lines and read each line separately to # retain spaces in filenames. - while read l; do + while read -r l; do # No results presents a blank line from heredoc. [ -z "${l}" ] && continue - read link + read -r link case "${link}" in ${STAGEDIR}*) err "Bad symlink '${l#${STAGEDIR}${PREFIX}/}' pointing inside the stage directory" @@ -170,7 +170,7 @@ esac # Use heredoc to avoid losing rc from find|while subshell. done <<-EOF - $(find ${STAGEDIR} -type l -exec stat -f "%N${LF}%Y" {} +) + $(find "${STAGEDIR}" -type l -exec stat -f "%N${LF}%Y" {} +) EOF return ${rc} @@ -181,7 +181,7 @@ rc=0 - while read f; do + while read -r f; do # No results presents a blank line from heredoc. [ -z "${f}" ] && continue # Ignore false-positive/harmless files @@ -194,7 +194,7 @@ rc=1 # Use heredoc to avoid losing rc from find|while subshell done <<-EOF - $(find ${TMPPLIST} ${STAGEDIR} -type f -exec grep -l "${STAGEDIR}" {} +) + $(find "${TMPPLIST}" "${STAGEDIR}" -type f -exec grep -l "${STAGEDIR}" {} +) EOF return ${rc} @@ -207,21 +207,21 @@ # Split file and result into 2 lines and read separately to ensure # files with spaces are kept intact. # Using readelf -h ... /ELF Header:/ will match on all ELF files. - find ${STAGEDIR} -type f ! -name '*.a' ! -name '*.o' \ - -exec readelf -S {} + 2>/dev/null | awk '\ - /File:/ {sub(/File: /, "", $0); file=$0} \ + find "${STAGEDIR}" -type f ! -name '*.a' ! -name '*.o' \ + -exec readelf -S {} + 2>/dev/null | awk ' + /File:/ {sub(/File: /, "", $0); file=$0} /SYMTAB/ {print file}' | - while read f; do + while read -r f; do warn "'${f#${STAGEDIR}${PREFIX}/}' is not stripped consider trying INSTALL_TARGET=install-strip or using \${STRIP_CMD}" done } desktopfileutils() { if [ -z "${USESDESKTOPFILEUTILS}" ]; then - grep -q MimeType= ${STAGEDIR}${PREFIX}/share/applications/*.desktop 2>/dev/null && + 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 || + grep -q MimeType= "${STAGEDIR}${PREFIX}"/share/applications/*.desktop 2>/dev/null || warn "you may not need USES=desktop-file-utils" fi return 0 @@ -248,22 +248,23 @@ suidfiles() { local filelist - filelist=`find ${STAGEDIR} -type f \ + filelist=$(find "${STAGEDIR}" -type f \ \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ - \( -perm -u+s -or -perm -g+s \)` + \( -perm -u+s -or -perm -g+s \)) if [ -n "${filelist}" ]; then warn "setuid files in the stage directory (are these necessary?):" - ls -liTd ${filelist} + ls -liTd "${filelist}" fi return 0 } libtool() { if [ -z "${USESLIBTOOL}" ]; then - find ${STAGEDIR} -name '*.la' | while read f; do - grep -q 'libtool library' "${f}" && - err ".la libraries found, port needs USES=libtool" && - return 1 || true + find "${STAGEDIR}" -name '*.la' | while read -r f; do + if grep -q 'libtool library' "${f}"; then + err ".la libraries found, port needs USES=libtool" + return 1 + fi done # The return above continues here. fi @@ -274,16 +275,16 @@ if [ -n "${SITE_ARCH_REL}" -a -d "${STAGEDIR}${PREFIX}/${SITE_ARCH_REL}" ]; then has_some_libperl_so=0 files=0 - while read f; do + while read -r f; do # No results presents a blank line from heredoc. [ -z "${f}" ] && continue files=$((files+1)) - found=`readelf -d ${f} | awk "BEGIN {libperl=1; rpath=10; runpath=100} + found=$(readelf -d "${f}" | awk "BEGIN {libperl=1; rpath=10; runpath=100} /NEEDED.*${LIBPERL}/ { libperl = 0 } /RPATH.*perl.*CORE/ { rpath = 0 } /RUNPATH.*perl.*CORE/ { runpath = 0 } END {print libperl+rpath+runpath} - "` + ") case "${found}" in *1) warn "${f} is not linked with ${LIBPERL}, not respecting lddlflags?" @@ -291,7 +292,7 @@ *0) has_some_libperl_so=1 # Older Perl did not USE_LDCONFIG. - if [ ! -f ${LOCALBASE}/${LDCONFIG_DIR}/perl5 ]; then + if [ ! -f "${LOCALBASE}/${LDCONFIG_DIR}/perl5" ]; then case "${found}" in *1?) warn "${f} does not have a rpath to ${LIBPERL}, not respecting lddlflags?" @@ -307,7 +308,7 @@ esac # Use heredoc to avoid losing rc from find|while subshell done <<-EOT - $(find ${STAGEDIR}${PREFIX}/${SITE_ARCH_REL} -name '*.so') + $(find "${STAGEDIR}${PREFIX}/${SITE_ARCH_REL}" -name '*.so') EOT if [ ${files} -gt 0 -a ${has_some_libperl_so} -eq 0 ]; then @@ -320,7 +321,7 @@ } prefixvar() { - if [ ${PREFIX} != ${LINUXBASE} -a -d ${STAGEDIR}${PREFIX}/var ]; then + if [ "${PREFIX}" != "${LINUXBASE}" -a -d "${STAGEDIR}${PREFIX}/var" ]; then warn "port uses ${PREFIX}/var instead of /var" fi } @@ -352,7 +353,7 @@ lst=$2 for elt in ${lst} ; do - if [ ${elt} = ${str} ]; then + if [ "${elt}" = "${str}" ]; then return 0 fi done @@ -364,274 +365,274 @@ local lib_file=$2 # miscellaneous USE clauses - if [ ${pkg} = 'devel/gettext-runtime' ]; then + if [ "${pkg}" = 'devel/gettext-runtime' ]; then warn "you need USES+=gettext-runtime" - elif [ ${pkg} = 'databases/sqlite3' ]; then + elif [ "${pkg}" = 'databases/sqlite3' ]; then warn "you need USES+=sqlite" - elif [ ${pkg} = 'databases/sqlite2' ]; then + elif [ "${pkg}" = 'databases/sqlite2' ]; then warn "you need USES+=sqlite:2" # Gnome -> same as port # grep LIB_DEPENDS= Mk/Uses/gnome.mk |sed -e 's|\(.*\)_LIB_DEPENDS.*:\(.*\)\/\(.*\)|[ "\1" = "\3" ] \&\& echo "\\${pkg} = \\\"\2/\3\\\" -o \\\\"|'|sort|sh - elif [ ${pkg} = "accessibility/atk" -o \ - ${pkg} = "accessibility/atkmm" -o \ - ${pkg} = "graphics/cairo" -o \ - ${pkg} = "graphics/cairomm" -o \ - ${pkg} = "devel/dconf" -o \ - ${pkg} = "audio/esound" -o \ - ${pkg} = "devel/gconf2" -o \ - ${pkg} = "devel/gconfmm26" -o \ - ${pkg} = "devel/glib12" -o \ - ${pkg} = "devel/glib20" -o \ - ${pkg} = "devel/glibmm" -o \ - ${pkg} = "audio/gsound" -o \ - ${pkg} = "x11-toolkits/gtk12" -o \ - ${pkg} = "x11-toolkits/gtk20" -o \ - ${pkg} = "x11-toolkits/gtk30" -o \ - ${pkg} = "www/gtkhtml3" -o \ - ${pkg} = "www/gtkhtml4" -o \ - ${pkg} = "x11-toolkits/gtkmm20" -o \ - ${pkg} = "x11-toolkits/gtkmm24" -o \ - ${pkg} = "x11-toolkits/gtkmm30" -o \ - ${pkg} = "x11-toolkits/gtksourceview" -o \ - ${pkg} = "x11-toolkits/gtksourceview2" -o \ - ${pkg} = "x11-toolkits/gtksourceview3" -o \ - ${pkg} = "x11-toolkits/gtksourceviewmm3" -o \ - ${pkg} = "devel/libbonobo" -o \ - ${pkg} = "x11-toolkits/libbonoboui" -o \ - ${pkg} = "databases/libgda5" -o \ - ${pkg} = "databases/libgda5-ui" -o \ - ${pkg} = "databases/libgdamm5" -o \ - ${pkg} = "devel/libglade2" -o \ - ${pkg} = "x11/libgnome" -o \ - ${pkg} = "graphics/libgnomecanvas" -o \ - ${pkg} = "x11/libgnomekbd" -o \ - ${pkg} = "print/libgnomeprint" -o \ - ${pkg} = "x11-toolkits/libgnomeprintui" -o \ - ${pkg} = "x11-toolkits/libgnomeui" -o \ - ${pkg} = "devel/libgsf" -o \ - ${pkg} = "www/libgtkhtml" -o \ - ${pkg} = "x11-toolkits/libgtksourceviewmm" -o \ - ${pkg} = "graphics/librsvg2" -o \ - ${pkg} = "devel/libsigc++12" -o \ - ${pkg} = "devel/libsigc++20" -o \ - ${pkg} = "x11-toolkits/libwnck" -o \ - ${pkg} = "x11-toolkits/libwnck3" -o \ - ${pkg} = "textproc/libxml++26" -o \ - ${pkg} = "textproc/libxml2" -o \ - ${pkg} = "textproc/libxslt" -o \ - ${pkg} = "x11-wm/metacity" -o \ - ${pkg} = "x11-toolkits/pango" -o \ - ${pkg} = "x11-toolkits/pangomm" -o \ - ${pkg} = "x11-toolkits/pangox-compat" -o \ - ${pkg} = "x11-toolkits/vte" -o \ - ${pkg} = "x11-toolkits/vte3" ]; then + elif [ "${pkg}" = "accessibility/atk" -o \ + "${pkg}" = "accessibility/atkmm" -o \ + "${pkg}" = "graphics/cairo" -o \ + "${pkg}" = "graphics/cairomm" -o \ + "${pkg}" = "devel/dconf" -o \ + "${pkg}" = "audio/esound" -o \ + "${pkg}" = "devel/gconf2" -o \ + "${pkg}" = "devel/gconfmm26" -o \ + "${pkg}" = "devel/glib12" -o \ + "${pkg}" = "devel/glib20" -o \ + "${pkg}" = "devel/glibmm" -o \ + "${pkg}" = "audio/gsound" -o \ + "${pkg}" = "x11-toolkits/gtk12" -o \ + "${pkg}" = "x11-toolkits/gtk20" -o \ + "${pkg}" = "x11-toolkits/gtk30" -o \ + "${pkg}" = "www/gtkhtml3" -o \ + "${pkg}" = "www/gtkhtml4" -o \ + "${pkg}" = "x11-toolkits/gtkmm20" -o \ + "${pkg}" = "x11-toolkits/gtkmm24" -o \ + "${pkg}" = "x11-toolkits/gtkmm30" -o \ + "${pkg}" = "x11-toolkits/gtksourceview" -o \ + "${pkg}" = "x11-toolkits/gtksourceview2" -o \ + "${pkg}" = "x11-toolkits/gtksourceview3" -o \ + "${pkg}" = "x11-toolkits/gtksourceviewmm3" -o \ + "${pkg}" = "devel/libbonobo" -o \ + "${pkg}" = "x11-toolkits/libbonoboui" -o \ + "${pkg}" = "databases/libgda5" -o \ + "${pkg}" = "databases/libgda5-ui" -o \ + "${pkg}" = "databases/libgdamm5" -o \ + "${pkg}" = "devel/libglade2" -o \ + "${pkg}" = "x11/libgnome" -o \ + "${pkg}" = "graphics/libgnomecanvas" -o \ + "${pkg}" = "x11/libgnomekbd" -o \ + "${pkg}" = "print/libgnomeprint" -o \ + "${pkg}" = "x11-toolkits/libgnomeprintui" -o \ + "${pkg}" = "x11-toolkits/libgnomeui" -o \ + "${pkg}" = "devel/libgsf" -o \ + "${pkg}" = "www/libgtkhtml" -o \ + "${pkg}" = "x11-toolkits/libgtksourceviewmm" -o \ + "${pkg}" = "graphics/librsvg2" -o \ + "${pkg}" = "devel/libsigc++12" -o \ + "${pkg}" = "devel/libsigc++20" -o \ + "${pkg}" = "x11-toolkits/libwnck" -o \ + "${pkg}" = "x11-toolkits/libwnck3" -o \ + "${pkg}" = "textproc/libxml++26" -o \ + "${pkg}" = "textproc/libxml2" -o \ + "${pkg}" = "textproc/libxslt" -o \ + "${pkg}" = "x11-wm/metacity" -o \ + "${pkg}" = "x11-toolkits/pango" -o \ + "${pkg}" = "x11-toolkits/pangomm" -o \ + "${pkg}" = "x11-toolkits/pangox-compat" -o \ + "${pkg}" = "x11-toolkits/vte" -o \ + "${pkg}" = "x11-toolkits/vte3" ]; then warn "you need USE_GNOME+=${pkg#*/}" # Gnome different as port # grep LIB_DEPENDS= Mk/Uses/gnome.mk |sed -e 's|\(.*\)_LIB_DEPENDS.*:\(.*\)\/\(.*\)|[ "\1" = "\3" ] \|\| echo "elif [ \\${pkg} = \\\"\2/\3\\\" ]; then; warn \\\"you need USE_GNOME+=\1\\\""|'|sort|sh - elif [ ${pkg} = "databases/evolution-data-server" ]; then warn "you need USE_GNOME+=evolutiondataserver3" - elif [ ${pkg} = "graphics/gdk-pixbuf" ]; then warn "you need USE_GNOME+=gdkpixbuf" - elif [ ${pkg} = "graphics/gdk-pixbuf2" ]; then warn "you need USE_GNOME+=gdkpixbuf2" - elif [ ${pkg} = "x11/gnome-desktop" ]; then warn "you need USE_GNOME+=gnomedesktop3" - elif [ ${pkg} = "devel/gnome-vfs" ]; then warn "you need USE_GNOME+=gnomevfs2" - elif [ ${pkg} = "devel/gobject-introspection" ]; then warn "you need USE_GNOME+=introspection" - elif [ ${pkg} = "graphics/libart_lgpl" ]; then warn "you need USE_GNOME+=libartlgpl2" - elif [ ${pkg} = "devel/libIDL" ]; then warn "you need USE_GNOME+=libidl" - elif [ ${pkg} = "x11-fm/nautilus" ]; then warn "you need USE_GNOME+=nautilus3" - elif [ ${pkg} = "devel/ORBit2" ]; then warn "you need USE_GNOME+=orbit2" + elif [ "${pkg}" = "databases/evolution-data-server" ]; then warn "you need USE_GNOME+=evolutiondataserver3" + elif [ "${pkg}" = "graphics/gdk-pixbuf" ]; then warn "you need USE_GNOME+=gdkpixbuf" + elif [ "${pkg}" = "graphics/gdk-pixbuf2" ]; then warn "you need USE_GNOME+=gdkpixbuf2" + elif [ "${pkg}" = "x11/gnome-desktop" ]; then warn "you need USE_GNOME+=gnomedesktop3" + elif [ "${pkg}" = "devel/gnome-vfs" ]; then warn "you need USE_GNOME+=gnomevfs2" + elif [ "${pkg}" = "devel/gobject-introspection" ]; then warn "you need USE_GNOME+=introspection" + elif [ "${pkg}" = "graphics/libart_lgpl" ]; then warn "you need USE_GNOME+=libartlgpl2" + elif [ "${pkg}" = "devel/libIDL" ]; then warn "you need USE_GNOME+=libidl" + elif [ "${pkg}" = "x11-fm/nautilus" ]; then warn "you need USE_GNOME+=nautilus3" + elif [ "${pkg}" = "devel/ORBit2" ]; then warn "you need USE_GNOME+=orbit2" # mate - # grep LIB_DEPENDS= Mk/Uses/mate.mk |sed -e 's|\(.*\)_LIB_DEPENDS.*:\(.*\)\/\(.*\)|elif [ ${pkg} = "\2/\3" ]; then warn "you need USE_MATE+=\1"|' - elif [ ${pkg} = "x11-fm/caja" ]; then warn "you need USE_MATE+=caja" - elif [ ${pkg} = "sysutils/mate-control-center" ]; then warn "you need USE_MATE+=controlcenter" - elif [ ${pkg} = "x11/mate-desktop" ]; then warn "you need USE_MATE+=desktop" - elif [ ${pkg} = "x11/libmatekbd" ]; then warn "you need USE_MATE+=libmatekbd" - elif [ ${pkg} = "net/libmateweather" ]; then warn "you need USE_MATE+=libmateweather" - elif [ ${pkg} = "x11-wm/marco" ]; then warn "you need USE_MATE+=marco" - elif [ ${pkg} = "x11/mate-menus" ]; then warn "you need USE_MATE+=menus" - elif [ ${pkg} = "x11/mate-panel" ]; then warn "you need USE_MATE+=panel" - elif [ ${pkg} = "sysutils/mate-polkit" ]; then warn "you need USE_MATE+=polkit" + # grep LIB_DEPENDS= Mk/Uses/mate.mk |sed -e 's|\(.*\)_LIB_DEPENDS.*:\(.*\)\/\(.*\)|elif [ "${pkg}" = "\2/\3" ]; then warn "you need USE_MATE+=\1"|' + elif [ "${pkg}" = "x11-fm/caja" ]; then warn "you need USE_MATE+=caja" + elif [ "${pkg}" = "sysutils/mate-control-center" ]; then warn "you need USE_MATE+=controlcenter" + elif [ "${pkg}" = "x11/mate-desktop" ]; then warn "you need USE_MATE+=desktop" + elif [ "${pkg}" = "x11/libmatekbd" ]; then warn "you need USE_MATE+=libmatekbd" + elif [ "${pkg}" = "net/libmateweather" ]; then warn "you need USE_MATE+=libmateweather" + elif [ "${pkg}" = "x11-wm/marco" ]; then warn "you need USE_MATE+=marco" + elif [ "${pkg}" = "x11/mate-menus" ]; then warn "you need USE_MATE+=menus" + elif [ "${pkg}" = "x11/mate-panel" ]; then warn "you need USE_MATE+=panel" + elif [ "${pkg}" = "sysutils/mate-polkit" ]; then warn "you need USE_MATE+=polkit" # KDE - # grep -B1 _LIB= Mk/Uses/kde.mk | grep _PORT=|sed -e 's/^\(.*\)_PORT=[[:space:]]*\([^[:space:]]*\).*/elif [ ${pkg} = "\2" ]; then warn "you need to use USE_KDE+=\1"/' - elif [ ${pkg} = "sysutils/baloo" ]; then warn "you need to use USE_KDE+=baloo" - elif [ ${pkg} = "sysutils/baloo-widgets" ]; then warn "you need to use USE_KDE+=baloo-widgets" - elif [ ${pkg} = "x11/kactivities" ]; then warn "you need to use USE_KDE+=kactivities" - elif [ ${pkg} = "editors/kate" ]; then warn "you need to use USE_KDE+=kate" - elif [ ${pkg} = "x11/kdelibs4" ]; then warn "you need to use USE_KDE+=kdelibs" - elif [ ${pkg} = "sysutils/kfilemetadata" ]; then warn "you need to use USE_KDE+=kfilemetadata" - elif [ ${pkg} = "audio/libkcddb" ]; then warn "you need to use USE_KDE+=libkcddb" - elif [ ${pkg} = "audio/libkcompactdisc" ]; then warn "you need to use USE_KDE+=libkcompactdisc" - elif [ ${pkg} = "graphics/libkdcraw-kde4" ]; then warn "you need to use USE_KDE+=libkdcraw" - elif [ ${pkg} = "misc/libkdeedu" ]; then warn "you need to use USE_KDE+=libkdeedu" - elif [ ${pkg} = "games/libkdegames" ]; then warn "you need to use USE_KDE+=libkdegames" - elif [ ${pkg} = "graphics/libkexiv2-kde4" ]; then warn "you need to use USE_KDE+=libkexiv2" - elif [ ${pkg} = "graphics/libkipi-kde4" ]; then warn "you need to use USE_KDE+=libkipi" - elif [ ${pkg} = "x11/libkonq" ]; then warn "you need to use USE_KDE+=libkonq" - elif [ ${pkg} = "graphics/libksane" ]; then warn "you need to use USE_KDE+=libksane" - elif [ ${pkg} = "astro/marble" ]; then warn "you need to use USE_KDE+=marble" - elif [ ${pkg} = "sysutils/nepomuk-core" ]; then warn "you need to use USE_KDE+=nepomuk-core" - elif [ ${pkg} = "sysutils/nepomuk-widgets" ]; then warn "you need to use USE_KDE+=nepomuk-widgets" - elif [ ${pkg} = "graphics/okular" ]; then warn "you need to use USE_KDE+=okular" - elif [ ${pkg} = "deskutils/kdepimlibs4" ]; then warn "you need to use USE_KDE+=pimlibs" - elif [ ${pkg} = "devel/ruby-qtruby" ]; then warn "you need to use USE_KDE+=qtruby" - elif [ ${pkg} = "devel/smokegen" ]; then warn "you need to use USE_KDE+=smokegen" - elif [ ${pkg} = "devel/smokekde" ]; then warn "you need to use USE_KDE+=smokekde" - elif [ ${pkg} = "devel/smokeqt" ]; then warn "you need to use USE_KDE+=smokeqt" - elif [ ${pkg} = "x11/kde4-workspace" ]; then warn "you need to use USE_KDE+=workspace" - elif [ ${pkg} = "databases/akonadi" ]; then warn "you need to use USE_KDE+=akonadi" - elif [ ${pkg} = "x11-toolkits/attica" ]; then warn "you need to use USE_KDE+=attica" - elif [ ${pkg} = "x11/qimageblitz" ]; then warn "you need to use USE_KDE+=qimageblitz" - elif [ ${pkg} = "textproc/soprano" ]; then warn "you need to use USE_KDE+=soprano" - elif [ ${pkg} = "deskutils/libstreamanalyzer" ]; then warn "you need to use USE_KDE+=strigi" + # grep -B1 _LIB= Mk/Uses/kde.mk | grep _PORT=|sed -e 's/^\(.*\)_PORT=[[:space:]]*\([^[:space:]]*\).*/elif [ "${pkg}" = "\2" ]; then warn "you need to use USE_KDE+=\1"/' + elif [ "${pkg}" = "sysutils/baloo" ]; then warn "you need to use USE_KDE+=baloo" + elif [ "${pkg}" = "sysutils/baloo-widgets" ]; then warn "you need to use USE_KDE+=baloo-widgets" + elif [ "${pkg}" = "x11/kactivities" ]; then warn "you need to use USE_KDE+=kactivities" + elif [ "${pkg}" = "editors/kate" ]; then warn "you need to use USE_KDE+=kate" + elif [ "${pkg}" = "x11/kdelibs4" ]; then warn "you need to use USE_KDE+=kdelibs" + elif [ "${pkg}" = "sysutils/kfilemetadata" ]; then warn "you need to use USE_KDE+=kfilemetadata" + elif [ "${pkg}" = "audio/libkcddb" ]; then warn "you need to use USE_KDE+=libkcddb" + elif [ "${pkg}" = "audio/libkcompactdisc" ]; then warn "you need to use USE_KDE+=libkcompactdisc" + elif [ "${pkg}" = "graphics/libkdcraw-kde4" ]; then warn "you need to use USE_KDE+=libkdcraw" + elif [ "${pkg}" = "misc/libkdeedu" ]; then warn "you need to use USE_KDE+=libkdeedu" + elif [ "${pkg}" = "games/libkdegames" ]; then warn "you need to use USE_KDE+=libkdegames" + elif [ "${pkg}" = "graphics/libkexiv2-kde4" ]; then warn "you need to use USE_KDE+=libkexiv2" + elif [ "${pkg}" = "graphics/libkipi-kde4" ]; then warn "you need to use USE_KDE+=libkipi" + elif [ "${pkg}" = "x11/libkonq" ]; then warn "you need to use USE_KDE+=libkonq" + elif [ "${pkg}" = "graphics/libksane" ]; then warn "you need to use USE_KDE+=libksane" + elif [ "${pkg}" = "astro/marble" ]; then warn "you need to use USE_KDE+=marble" + elif [ "${pkg}" = "sysutils/nepomuk-core" ]; then warn "you need to use USE_KDE+=nepomuk-core" + elif [ "${pkg}" = "sysutils/nepomuk-widgets" ]; then warn "you need to use USE_KDE+=nepomuk-widgets" + elif [ "${pkg}" = "graphics/okular" ]; then warn "you need to use USE_KDE+=okular" + elif [ "${pkg}" = "deskutils/kdepimlibs4" ]; then warn "you need to use USE_KDE+=pimlibs" + elif [ "${pkg}" = "devel/ruby-qtruby" ]; then warn "you need to use USE_KDE+=qtruby" + elif [ "${pkg}" = "devel/smokegen" ]; then warn "you need to use USE_KDE+=smokegen" + elif [ "${pkg}" = "devel/smokekde" ]; then warn "you need to use USE_KDE+=smokekde" + elif [ "${pkg}" = "devel/smokeqt" ]; then warn "you need to use USE_KDE+=smokeqt" + elif [ "${pkg}" = "x11/kde4-workspace" ]; then warn "you need to use USE_KDE+=workspace" + elif [ "${pkg}" = "databases/akonadi" ]; then warn "you need to use USE_KDE+=akonadi" + elif [ "${pkg}" = "x11-toolkits/attica" ]; then warn "you need to use USE_KDE+=attica" + elif [ "${pkg}" = "x11/qimageblitz" ]; then warn "you need to use USE_KDE+=qimageblitz" + elif [ "${pkg}" = "textproc/soprano" ]; then warn "you need to use USE_KDE+=soprano" + elif [ "${pkg}" = "deskutils/libstreamanalyzer" ]; then warn "you need to use USE_KDE+=strigi" # KDE Frameworks - elif [ ${pkg} = "devel/kf5-extra-cmake-modules" ]; then warn "you need to use USE_KDE+=ecm" - elif [ ${pkg} = "devel/kf5-kcmutils" ]; then warn "you need to use USE_KDE+=kcmutils" - elif [ ${pkg} = "devel/kf5-kdeclarative" ]; then warn "you need to use USE_KDE+=kdeclarative" - elif [ ${pkg} = "devel/kf5-kfilemetadata" ]; then warn "you need to use USE_KDE+=filemetadata5" - elif [ ${pkg} = "devel/kf5-kio" ]; then warn "you need to use USE_KDE+=kio" - elif [ ${pkg} = "devel/kf5-solid" ]; then warn "you need to use USE_KDE+=solid" - elif [ ${pkg} = "devel/kf5-threadweaver" ]; then warn "you need to use USE_KDE+=threadweaver" - elif [ ${pkg} = "devel/kio-extras-kf5" ]; then warn "you need to use USE_KDE+=kio-extras" - elif [ ${pkg} = "graphics/kf5-kimageformats" ]; then warn "you need to use USE_KDE+=kimageformats" - elif [ ${pkg} = "lang/kf5-kross" ]; then warn "you need to use USE_KDE+=kross" - elif [ ${pkg} = "security/kf5-kdesu" ]; then warn "you need to use USE_KDE+=kdesu" - elif [ ${pkg} = "sysutils/kf5-baloo" ]; then warn "you need to use USE_KDE+=baloo5" - elif [ ${pkg} = "sysutils/kf5-bluez-qt" ]; then warn "you need to use USE_KDE+=bluez-qt" - elif [ ${pkg} = "textproc/kf5-sonnet" ]; then warn "you need to use USE_KDE+=sonnet" - elif [ ${pkg} = "www/kf5-kdewebkit" ]; then warn "you need to use USE_KDE+=kdewebkit" - elif [ ${pkg} = "www/kf5-khtml" ]; then warn "you need to use USE_KDE+=khtml" - elif [ ${pkg} = "x11-themes/kf5-breeze-icons" ]; then warn "you need to use USE_KDE+=breeze-icons" - elif [ ${pkg} = "x11-themes/kf5-oxygen-icons5" ]; then warn "you need to use USE_KDE+=oxygen-icons5" - elif [ ${pkg} = "x11-toolkits/kf5-attica" ]; then warn "you need to use USE_KDE+=attica5" - elif [ ${pkg} = "x11/kf5-frameworkintegration" ]; then warn "you need to use USE_KDE+=frameworkintegration" - elif [ ${pkg} = "x11/kf5-kded" ]; then warn "you need to use USE_KDE+=kded" - elif [ ${pkg} = "x11/kf5-kdelibs4support" ]; then warn "you need to use USE_KDE+=kdelibs4support" - elif [ ${pkg} = "x11/kf5-plasma-framework" ]; then warn "you need to use USE_KDE+=plasma-framework" - elif expr ${pkg} : '.*/kf5-.*' > /dev/null; then - warn "you need USE_KDE+=$(echo ${pkg} | sed -E 's|.*/kf5-k||')" + elif [ "${pkg}" = "devel/kf5-extra-cmake-modules" ]; then warn "you need to use USE_KDE+=ecm" + elif [ "${pkg}" = "devel/kf5-kcmutils" ]; then warn "you need to use USE_KDE+=kcmutils" + elif [ "${pkg}" = "devel/kf5-kdeclarative" ]; then warn "you need to use USE_KDE+=kdeclarative" + elif [ "${pkg}" = "devel/kf5-kfilemetadata" ]; then warn "you need to use USE_KDE+=filemetadata5" + elif [ "${pkg}" = "devel/kf5-kio" ]; then warn "you need to use USE_KDE+=kio" + elif [ "${pkg}" = "devel/kf5-solid" ]; then warn "you need to use USE_KDE+=solid" + elif [ "${pkg}" = "devel/kf5-threadweaver" ]; then warn "you need to use USE_KDE+=threadweaver" + elif [ "${pkg}" = "devel/kio-extras-kf5" ]; then warn "you need to use USE_KDE+=kio-extras" + elif [ "${pkg}" = "graphics/kf5-kimageformats" ]; then warn "you need to use USE_KDE+=kimageformats" + elif [ "${pkg}" = "lang/kf5-kross" ]; then warn "you need to use USE_KDE+=kross" + elif [ "${pkg}" = "security/kf5-kdesu" ]; then warn "you need to use USE_KDE+=kdesu" + elif [ "${pkg}" = "sysutils/kf5-baloo" ]; then warn "you need to use USE_KDE+=baloo5" + elif [ "${pkg}" = "sysutils/kf5-bluez-qt" ]; then warn "you need to use USE_KDE+=bluez-qt" + elif [ "${pkg}" = "textproc/kf5-sonnet" ]; then warn "you need to use USE_KDE+=sonnet" + elif [ "${pkg}" = "www/kf5-kdewebkit" ]; then warn "you need to use USE_KDE+=kdewebkit" + elif [ "${pkg}" = "www/kf5-khtml" ]; then warn "you need to use USE_KDE+=khtml" + elif [ "${pkg}" = "x11-themes/kf5-breeze-icons" ]; then warn "you need to use USE_KDE+=breeze-icons" + elif [ "${pkg}" = "x11-themes/kf5-oxygen-icons5" ]; then warn "you need to use USE_KDE+=oxygen-icons5" + elif [ "${pkg}" = "x11-toolkits/kf5-attica" ]; then warn "you need to use USE_KDE+=attica5" + elif [ "${pkg}" = "x11/kf5-frameworkintegration" ]; then warn "you need to use USE_KDE+=frameworkintegration" + elif [ "${pkg}" = "x11/kf5-kded" ]; then warn "you need to use USE_KDE+=kded" + elif [ "${pkg}" = "x11/kf5-kdelibs4support" ]; then warn "you need to use USE_KDE+=kdelibs4support" + elif [ "${pkg}" = "x11/kf5-plasma-framework" ]; then warn "you need to use USE_KDE+=plasma-framework" + elif expr "${pkg}" : '.*/kf5-.*' > /dev/null; then + warn "you need USE_KDE+=$(echo "${pkg}" | sed -E 's|.*/kf5-k||')" # GStreamer 0.10 - elif [ ${pkg} = "multimedia/gstreamer" ]; then warn "you need to use USE_GSTREAMER+=yes" - elif [ ${pkg} = "multimedia/gstreamer-plugins" ]; then warn "you need to use USE_GSTREAMER+=yes" - elif [ ${pkg} = "multimedia/gstreamer-plugins-bad" ]; then warn "you need to use USE_GSTREAMER+=bad" + elif [ "${pkg}" = "multimedia/gstreamer" ]; then warn "you need to use USE_GSTREAMER+=yes" + elif [ "${pkg}" = "multimedia/gstreamer-plugins" ]; then warn "you need to use USE_GSTREAMER+=yes" + elif [ "${pkg}" = "multimedia/gstreamer-plugins-bad" ]; then warn "you need to use USE_GSTREAMER+=bad" # GStreamer 1 - elif [ ${pkg} = "multimedia/gstreamer1" ]; then warn "you need to use USE_GSTREAMER1+=yes" - elif [ ${pkg} = "multimedia/gstreamer1-plugins" ]; then warn "you need to use USE_GSTREAMER1+=yes" - elif [ ${pkg} = "multimedia/gstreamer1-plugins-bad" ]; then warn "you need to use USE_GSTREAMER1+=bad" + elif [ "${pkg}" = "multimedia/gstreamer1" ]; then warn "you need to use USE_GSTREAMER1+=yes" + elif [ "${pkg}" = "multimedia/gstreamer1-plugins" ]; then warn "you need to use USE_GSTREAMER1+=yes" + elif [ "${pkg}" = "multimedia/gstreamer1-plugins-bad" ]; then warn "you need to use USE_GSTREAMER1+=bad" # sdl-related - elif [ ${pkg} = 'devel/sdl12' ]; then + elif [ "${pkg}" = 'devel/sdl12' ]; then warn "you need USE_SDL+=sdl" - elif echo ${pkg} | grep -E '/sdl_(console|gfx|image|mixer|mm|net|pango|sound|ttf)$' > /dev/null; then - warn "you need USE_SDL+=$(echo ${pkg} | sed -E 's|.*/sdl_||')" - elif [ ${pkg} = 'devel/sdl20' ]; then + elif echo "${pkg}" | grep -E '/sdl_(console|gfx|image|mixer|mm|net|pango|sound|ttf)$' > /dev/null; then + warn "you need USE_SDL+=$(echo "${pkg}" | sed -E 's|.*/sdl_||')" + elif [ "${pkg}" = 'devel/sdl20' ]; then warn "you need USE_SDL+=sdl2" - elif echo ${pkg} | grep -E '/sdl2_(gfx|image|mixer|net|ttf)$' > /dev/null; then - warn "you need USE_SDL+=$(echo ${pkg} | sed -E 's|.*/sdl2_||')2" + elif echo "${pkg}" | grep -E '/sdl2_(gfx|image|mixer|net|ttf)$' > /dev/null; then + warn "you need USE_SDL+=$(echo "${pkg}" | sed -E 's|.*/sdl2_||')2" # gl-related - elif expr ${lib_file} : "${LOCALBASE}/lib/libGL.so.*$" > /dev/null; then + elif expr "${lib_file}" : "${LOCALBASE}/lib/libGL.so.*$" > /dev/null; then warn "you need USE_GL+=gl" - elif expr ${lib_file} : "${LOCALBASE}/lib/libgbm.so.*$" > /dev/null; then + elif expr "${lib_file}" : "${LOCALBASE}/lib/libgbm.so.*$" > /dev/null; then warn "you need USE_GL+=gbm" - elif expr ${lib_file} : "${LOCALBASE}/lib/libGLESv2.so.*$" > /dev/null; then + elif expr "${lib_file}" : "${LOCALBASE}/lib/libGLESv2.so.*$" > /dev/null; then warn "you need USE_GL+=glesv2" - elif expr ${lib_file} : "${LOCALBASE}/lib/libEGL.so.*$" > /dev/null; then + elif expr "${lib_file}" : "${LOCALBASE}/lib/libEGL.so.*$" > /dev/null; then warn "you need USE_GL+=egl" - elif [ ${pkg} = 'graphics/glew' ]; then + elif [ "${pkg}" = 'graphics/glew' ]; then warn "you need USE_GL+=glew" - elif [ ${pkg} = 'graphics/libGLU' ]; then + elif [ "${pkg}" = 'graphics/libGLU' ]; then warn "you need USE_GL+=glu" - elif [ ${pkg} = 'graphics/libGLw' ]; then + elif [ "${pkg}" = 'graphics/libGLw' ]; then warn "you need USE_GL+=glw" - elif [ ${pkg} = 'graphics/freeglut' ]; then + elif [ "${pkg}" = 'graphics/freeglut' ]; then warn "you need USE_GL+=glut" # Xorg-libraries: this should be by XORG_MODULES @ bsd.xorg.mk - elif echo ${pkg} | grep -E '/lib(X11|Xau|Xdmcp|Xext|SM|ICE|Xfixes|Xft|Xdamage|Xcomposite|Xcursor|Xinerama|Xmu|Xmuu|Xpm|Xt|Xtst|Xi|Xrandr|Xrender|Xres|XScrnSaver|Xv|Xxf86vm|Xxf86dga|Xxf86misc|xcb)$' > /dev/null; then - warn "you need USE_XORG+=$(echo ${pkg} | sed -E 's|.*/lib||' | tr '[:upper:]' '[:lower:]')" - elif [ ${pkg} = 'x11/pixman' ]; then + elif echo "${pkg}" | grep -E '/lib(X11|Xau|Xdmcp|Xext|SM|ICE|Xfixes|Xft|Xdamage|Xcomposite|Xcursor|Xinerama|Xmu|Xmuu|Xpm|Xt|Xtst|Xi|Xrandr|Xrender|Xres|XScrnSaver|Xv|Xxf86vm|Xxf86dga|Xxf86misc|xcb)$' > /dev/null; then + warn "you need USE_XORG+=$(echo "${pkg}" | sed -E 's|.*/lib||' | tr '[:upper:]' '[:lower:]')" + elif [ "${pkg}" = 'x11/pixman' ]; then warn "you need USE_XORG+=pixman" # Qt4 - elif expr ${pkg} : '.*/qt4-.*' > /dev/null; then - warn "you need USE_QT4+=$(echo ${pkg} | sed -E 's|.*/qt4-||')" - elif expr ${pkg} : '.*/.*-qt4' > /dev/null; then - warn "you need USE_QT4+=$(echo ${pkg} | sed -E 's|.*/(.*)-qt4|\1|')" + elif expr "${pkg}" : '.*/qt4-.*' > /dev/null; then + warn "you need USE_QT4+=$(echo "${pkg}" | sed -E 's|.*/qt4-||')" + elif expr "${pkg}" : '.*/.*-qt4' > /dev/null; then + warn "you need USE_QT4+=$(echo "${pkg}" | sed -E 's|.*/(.*)-qt4|\1|')" # Qt5 - elif expr ${pkg} : '.*/qt5-.*' > /dev/null; then - warn "you need USE_QT5+=$(echo ${pkg} | sed -E 's|.*/qt5-||')" + elif expr "${pkg}" : '.*/qt5-.*' > /dev/null; then + warn "you need USE_QT5+=$(echo "${pkg}" | sed -E 's|.*/qt5-||')" # MySQL - elif expr ${lib_file} : "${LOCALBASE}/lib/mysql/[^/]*$" > /dev/null; then + elif expr "${lib_file}" : "${LOCALBASE}/lib/mysql/[^/]*$" > /dev/null; then warn "you need USES+=mysql" # postgresql - elif expr ${pkg} : "^databases/postgresql.*-client" > /dev/null; then + elif expr "${pkg}" : "^databases/postgresql.*-client" > /dev/null; then warn "you need USES+=pgsql" # bdb - elif expr ${pkg} : "^databases/db[456]" > /dev/null; then + elif expr "${pkg}" : "^databases/db[456]" > /dev/null; then warn "you need USES+=bdb" # fam/gamin - elif [ ${pkg} = "devel/fam" -o ${pkg} = "devel/gamin" ]; then + elif [ "${pkg}" = "devel/fam" -o "${pkg}" = "devel/gamin" ]; then warn "you need USES+=fam" # firebird - elif [ ${pkg} = "databases/firebird25-client" ]; then + elif [ "${pkg}" = "databases/firebird25-client" ]; then warn "you need USES+=firebird" # fuse - elif [ ${pkg} = "sysutils/fusefs-libs" ]; then + elif [ "${pkg}" = "sysutils/fusefs-libs" ]; then warn "you need USES+=fuse" # gnustep - elif [ ${pkg} = "lang/gnustep-base" ]; then + elif [ "${pkg}" = "lang/gnustep-base" ]; then warn "you need USES+=gnustep and USE_GNUSTEP+=base" - elif [ ${pkg} = "x11-toolkits/gnustep-gui" ]; then + elif [ "${pkg}" = "x11-toolkits/gnustep-gui" ]; then warn "you need USES+=gnustep and USE_GNUSTEP+=gui" # iconv - elif [ ${pkg} = "converters/libiconv" ]; then + elif [ "${pkg}" = "converters/libiconv" ]; then warn "you need USES+=iconv, USES+=iconv:wchar_t, or USES+=iconv:translit depending on needs" # jpeg - elif [ ${pkg} = "graphics/jpeg" -o ${pkg} = "graphics/jpeg-turbo" ]; then + elif [ "${pkg}" = "graphics/jpeg" -o "${pkg}" = "graphics/jpeg-turbo" ]; then warn "you need USES+=jpeg" # libarchive - elif [ ${pkg} = "archivers/libarchive" ]; then + elif [ "${pkg}" = "archivers/libarchive" ]; then warn "you need USES+=libarchive" - elif [ ${pkg} = "devel/libedit" ]; then + elif [ "${pkg}" = "devel/libedit" ]; then warn "you need USES+=libedit" # lua - elif expr ${pkg} : "^lang/lua" > /dev/null; then + elif expr "${pkg}" : "^lang/lua" > /dev/null; then warn "you need USES+=lua" # motif - elif [ ${pkg} = "x11-toolkits/lesstif" -o ${pkg} = "x11-toolkits/open-motif" ]; then + elif [ "${pkg}" = "x11-toolkits/lesstif" -o "${pkg}" = "x11-toolkits/open-motif" ]; then warn "you need USES+=motif" # ncurses - elif [ ${pkg} = "devel/ncurses" ]; then + elif [ "${pkg}" = "devel/ncurses" ]; then warn "you need USES+=ncurses" # objc - elif [ ${pkg} = "lang/libobjc2" ]; then + elif [ "${pkg}" = "lang/libobjc2" ]; then warn "you need USES+=objc" # openal - elif [ ${pkg} = "audio/openal" -o ${pkg} = "audio/openal-soft" -o ${pkg} = "audio/freealut" ]; then + elif [ "${pkg}" = "audio/openal" -o "${pkg}" = "audio/openal-soft" -o "${pkg}" = "audio/freealut" ]; then warn "you need USES+=openal" # pure - elif [ ${pkg} = "lang/pure" ]; then + elif [ "${pkg}" = "lang/pure" ]; then warn "you need USES+=pure" # readline - elif [ ${pkg} = "devel/readline" ]; then + elif [ "${pkg}" = "devel/readline" ]; then warn "you need USES+=readline" # ssl - elif [ ${pkg} = "security/openssl" -o ${pkg} = "security/openssl-devel" \ - -o ${pkg} = "security/libressl" -o ${pkg} = "security/libressl-devel" \ + elif [ "${pkg}" = "security/openssl" -o "${pkg}" = "security/openssl-devel" \ + -o "${pkg}" = "security/libressl" -o "${pkg}" = "security/libressl-devel" \ ]; then warn "you need USES=ssl" # Tcl - elif expr ${pkg} : "^lang/tcl" > /dev/null; then + elif expr "${pkg}" : "^lang/tcl" > /dev/null; then warn "you need USES+=tcl" # Tk - elif expr ${pkg} : "^x11-toolkits/tk" > /dev/null; then + elif expr "${pkg}" : "^x11-toolkits/tk" > /dev/null; then warn "you need USES+=tk" # Xfce - # grep LIB_DEPENDS= Mk/Uses/xfce.mk |sed -e 's|\(.*\)_LIB_DEPENDS.*:\(.*\)\/\(.*\)|elif [ ${pkg} = "\2/\3" ]; then warn "you need USE_XFCE+=\1"|' - elif [ ${pkg} = "sysutils/garcon" ]; then warn "you need USE_XFCE+=garcon" - elif [ ${pkg} = "x11/libexo" ]; then warn "you need USE_XFCE+=libexo" - elif [ ${pkg} = "x11-toolkits/libxfce4gui" ]; then warn "you need USE_XFCE+=libgui" - elif [ ${pkg} = "x11/libxfce4menu" ]; then warn "you need USE_XFCE+=libmenu" - elif [ ${pkg} = "x11/libxfce4util" ]; then warn "you need USE_XFCE+=libutil" - elif [ ${pkg} = "x11-wm/xfce4-panel" ]; then warn "you need USE_XFCE+=panel" - elif [ ${pkg} = "x11-fm/thunar" ]; then warn "you need USE_XFCE+=thunar" - elif [ ${pkg} = "x11/xfce4-conf" ]; then warn "you need USE_XFCE+=xfconf" + # grep LIB_DEPENDS= Mk/Uses/xfce.mk |sed -e 's|\(.*\)_LIB_DEPENDS.*:\(.*\)\/\(.*\)|elif [ "${pkg}" = "\2/\3" ]; then warn "you need USE_XFCE+=\1"|' + elif [ "${pkg}" = "sysutils/garcon" ]; then warn "you need USE_XFCE+=garcon" + elif [ "${pkg}" = "x11/libexo" ]; then warn "you need USE_XFCE+=libexo" + elif [ "${pkg}" = "x11-toolkits/libxfce4gui" ]; then warn "you need USE_XFCE+=libgui" + elif [ "${pkg}" = "x11/libxfce4menu" ]; then warn "you need USE_XFCE+=libmenu" + elif [ "${pkg}" = "x11/libxfce4util" ]; then warn "you need USE_XFCE+=libutil" + elif [ "${pkg}" = "x11-wm/xfce4-panel" ]; then warn "you need USE_XFCE+=panel" + elif [ "${pkg}" = "x11-fm/thunar" ]; then warn "you need USE_XFCE+=thunar" + elif [ "${pkg}" = "x11/xfce4-conf" ]; then warn "you need USE_XFCE+=xfconf" # default - elif expr ${lib_file} : "${LOCALBASE}/lib/[^/]*$" > /dev/null; then + elif expr "${lib_file}" : "${LOCALBASE}/lib/[^/]*$" > /dev/null; then lib_file=${lib_file#${LOCALBASE}/lib/} lib_file=${lib_file%.so*}.so warn "you need LIB_DEPENDS+=${lib_file}:${pkg}" @@ -645,18 +646,18 @@ # Check all dynamicaly linked ELF files # Some .so are not executable, but we want to check them too. - while read file; do + while read -r file; do # No results presents a blank line from heredoc. [ -z "${file}" ] && continue - while read dep_file; do + while read -r dep_file; do # No results presents a blank line from heredoc. [ -z "${dep_file}" ] && continue # Skip files we already checked. - if listcontains ${dep_file} "${already}"; then + if listcontains "${dep_file}" "${already}"; then continue fi - if $(pkg which -q ${dep_file} > /dev/null 2>&1); then - dep_file_pkg=$(pkg which -qo ${dep_file}) + if pkg which -q "${dep_file}" > /dev/null 2>&1; then + dep_file_pkg=$(pkg which -qo "${dep_file}") # Check that the .so we need has a SONAME if [ "${dep_file_pkg}" != "${PKGORIGIN}" ]; then @@ -666,9 +667,9 @@ fi # If we don't already depend on it, and we don't provide it - if ! listcontains ${dep_file_pkg} "${LIB_RUN_DEPENDS} ${PKGORIGIN}"; then + if ! listcontains "${dep_file_pkg}" "${LIB_RUN_DEPENDS} ${PKGORIGIN}"; then err "${file} is linked to ${dep_file} from ${dep_file_pkg} but it is not declared as a dependency" - proxydeps_suggest_uses ${dep_file_pkg} ${dep_file} + proxydeps_suggest_uses "${dep_file_pkg}" "${dep_file}" rc=1 fi else @@ -678,10 +679,10 @@ already="${already} ${dep_file}" done <<-EOT $(env LD_LIBMAP_DISABLE=1 ldd -a "${STAGEDIR}${file}" | \ - awk '\ - BEGIN {section=0}\ - /^\// {section++}\ - !/^\// && section<=1 && ($3 ~ "^'${PREFIX}'" || $3 ~ "^'${LOCALBASE}'") {print $3}') + awk ' + BEGIN {section=0} + /^\// {section++} + !/^\// && section<=1 && ($3 ~ "^'"${PREFIX}"'" || $3 ~ "^'"${LOCALBASE}"'") {print $3}') EOT done <<-EOT $(list_stagedir_elfs | \ @@ -697,13 +698,13 @@ } sonames() { - [ ! -d ${STAGEDIR}${PREFIX}/lib -o -n "${BUNDLE_LIBS}" ] && return 0 - while read f; do + [ ! -d "${STAGEDIR}${PREFIX}/lib" -o -n "${BUNDLE_LIBS}" ] && return 0 + while read -r f; do # No results presents a blank line from heredoc. [ -z "${f}" ] && continue # Ignore symlinks [ -f "${f}" -a ! -L "${f}" ] || continue - if ! readelf -d ${f} | grep -q SONAME; then + if ! readelf -d "${f}" | grep -q SONAME; then warn "${f} doesn't have a SONAME." warn "pkg(8) will not register it as being provided by the port." warn "If another port depend on it, pkg will not be able to know where it comes from." @@ -718,7 +719,7 @@ fi # Use heredoc to avoid losing rc from find|while subshell done <<-EOT - $(find ${STAGEDIR}${PREFIX}/lib -name '*.so.*') + $(find "${STAGEDIR}${PREFIX}/lib" -name '*.so.*') EOT } @@ -740,13 +741,13 @@ local portname version module gotsome [ -x "${LOCALBASE}/bin/corelist" ] || return 0 for dep in ${UNIFIED_DEPENDS}; do - portname=$(expr "${dep}" : ".*/p5-\(.*\)") + portname=$(expr "${dep}" : ".*/p5-\\(.*\\)") if [ -n "${portname}" ]; then gotsome=1 module=$(perlcore_port_module_mapping "${portname}") - version=$(expr "${dep}" : ".*>=*\([^:<]*\)") + version=$(expr "${dep}" : ".*>=*\\([^:<]*\\)") - while read l; do + while read -r l; do case "${l}" in *was\ not\ in\ CORE*) # This never was with Perl @@ -771,7 +772,7 @@ err "This line is not handled: \"${l}\"" esac done <<-EOT - $(${LOCALBASE}/bin/corelist "${module}"|tail -1) + $("${LOCALBASE}"/bin/corelist "${module}"|tail -1) EOT fi done @@ -783,7 +784,7 @@ no_arch() { [ -z "$NO_ARCH" ] && return rc=0 - while read f; do + while read -r f; do [ -z "$f" ] && continue if [ -n "$NO_ARCH_IGNORE" ]; then skip= @@ -794,7 +795,7 @@ done [ "$skip" ] && continue fi - err "'${f#.}' is a architecture specific binary file and you have set NO_ARCH. Either remove NO_ARCH or add '$(basename $f)' to NO_ARCH_IGNORE." + err "'${f#.}' is a architecture specific binary file and you have set NO_ARCH. Either remove NO_ARCH or add '$(basename "$f")' to NO_ARCH_IGNORE." rc=1 done <<-EOF $(list_stagedir_elfs \ @@ -809,19 +810,22 @@ { rc=0 if [ "${PKGBASE%%-*}" = "rubygem" ]; then + # shellcheck disable=SC2153 + # In the heredoc, ${PORTNAME} comes from the environment, not + # to be confused with ${portname} while read -r l; do if [ -n "${l}" ]; then name=${l%% *} vers=${l#* } while read -r v; do if ! while read -r p; do - ${LOCALBASE}/bin/ruby -e "puts 'OK' if Gem::Dependency.new('${name}','${v}').match?('${name}','${p}')" + "${LOCALBASE}"/bin/ruby -e "puts 'OK' if Gem::Dependency.new('${name}','${v}').match?('${name}','${p}')" done | grep -qFx OK; then - err RubyGem dependency ${name} ${v} is not satisfied. + err RubyGem dependency "${name}" "${v}" is not satisfied. rc=1 fi <<-EOF - $(${LOCALBASE}/bin/gem list -e "${name}" \ - | sed "s|.*(\(.*\))|\1|" \ + $("${LOCALBASE}"/bin/gem list -e "${name}" \ + | sed "s|.*(\\(.*\\))|\\1|" \ | tr -d ' ' \ | tr , '\n') EOF @@ -833,7 +837,7 @@ EOF fi done <<-EOF - $(grep -a 'add_runtime_dependency' ${STAGEDIR}${PREFIX}/lib/ruby/gems/*/specifications/${PORTNAME}-*.gemspec \ + $(grep -a 'add_runtime_dependency' "${STAGEDIR}${PREFIX}"/lib/ruby/gems/*/specifications/"${PORTNAME}"-*.gemspec \ | sed 's|.*<\(.*\)>.*\[\(.*\)\])|\1 \2|' \ | sort -u) EOF @@ -876,12 +880,12 @@ # use bundle to check if Gemfile is satisfied # if bundle returns 1 the Gemfile is not satisfied # and so stage-qa isn't also - if ! bundle check --dry-run --gemfile $f > /dev/null 2>&1; then + if ! bundle check --dry-run --gemfile "$f" > /dev/null 2>&1; then warn "Dependencies defined in ${f} are not satisfied" fi done <<-EOF - $(find ${STAGEDIR} -name Gemfile) + $(find "${STAGEDIR}" -name Gemfile) EOF return 0 } @@ -908,7 +912,7 @@ checks="$checks proxydeps sonames perlcore no_arch gemdeps gemfiledeps flavors" ret=0 -cd ${STAGEDIR} +cd "${STAGEDIR}" || exit 1 for check in ${checks}; do ${check} || ret=1 done Index: Mk/Scripts/smart_makepatch.sh =================================================================== --- Mk/Scripts/smart_makepatch.sh +++ Mk/Scripts/smart_makepatch.sh @@ -48,12 +48,12 @@ strip_path() { local raw_name=$1 if [ "${STRIP_COMPONENTS}" = "0" ]; then - echo ${raw_name} + echo "${raw_name}" else - echo ${raw_name} | awk -v sc=${STRIP_COMPONENTS} -F "/" \ - '{ for (x = sc + 1; x <= NF; x++) { \ - slash = (x>sc+1) ? "/" : ""; \ - printf ("%s%s", slash, $x); \ + echo "${raw_name}" | awk -v sc="${STRIP_COMPONENTS}" -F "/" \ + '{ for (x = sc + 1; x <= NF; x++) { + slash = (x>sc+1) ? "/" : ""; + printf ("%s%s", slash, $x); }}' fi } @@ -61,15 +61,17 @@ std_patch_filename() { local sans_cwd local raw_name - sans_cwd=$(echo $1 | sed 's|^\.\/||') - raw_name=$(strip_path ${sans_cwd}) - echo patch-$(echo ${raw_name} | sed -e 's|_|&&|g; s|/|_|g') + sans_cwd=$(echo "$1" | sed 's|^\.\/||') + raw_name=$(strip_path "${sans_cwd}") + echo "patch-$(echo "${raw_name}" | sed -e 's|_|&&|g; s|/|_|g')" } patchdir_files_list() { if [ -d "${PATCHDIR}" ]; then - (cd ${PATCHDIR} && \ - find * -type f -name "patch-*" -maxdepth 0 \ + # shellcheck disable=SC2035 + # -f already makes sure what follows is not a flag + (cd "${PATCHDIR}" && \ + find -f * -type f -name "patch-*" -maxdepth 0 \ 2>/dev/null | sed -e '/\.orig$/d' ) fi; @@ -81,28 +83,28 @@ local first_target local testres local lps - first_target=$(echo $2 | sed 's|^\.\/||') + first_target=$(echo "$2" | sed 's|^\.\/||') for lps in __ - + ; do - testres=patch-$(echo ${first_target} | sed -e "s|/|${lps}|g") + testres=patch-$(echo "${first_target}" | sed -e "s|/|${lps}|g") if [ "${testres}" = "${current_patch_name}" ]; then result=${testres} break fi done - echo ${result} + echo "${result}" } map_existing_patches() { - mkdir -p ${WORKAREA} - : > ${PATCHMAP} + mkdir -p "${WORKAREA}" + : > "${PATCHMAP}" local target local future_name local std_target local P local t for P in ${old_patch_list}; do - target=$(cd ${PATCHDIR} && \ - grep "^+++ " ${P} | awk '{print $2}' + target=$(cd "${PATCHDIR}" && \ + grep "^+++ " "${P}" | awk '{print $2}' ) # For single patches, we honor previous separators, but use # a standard patch name if the current patch name does not @@ -114,12 +116,12 @@ future_name=${P} break; fi - std_target=$(std_patch_filename ${t}) - future_name=$(valid_name ${P} ${t} ${std_target}) + std_target=$(std_patch_filename "${t}") + future_name=$(valid_name "${P}" "${t}" "${std_target}") done for t in ${target}; do - std_target=$(std_patch_filename ${t}) - echo "${future_name} ${std_target}" >> ${PATCHMAP} + std_target=$(std_patch_filename "${t}") + echo "${future_name} ${std_target}" >> "${PATCHMAP}" done done } @@ -130,54 +132,54 @@ local rawname local fname local num - contains=$(grep "^+++ " ${existing_patch} | awk '{x++; print x}') + contains=$(grep "^+++ " "${existing_patch}" | awk '{x++; print x}') for num in ${contains}; do - rawname=$(grep "^+++ " ${existing_patch} | \ - awk -v num=${num} '{x++; if (x==num) print $2}') - fname=$(std_patch_filename $rawname) - awk -v num=${num} '\ - BEGIN { done=0; x=0; hunk=0; looking=(num==1) } \ - { \ - if (!done) { \ - if ($1 == "@@") { \ - split ($2,a,","); \ - split ($3,b,","); \ + rawname=$(grep "^+++ " "${existing_patch}" | \ + awk -v num="${num}" '{x++; if (x==num) print $2}') + fname=$(std_patch_filename "$rawname") + awk -v num="${num}" ' + BEGIN { done=0; x=0; hunk=0; looking=(num==1) } + { + if (!done) { + if ($1 == "@@") { + split ($2,a,","); + split ($3,b,","); hca = a[2]; hcb = a[3]; hunk = 1; - } else if (hunk) { \ - first=substr($1,1,1); \ - if (first == "-") { hca-- } \ - else if (first == "+") { hcb-- } \ - else {hca--; hcb--} \ - if (hca == 0 && hcb == 0) {hunk = 0} \ - } \ - if ($1 == "---") { \ - x++; \ - if (x == num) { done = 1 } \ - if (x + 1 == num) { looking = 1 } \ - } else if (!hunk && looking) { \ - if ($1!="diff" && $1!="index" && $1!="+++") {\ - print $0 \ - } \ - } \ - } \ - }' ${existing_patch} > ${COMMENTS}/${fname} + } else if (hunk) { + first=substr($1,1,1); + if (first == "-") { hca-- } + else if (first == "+") { hcb-- } + else {hca--; hcb--} + if (hca == 0 && hcb == 0) {hunk = 0} + } + if ($1 == "---") { + x++; + if (x == num) { done = 1 } + if (x + 1 == num) { looking = 1 } + } else if (!hunk && looking) { + if ($1!="diff" && $1!="index" && $1!="+++") { + print $0 + } + } + } + }' "${existing_patch}" > "${COMMENTS}/${fname}" done } extract_comments() { - mkdir -p ${COMMENTS} - rm -f ${COMMENTS}/* + mkdir -p "${COMMENTS}" + rm -f "${COMMENTS}"/* local P for P in ${old_patch_list}; do - extract_comment_from_patch ${P} + extract_comment_from_patch "${P}" done } regenerate_patches() { - mkdir -p ${REGENNED} - rm -f ${REGENNED}/* + mkdir -p "${REGENNED}" + rm -f "${REGENNED}"/* [ ! -d "${PATCH_WRKSRC}" ] && return local F @@ -185,48 +187,52 @@ local OUT local ORIG local new_list + # shellcheck disable=SC2035 + # -f already makes sure what follows is not a flag new_list=$(cd "${PATCH_WRKSRC}" && \ - find -s * -type f -name '*.orig' 2>/dev/null) + find -s -f * -type f -name '*.orig' 2>/dev/null) (cd "${PATCH_WRKSRC}" && for F in ${new_list}; do ORIG=${F#./} NEW=${ORIG%.orig} - cmp -s ${ORIG} ${NEW} && continue - OUT=${REGENNED}/$(std_patch_filename ${NEW}) - TZ=UTC diff -udp ${ORIG} ${NEW} | sed \ + cmp -s "${ORIG}" "${NEW}" && continue + OUT=${REGENNED}/$(std_patch_filename "${NEW}") + TZ=UTC diff -udp "${ORIG}" "${NEW}" | sed \ -e '/^---/s|\.[0-9]* +0000$| UTC|' \ -e '/^+++/s|\([[:blank:]][-0-9:.+]*\)*$||' \ - > ${OUT} || true + > "${OUT}" || true done) } get_patch_name() { - awk -v name=$1 '\ - { if ($2 == name) \ - { \ - if (!done) { print $1 }; \ - done = 1; \ - } \ - } \ - END { if (!done) print name }' ${PATCHMAP} + awk -v name="$1" ' + { if ($2 == name) + { + if (!done) { print $1 }; + done = 1; + } + } + END { if (!done) print name }' "${PATCHMAP}" } stage_patches() { - mkdir -p ${DESTDIR} - rm -f ${DESTDIR}/* + mkdir -p "${DESTDIR}" + rm -f "${DESTDIR}"/* local P local name local patch_list - patch_list=$(cd ${REGENNED} && find * -name "patch-*" 2>/dev/null) + # shellcheck disable=SC2035 + # -f already makes sure what follows is not a flag + patch_list=$(cd "${REGENNED}" && find -f * -name "patch-*" 2>/dev/null) for P in ${patch_list}; do - name=$(get_patch_name ${P}) - [ -e ${COMMENTS}/${P} ] && cat ${COMMENTS}/${P} \ - >> ${DESTDIR}/${name} + name=$(get_patch_name "${P}") + [ -e "${COMMENTS}/${P}" ] && cat "${COMMENTS}/${P}" \ + >> "${DESTDIR}/${name}" if [ "${P}" = "${name}" ]; then echo "Generated ${P}" else echo "Generated ${P} >> ${name} (legacy)" fi - cat ${REGENNED}/${P} >> ${DESTDIR}/${name} + cat "${REGENNED}/${P}" >> "${DESTDIR}/${name}" done } @@ -239,47 +245,48 @@ local cpatch local cpatch_stripped for P in ${old_patch_list}; do - if [ -e ${DESTDIR}/${P} ]; then + if [ -e "${DESTDIR}/${P}" ]; then ppatch=${PATCHDIR}/${P} cpatch=${DESTDIR}/${P} ppatch_stripped=$(mktemp -t portpatch) cpatch_stripped=$(mktemp -t portpatch) - egrep -v -- '--- .+ UTC$' ${ppatch} \ - > ${ppatch_stripped} - egrep -v -- '--- .+ UTC$' ${cpatch} \ - > ${cpatch_stripped} + grep -E -v -- '--- .+ UTC$' "${ppatch}" \ + > "${ppatch_stripped}" + grep -E -v -- '--- .+ UTC$' "${cpatch}" \ + > "${cpatch_stripped}" # Don't replace patches with only metadata changes - if ! cmp -s ${ppatch_stripped} ${cpatch_stripped}; then + if ! cmp -s "${ppatch_stripped}" "${cpatch_stripped}"; then archive_patch_list="${archive_patch_list} ${P}" else echo "${P} only contains metadata changes; not replacing" - rm ${cpatch} + rm "${cpatch}" fi - rm ${ppatch_stripped} - rm ${cpatch_stripped} + rm "${ppatch_stripped}" + rm "${cpatch_stripped}" fi done old_patch_list=${archive_patch_list} } conserve_old_patches() { - mkdir -p ${SAVEDIR} - rm -f ${SAVEDIR}/* + mkdir -p "${SAVEDIR}" + rm -f "${SAVEDIR}"/* [ -z "${old_patch_list}" ] && return local P for P in ${old_patch_list}; do - mv ${PATCHDIR}/${P} ${SAVEDIR}/${P} + mv "${PATCHDIR}/${P}" "${SAVEDIR}/${P}" done echo "The previous patches have been placed here:" - echo ${SAVEDIR} + echo "${SAVEDIR}" } install_regenerated_patches() { - local testdir=$(find ${DESTDIR} -empty) + local testdir + testdir=$(find "${DESTDIR}" -empty) if [ -z "${testdir}" ]; then - mkdir -p ${PATCHDIR} - find ${DESTDIR} -type f -exec mv {} ${PATCHDIR}/ \; + mkdir -p "${PATCHDIR}" + find "${DESTDIR}" -type f -exec mv {} "${PATCHDIR}"/ \; fi }