#!/bin/bash { # DietPi-Update pre-patches that need to run before new scripts are downloaded and/or before APT upgrades # Created by MichaIng / micha@dietpi.com / https://dietpi.com/ # License: GPLv2 / https://github.com/MichaIng/DietPi#license # Load DietPi-Globals . /boot/dietpi/func/dietpi-globals readonly G_PROGRAM_NAME='DietPi-Pre-patches' G_CHECK_ROOT_USER "$@" G_CHECK_ROOTFS_RW G_INIT # Use DietPi version from inputs to reapply pre-patches on updater internal subversion decrease [[ $1 ]] && G_DIETPI_VERSION_CORE=$1 [[ $2 ]] && G_DIETPI_VERSION_SUB=$2 # IMPORTANT: This script can be called with DietPi v6.17, hence assure compatibility! # - Pre-v6.29: Create G_EXEC as G_RUN_CMD wrapper declare -F G_EXEC > /dev/null || G_EXEC(){ G_RUN_CMD "$@"; } # v7.0 if (( $G_DIETPI_VERSION_CORE < 7 || ( $G_DIETPI_VERSION_CORE == 7 && $G_DIETPI_VERSION_SUB < 0 ) )) && [[ -f '/etc/apt/trusted.gpg.d/dietpi-jellyfin.gpg' ]] && (( $(date -u '+%Y%m%d' -r '/etc/apt/trusted.gpg.d/dietpi-jellyfin.gpg') < 20201216 )) then G_DIETPI-NOTIFY 2 'Updating Jellyfin APT repo key' G_EXEC curl -sSfLO 'https://repo.jellyfin.org/jellyfin_team.gpg.key' G_EXEC gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-jellyfin.gpg --yes jellyfin_team.gpg.key G_EXEC rm jellyfin_team.gpg.key fi # v7.4 if (( $G_DIETPI_VERSION_CORE < 7 || ( $G_DIETPI_VERSION_CORE == 7 && $G_DIETPI_VERSION_SUB < 4 ) )) && getent passwd debian-transmission > /dev/null && ! getent group debian-transmission > /dev/null then G_DIETPI-NOTIFY 2 'Recreating the "debian-transmission" group for the "debian-transmission" user to prevent Transmission package upgrade issues: https://github.com/MichaIng/DietPi/issues/4244' G_EXEC groupadd -r debian-transmission G_EXEC usermod -aG debian-transmission debian-transmission fi # v7.7 if (( $G_DIETPI_VERSION_CORE < 7 || ( $G_DIETPI_VERSION_CORE == 7 && $G_DIETPI_VERSION_SUB < 7 ) )) then if [[ $G_HW_ARCH == 10 && $(findmnt -Ufnro FSTYPE -M /boot) == 'vfat' ]] then G_DIETPI-NOTIFY 2 'Creating kernel upgrade hook to remove existing files from /boot FAT partition before installing the new files: https://github.com/MichaIng/DietPi/issues/4788' G_EXEC mkdir -p /etc/kernel/preinst.d cat << '_EOF_' > /etc/kernel/preinst.d/dietpi #!/bin/sh -e # Remove old kernel files if existing: https://github.com/MichaIng/DietPi/issues/4788 { # Fail if the package name was not passed, which is done when being invoked by dpkg if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ] then echo 'DPKG_MAINTSCRIPT_PACKAGE was not set, this script must be invoked by dpkg.' exit 1 fi # Loop through files in /boot, shipped by the package, and remove them, if existing for file in $(dpkg -L "$DPKG_MAINTSCRIPT_PACKAGE" | grep '^/boot/') do [ ! -f "$file" ] || rm "$file" done } _EOF_ G_EXEC chmod +x /etc/kernel/preinst.d/dietpi fi G_DIETPI-NOTIFY 2 'Connecting to Mosquitto and Webmin repositories via plain HTTP once until latest OpenSSL has been installed: https://github.com/MichaIng/DietPi/issues/4795' G_EXEC sed --follow-symlinks -Ei 's#https://(repo.mosquitto.org|download.webmin.com)#http://\1#' /etc/apt/sources.list [[ $(find /etc/apt/sources.list/*.list 2> /dev/null) ]] && G_EXEC sed --follow-symlinks -Ei 's#https://(repo.mosquitto.org|download.webmin.com)#http://\1#' /etc/apt/sources.list.d/*.list # Add execute permissions to kernel/initramfs hooks [[ -f '/etc/initramfs/post-update.d/99-dietpi-uboot' && ! -x '/etc/initramfs/post-update.d/99-dietpi-uboot' ]] && G_EXEC chmod +x /etc/initramfs/post-update.d/99-dietpi-uboot [[ -f '/etc/kernel/preinst.d/dietpi-initramfs_cleanup' && ! -x '/etc/kernel/preinst.d/dietpi-initramfs_cleanup' ]] && G_EXEC chmod +x /etc/kernel/preinst.d/dietpi-initramfs_cleanup fi # v8.0: ARMv6: Remove Mosquitto repository: https://github.com/MichaIng/DietPi/issues/5140 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 0 ) )) && [[ $G_HW_ARCH == 1 && -f '/etc/apt/sources.list.d/dietpi-mosquitto.list' ]] then G_DIETPI-NOTIFY 2 'Removing Mosquitto APT repository as the latest builds are not compatible with ARMv6: https://github.com/MichaIng/DietPi/issues/5140' G_EXEC rm /etc/apt/sources.list.d/dietpi-mosquitto.list [[ -f '/etc/apt/trusted.gpg.d/dietpi-mosquitto.gpg' ]] && G_EXEC rm /etc/apt/trusted.gpg.d/dietpi-mosquitto.gpg fi # v8.2: Remove immutable flag from MS VSCode repo and key, when present, else the "raspberrypi-sys-mods" package and our own patch cannot remove them: https://github.com/MichaIng/DietPi/issues/5267 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 2 ) )) then if (( $G_HW_MODEL < 10 )) then [[ -f '/etc/apt/trusted.gpg.d/microsoft.gpg' && $(lsattr /etc/apt/trusted.gpg.d/microsoft.gpg 2> /dev/null) == *'i'* ]] && G_EXEC chattr -i /etc/apt/trusted.gpg.d/microsoft.gpg [[ -f '/etc/apt/sources.list.d/vscode.list' && $(lsattr /etc/apt/sources.list.d/vscode.list 2> /dev/null) == *'i'* ]] && G_EXEC chattr -i /etc/apt/sources.list.d/vscode.list fi # https://github.com/MichaIng/DietPi/commit/c52e812 # shellcheck disable=SC2016 if grep -q 'chmod -R g-w "DietPi-\$G_GITBRANCH"' /boot/dietpi/dietpi-update then GITBRANCH_TARGET=$(sed -n '/^[[:blank:]]*DEV_GITBRANCH=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) [[ $GITBRANCH_TARGET == "$G_GITBRANCH" ]] || G_EXEC ln -s '/tmp/DietPi-Update/DietPi-'{"$GITBRANCH_TARGET","$G_GITBRANCH"} fi fi # v8.5: https://github.com/MichaIng/DietPi/issues/5467 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 5 ) )) && dpkg-query -s systemd-timesyncd &> /dev/null && [[ $(apt-mark showauto systemd-timesyncd) ]] then G_DIETPI-NOTIFY 2 'Marking systemd-timesyncd as manually installed to prevent its autoremoval' G_EXEC apt-mark manual systemd-timesyncd fi # v8.6 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 6 ) )) && [[ -f '/etc/kernel/postinst.d/dietpi-initramfs_cleanup' ]] then G_DIETPI-NOTIFY 2 'Updating initramfs cleanup script' cat << '_EOF_' > /etc/kernel/postinst.d/dietpi-initramfs_cleanup #!/bin/dash -e echo 'Removing obsolete initramfs images' find /boot -maxdepth 1 -name 'initrd.img-*' -o -name 'uInitrd-*' | while read -r f do [ ! -d "/lib/modules/${f#*-}" ] || continue rm -v "$f" done exit 0 _EOF_ G_EXEC chmod +x /etc/kernel/postinst.d/dietpi-initramfs_cleanup G_EXEC mkdir -p /etc/kernel/postrm.d G_EXEC ln -sf /etc/kernel/post{inst,rm}.d/dietpi-initramfs_cleanup fi # v8.7 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 7 ) )) && [[ -f '/etc/apt/sources.list.d/dietpi-tailscale.list' && ! -f '/etc/apt/trusted.gpg.d/dietpi-tailscale.gpg' ]] then G_DIETPI-NOTIFY 2 'Removing invalid Tailscale APT list' G_EXEC rm /etc/apt/sources.list.d/dietpi-tailscale.list fi # v8.11 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 11 ) )) && [[ -f '/etc/apt/sources.list.d/grafana.list' ]] then G_DIETPI-NOTIFY 2 'Updating Grafana APT list to use the new repository: https://grafana.com/docs/grafana/latest/setup-grafana/installation/debian/#repository-migration-november-8th-2022' G_EXEC eval "echo 'deb https://apt.grafana.com stable main' > /etc/apt/sources.list.d/grafana.list" fi # v8.14 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 14 ) )) then if [[ -f '/etc/apt/trusted.gpg.d/dietpi-influxdb.gpg' ]] && (( $(date -u '+%Y%m%d' -r '/etc/apt/trusted.gpg.d/dietpi-influxdb.gpg') < 20230127 )) then G_DIETPI-NOTIFY 2 'Updating InfluxDB APT repo key' # https://github.com/influxdata/influxdb/pull/24061 G_EXEC curl -sSfLO 'https://repos.influxdata.com/influxdata-archive_compat.key' G_EXEC gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-influxdb.gpg --yes influxdata-archive_compat.key G_EXEC rm influxdata-archive_compat.key fi if (( $G_DISTRO > 6 )) && [[ -f '/etc/apt/sources.list.d/dietpi-jellyfin.list' ]] && grep -q 'bullseye' /etc/apt/sources.list.d/dietpi-jellyfin.list then G_DIETPI-NOTIFY 2 'Updating Jellyfin APT repo suite' G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/dietpi-jellyfin.list fi if (( $G_DISTRO > 6 )) && [[ -f '/etc/apt/sources.list.d/docker.list' ]] && grep -q 'bullseye' /etc/apt/sources.list.d/docker.list then G_DIETPI-NOTIFY 2 'Updating Docker APT repo suite' G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/docker.list fi fi # v8.15 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 15 ) )) then if [[ $G_RASPBIAN != 1 ]] && (( $G_DISTRO > 6 )) && grep -q 'non-free' /etc/apt/sources.list && ! grep -q 'non-free-firmware' /etc/apt/sources.list then # https://www.debian.org/releases/bookworm/amd64/release-notes/ch-information.en.html#non-free-split G_DIETPI-NOTIFY 2 'Adding new non-free-firmware component to APT lists, to re-enable firmware upgrades' G_EXEC sed --follow-symlinks -i '/non-free/s/$/ non-free-firmware/' /etc/apt/sources.list fi fi # v8.23 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 23 ) )) then # RISC-V: Migrate from Debian ports to regular Debian Sid if (( $G_HW_ARCH == 11 )) then G_DIETPI-NOTIFY 2 'Migrating from Debian ports to regular Debian Sid repository, which now supports RISC-V' G_EXEC eval 'echo '\''deb https://deb.debian.org/debian sid main contrib non-free non-free-firmware'\'' > /etc/apt/sources.list' dpkg-query -s 'debian-ports-archive-keyring' &> /dev/null && G_EXEC apt-mark auto debian-ports-archive-keyring # RPi/ARMv6 container Bookworm elif [[ $G_DISTRO -ge 7 && -f '/etc/apt/sources.list.d/raspi.list' ]] then G_DIETPI-NOTIFY 2 'Removing faulty non-free-firmware component if present' (( $G_RASPBIAN )) && G_EXEC sed --follow-symlinks -i 's/ non-free-firmware$//' /etc/apt/sources.list fi # Migrate Sonarr keyring from apt-key and /etc/apt/trusted.gpg to /etc/apt/trusted.gpg.d if [[ -f '/etc/apt/trusted.gpg' && $(apt-key --keyring /etc/apt/trusted.gpg list '2009837CBFFD68F45BC180471F4F90DE2A9B4BF8' 2> /dev/null) ]] then G_DIETPI-NOTIFY 2 'Migrating Sonarr keyring from apt-key and /etc/apt/trusted.gpg to /etc/apt/trusted.gpg.d' G_EXEC eval 'curl -sSf '\''https://keyserver.ubuntu.com/pks/lookup?search=0x2009837CBFFD68F45BC180471F4F90DE2A9B4BF8&op=get'\'' | gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-sonarr.gpg --yes' G_EXEC apt-key --keyring /etc/apt/trusted.gpg del '2009837CBFFD68F45BC180471F4F90DE2A9B4BF8' [[ $(apt-key --keyring /etc/apt/trusted.gpg list 2> /dev/null) ]] || G_EXEC rm /etc/apt/trusted.gpg fi # Workaround for Beta v8.23.1 users as previous gpg method installed a 0600 file [[ -f '/etc/apt/trusted.gpg.d/dietpi-sonarr.gpg' ]] && G_EXEC chmod 0644 /etc/apt/trusted.gpg.d/dietpi-sonarr.gpg fi # v8.24 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 24 ) )) then if [[ $G_DISTRO -ge 7 && -f '/etc/apt/sources.list.d/dietpi-mosquitto.list' ]] then G_DIETPI-NOTIFY 2 'Migrating Mosquitto APT repository to Bookworm' G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/dietpi-mosquitto.list fi if [[ $G_DISTRO == 7 && -f '/etc/apt/sources.list.d/dietpi-mympd.list' ]] then G_DIETPI-NOTIFY 2 'Migrating myMPD APT repository from testing suite to Bookworm suite' G_EXEC sed --follow-symlinks -i 's/Debian_Testing/Debian_12/' /etc/apt/sources.list.d/dietpi-mympd.list fi if [[ -f '/etc/apt/sources.list.d/dietpi-openhab.list' ]] then G_DIETPI-NOTIFY 2 'Migrating openHAB APT repository from testing suite to stable suite' G_EXEC sed --follow-symlinks -i 's/ testing / stable /' /etc/apt/sources.list.d/dietpi-openhab.list fi if [[ $G_DISTRO -ge 7 && -f '/etc/apt/sources.list.d/raspi.list' ]] && dpkg-query -s 'kodi-repository-kodi' &> /dev/null then G_DIETPI-NOTIFY 2 'Purging conflicting kodi-repository-kodi package' G_AGP kodi-repository-kodi fi fi # v8.25 if (( $G_DIETPI_VERSION_CORE < 8 || ( $G_DIETPI_VERSION_CORE == 8 && $G_DIETPI_VERSION_SUB < 25 ) )) then if [[ -f '/etc/apt/sources.list.d/webmin.list' ]] then G_DIETPI-NOTIFY 2 'Updating Webmin APT repo' G_EXEC eval 'curl -sSfL '\''https://webmin.com/developers-key.asc'\'' | gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-webmin.gpg --yes' G_EXEC eval 'echo '\''deb https://download.webmin.com/download/newkey/repository stable contrib'\'' > /etc/apt/sources.list.d/webmin.list' fi fi # v9.0 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 0 ) )) then if dpkg-query -s rpi-eeprom &> /dev/null then G_DIETPI-NOTIFY 2 'Reverting now obsolete rpi-eeprom hold' G_EXEC apt-mark unhold rpi-eeprom fi if (( $G_HW_MODEL < 10 || ( $G_HW_MODEL == 75 && ${G_RASPBIAN:-0} == 1 ) )) then G_DIETPI-NOTIFY 2 'Migrating from raspberrypi.org to raspberrypi.com' G_EXEC sed --follow-symlinks -i 's/raspberrypi.org/raspberrypi.com/' /etc/apt/sources.list /boot/dietpi.txt find /etc/apt/sources.list.d/* &> /dev/null && G_EXEC sed --follow-symlinks -i 's/raspberrypi.org/raspberrypi.com/' /etc/apt/sources.list.d/*.list find /etc/apt/preferences.d/* &> /dev/null && G_EXEC sed --follow-symlinks -i 's/raspberrypi.org/raspberrypi.com/' /etc/apt/preferences.d/* fi GITBRANCH_TARGET=$(sed -n '/^[[:blank:]]*DEV_GITBRANCH=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) GITBRANCH_TARGET=${GITBRANCH_TARGET:-master} GITBRANCH_TARGET=${GITBRANCH_TARGET//\//-} G_EXEC mkdir -p "../DietPi-Update/DietPi-$GITBRANCH_TARGET/dietpi" # shellcheck disable=SC2261 grep -q 'DietPi v6' /boot/dietpi/dietpi-update && > "../DietPi-Update/DietPi-$GITBRANCH_TARGET/dietpi/server_version-6" > "../DietPi-Update/DietPi-$GITBRANCH_TARGET/dietpi/pre-patch_file" > /boot/dietpi/patch_file fi # v9.4 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 4 ) )) then if (( $G_HW_MODEL < 10 && $G_DISTRO > 6 )) && dpkg-query -s 'raspi-firmware' &> /dev/null && ! apt-mark showmanual | grep -qE '^(initramfs-tools|dracut|tiny-initramfs)(-core)?$' then G_DIETPI-NOTIFY 2 'Satisfying initramfs package dependency of raspi-firmware with initramfs-tools' # https://github.com/RPi-Distro/repo/issues/358 G_CONFIG_INJECT 'SKIP_INITRAMFS_GEN=' 'SKIP_INITRAMFS_GEN=yes' /etc/default/raspi-firmware G_AGI initramfs-tools G_EXEC apt-mark auto initramfs-tools G_AGP tiny-initramfs dracut G_EXEC rm -f /boot/initrd.img-* /boot/firmware/initramfs* fi fi # v9.6 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 6 ) )) then # https://github.com/MichaIng/DietPi/issues/6332#issuecomment-2162959873 if (( $G_HW_MODEL == 10 )) then G_DIETPI-NOTIFY 2 'Re-allowing kernel upgrades on Odroid C1' [[ -f '/etc/apt/preferences.d/00-dietpi-odroidc1' ]] && G_EXEC rm /etc/apt/preferences.d/00-dietpi-odroidc1 mapfile -t apackages < <(apt-mark showhold | grep -E '^linux-(image|dtb|headers}-(current|edge)-meson$') [[ ${apackages[0]} ]] && G_EXEC apt-mark unhold "${apackages[@]}" unset -v apackages fi fi # v9.8 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 8 ) )) then # https://dietpi.com/forum/t/20771 if [[ $G_HW_MODEL == 72 && -f '/etc/apt/sources.list.d/dietpi.list' ]] then G_DIETPI-NOTIFY 2 'Fix ROCK 4 APT component' if dpkg-query -s 'linux-u-boot-rockpi-4b-current' &> /dev/null then all_components='rock4' elif dpkg-query -s 'linux-u-boot-rock-4se-current' &> /dev/null then all_components='rock4se' elif dpkg-query -s 'linux-u-boot-rockpi-4cplus-current' &> /dev/null then all_components='rock4cplus' fi G_EXEC sed --follow-symlinks -i '\|^deb https://dietpi.com/apt all |d' /etc/apt/sources.list.d/dietpi.list G_EXEC eval "echo 'deb https://dietpi.com/apt all $all_components' >> /etc/apt/sources.list.d/dietpi.list" fi fi # v9.10 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 10 ) )) then if (( $G_HW_ARCH == 11 )) then G_DIETPI-NOTIFY 2 'Migrating RISC-V systems from Debian Sid/unstable to Trixie/testing' G_EXEC sed --follow-symlinks -i 's/ sid / trixie /' /etc/apt/sources.list fi fi # v9.12 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 12 ) )) then if [[ -f '/etc/apt/trusted.gpg.d/dietpi-mympd.gpg' ]] then G_DIETPI-NOTIFY 2 'Updating myMPD APT repo key' # Distro: https://download.opensuse.org/repositories/home:/jcorporation/ distro='Debian_' (( $G_HW_ARCH == 1 )) && distro='Raspbian_' case $G_DISTRO in 6) distro+='11';; 7) distro+='12';; 8) (( $G_HW_ARCH == 1 )) && distro+='Testing' || distro+='13';; *) distro+='Testing';; esac G_EXEC curl -sSfLo '/etc/apt/trusted.gpg.d/dietpi-mympd.asc' "https://download.opensuse.org/repositories/home:/jcorporation/$distro/Release.key" G_EXEC rm /etc/apt/trusted.gpg.d/dietpi-mympd.gpg fi fi # v9.13 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 13 ) )) then if (( $G_DISTRO > 7 && ! ${G_RASPBIAN:-0} )) && [[ -f '/etc/apt/sources.list.d/docker.list' ]] then G_DIETPI-NOTIFY 2 'Migrating Docker repo from Bookworm to Trixie suite' G_EXEC sed --follow-symlinks -i 's/bookworm/trixie/' /etc/apt/sources.list.d/docker.list fi if [[ $G_HW_MODEL == 1[0-6] ]] && [[ $(find /etc/apt/sources.list.d -name 'meveric*.list') ]] then G_DIETPI-NOTIFY 2 'Migrating legacy Odroid systems back to ODROID Project Hosting APT repo, as we removed our mirror' G_EXEC sed --follow-symlinks -i 's|https://dietpi.com/meveric|https://oph.mdrjr.net/meveric|' /etc/apt/sources.list.d/meveric*.list fi fi # v9.14 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 14 ) )) then # Webmin: gpg => asc, webmin.list => dietpi-webmin.list, install repo for RISC-V, previously not available if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[115\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Installing new Webmin repo key and list' G_EXEC curl -sSfLo /etc/apt/trusted.gpg.d/dietpi-webmin.asc 'https://webmin.com/developers-key.asc' G_EXEC eval 'echo '\''deb https://download.webmin.com/download/newkey/repository stable contrib'\'' > /etc/apt/sources.list.d/dietpi-webmin.list' G_EXEC rm -f /etc/apt/sources.list.d/webmin.list /etc/apt/trusted.gpg.d/dietpi-webmin.gpg fi fi # v9.15 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 15 ) )) then if (( $G_DISTRO < 9 )) && [[ -f '/etc/apt/sources.list.d/raspi.list' && -f '/etc/apt/preferences.d/dietpi-ffmpeg' ]] then G_DIETPI-NOTIFY 2 'Removing obsolete FFmpeg workaround from RPi systems' G_EXEC rm /etc/apt/preferences.d/dietpi-ffmpeg fi if (( $G_DISTRO < 7 )) && grep -q '^deb .* bullseye-backports ' /etc/apt/sources.list then G_DIETPI-NOTIFY 2 'Pulling bullseye-backports APT suite from archive.debian.org, since it has been removed from main repo' G_EXEC sed --follow-symlinks -i 's|^[[:blank:]]*deb[[:blank:]].*[[:blank:]]bullseye-backports[[:blank:]]|deb https://archive.debian.org/debian bullseye-backports |' /etc/apt/sources.list fi fi # v9.16 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 16 ) )) then if (( $G_HW_MODEL < 10 || ( $G_HW_MODEL == 75 && ${G_RASPBIAN:-0} == 1 ) )) || [[ -f '/etc/apt/sources.list.d/raspi.list' ]] then G_DIETPI-NOTIFY 2 'Blocking conflicting Raspberry Pi desktop packages' # - https://github.com/MichaIng/DietPi/issues/1558#issuecomment-691206284 # - https://github.com/MichaIng/DietPi/issues/4687 G_EXEC eval 'cat << '\''_EOF_'\'' > /etc/apt/preferences.d/dietpi-raspberrypi Package: src:openbox src:obconf src:pcmanfm src:libfm src:gtk* src:lx* Pin: origin archive.raspberrypi.com Pin-Priority: -1 _EOF_' [[ -f '/etc/apt/preferences.d/dietpi-lxde' ]] && G_EXEC rm /etc/apt/preferences.d/dietpi-lxde G_DIETPI-NOTIFY 2 'Updating Raspberry Pi APT repository list' G_EXEC eval "echo 'deb https://archive.raspberrypi.com/debian ${G_DISTRO_NAME/forky/trixie} main' > /etc/apt/sources.list.d/raspi.list" fi for i in php openssl xrdp wireguard kodi openhab do [[ -f /etc/apt/preferences.d/dietpi-$i ]] || continue G_DIETPI-NOTIFY 2 "Removing obsolete $i APT pin" G_EXEC rm "/etc/apt/preferences.d/dietpi-$i" done if (( $G_HW_ARCH == 1 || ( $G_HW_ARCH == 2 && $G_DISTRO < 8 ) )) && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[206\]=2' /boot/dietpi/.installed && (( $(java -version 2>&1 | mawk -F\" '{print substr($2,0,2);exit}') < 21 )) then G_DIETPI-NOTIFY 2 'Preventing incompatible openHAB 5 upgrade which requires Java 21' G_EXEC eval 'cat << '\''_EOF_'\'' > /etc/apt/preferences.d/dietpi-openhab Package: src:openhab* Pin: version 5.* Pin-Priority: -1 _EOF_' if dpkg --compare-versions "$(dpkg-query -Wf '${version}' openhab 2> /dev/null)" ge 5 then G_DIETPI-NOTIFY 2 'Enforcing downgrade of incompatible openHAB 5 to latest openHAB 4' G_EXEC eval 'cat << '\''_EOF_'\'' > /etc/apt/preferences.d/dietpi-openhab-tmp Package: src:openhab* Pin: version 4.* Pin-Priority: 1000 _EOF_' G_EXEC eval 'echo '\''APT::Get::Allow-Downgrades "1";'\'' > /etc/apt/apt.conf.d/dietpi-openhab-tmp' fi fi # Consolidate and redo all Armbian APT repo related patches [[ -f '/etc/apt/sources.list.d/armbian.list' ]] && G_EXEC mv /etc/apt/sources.list.d/{,dietpi-}armbian.list if [[ -f '/etc/apt/sources.list.d/dietpi-armbian.list' ]] then # Remove Armbian APT repository from all systems which have an "all" component for kernel/bootloader/firmware packages form our APT repository if [[ -f '/etc/apt/sources.list.d/dietpi.list' ]] && grep -q 'dietpi.com/apt all' /etc/apt/sources.list.d/dietpi.list then G_DIETPI-NOTIFY 2 'Removing obsolete Armbian APT repository' G_EXEC rm /etc/apt/sources.list.d/dietpi-armbian.list [[ -f '/etc/apt/preferences.d/dietpi-armbian' ]] && G_EXEC rm /etc/apt/preferences.d/dietpi-armbian [[ -f '/etc/apt/trusted.gpg.d/dietpi-armbian.gpg' ]] && G_EXEC rm /etc/apt/trusted.gpg.d/dietpi-armbian.gpg else G_DIETPI-NOTIFY 2 'Updating Armbian APT repository key' G_EXEC eval 'curl -sSfL '\''https://apt.armbian.com/armbian.key'\'' | gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-armbian.gpg --yes' if [[ -f '/etc/apt/trusted.gpg' && $(apt-key --keyring /etc/apt/trusted.gpg list 'DF00FAF1C577104B50BF1D0093D6889F9F0E78D5' 2> /dev/null) ]] then G_DIETPI-NOTIFY 2 'Removing Armbian keyring from obsolete /etc/apt/trusted.gpg' G_EXEC apt-key --keyring /etc/apt/trusted.gpg del 'DF00FAF1C577104B50BF1D0093D6889F9F0E78D5' [[ $(apt-key --keyring /etc/apt/trusted.gpg list 2> /dev/null) ]] || G_EXEC rm /etc/apt/trusted.gpg fi G_DIETPI-NOTIFY 2 'Updating Armbian APT repository list entry' suite='bookworm' (( $G_DISTRO > 7 )) && suite=$G_DISTRO_NAME G_EXEC eval "echo 'deb https://apt.armbian.com $suite main' > /etc/apt/sources.list.d/dietpi-armbian.list" G_DIETPI-NOTIFY 2 'Preventing any unintended packages from being installed from Armbian'\''s APT repository' G_EXEC eval 'cat << '\''_EOF_'\'' > /etc/apt/preferences.d/dietpi-armbian Package: * Pin: origin apt.armbian.com Pin-Priority: -1 Package: armbian-firmware* linux-* Pin: origin apt.armbian.com Pin-Priority: 500 _EOF_' fi fi # Update Grafana APT key, expired at 2025-08-23 if [[ -f '/etc/apt/trusted.gpg.d/dietpi-grafana.gpg' ]] && (( $(date -u '+%Y%m%d' -r '/etc/apt/trusted.gpg.d/dietpi-grafana.gpg') < 20250823 )) then G_DIETPI-NOTIFY 2 'Updating Grafana APT repo key' G_EXEC curl -sSfLO 'https://apt.grafana.com/gpg.key' G_EXEC gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-grafana.gpg --yes gpg.key G_EXEC rm gpg.key fi fi # v9.17 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 17 ) )) then if (( $G_HW_MODEL < 10 || ( $G_HW_MODEL == 75 && ${G_RASPBIAN:-0} == 1 ) )) || [[ -f '/etc/apt/sources.list.d/raspi.list' ]] then G_DIETPI-NOTIFY 2 'Assuring that Raspberry Pi and Raspbian repo keys are in /etc/apt/trusted.gpg.d only and not in legacy /etc/apt/trusted.gpg' G_AG_CHECK_INSTALL_PREREQ raspberrypi-archive-keyring [[ -f '/usr/share/keyrings/raspbian-archive-keyring.gpg' && ! -f '/etc/apt/trusted.gpg.d/raspbian-archive-keyring.gpg' ]] && G_EXEC ln -sf /usr/share/keyrings/raspbian-archive-keyring.gpg /etc/apt/trusted.gpg.d/raspbian-archive-keyring.gpg if [[ -f '/etc/apt/trusted.gpg' ]] then [[ $(apt-key --keyring /etc/apt/trusted.gpg list 'CF8A1AF502A2AA2D763BAE7E82B129927FA3303E' 2> /dev/null) ]] && G_EXEC apt-key --keyring /etc/apt/trusted.gpg del 'CF8A1AF502A2AA2D763BAE7E82B129927FA3303E' # archive.raspberrypi.com [[ $(apt-key --keyring /etc/apt/trusted.gpg list 'A0DA38D0D76E8B5D638872819165938D90FDDD2E' 2> /dev/null) ]] && G_EXEC apt-key --keyring /etc/apt/trusted.gpg del 'A0DA38D0D76E8B5D638872819165938D90FDDD2E' # Raspbian [[ $(apt-key --keyring /etc/apt/trusted.gpg list 2> /dev/null) ]] || G_EXEC rm /etc/apt/trusted.gpg fi fi if (( $G_DISTRO > 7 )) && [[ -f '/etc/apt/trusted.gpg' ]] then G_DIETPI-NOTIFY 2 'Removing /etc/apt/trusted.gpg, deprecated since Bookworm and obsolete since Trixie' G_EXEC rm /etc/apt/trusted.gpg fi fi # v9.18 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 18 ) )) then if (( $G_DISTRO > 8 )) && [[ -f '/etc/apt/sources.list.d/raspi.list' ]] then G_DIETPI-NOTIFY 2 'Blocking incompatible FFmpeg from RPi Trixie repo on Forky systems' G_EXEC eval 'cat << '\''_EOF_'\'' > /etc/apt/preferences.d/dietpi-ffmpeg Package: src:ffmpeg Pin: origin archive.raspberrypi.com Pin-Priority: -1 _EOF_' fi if (( $G_HW_MODEL < 10 )) && [[ -f '/etc/apt/sources.list.d/dietpi.list' ]] && grep -q ' rpi[2-5]$' /etc/apt/sources.list.d/dietpi.list then G_DIETPI-NOTIFY 2 'Removing obsolete APT repo component for Raspberry Pi' G_EXEC sed --follow-symlinks -i '1s/ rpi[2-5]$//' /etc/apt/sources.list.d/dietpi.list fi if [[ $G_DISTRO == 8 && -f '/etc/apt/sources.list.d/dietpi-mympd.list' ]] && (( $G_HW_ARCH != 1 )) then G_DIETPI-NOTIFY 2 'Update myMPD APT repository on Debian Trixie' G_EXEC sed --follow-symlinks -i 's/Debian_Testing/Debian_13/g' /etc/apt/sources.list.d/dietpi-mympd.list fi if (( $G_DISTRO > 7 )) && [[ -f '/etc/apt/sources.list.d/dietpi-moonlight-qt.list' ]] then G_DIETPI-NOTIFY 2 'Updating Moonlight (GUI) APT repository on Debian Trixie and Forky' G_EXEC sed --follow-symlinks -Ei 's/ (bookworm|sid) / trixie /' /etc/apt/sources.list.d/dietpi-moonlight-qt.list fi if (( $G_DISTRO > 7 )) && [[ -f '/etc/apt/sources.list.d/dietpi-mopidy.list' ]] then G_DIETPI-NOTIFY 2 'Updating Mopidy APT repository on Debian Trixie and Forky' G_EXEC sed --follow-symlinks -i 's/ bookworm / trixie /' /etc/apt/sources.list.d/dietpi-mopidy.list fi if (( $G_DISTRO > 7 )) && [[ -f '/etc/apt/sources.list.d/dietpi-zerotier.list' ]] then G_DIETPI-NOTIFY 2 'Updating Zerotier APT repository on Debian Trixie and Forky' G_EXEC sed --follow-symlinks -i 's/bookworm/trixie/g' /etc/apt/sources.list.d/dietpi-zerotier.list fi fi # v9.19 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 19 ) )) then if [[ -f '/etc/apt/sources.list.d/dietpi-realvnc.list' ]] then G_DIETPI-NOTIFY 2 'Removing obsolete RealVNC repo list' G_EXEC rm /etc/apt/sources.list.d/dietpi-realvnc.list fi if [[ -f '/etc/apt/preferences.d/dietpi-realvnc' ]] then G_DIETPI-NOTIFY 2 'Removing obsolete RealVNC repo pins' G_EXEC rm /etc/apt/preferences.d/dietpi-realvnc fi if (( $G_DISTRO == 8 && ( $G_HW_ARCH == 2 || $G_HW_ARCH == 3 || $G_HW_ARCH == 10 ) )) && [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[123\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Adding Mosquitto APT repository for Debian Trixie' G_EXEC curl -sSfLO 'https://repo.mosquitto.org/debian/mosquitto-repo.gpg' G_EXEC gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-mosquitto.gpg --yes mosquitto-repo.gpg G_EXEC rm mosquitto-repo.gpg G_EXEC eval "echo 'deb https://repo.mosquitto.org/debian $G_DISTRO_NAME main' > /etc/apt/sources.list.d/dietpi-mosquitto.list" fi if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[111\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Adding UrBackup APT repository' # APT distro distro='Debian_' (( $G_HW_ARCH == 1 )) && distro='Raspbian_' case $G_DISTRO in 6) distro+='11';; 7) distro+='12';; *) (( $G_HW_ARCH == 1 )) && distro+='12' || distro+='13';; esac # APT key G_EXEC mkdir -p /etc/apt/keyrings G_EXEC curl -sSfLo /etc/apt/keyrings/dietpi-urbackup.asc "https://download.opensuse.org/repositories/home:/uroni/$distro/Release.key" # APT source G_EXEC eval "cat << '_EOF_' > /etc/apt/sources.list.d/dietpi-urbackup.sources Types: deb URIs: https://download.opensuse.org/repositories/home:/uroni/$distro Suites: / Signed-By: /etc/apt/keyrings/dietpi-urbackup.asc _EOF_" # Beta cleanup [[ -f '/etc/apt/sources.list.d/dietpi-urbackup.list' ]] && G_EXEC rm /etc/apt/sources.list.d/dietpi-urbackup.list fi fi # v9.20 if (( $G_DIETPI_VERSION_CORE < 9 || ( $G_DIETPI_VERSION_CORE == 9 && $G_DIETPI_VERSION_SUB < 20 ) )) then # Enforce downgrade of Armbian's base-files package to Debian's: https://github.com/MichaIng/DietPi/issues/6227#issuecomment-1713688577 if dpkg --compare-versions "$(dpkg-query -Wf '${Version}' base-files)" ge 15 then G_DIETPI-NOTIFY 2 'Enforcing downgrade of Armbian'\''s base-files package to Debian'\''s' G_EXEC eval 'cat << '\''_EOF_'\'' > /etc/apt/preferences.d/dietpi-armbian-tmp Package: base-files Pin: release o=Debian Pin-Priority: 1000 _EOF_' G_EXEC eval 'echo '\''APT::Get::Allow-Downgrades "1";'\'' > /etc/apt/apt.conf.d/dietpi-armbian-tmp' fi fi exit 0 }