diff options
| author | Wolfram Schneider <wosch@FreeBSD.org> | 2024-07-07 12:59:20 +0000 |
|---|---|---|
| committer | Wolfram Schneider <wosch@FreeBSD.org> | 2024-07-13 10:14:27 +0000 |
| commit | 3e8a2296e9ad827268d0398738a3ed95877d872e (patch) | |
| tree | ef8b785063ce029d80d30a8539d8dd8a51ecdba8 /tools | |
| parent | 8b5eb0cf6c4f586f891fef7fb067beb343826435 (diff) | |
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/build/stale-symlink-buildworld.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/build/stale-symlink-buildworld.sh b/tools/build/stale-symlink-buildworld.sh new file mode 100755 index 000000000000..a4515db3fccb --- /dev/null +++ b/tools/build/stale-symlink-buildworld.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Copyright (c) Feb 2024 Wolfram Schneider <wosch@FreeBSD.org> +# SPDX-License-Identifier: BSD-2-Clause +# +# stale-symlink-buildworld.sh - check for stale symlinks on a FreeBSD system +# +# You can run the script before or after `make installworld' +# + +PATH="/bin:/usr/bin"; export PATH + +: ${ncpu=$(nproc)} + +# check other directories as well +: ${STALE_SYMLINK_BUILDWORLD_DIRS="/usr/obj"} + +trap 'rm -f $script' 0 +script=$(mktemp -t stale-symlink) +chmod u+x $script + +# create a temporary shell script to check for stale symbolic links +cat << 'EOF' > $script +file="$1" + +if [ ! -e "$file" ]; then + echo "stale symlink detected: $(ls -ld $file)" >&2 + exit 1 +else + exit 0 +fi +EOF + +find -s -H \ + /bin \ + /boot \ + /etc \ + /lib \ + /libexec \ + /sbin \ + /usr/bin \ + /usr/include \ + /usr/lib \ + /usr/lib32 \ + /usr/libdata \ + /usr/libexec \ + /usr/sbin \ + /usr/src \ + /usr/share \ + $STALE_SYMLINK_BUILDWORLD_DIRS \ + -type l \ + -print0 | xargs -n1 -0 -P${ncpu} $script + +#EOF |
