Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions src/initialize/debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,36 @@ debug() {


_about_debug() {
cat <<-EOF
cat <<EOF

Usage: debug <option> || <"message string">
Options:
help Show this help message
"message string" Show debug message (DEBUG non-zero)
reset (Re)set starting point
total Show total time and reset
Options:
help Show this help message
"message string" Show debug message (DEBUG non-zero)
reset (Re)set starting point
total Show total time and reset


When providing a "message string", elapsed time since last debug call is shown if DEBUG is set.
EOF
EOF
}


if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
DEBUG=${DEBUG:-true}

debug "debug initialized"

# --- Capture and assert help output ---
help_output="$(debug help)" # Capture
echo "$help_output" | grep -q "Usage: debug" || { # Assert
echo "Help output does not contain expected usage string"
exit 1
}
# --- end assertion ---

debug "$help_output"
debug "test complete"
debug total

fi
38 changes: 0 additions & 38 deletions tests/test_debug.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tools/consolidate_00_lib_src.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -euo pipefail

SRC_ROOT="./src"
LIB_ROOT="./lib/armbian-config"
Expand Down
4 changes: 3 additions & 1 deletion tools/consolidate_01_lib_metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ set -euo pipefail

SRC_ROOT="./src"
OUT_FILE="./lib/armbian-config/module_options_arrays.sh"
LIB_ROOT="./lib/armbian-config"
IGNORE_FILES=("readme.sh")


mkdir -p "$LIB_ROOT"
declare -A array_entries
declare -A group_counts # For unique id per group

Expand Down
17 changes: 7 additions & 10 deletions tools/staging_00_setup_scaffold.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ group=\${group:-managers}
contributor=\${contributor:-}
maintainer=\${maintainer:-false}
arch=\${arch:-"arm64 armhf x86-64"}
require_os=\${require_os:-"Debian Ubuntu"}
require_os=\${require_os:-"Armbian Debian Ubuntu"}
require_kernel=\${require_kernel:-5.15+}
port=\${port:-false}
helpers=_about_${MODULE}

EOF

# Output .sh module template inside ./staging
Expand All @@ -59,14 +61,7 @@ _about_${MODULE}() {
echo "help - this message"
}

EOF

# Output .sh module template inside ./staging
cat > "${STAGING_DIR}/test_${MODULE}.sh" <<EOF
#!/bin/bash
set -euo pipefail

# ${MODULE} - Armbian Config V3 test
# ${MODULE} - Armbian Config V3 Test

if [[ "\${BASH_SOURCE[0]}" == "\${0}" ]]; then
echo "${MODULE} - Armbian Config V3 test"
Expand All @@ -77,9 +72,11 @@ fi
EOF

# Output .sh module template inside ./staging
cat > "${STAGING_DIR}/doc_${MODULE}.md" <<EOF
cat > "${STAGING_DIR}/docs_${MODULE}.md" <<EOF
# ${MODULE} - Armbian Config V3 extra documents

## TODO: EXTRA Documents about the feature.

EOF

echo -e "Staging: Complete\nScaffold for ${MODULE} can be found at ${STAGING_DIR}/."
10 changes: 5 additions & 5 deletions tools/staging_01_check_required.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ check_module_files() {
fail=0

# Required files
for req in "test_${module}.sh" "${module}.sh" "${module}.conf"; do
for req in "${module}.sh" "${module}.conf"; do
if [[ -f "${STAGING_DIR}/${req}" ]]; then
echo "PASS: Found required ${req}"
else
Expand All @@ -23,7 +23,7 @@ check_module_files() {
done

# Optional file
opt="doc_${module}.md"
opt="docs_${module}.md"
if [[ -f "${STAGING_DIR}/${opt}" ]]; then
echo "PASS: Found optional ${opt}"
else
Expand All @@ -33,13 +33,13 @@ check_module_files() {
return $fail
}

main() {
check_required() {
[[ -d "$STAGING_DIR" ]] || { echo "No staging directory."; exit 1; }
modules=($(extract_module_names))
overall_fail=0

for mod in "${modules[@]}"; do
echo "== Checking module: $mod =="
echo "== Checking module: ($mod) =="
check_module_files "$mod" || overall_fail=1
echo
done
Expand All @@ -54,5 +54,5 @@ main() {
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main
check_required
fi
35 changes: 22 additions & 13 deletions tools/staging_03_promote_module.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
#!/bin/bash
set -e

# Move test_*.sh scripts from staging to tests/
for test_file in ./staging/test_*.sh; do
[ -f "$test_file" ] || continue
echo "Moving $test_file to ./tests/"
mv "$test_file" ./tests/

DOC_ROOT="./docs"

mkdir -p "$DOC_ROOT"
declare -A array_entries
declare -A group_counts # For unique id per group



# Move docs_*.sh scripts from staging to docs/
for docs_file in ./staging/docs_*.md; do
[ -f "$docs_file" ] || continue
echo "Moving $docs_file to ./docs/"
mv "$docs_file" ./docs/
done

# Move *.sh (not test_*.sh) with a matching .meta file to src/$parent/
# Move *.sh (not docs_*.sh) with a matching .conf file to src/$parent/
for sh_file in ./staging/*.sh; do
[[ "$sh_file" == *test_*.sh ]] && continue
[[ "$sh_file" == *docs_*.sh ]] && continue
[ -f "$sh_file" ] || continue
base_name=$(basename "$sh_file" .sh)
meta_file="./staging/${base_name}.meta"
if [ -f "$meta_file" ]; then
parent=$(awk -F= '/^parent=/{print $2}' "$meta_file" | head -n1)
conf_file="./staging/${base_name}.conf"
if [ -f "$conf_file" ]; then
parent=$(awk -F= '/^parent=/{print $2}' "$conf_file" | head -n1)
if [ -n "$parent" ]; then
dest_dir="./src/$parent"
mkdir -p "$dest_dir"
echo "Moving $sh_file and $meta_file to $dest_dir/"
echo "Moving $sh_file and $conf_file to $dest_dir/"
mv "$sh_file" "$dest_dir/"
mv "$meta_file" "$dest_dir/"
mv "$conf_file" "$dest_dir/"
else
echo "No parent= in $meta_file, skipping $sh_file"
echo "No parent= in $conf_file, skipping $sh_file"
fi
fi
done
Loading