Update Template for Debian with fixes and improvements

This commit is contained in:
2026-04-17 07:31:56 +02:00
parent 005213ac7f
commit 3b14aa7c2b
6 changed files with 81 additions and 12 deletions

View File

@@ -26,9 +26,10 @@ die() { echo "ERROR: $*" >&2; exit 1; }
usage() {
cat <<EOF
Usage: $(basename "$0") [OPTIONS]
Usage: $(basename "$0") [OPTIONS] [BD-NUMBER...]
Build all Debian amd64 BD ISOs from jigdo files without using jigdo-lite.
Build Debian amd64 BD ISOs from jigdo files without using jigdo-lite.
If no BD numbers are given, all available BDs are built.
Options:
-o DIR Output directory (default: ./debian-isos, or \$OUTPUT_DIR)
@@ -36,14 +37,18 @@ Options:
-s DIR Scan DIR for locally cached .deb packages to reuse
-h Show this help
Arguments:
BD-NUMBER One or more disc numbers to build (1-6). Multiple allowed.
Environment:
FETCH_BATCH_SIZE Number of package URLs fetched per batch (default: 30)
Examples:
$(basename "$0")
$(basename "$0") -o /data/isos
$(basename "$0") -s /var/cache/apt/archives
$(basename "$0") -m http://ftp.de.debian.org/debian
$(basename "$0") # build all BDs
$(basename "$0") 1 # build BD-1 only
$(basename "$0") 1 2 3 # build BD-1, BD-2, BD-3
$(basename "$0") -o /data/isos 1 2
$(basename "$0") -s /var/cache/apt/archives 1
EOF
}
@@ -281,12 +286,15 @@ build_image() {
}
main() {
local -a selected_nums=()
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help) usage; exit 0 ;;
-o|--output) OUTPUT_DIR="$2"; shift 2 ;;
-m|--mirror) MIRROR="$2"; shift 2 ;;
-s|--scan) SCAN_DIR="$2"; shift 2 ;;
[1-6]) selected_nums+=("$1"); shift ;;
*) die "Unknown option: $1" ;;
esac
done
@@ -295,9 +303,9 @@ main() {
mkdir -p "$OUTPUT_DIR"
[[ -n "$SCAN_DIR" && ! -d "$SCAN_DIR" ]] && die "Scan directory not found: $SCAN_DIR"
local -a images=()
local -a all_images=()
while IFS= read -r name; do
images+=("${name%.jigdo}")
all_images+=("${name%.jigdo}")
done < <(
wget -qO- "${JIGDO_URL}/" \
| grep -oP 'href="debian-[^"]+BD-[0-9]+\.jigdo"' \
@@ -306,7 +314,19 @@ main() {
| sort -uV
)
(( ${#images[@]} > 0 )) || die "No BD jigdo files found at $JIGDO_URL"
(( ${#all_images[@]} > 0 )) || die "No BD jigdo files found at $JIGDO_URL"
local -a images=()
if (( ${#selected_nums[@]} == 0 )); then
images=("${all_images[@]}")
else
for n in "${selected_nums[@]}"; do
local match
match=$(printf '%s\n' "${all_images[@]}" | grep -i "BD-${n}\b" | head -1)
[[ -n "$match" ]] || die "BD-${n} not found in jigdo index"
images+=("$match")
done
fi
echo "Mirror: $(normalize_mirror "$MIRROR")"
echo "Output: $OUTPUT_DIR"