Path: blob/main/Tools/scripts/search_lib_depends_and_bump.sh
16462 views
#!/bin/sh1#2# You pass the script a port where the library has changed its ABI.3# The script will search for this port over the complete directory you are located now4# and will bump all ports using `Tools/scripts/bump-revision.sh`5#6# Version 0.27# License: MIT8# Matthias Fechner <[email protected]>910usage() {11echo "$0 devel/libgit2"12echo ""13echo "Search for all ports having devel/libgit2 as a LIB_DEPENDS"14echo "and bump the REVISION using the script 'Tools/scripts/bump-revision.sh'"15echo "After this check all modified ports with portlint."16echo ""17echo "Make sure you execute the script in the ports directory."18exit 119}2021[ "${1}" != "" ] || usage2223# check that portlint is available24if [ x`which portlint` = x"" ]; then25echo "Please install portlint with"26echo "pkg install portlint"27echo "to continue."28exit 1;29fi3031PORT_TO_SEARCH=${1}32BASEDIR=$(pwd)33# Get a list of all ports34echo "Prepare a list of all ports"35ports=`find . -name Makefile -maxdepth 3 -not \( -path "./distfiles/*" -prune \) -not \( -path "./Tools/*" -prune \) -not \( -path "./Templates/*" -prune \) -print | sort`36echo "done."37echo3839PORTS_TO_BUMP=""40echo Check ports with dependency to ${PORT_TO_SEARCH}41for port in ${ports}; do42DIR=$(dirname "${port}")43printf "Analyse ${DIR}"44LIBDEPENDS=$(make -n -V LIB_DEPENDS -C ${DIR})45#echo "Search >${PORT_TO_SEARCH}< in >${LIBDEPENDS}<"46case "${LIBDEPENDS}" in47*"${PORT_TO_SEARCH}"*)48PORTS_TO_BUMP="${PORTS_TO_BUMP} ${DIR}";;49esac50printf "\033[2K\r"51done52echo "done."5354echo "Bump PORTREVISION of following ports:"55for PORT_TO_BUMP in ${PORTS_TO_BUMP}; do56echo ${PORT_TO_BUMP}57done58echo59read -p "Press CTRL+c to stop or ENTER to continue..." USERINPUT6061for PORT_TO_BUMP in ${PORTS_TO_BUMP}; do62sh ./Tools/scripts/bump-revision.sh ${PORT_TO_BUMP}63done6465# Now we run portlint on all port we modified66# I borrowed here code from doportlint67echo68TMPFILE=$(mktemp)69while [ "1" = "1" ]70do71FAILED_PORTS=""72FAILURES=073echo "Use TMP file ${TMPFILE}"74for PORT in ${PORTS_TO_BUMP}; do75FAILURE=076echo "Running portlint in ${PORT}"77cd ${PORT}78portlint > ${TMPFILE} 2> /dev/null || FAILURE=179grep '^looks fine\.$' ${TMPFILE} > /dev/null 2> /dev/null || FAILURE=18081if [ x${FAILURE} = "x1" ]; then82FAILURES=$((${FAILURES}+1))83FAILED_PORTS="${FAILED_PORTS} ${PORT}"84{ echo '--------------- portlint failed for '${PORT}; \85grep -v '^OK:' ${TMPFILE} |\86sed -e 's/^0 fatal errors and //'; }87echo ""88fi89rm -f ${TMPFILE}90cd ${BASEDIR}91done92if [ x${FAILURES} = "x0" ]; then93echo "All portlint test successfull, please review the changes before you commit them carefully."94echo "You maybe want to run now"95echo "git diff"96echo97break;98fi99PORTS_TO_BUMP=${FAILED_PORTS}100read -p "${FAILURES} failures, please fix portlint error and warnings and press ENTER to retest" USERINPUT101echo102echo103echo "------------------------------------ NEW Portlint -----------------------------"104done105106107108