rwx/sh/debian.sh
2024-11-20 09:27:41 +01:00

76 lines
1.6 KiB
Bash

SH_DEBIAN_CODENAME="$(
grep "VERSION_CODENAME" "/etc/os-release" |
cut --delimiter "=" --fields "2"
)"
sh_apt_clean() {
apt-get \
clean
}
sh_apt_conf_write() {
printf "\
Acquire::AllowInsecureRepositories False;
Acquire::AllowWeakRepositories False;
Acquire::AllowDowngradeToInsecureRepositories False;
Acquire::Check-Valid-Until True;
APT::Install-Recommends False;
APT::Install-Suggests False;
APT::Get::Show-Versions True;
Dir::Etc::SourceParts \"\";
Dpkg::Progress True;
" >"/etc/apt/apt.conf.d/apt.conf"
}
sh_apt_install_backports() {
sh_apt_install_target "${SH_DEBIAN_CODENAME}-backports" "${@}"
}
sh_apt_install_release() {
sh_apt_install_target "${SH_DEBIAN_CODENAME}" "${@}"
}
sh_apt_install_target() {
local target="${1}"
shift
local package
for package in "${@}"; do
sh_log_info
sh_log_info "${package}${target}"
apt-get \
install \
--assume-yes \
--target-release "${target}" \
"${package}"
sh_apt_clean
done
}
sh_apt_sources_write() {
printf "%s" "\
deb https://deb.debian.org/debian \
${SH_DEBIAN_CODENAME} main non-free-firmware contrib non-free
deb https://deb.debian.org/debian \
${SH_DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free
deb https://deb.debian.org/debian \
${SH_DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free
deb https://deb.debian.org/debian-security \
${SH_DEBIAN_CODENAME}-security main non-free-firmware contrib non-free
" >"/etc/apt/sources.list"
}
sh_apt_update() {
apt-get \
update
}
sh_apt_upgrade() {
apt-get \
upgrade \
--assume-yes
sh_apt_clean
}
sh_debian_frontend_disable() {
export DEBIAN_FRONTEND="noninteractive"
}