Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F154449631
D37430.id113255.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D37430.id113255.diff
View Options
Index: .hooks/pre-commit.d/check_rmport
===================================================================
--- /dev/null
+++ .hooks/pre-commit.d/check_rmport
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# Check that a removed port is in moved, and not referenced by other ports anymore.
+
+check_moved() {
+ local status=0
+ local removed_port=$1
+ local rm_moved=$(awk -F '|' -vrm=${removed_port} '$1==rm && length($2)==0' MOVED)
+ if [ -z "${rm_moved}" ] ; then
+ echo "[pre-commit] ERROR: no MOVED entry for '${removed_port}'."
+ status=1
+ fi
+ local mv_moved=$(awk -F '|' -vrm=${removed_port} '$2==rm' MOVED)
+ if [ -n "${mv_moved}" ] ; then
+ echo "[pre-commit] ERROR: ports are marked moved to '${removed_port}' in MOVED."
+ status=1
+ fi
+ return $status
+}
+
+check_deps() {
+ local status=0
+ local removed_port=$1
+ # check other port Makefiles for the port -- check for lines ala "...=...foo/bar"
+ references=`find $(make -VSUBDIR) -type f -name Makefile\* -depth 2 | xargs grep -lE "[^#]*=.*${removed_port}(@[a-z0-9-]+)?\s*[\\]?$"`
+ if [ -n "${references}" ] ; then
+ echo "[pre-commit] ERROR: port '${removed_port}' still referenced in:"
+ for reference in ${references} ; do
+ echo " * ${reference}"
+ done
+ status=1
+ fi
+ # check framework files for the port -- check for lines ala "...=...foo/bar"
+ references=`find Mk -type f -name \*.mk | xargs grep -lE "[^#]*=.*${removed_port}(@[a-z0-9-]+)?\s*[\\]?$"`
+ if [ -n "${references}" ] ; then
+ echo "[pre-commit] ERROR: port '${removed_port}' still referenced in:"
+ for reference in ${references} ; do
+ echo " * ${reference}"
+ done
+ status=1
+ fi
+ return $status
+}
+
+status=0
+category_regex="($(make -VSUBDIR | sed 's# #\|#g'))"
+removed_makefiles=$(git diff --name-only --cached --diff-filter=D | grep -E "^${category_regex}/[^/]+/Makefile$")
+if [ $? -eq 0 ] ; then
+ for removed_makefile in ${removed_makefiles} ; do
+ category=$(echo "${removed_makefile}" | awk -F '/' '{print $1}')
+ port=$(echo "${removed_makefile}" | awk -F '/' '{print $2}')
+ check_moved ${category}/${port}
+ if [ $? -ne 0 ] ; then
+ status=1
+ fi
+ check_deps ${category}/${port}
+ if [ $? -ne 0 ] ; then
+ status=1
+ fi
+ done
+fi
+if [ ${status} -eq 1 ] ; then
+ echo "[pre-commit] ERROR: removal of ports is incomplete. Please fix above issues."
+ exit 1
+fi
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 29, 3:42 PM (2 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32354139
Default Alt Text
D37430.id113255.diff (2 KB)
Attached To
Mode
D37430: framework: new hook to try to ensure clean removal of ports
Attached
Detach File
Event Timeline
Log In to Comment