Add faster group-detection in autoinstall (dynamic groups are now impossible)

Allow for absolute paths in autoinstall exe
Add timer in run.sh
This commit is contained in:
Tobias Reisinger 2024-06-21 22:35:59 +02:00
parent 2aa4ae8b58
commit 67fed76c68
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
3 changed files with 13 additions and 15 deletions

View file

@ -5,7 +5,7 @@ completions=${args[--completions]:-}
target=${args[target]:?} target=${args[target]:?}
url=${args[url]:?} url=${args[url]:?}
if [ "${action:-file}" = "exe" ] if [ "${action:-file}" = "exe" ] && ! echo "$target" | grep -q "/"
then then
if [ -x "$(command -v "$target")" ] if [ -x "$(command -v "$target")" ]
then then

View file

@ -47,29 +47,18 @@ _handle_entry() {
AUTOINSTALL_ITEM_TARGET \ AUTOINSTALL_ITEM_TARGET \
AUTOINSTALL_ITEM_HOOK \ AUTOINSTALL_ITEM_HOOK \
AUTOINSTALL_ITEM_PIPE \ AUTOINSTALL_ITEM_PIPE \
AUTOINSTALL_ITEM_COMPLETIONS \ AUTOINSTALL_ITEM_COMPLETIONS
AUTOINSTALL_ITEM_GROUPS
eval "$1" eval "$1"
# check if we have the required vars # check if we have the required vars
if [[ -z "${AUTOINSTALL_ITEM_TYPE:-}" \ if [[ -z "${AUTOINSTALL_ITEM_TYPE:-}" \
|| -z "${AUTOINSTALL_ITEM_SOURCE:-}" \ || -z "${AUTOINSTALL_ITEM_SOURCE:-}" \
|| -z "${AUTOINSTALL_ITEM_TARGET:-}" \ || -z "${AUTOINSTALL_ITEM_TARGET:-}" ]]
|| -z "${AUTOINSTALL_ITEM_GROUPS:-}" ]]
then then
return return
fi fi
if [[ "$group" != "all" ]]
then
# check if group is in groups
if [[ ! "${AUTOINSTALL_ITEM_GROUPS}" =~ (^|,)$group(,|$) ]]
then
return
fi
fi
_install_entry "$AUTOINSTALL_ITEM_TYPE" "$AUTOINSTALL_ITEM_SOURCE" \ _install_entry "$AUTOINSTALL_ITEM_TYPE" "$AUTOINSTALL_ITEM_SOURCE" \
"$AUTOINSTALL_ITEM_TARGET" "${AUTOINSTALL_ITEM_HOOK:-}" "${AUTOINSTALL_ITEM_PIPE:-}" "${AUTOINSTALL_ITEM_COMPLETIONS:-}" "$AUTOINSTALL_ITEM_TARGET" "${AUTOINSTALL_ITEM_HOOK:-}" "${AUTOINSTALL_ITEM_PIPE:-}" "${AUTOINSTALL_ITEM_COMPLETIONS:-}"
@ -86,5 +75,14 @@ while [[ $line -lt $file_lines ]]; do
continue continue
fi fi
if [[ "$group" != "all" ]]
then
# check if group is in groups
if ! echo "$entry" | grep -qE "^AUTOINSTALL_ITEM_GROUPS=\"(.*,)?$group(,.*)?\"$"
then
continue
fi
fi
_handle_entry "$entry" || true # ignore errors _handle_entry "$entry" || true # ignore errors
done done

2
run.sh
View file

@ -8,4 +8,4 @@ make generate
printf "\nBuild complete. Running...\n==========================\n\n" printf "\nBuild complete. Running...\n==========================\n\n"
"./output/$target" "$@" time "./output/$target" "$@"