Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/Tools/scripts/search_lib_depends_and_bump.sh
16462 views
1
#!/bin/sh
2
#
3
# You pass the script a port where the library has changed its ABI.
4
# The script will search for this port over the complete directory you are located now
5
# and will bump all ports using `Tools/scripts/bump-revision.sh`
6
#
7
# Version 0.2
8
# License: MIT
9
# Matthias Fechner <[email protected]>
10
11
usage() {
12
echo "$0 devel/libgit2"
13
echo ""
14
echo "Search for all ports having devel/libgit2 as a LIB_DEPENDS"
15
echo "and bump the REVISION using the script 'Tools/scripts/bump-revision.sh'"
16
echo "After this check all modified ports with portlint."
17
echo ""
18
echo "Make sure you execute the script in the ports directory."
19
exit 1
20
}
21
22
[ "${1}" != "" ] || usage
23
24
# check that portlint is available
25
if [ x`which portlint` = x"" ]; then
26
echo "Please install portlint with"
27
echo "pkg install portlint"
28
echo "to continue."
29
exit 1;
30
fi
31
32
PORT_TO_SEARCH=${1}
33
BASEDIR=$(pwd)
34
# Get a list of all ports
35
echo "Prepare a list of all ports"
36
ports=`find . -name Makefile -maxdepth 3 -not \( -path "./distfiles/*" -prune \) -not \( -path "./Tools/*" -prune \) -not \( -path "./Templates/*" -prune \) -print | sort`
37
echo "done."
38
echo
39
40
PORTS_TO_BUMP=""
41
echo Check ports with dependency to ${PORT_TO_SEARCH}
42
for port in ${ports}; do
43
DIR=$(dirname "${port}")
44
printf "Analyse ${DIR}"
45
LIBDEPENDS=$(make -n -V LIB_DEPENDS -C ${DIR})
46
#echo "Search >${PORT_TO_SEARCH}< in >${LIBDEPENDS}<"
47
case "${LIBDEPENDS}" in
48
*"${PORT_TO_SEARCH}"*)
49
PORTS_TO_BUMP="${PORTS_TO_BUMP} ${DIR}";;
50
esac
51
printf "\033[2K\r"
52
done
53
echo "done."
54
55
echo "Bump PORTREVISION of following ports:"
56
for PORT_TO_BUMP in ${PORTS_TO_BUMP}; do
57
echo ${PORT_TO_BUMP}
58
done
59
echo
60
read -p "Press CTRL+c to stop or ENTER to continue..." USERINPUT
61
62
for PORT_TO_BUMP in ${PORTS_TO_BUMP}; do
63
sh ./Tools/scripts/bump-revision.sh ${PORT_TO_BUMP}
64
done
65
66
# Now we run portlint on all port we modified
67
# I borrowed here code from doportlint
68
echo
69
TMPFILE=$(mktemp)
70
while [ "1" = "1" ]
71
do
72
FAILED_PORTS=""
73
FAILURES=0
74
echo "Use TMP file ${TMPFILE}"
75
for PORT in ${PORTS_TO_BUMP}; do
76
FAILURE=0
77
echo "Running portlint in ${PORT}"
78
cd ${PORT}
79
portlint > ${TMPFILE} 2> /dev/null || FAILURE=1
80
grep '^looks fine\.$' ${TMPFILE} > /dev/null 2> /dev/null || FAILURE=1
81
82
if [ x${FAILURE} = "x1" ]; then
83
FAILURES=$((${FAILURES}+1))
84
FAILED_PORTS="${FAILED_PORTS} ${PORT}"
85
{ echo '--------------- portlint failed for '${PORT}; \
86
grep -v '^OK:' ${TMPFILE} |\
87
sed -e 's/^0 fatal errors and //'; }
88
echo ""
89
fi
90
rm -f ${TMPFILE}
91
cd ${BASEDIR}
92
done
93
if [ x${FAILURES} = "x0" ]; then
94
echo "All portlint test successfull, please review the changes before you commit them carefully."
95
echo "You maybe want to run now"
96
echo "git diff"
97
echo
98
break;
99
fi
100
PORTS_TO_BUMP=${FAILED_PORTS}
101
read -p "${FAILURES} failures, please fix portlint error and warnings and press ENTER to retest" USERINPUT
102
echo
103
echo
104
echo "------------------------------------ NEW Portlint -----------------------------"
105
done
106
107
108