Files
ProxmoxVE/.github/workflows/scripts/generate-app-headers.sh
T
CanbiZ (MickLesk) f212f93d89 Stop generating header filenames with a newline in them (#17435)
generate-app-headers.sh read APP with a plain grep -oP, so a script that
sets APP twice yielded both lines and the filename became
"almalinux
almalinux${var_version}vm". Three of those are in the tree
and they make main impossible to check out on Windows.

Nothing reads vm/headers: get_header fetches banners from the core
repo, which already carries clean almalinux, debian and ubuntu.
2026-09-22 14:30:44 +02:00

55 lines
1.5 KiB
Bash
Executable File
Generated

#!/usr/bin/env bash
# Function for generating Figlet headers
generate_headers() {
local base_dir=$1
local target_subdir=$2
local search_pattern=$3
local headers_dir="${base_dir}/headers"
mkdir -p "$headers_dir"
rm -f "$headers_dir"/*
# Recursive or non-recursive search
if [[ "$search_pattern" == "**" ]]; then
shopt -s globstar nullglob
file_list=("${base_dir}"/**/*.sh)
shopt -u globstar
else
file_list=("${base_dir}"/*.sh)
fi
for script in "${file_list[@]}"; do
[[ -f "$script" ]] || continue
# -m1: a script that sets APP twice (the second carrying ${var_version})
# otherwise yields both lines, and the filename gets a newline in it.
app_name=$(grep -m1 -oP '^APP="\K[^"]+' "$script" 2>/dev/null)
if [[ -n "$app_name" ]]; then
# core.func/vm-core.func look the header up as "${APP,,}" without spaces,
# so the generated file has to be named after APP - not after the script.
output_file="${headers_dir}/$(echo "${app_name,,}" | tr -d ' ')"
figlet_output=$(figlet -w 500 -f slant "$app_name")
if [[ -n "$figlet_output" ]]; then
echo "$figlet_output" >"$output_file"
echo "Generated: $output_file"
else
echo "Figlet failed for $app_name in $script"
fi
else
echo "No APP name found in $script, skipping."
fi
done
}
# ct
generate_headers "./ct" "headers" "*"
# tools (addon, pve, ...)
generate_headers "./tools" "headers" "**"
# vm
generate_headers "./vm" "headers" "*"
echo "Completed processing all sections."