V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m54s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m54s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -15,10 +15,9 @@ guard_sourcing
|
||||
#######################################
|
||||
# Generate target '/etc/apt/sources.list' entries.
|
||||
# Globals:
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_ARCHITECTURE
|
||||
# VAR_CODENAME
|
||||
# VAR_VERSION
|
||||
# VAR_RUN_RECOVERY
|
||||
# apt_contrib
|
||||
# apt_deb_sources
|
||||
# apt_mirror_directory
|
||||
@@ -39,8 +38,12 @@ guard_sourcing
|
||||
#######################################
|
||||
generate_sources() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -a ary_components=()
|
||||
declare var_arch="" var_codename="" var_deb_src="" var_dir="" var_hostname="" var_hostsecure="" var_url="" var_surl=""
|
||||
declare -a ary_components=()
|
||||
declare var_arch="" var_codename="" var_deb_src="" var_dir="" var_hostname="" var_hostsecure="" var_url="" var_surl=""
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
# shellcheck disable=SC2154 # "${architecture}"
|
||||
var_arch="${architecture,,}"
|
||||
@@ -77,25 +80,25 @@ generate_sources() {
|
||||
|
||||
fi
|
||||
|
||||
: >| "${TARGET}/etc/apt/sources.list"
|
||||
chmod 0644 "${TARGET}/etc/apt/sources.list"
|
||||
: >| "${var_target}/etc/apt/sources.list"
|
||||
chmod 0644 "${var_target}/etc/apt/sources.list"
|
||||
|
||||
### Main Repository
|
||||
# shellcheck disable=SC2153
|
||||
insert_header "${TARGET}/etc/apt/sources.list"
|
||||
insert_comments "${TARGET}/etc/apt/sources.list"
|
||||
cat << EOF >> "${TARGET}/etc/apt/sources.list"
|
||||
insert_header "${var_target}/etc/apt/sources.list"
|
||||
insert_comments "${var_target}/etc/apt/sources.list"
|
||||
cat << EOF >> "${var_target}/etc/apt/sources.list"
|
||||
#------------------------------------------------------------------------------------------------------------------------------#
|
||||
# OFFICIAL DEBIAN REPOS #
|
||||
#------------------------------------------------------------------------------------------------------------------------------#
|
||||
deb ${var_url} ${var_codename} ${ary_components[*]}
|
||||
EOF
|
||||
do_log "info" "file_only" "4100() ${TARGET}/etc/apt/sources.list entry generated: 'deb ${var_url} ${var_codename} ${ary_components[*]}'."
|
||||
do_log "info" "file_only" "4100() ${var_target}/etc/apt/sources.list entry generated: 'deb ${var_url} ${var_codename} ${ary_components[*]}'."
|
||||
|
||||
if [[ "${var_deb_src}" == "true" ]]; then
|
||||
|
||||
echo "deb-src ${var_url} ${var_codename} ${ary_components[*]}" >> "${TARGET}/etc/apt/sources.list"
|
||||
do_log "info" "file_only" "4100() ${TARGET}/etc/apt/sources.list entry generated: 'deb-src ${var_url} ${var_codename} ${ary_components[*]}'."
|
||||
echo "deb-src ${var_url} ${var_codename} ${ary_components[*]}" >> "${var_target}/etc/apt/sources.list"
|
||||
do_log "info" "file_only" "4100() ${var_target}/etc/apt/sources.list entry generated: 'deb-src ${var_url} ${var_codename} ${ary_components[*]}'."
|
||||
|
||||
fi
|
||||
|
||||
@@ -103,16 +106,16 @@ EOF
|
||||
### Security Repository
|
||||
if [[ "${apt_updates_security,,}" == "true" ]]; then
|
||||
|
||||
cat << EOF >> "${TARGET}/etc/apt/sources.list"
|
||||
cat << EOF >> "${var_target}/etc/apt/sources.list"
|
||||
|
||||
deb ${var_surl} ${var_codename}-security ${ary_components[*]}
|
||||
EOF
|
||||
do_log "info" "file_only" "4100() ${TARGET}/etc/apt/sources.list entry generated: 'deb ${var_surl} ${var_codename}-security ${ary_components[*]}'."
|
||||
do_log "info" "file_only" "4100() ${var_target}/etc/apt/sources.list entry generated: 'deb ${var_surl} ${var_codename}-security ${ary_components[*]}'."
|
||||
|
||||
if [[ "${var_deb_src}" == "true" ]]; then
|
||||
|
||||
echo "deb-src ${var_surl} ${var_codename}-security ${ary_components[*]}" >> "${TARGET}/etc/apt/sources.list"
|
||||
do_log "info" "file_only" "4100() ${TARGET}/etc/apt/sources.list entry generated: 'deb-src ${var_surl} ${var_codename}-security ${ary_components[*]}'."
|
||||
echo "deb-src ${var_surl} ${var_codename}-security ${ary_components[*]}" >> "${var_target}/etc/apt/sources.list"
|
||||
do_log "info" "file_only" "4100() ${var_target}/etc/apt/sources.list entry generated: 'deb-src ${var_surl} ${var_codename}-security ${ary_components[*]}'."
|
||||
|
||||
fi
|
||||
|
||||
@@ -122,16 +125,16 @@ EOF
|
||||
### Updates Repository
|
||||
if [[ "${apt_updates_release,,}" == "true" ]]; then
|
||||
|
||||
cat << EOF >> "${TARGET}/etc/apt/sources.list"
|
||||
cat << EOF >> "${var_target}/etc/apt/sources.list"
|
||||
|
||||
deb ${var_url} ${var_codename}-updates ${ary_components[*]}
|
||||
EOF
|
||||
do_log "info" "file_only" "4100() ${TARGET}/etc/apt/sources.list entry generated: 'deb ${var_url} ${var_codename}-updates ${ary_components[*]}'."
|
||||
do_log "info" "file_only" "4100() ${var_target}/etc/apt/sources.list entry generated: 'deb ${var_url} ${var_codename}-updates ${ary_components[*]}'."
|
||||
|
||||
if [[ "${var_deb_src}" == "true" ]]; then
|
||||
|
||||
echo "deb-src ${var_url} ${var_codename}-updates ${ary_components[*]}" >> "${TARGET}/etc/apt/sources.list"
|
||||
do_log "info" "file_only" "4100() ${TARGET}/etc/apt/sources.list entry generated: 'deb-src ${var_url} ${var_codename}-updates ${ary_components[*]}'."
|
||||
echo "deb-src ${var_url} ${var_codename}-updates ${ary_components[*]}" >> "${var_target}/etc/apt/sources.list"
|
||||
do_log "info" "file_only" "4100() ${var_target}/etc/apt/sources.list entry generated: 'deb-src ${var_url} ${var_codename}-updates ${ary_components[*]}'."
|
||||
|
||||
fi
|
||||
|
||||
@@ -141,16 +144,16 @@ EOF
|
||||
### Backports Repository
|
||||
if [[ "${apt_updates_backports,,}" == "true" ]]; then
|
||||
|
||||
cat << EOF >> "${TARGET}/etc/apt/sources.list"
|
||||
cat << EOF >> "${var_target}/etc/apt/sources.list"
|
||||
|
||||
deb ${var_url} ${var_codename}-backports ${ary_components[*]}
|
||||
EOF
|
||||
do_log "info" "file_only" "4100() ${TARGET}/etc/apt/sources.list entry generated: 'deb ${var_url} ${var_codename}-backports ${ary_components[*]}'."
|
||||
do_log "info" "file_only" "4100() ${var_target}/etc/apt/sources.list entry generated: 'deb ${var_url} ${var_codename}-backports ${ary_components[*]}'."
|
||||
|
||||
if [[ "${var_deb_src,,}" == "true" ]]; then
|
||||
|
||||
echo "deb-src ${var_url} ${var_codename}-backports ${ary_components[*]}" >> "${TARGET}/etc/apt/sources.list"
|
||||
do_log "info" "file_only" "4100() ${TARGET}/etc/apt/sources.list entry generated: 'deb-src ${var_url} ${var_codename}-backports ${ary_components[*]}'."
|
||||
echo "deb-src ${var_url} ${var_codename}-backports ${ary_components[*]}" >> "${var_target}/etc/apt/sources.list"
|
||||
do_log "info" "file_only" "4100() ${var_target}/etc/apt/sources.list entry generated: 'deb-src ${var_url} ${var_codename}-backports ${ary_components[*]}'."
|
||||
|
||||
fi
|
||||
|
||||
@@ -158,32 +161,35 @@ EOF
|
||||
|
||||
|
||||
### Clean up 'sources.list'
|
||||
sed -i '/^#/!s/[[:space:]]\+/ /g' "${TARGET}/etc/apt/sources.list"
|
||||
sed -i '/^#/!s/[[:space:]]\+/ /g' "${var_target}/etc/apt/sources.list"
|
||||
|
||||
cat << EOF >> "${TARGET}/etc/apt/sources.list"
|
||||
cat << EOF >> "${var_target}/etc/apt/sources.list"
|
||||
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf
|
||||
EOF
|
||||
|
||||
|
||||
insert_header "${TARGET}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
insert_comments "${TARGET}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
cat << 'EOF' >> "${TARGET}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
insert_header "${var_target}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
insert_comments "${var_target}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
cat << 'EOF' >> "${var_target}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
Acquire::PDiffs "false";
|
||||
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf
|
||||
EOF
|
||||
sed -i -E 's|^([[:space:]]*)#+|\1//|' "${TARGET}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
sed -i -E 's|^([[:space:]]*)#+|\1//|' "${var_target}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
|
||||
insert_header "${TARGET}/etc/apt/apt.conf.d/91-acquire"
|
||||
insert_comments "${TARGET}/etc/apt/apt.conf.d/91-acquire"
|
||||
cat << 'EOF' >> "${TARGET}/etc/apt/apt.conf.d/91-acquire"
|
||||
insert_header "${var_target}/etc/apt/apt.conf.d/91-acquire"
|
||||
insert_comments "${var_target}/etc/apt/apt.conf.d/91-acquire"
|
||||
cat << 'EOF' >> "${var_target}/etc/apt/apt.conf.d/91-acquire"
|
||||
Acquire::Retries "3";
|
||||
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf
|
||||
EOF
|
||||
sed -i -E 's|^([[:space:]]*)#+|\1//|' "${TARGET}/etc/apt/apt.conf.d/91-acquire"
|
||||
sed -i -E 's|^([[:space:]]*)#+|\1//|' "${var_target}/etc/apt/apt.conf.d/91-acquire"
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f generate_sources
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
@@ -36,8 +36,12 @@ guard_sourcing
|
||||
#######################################
|
||||
generate_sources822() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -a ary_components=() ary_types=()
|
||||
declare var_arch="" var_codename="" var_deb_src="" var_dir="" var_hostname="" var_hostsecure="" var_url="" var_surl=""
|
||||
declare -a ary_components=() ary_types=()
|
||||
declare var_arch="" var_codename="" var_deb_src="" var_dir="" var_hostname="" var_hostsecure="" var_url="" var_surl=""
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
# shellcheck disable=SC2154 # "${architecture}"
|
||||
var_arch="${architecture,,}"
|
||||
@@ -79,9 +83,9 @@ generate_sources822() {
|
||||
|
||||
|
||||
### Main Repository
|
||||
insert_header "${TARGET}/etc/apt/sources.list.d/trixie.sources"
|
||||
insert_comments "${TARGET}/etc/apt/sources.list.d/trixie.sources"
|
||||
cat << EOF >> "${TARGET}/etc/apt/sources.list.d/trixie.sources"
|
||||
insert_header "${var_target}/etc/apt/sources.list.d/trixie.sources"
|
||||
insert_comments "${var_target}/etc/apt/sources.list.d/trixie.sources"
|
||||
cat << EOF >> "${var_target}/etc/apt/sources.list.d/trixie.sources"
|
||||
#------------------------------------------------------------------------------------------------------------------------------#
|
||||
# OFFICIAL DEBIAN REPOS #
|
||||
#------------------------------------------------------------------------------------------------------------------------------#
|
||||
@@ -98,9 +102,9 @@ EOF
|
||||
|
||||
### Security Repository
|
||||
if [[ "${apt_updates_security,,}" == "true" ]]; then
|
||||
insert_header "${TARGET}/etc/apt/sources.list.d/trixie-security.sources"
|
||||
insert_comments "${TARGET}/etc/apt/sources.list.d/trixie-security.sources"
|
||||
cat << EOF >> "${TARGET}/etc/apt/sources.list.d/trixie-security.sources"
|
||||
insert_header "${var_target}/etc/apt/sources.list.d/trixie-security.sources"
|
||||
insert_comments "${var_target}/etc/apt/sources.list.d/trixie-security.sources"
|
||||
cat << EOF >> "${var_target}/etc/apt/sources.list.d/trixie-security.sources"
|
||||
#------------------------------------------------------------------------------------------------------------------------------#
|
||||
# OFFICIAL DEBIAN REPOS #
|
||||
#------------------------------------------------------------------------------------------------------------------------------#
|
||||
@@ -117,9 +121,9 @@ EOF
|
||||
|
||||
### Updates Repository
|
||||
if [[ "${apt_updates_release,,}" == "true" ]]; then
|
||||
insert_header "${TARGET}/etc/apt/sources.list.d/trixie-updates.sources"
|
||||
insert_comments "${TARGET}/etc/apt/sources.list.d/trixie-updates.sources"
|
||||
cat << EOF >> "${TARGET}/etc/apt/sources.list.d/trixie-updates.sources"
|
||||
insert_header "${var_target}/etc/apt/sources.list.d/trixie-updates.sources"
|
||||
insert_comments "${var_target}/etc/apt/sources.list.d/trixie-updates.sources"
|
||||
cat << EOF >> "${var_target}/etc/apt/sources.list.d/trixie-updates.sources"
|
||||
#------------------------------------------------------------------------------------------------------------------------------#
|
||||
# OFFICIAL DEBIAN REPOS #
|
||||
#------------------------------------------------------------------------------------------------------------------------------#
|
||||
@@ -137,9 +141,9 @@ EOF
|
||||
|
||||
### Backports Repository
|
||||
if [[ "${apt_updates_backports,,}" == "true" ]]; then
|
||||
insert_header "${TARGET}/etc/apt/sources.list.d/trixie-backports.sources"
|
||||
insert_comments "${TARGET}/etc/apt/sources.list.d/trixie-backports.sources"
|
||||
cat << EOF >> "${TARGET}/etc/apt/sources.list.d/trixie-backports.sources"
|
||||
insert_header "${var_target}/etc/apt/sources.list.d/trixie-backports.sources"
|
||||
insert_comments "${var_target}/etc/apt/sources.list.d/trixie-backports.sources"
|
||||
cat << EOF >> "${var_target}/etc/apt/sources.list.d/trixie-backports.sources"
|
||||
#------------------------------------------------------------------------------------------------------------------------------#
|
||||
# OFFICIAL DEBIAN REPOS #
|
||||
#------------------------------------------------------------------------------------------------------------------------------#
|
||||
@@ -156,30 +160,33 @@ EOF
|
||||
fi
|
||||
|
||||
|
||||
if [[ -f "${TARGET}/etc/apt/sources.list" ]]; then
|
||||
rm -f "${TARGET}/etc/apt/sources.list"
|
||||
if [[ -f "${var_target}/etc/apt/sources.list" ]]; then
|
||||
rm -f "${var_target}/etc/apt/sources.list"
|
||||
fi
|
||||
|
||||
|
||||
insert_header "${TARGET}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
insert_comments "${TARGET}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
cat << 'EOF' >> "${TARGET}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
insert_header "${var_target}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
insert_comments "${var_target}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
cat << 'EOF' >> "${var_target}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
Acquire::PDiffs "false";
|
||||
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf
|
||||
EOF
|
||||
sed -i -E 's|^([[:space:]]*)#+|\1//|' "${TARGET}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
sed -i -E 's|^([[:space:]]*)#+|\1//|' "${var_target}/etc/apt/apt.conf.d/90-no-pdiffs"
|
||||
|
||||
|
||||
insert_header "${TARGET}/etc/apt/apt.conf.d/91-acquire"
|
||||
insert_comments "${TARGET}/etc/apt/apt.conf.d/91-acquire"
|
||||
cat << 'EOF' >> "${TARGET}/etc/apt/apt.conf.d/91-acquire"
|
||||
insert_header "${var_target}/etc/apt/apt.conf.d/91-acquire"
|
||||
insert_comments "${var_target}/etc/apt/apt.conf.d/91-acquire"
|
||||
cat << 'EOF' >> "${var_target}/etc/apt/apt.conf.d/91-acquire"
|
||||
Acquire::Retries "3";
|
||||
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf
|
||||
EOF
|
||||
sed -i -E 's|^([[:space:]]*)#+|\1//|' "${TARGET}/etc/apt/apt.conf.d/91-acquire"
|
||||
sed -i -E 's|^([[:space:]]*)#+|\1//|' "${var_target}/etc/apt/apt.conf.d/91-acquire"
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f generate_sources822
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
@@ -18,7 +18,9 @@ guard_sourcing
|
||||
# to suppress the 'update-initramfs'-Kernel-Hooks, according to the initramfs-tools manpage:
|
||||
# https://manpages.debian.org/testing/initramfs-tools-core/initramfs-tools.7.en.html
|
||||
# Globals:
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_RUN_RECOVERY
|
||||
# apt_updates_policy
|
||||
# Arguments:
|
||||
# None
|
||||
@@ -28,19 +30,23 @@ guard_sourcing
|
||||
update_sources() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -r var_logfile="/root/.ciss/cdi/log/4110_update_sources.log"
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
chroot_logger "${TARGET}${var_logfile}"
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
chroot_logger "${var_target}${var_logfile}"
|
||||
|
||||
### Update generated sources.
|
||||
# shellcheck disable=SC2312
|
||||
chroot_script "${TARGET}" "apt-get update 2>&1 | tee -a ${var_logfile}; echo ExitCode: \$? >> ${var_logfile}"
|
||||
chroot_script "${var_target}" "apt-get update 2>&1 | tee -a ${var_logfile}; echo ExitCode: \$? >> ${var_logfile}"
|
||||
do_log "info" "file_only" "4110() Sources lists: updated successfully."
|
||||
|
||||
|
||||
### Update unattended, security, or no unattended updates at all.
|
||||
if [[ "${apt_updates_policy,,}" == "unattended" ]]; then
|
||||
|
||||
chroot_script "${TARGET}" "
|
||||
chroot_script "${var_target}" "
|
||||
export INITRD=No
|
||||
apt-get install -y --no-install-recommends --no-install-suggests unattended-upgrades 2>&1 | tee -a ${var_logfile}
|
||||
echo ExitCode: \$? >> ${var_logfile}
|
||||
@@ -49,14 +55,14 @@ update_sources() {
|
||||
|
||||
elif [[ "${apt_updates_policy,,}" == "security" ]]; then
|
||||
|
||||
chroot_script "${TARGET}" "
|
||||
chroot_script "${var_target}" "
|
||||
export INITRD=No
|
||||
apt-get install -y --no-install-recommends --no-install-suggests unattended-upgrades 2>&1 | tee -a ${var_logfile}
|
||||
echo ExitCode: \$? >> ${var_logfile}
|
||||
"
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
sed -i 's/^[[:space:]]*"origin=Debian,codename=\${distro_codename},label=Debian";/\/\/ &/' "${TARGET}/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
sed -i 's/^[[:space:]]*"origin=Debian,codename=\${distro_codename},label=Debian";/\/\/ &/' "${var_target}/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
do_log "info" "file_only" "4110() The update policy was set at installation time to: '${apt_updates_policy}'."
|
||||
|
||||
elif [[ "${apt_updates_policy,,}" == "none" ]]; then
|
||||
@@ -71,4 +77,7 @@ update_sources() {
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f update_sources
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
Reference in New Issue
Block a user