Update download_debian.sh script for Debian 13 (trixie)

cf @bug4451 https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=4451
This commit is contained in:
Julien Da Silva 2026-08-19 10:07:33 +02:00
parent 18816fe9fd
commit 672a9f9b5a
1 changed files with 73 additions and 18 deletions

View File

@ -1,11 +1,14 @@
#!/bin/bash
# Purpose {{{
# This script will download Debian netboot installer for both AMD64 and i368
# 1. Debian oldStable (Bookworm)
# 2. Debian oldStable (Bullseye)
# 3. Debian Unstable (Sid)
# and make a sample menu.cfg config file.
# This script will download Debian netboot installer and make a sample
# menu.cfg config file.
# 1. Debian Stable (Trixie) amd64
# 2. Debian oldStable (Bookworm) amd64, i386
# 3. Debian Unstable (Sid) amd64
#
# Note: i386 is no longer provided as an installation architecture from
# Trixie onwards, so the architecture list is per-suite.
# }}}
# Vars {{{
readonly PROGNAME=$(basename "${0}")
@ -26,6 +29,9 @@ DEBIAN_INSTALLER_DIR="${TFTP_DIRECTORY}/installer/debian"
# tftp sample config file
DEBIAN_CONFIG_PXE="${DEBIAN_INSTALLER_DIR}/menu.cfg.example"
# Debian suites to fetch
DEBIAN_SUITES="trixie bookworm sid"
## Colors
readonly PURPLE='\033[1;35m'
readonly RED='\033[0;31m'
@ -38,13 +44,16 @@ usage() { # {{{
usage: $PROGNAME [-d|-h]
This script will download "all" Debian's netboot installer for
tftp server for both AMD64 and i368 architectures.
tftp server.
EXAMPLES:
Architectures are selected per suite: i386 is no longer provided
as an installation architecture from Trixie onwards.
EXAMPLES :
- Download Debian's installers to default place (${TFTP_DIRECTORY})
${PROGNAME}
OPTIONS:
OPTIONS :
-d,--debug
Enable debug messages.
@ -60,7 +69,7 @@ debug_message() { # {{{
local_message="${1}"
## Print message if DEBUG is enable (=0)
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6b\e[m\n' "DEBUG ${PROGNAME}: ${local_message}"
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6b\e[m\n' "DEBUG ${PROGNAME} : ${local_message}"
return 0
}
@ -71,13 +80,40 @@ error_message() { # {{{
local_error_code="${2}"
## Print message
printf '%b\n' "ERROR ${PROGNAME}: ${RED}${local_error_message}${RESET}"
printf '%b\n' "ERROR ${PROGNAME} : ${RED}${local_error_message}${RESET}"
exit "${local_error_code:=66}"
}
# }}}
get_arch_list() { # {{{
# Return the list of architectures available for a given Debian suite.
# i386 was dropped as an installation architecture starting with Trixie.
local_distro="${1}"
case "${local_distro}" in
trixie|sid|forky )
return_arch_list="amd64"
;;
* )
return_arch_list="amd64 i386"
;;
esac
debug_message "get_arch_list \
Architectures for ${RED}${local_distro}${COLOR_DEBUG} : ${RED}${return_arch_list}${COLOR_DEBUG} ."
## Unset variables
unset local_distro
printf '%s' "${return_arch_list}"
}
# }}}
download_file() { # {{{
# Download a file to a temporary location and move it into place only if
# the transfer succeeded. A failed download therefore never overwrites a
# working file with an empty one.
local_url="${1}"
local_dest_file="${2}"
@ -85,11 +121,24 @@ download_file() { # {{{
debug_message "download_file \
Download ${local_url} to ${RED}${local_dest_file}${COLOR_DEBUG} ."
wget --quiet "${local_url}" --output-document="${local_dest_file}"
local_tmp_file="${local_dest_file}.part"
if wget --quiet "${local_url}" --output-document="${local_tmp_file}"; then
mv -- "${local_tmp_file}" "${local_dest_file}"
return_download_file="0"
else
rm --force -- "${local_tmp_file}"
debug_message "download_file \
Download of ${RED}${local_url}${COLOR_DEBUG} failed."
return_download_file="1"
fi
## Unset variables
unset local_url
unset local_dest_file
unset local_tmp_file
return "${return_download_file}"
}
# }}}
is_file_empty() { # {{{
@ -129,27 +178,33 @@ Create ${DEBIAN_INSTALLER_DIR} tree."
true > "${DEBIAN_CONFIG_PXE}"
# Parse all Debian's distribution
for DISTRO in bookworm bullseye sid; do # For "all" Debian's version
for DISTRO in ${DEBIAN_SUITES}; do # For "all" Debian's version
## Architecture list depends on the suite
ARCH_LIST=$(get_arch_list "${DISTRO}")
## Then parse architecture
for ARCH in amd64 i386; do # For all classic architecture
for ARCH in ${ARCH_LIST}; do
debug_message "Main FOR loop \
Manage ${RED}${DISTRO}${COLOR_DEBUG} release with ${RED}${ARCH}${COLOR_DEBUG} architecture."
### Create destination directory
mkdir --parents -- ${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH} \
mkdir --parents -- "${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}" \
|| error_message "Can't create ${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH} tree." "1"
### Download linux file
download_file "http://deb.debian.org/debian/dists/${DISTRO}/main/installer-${ARCH}/current/images/netboot/debian-installer/${ARCH}/linux" \
"${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}/linux"
"${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}/linux" \
|| error_message "Can't download linux for ${DISTRO}/${ARCH} !" "2"
is_file_empty "${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}/linux" \
&& error_message "${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}/linux is empty !" "2"
&& error_message "${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}/linux is empty !" "2"
### Download initrd.gz
download_file "http://deb.debian.org/debian/dists/${DISTRO}/main/installer-${ARCH}/current/images/netboot/debian-installer/${ARCH}/initrd.gz" \
"${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}/initrd.gz"
"${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}/initrd.gz" \
|| error_message "Can't download initrd.gz for ${DISTRO}/${ARCH} !" "2"
is_file_empty "${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}/initrd.gz" \
&& error_message "${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}/initrd.gz is empty !" "2"
&& error_message "${DEBIAN_INSTALLER_DIR}/${DISTRO}/${ARCH}/initrd.gz is empty !" "2"
### Config file
debug_message "Main FOR loop \