Просмотр исходного кода

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 793ebd5d2809 (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: 793ebd5d28095c8df45a0d183d273d8a84b3f0a4
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>
José Luis Salvador Rufo 1 месяц назад
Родитель
Сommit
92da94bf21
1 измененных файлов с 4 добавлено и 0 удалено
  1. 4 0
      support/scripts/check-merged

+ 4 - 0
support/scripts/check-merged

@@ -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