Bug 276235 - `make installworld’ should check for stale symlinks
Summary: `make installworld’ should check for stale symlinks
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: tests (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-testing (Nobody)
URL:
Keywords:
Depends on: 260841
Blocks:
  Show dependency treegraph
 
Reported: 2024-01-10 08:10 UTC by Wolfram Schneider
Modified: 2024-02-12 10:23 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfram Schneider freebsd_committer freebsd_triage 2024-01-10 08:10:18 UTC
In 14.0-RELEASE and the branch releng/14.0 we have the problem that some of the locale symlinks are wrong. See Bug 260841

I think we can detect this kind of stale symlinks during `make installworld’ and bail out:

As an example:

(set -o pipefail; sudo find /bin /boot /etc /lib /libexec /sbin /usr/bin /usr/include /usr/lib /usr/lib32 /usr/libdata/ /usr/libexec/ /usr/sbin /usr/share/ -type l -print0 | perl -0e 'while(<>) { if (! -e $_) { print; $exit=1}}; exit $exit' | xargs -0 ls -ld); echo $?

lrwxr-xr-x  1 root wheel 31 Nov 10 07:59 /usr/share/locale/nn_NO.ISO8859-1/LC_MESSAGES -> ../nn_NO.ISO8859-15/LC_MESSAGES
lrwxr-xr-x  1 root wheel 31 Nov 10 07:59 /usr/share/locale/nn_NO.ISO8859-15/LC_MESSAGES -> ../nn_NO.ISO8859-15/LC_MESSAGES
lrwxr-xr-x  1 root wheel 30 Nov 10 07:59 /usr/share/locale/sl_SI.ISO8859-2/LC_MESSAGES -> ../sr_RS.ISO8859-2/LC_MESSAGES
1


Maybe we should write a shell script and put it in src/tools/stale-symlinks.sh and call it from `make installworld’ as the last step.
Comment 1 Wolfram Schneider freebsd_committer freebsd_triage 2024-02-12 10:23:12 UTC
Here is an example without perl, just the base tools:

find /bin /boot /etc /lib /libexec /sbin /usr/bin /usr/include /usr/lib /usr/lib32 /usr/libdata/ /usr/libexec/ /usr/sbin /usr/share/ -type l -print0 | xargs -n1 -0 -P$(sysctl -n hw.ncpu) ./stale-symlink.sh


cat stale-symlink.sh 
#!/bin/sh

file="$1"

if [ ! -e "$file" ]; then
  echo "stale symlink detected: $(ls -ld $file)" >&2
  exit 1
else
  exit 0
fi