support/scripts/check-merged: fix checking custom skeletons

When using a custom skeleton where the merged symlinks are missing,
the build fails with errors like:

    support/scripts/check-merged -t skeleton -u -b /usr/src/simplek8s/rootfs-skeleton
    The skeleton in -t is not properly setup:
    - /usr/bin should exist, be a directory, and not be a symlink
    - /usr/lib should exist, be a directory, and not be a symlink
    The skeleton in skeleton is not properly setup:
    - /usr/bin should exist, be a directory, and not be a symlink
    - /usr/lib should exist, be a directory, and not be a symlink
    [...]

Commit 793ebd5d28 (support/scripts/check-merged: use getopts instead of
getopt) intoduced a flawed use of getopts: unlike getopt, getopts does not
conume the positional arguments.  This causes the check for directory
validity to also check each option as if they were directories.

For overlays, this is transparently ignored, because the checks are only lax
for overlays (missing symlinks are OK).

However, for skeletons, the checks are strict.  Because of that, a missing
symlink is considered an error, when it should be considered as being OK.

The fix is to actually consume the positional args to only keep the list of
directories to validate, like is done for example in
support/download/dl-wrapper.

Fixes: 793ebd5d28
Reviewed-by: Yann E. MORIN <yann.morin.1998@free.fr>
Acked-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Edgar Bonet <bonet@grenoble.cnrs.fr>
Signed-off-by: José Luis Salvador Rufo <salvador.joseluis@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
José Luis Salvador Rufo
2025-11-29 21:34:55 +01:00
committed by Peter Korsgaard
parent b871105790
commit 92da94bf21

View File

@@ -47,6 +47,10 @@ while getopts "t:ub" OPT; do
esac
done
# Remove the options processed by getopts from $@,
# so that $@ now contains only the root directories to check.
shift $((OPTIND -1))
if [ "${type}" = "skeleton" ]; then
strict=true
else