config initial test

Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
Michael Shaw 2026-04-12 08:45:35 -04:00
commit 552f45c258
17 changed files with 168 additions and 20 deletions

58
scripts/config.sh Executable file
View file

@ -0,0 +1,58 @@
#!/bin/bash
CONFIG_FILE=".config"
# --- The Engine ---
run_menuconfig() {
local TITLE="$1"
shift
local OPTIONS=("$@") # Array of "KEY" "DESCRIPTION"
local DIALOG_ARGS=()
# 1. Build the dialog arguments dynamically
for ((i=0; i<${#OPTIONS[@]}; i+=2)); do
KEY="${OPTIONS[i]}"
DESC="${OPTIONS[i+1]}"
# Check current state in .config
STATE="OFF"
if grep -q "^CONFIG_${KEY}=y" "$CONFIG_FILE" 2>/dev/null; then
STATE="ON"
fi
DIALOG_ARGS+=("$KEY" "$DESC" "$STATE")
done
# 2. Show the menu
CHOICES=$(dialog --stdout --backtitle "Project Setup" \
--title "$TITLE" \
--checklist "Use SPACE to toggle, ENTER to save:" 15 70 10 \
"${DIALOG_ARGS[@]}")
# 3. Save if user didn't cancel
if [ $? -eq 0 ]; then
echo "# Generated Configuration" > "$CONFIG_FILE"
for OPTION in $CHOICES; do
CLEAN=$(echo "$OPTION" | tr -d '"')
echo "CONFIG_${CLEAN}=y" >> "$CONFIG_FILE"
done
# Add "is not set" for everything else to be professional
for ((i=0; i<${#OPTIONS[@]}; i+=2)); do
KEY="${OPTIONS[i]}"
if ! grep -q "CONFIG_${KEY}=y" "$CONFIG_FILE"; then
echo "# CONFIG_${KEY} is not set" >> "$CONFIG_FILE"
fi
done
fi
}
# --- How you use it ---
# Format: "VARIABLE_NAME" "Human Readable Description"
MY_FEATURES=(
"DRIVER_USB" "Include USB Driver Support"
"FS_EXT4" "Enable EXT4 Filesystem"
"NET_WIFI" "Wireless Networking Support"
"DEBUG_SYMBOLS" "Compile with Debug Symbols"
)
run_menuconfig "System Features" "${MY_FEATURES[@]}"