186 lines
7.1 KiB
Bash
186 lines
7.1 KiB
Bash
#!/bin/bash
|
|
# SPDX-Version: 3.0
|
|
# SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; <msw@coresecret.dev>
|
|
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git
|
|
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
|
|
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <msw@coresecret.dev>
|
|
# SPDX-FileType: SOURCE
|
|
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
|
|
# SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework.
|
|
# SPDX-PackageName: CISS.debian.installer
|
|
# SPDX-Security-Contact: security@coresecret.eu
|
|
|
|
guard_sourcing
|
|
|
|
#######################################
|
|
# Generate target '/etc/apt/sources.list.d/' deb.822 entries.
|
|
# Globals:
|
|
# TARGET
|
|
# apt_contrib
|
|
# apt_deb_sources
|
|
# apt_mirror_directory
|
|
# apt_mirror_hostname
|
|
# apt_mirror_protocol
|
|
# apt_non_free
|
|
# apt_non_free_firmware
|
|
# apt_sec
|
|
# apt_updates_backports
|
|
# apt_updates_release
|
|
# apt_updates_security
|
|
# architecture
|
|
# distribution
|
|
# Arguments:
|
|
# None
|
|
# Returns:
|
|
# 0: on success
|
|
#######################################
|
|
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=""
|
|
|
|
# shellcheck disable=SC2154 # "${architecture}"
|
|
var_arch="${architecture,,}"
|
|
# shellcheck disable=SC2154 # "${distribution}"
|
|
var_codename="${distribution,,}"
|
|
# shellcheck disable=SC2154 # "${apt_deb_sources}"
|
|
var_deb_src="${apt_deb_sources,,}"
|
|
# shellcheck disable=SC2154 # "${apt_mirror_directory}"
|
|
var_dir="${apt_mirror_directory,,}"
|
|
# shellcheck disable=SC2154 # "${apt_mirror_hostname}"
|
|
var_hostname="${apt_mirror_hostname,,}"
|
|
# shellcheck disable=SC2154 # "${apt_sec}"
|
|
var_hostsecure="${apt_sec,,}"
|
|
|
|
ary_components=( "main" )
|
|
[[ "${apt_contrib,,}" == "true" ]] && ary_components+=( "contrib" )
|
|
[[ "${apt_non_free,,}" == "true" ]] && ary_components+=( "non-free" )
|
|
[[ "${apt_non_free_firmware,,}" == "true" ]] && ary_components+=( "non-free-firmware" )
|
|
|
|
ary_types=( "deb" )
|
|
[[ "${apt_deb_sources,,}" == "true" ]] && ary_types+=( "deb-src" )
|
|
|
|
if [[ "${apt_mirror_protocol,,}" == "https" ]]; then
|
|
|
|
var_url="https://${var_hostname}${var_dir}"
|
|
var_surl="https://${var_hostsecure}/debian-security"
|
|
|
|
elif [[ "${apt_mirror_protocol,,}" == "http" ]]; then
|
|
|
|
var_url="http://${var_hostname}${var_dir}"
|
|
var_surl="http://${var_hostsecure}/debian-security"
|
|
|
|
else
|
|
|
|
var_url="https://${var_hostname}${var_dir}"
|
|
var_surl="https://${var_hostsecure}/debian-security"
|
|
|
|
fi
|
|
|
|
|
|
### 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"
|
|
#------------------------------------------------------------------------------------------------------------------------------#
|
|
# OFFICIAL DEBIAN REPOS #
|
|
#------------------------------------------------------------------------------------------------------------------------------#
|
|
Types: ${ary_types[*]}
|
|
URIs: ${var_url}
|
|
Suites: ${var_codename}
|
|
Components: ${ary_components[*]}
|
|
Enabled: yes
|
|
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
|
|
|
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf
|
|
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"
|
|
#------------------------------------------------------------------------------------------------------------------------------#
|
|
# OFFICIAL DEBIAN REPOS #
|
|
#------------------------------------------------------------------------------------------------------------------------------#
|
|
Types: ${ary_types[*]}
|
|
URIs: ${var_surl}
|
|
Suites: ${var_codename}-security
|
|
Components: ${ary_components[*]}
|
|
Enabled: yes
|
|
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
|
|
|
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf
|
|
EOF
|
|
fi
|
|
|
|
### 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"
|
|
#------------------------------------------------------------------------------------------------------------------------------#
|
|
# OFFICIAL DEBIAN REPOS #
|
|
#------------------------------------------------------------------------------------------------------------------------------#
|
|
Types: ${ary_types[*]}
|
|
URIs: ${var_url}
|
|
Suites: ${var_codename}-updates
|
|
Components: ${ary_components[*]}
|
|
Enabled: yes
|
|
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
|
|
|
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf
|
|
EOF
|
|
fi
|
|
|
|
|
|
### 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"
|
|
#------------------------------------------------------------------------------------------------------------------------------#
|
|
# OFFICIAL DEBIAN REPOS #
|
|
#------------------------------------------------------------------------------------------------------------------------------#
|
|
Types: ${ary_types[*]}
|
|
URIs: ${var_url}
|
|
Suites: ${var_codename}-backports
|
|
Components: ${ary_components[*]}
|
|
Enabled: yes
|
|
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
|
|
|
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
if [[ -f "${TARGET}/etc/apt/sources.list" ]]; then
|
|
rm -f "${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"
|
|
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"
|
|
|
|
|
|
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"
|
|
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"
|
|
|
|
guard_dir && return 0
|
|
}
|
|
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|