From b1f0e8045de5e828430e461e46dd8e1e5e66c423 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Fri, 27 Sep 2024 13:45:15 +0200 Subject: [PATCH] Enable distro upgrades procedure --- .github/workflows/unit-tests.yml | 8 ++-- lib/armbian-configng/config.ng.jobs.json | 31 ++++++++++++++- lib/armbian-configng/config.ng.software.sh | 46 ++++++++++++++++++++++ lib/armbian-configng/config.ng.system.sh | 4 +- tests/README.md | 2 +- tests/S26.conf | 2 + tests/S27.conf | 2 + 7 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 tests/S26.conf create mode 100644 tests/S27.conf diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 7471260cd..5e42094c0 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -45,7 +45,7 @@ jobs: echo 'JSON_CONTENT<> $GITHUB_OUTPUT # define docker images where we will run test install - dockerimages=("debian:bookworm" "debian:trixie" "ubuntu:jammy" "ubuntu:noble") + dockerimages=( "debian:bookworm" "debian:trixie" "ubuntu:focal" "ubuntu:jammy" "ubuntu:noble") # read tests cases and loop them @@ -110,14 +110,16 @@ jobs: apt -y install wget gpg # add armbian repository - URL=apt.armbian.com + URL=beta.armbian.com wget https://${URL}/armbian.key -O key gpg --dearmor < key | tee /usr/share/keyrings/armbian.gpg > /dev/null chmod go+r /usr/share/keyrings/armbian.gpg echo "deb [signed-by=/usr/share/keyrings/armbian.gpg] http://${URL} $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" | tee /etc/apt/sources.list.d/armbian.list apt update -y apt upgrade -y - apt -y install sudo procps systemd whiptail jq lsb-release iproute2 + apt -y -o Dpkg::Options::="--force-confold" install sudo procps systemd whiptail jq lsb-release iproute2 armbian-bsp-cli-wsl2-x86-current-grub + sudo -b unshare --pid --fork --mount-proc /lib/systemd/systemd --system-unit=basic.target + cat /etc/armbian-distribution-status # install packages / except howdy as its too large export DEBIAN_FRONTEND=noninteractive diff --git a/lib/armbian-configng/config.ng.jobs.json b/lib/armbian-configng/config.ng.jobs.json index c2c59a431..b2298a6e9 100644 --- a/lib/armbian-configng/config.ng.jobs.json +++ b/lib/armbian-configng/config.ng.jobs.json @@ -355,8 +355,37 @@ "src_reference": "", "author": "Igor Pecovnik", "condition": "" + }, + { + "id": "S25", + "description": "Distribution upgrades", + "condition": "[ -f /etc/armbian-distribution-status ] && release_upgrade rolling verify", + "sub": [ + { + "id": "S26", + "description": "Upgrade to latest stable / LTS", + "prompt": "Release upgrade is irriversible operation which upgrades all packages. \n\nResoulted upgrade might break your build beyond repair!", + "command": [ + "release_upgrade stable" + ], + "status": "Active", + "author": "Igor Pecovnik", + "condition": "[ -f /etc/armbian-distribution-status ] && release_upgrade stable verify" + }, + { + "id": "S27", + "description": "Upgrade to rolling unstable", + "prompt": "Release upgrade is irriversible operation which upgrades all packages. \n\nResoulted upgrade might break your build beyond repair!", + "command": [ + "release_upgrade rolling" + ], + "status": "Active", + "author": "Igor Pecovnik", + "condition": "[ -f /etc/armbian-distribution-status ] && release_upgrade rolling verify" + } + ] } - ] + ] }, { "id": "Network", diff --git a/lib/armbian-configng/config.ng.software.sh b/lib/armbian-configng/config.ng.software.sh index 84ff09b24..6b0cab4de 100644 --- a/lib/armbian-configng/config.ng.software.sh +++ b/lib/armbian-configng/config.ng.software.sh @@ -106,3 +106,49 @@ install_docker() { whiptail --msgbox "ERROR ! ${DISTRO} $DISTROID distribution not found in repository!" 7 70 fi } + + +release_upgrade(){ + + local upgrade_type=$1 + local verify=$2 + + local distroid=$DISTROID + distroid=bookworm + + if [[ "${upgrade_type}" == stable ]]; then + local filter=$(grep "supported" /etc/armbian-distribution-status | cut -d"=" -f1) + elif [[ "${upgrade_type}" == rolling ]]; then + local filter=$(grep "eos\|csc" /etc/armbian-distribution-status | cut -d"=" -f1 | sed "s/sid/testing/g") + else + local filter=$(cat /etc/armbian-distribution-status | cut -d"=" -f1) + fi + + local upgrade=$(for j in $filter; do + for i in $(grep "^${distroid}" /etc/armbian-distribution-status | cut -d";" -f2 | cut -d"=" -f2 | sed "s/,/ /g"); do + + if [[ $i == $j ]]; then + echo $i + fi + done + done | tail -1) + if [[ -z $upgrade ]]; then + return 1; + elif [[ -z $verify ]]; then + + ls -l /etc/apt/sources.list.d/ + ls -l /etc/apt/ + echo "####" + [[ -f /etc/apt/sources.list.d/ubuntu.sources ]] && sed -i "s/$distroid/$upgrade/g" /etc/apt/sources.list.d/ubuntu.sources + [[ -f /etc/apt/sources.list.d/ubuntu.sources ]] && sed -i "s/$distroid/$upgrade/g" /etc/apt/sources.list.d/debian.sources + [[ -f /etc/apt/sources.list ]] && sed -i "s/$distroid/$upgrade/g" /etc/apt/sources.list + [[ "${upgrade}" == "testing" ]] && upgrade="sid" + [[ -f /etc/apt/sources.list.d/armbian.list ]] && sed -i "s/$distroid/$upgrade/g" /etc/apt/sources.list.d/armbian.list + apt_install_wrapper apt-get -y update + apt_install_wrapper apt-get -y -o Dpkg::Options::="--force-confold" upgrade --without-new-pkgs + apt_install_wrapper apt-get -y -o Dpkg::Options::="--force-confold" full-upgrade + apt_install_wrapper apt-get -y --purge autoremove + cat /etc/debian_version + cat /etc/os-release + fi +} diff --git a/lib/armbian-configng/config.ng.system.sh b/lib/armbian-configng/config.ng.system.sh index 4fffcc4fd..2181f68ca 100644 --- a/lib/armbian-configng/config.ng.system.sh +++ b/lib/armbian-configng/config.ng.system.sh @@ -13,10 +13,10 @@ module_options+=( # function apt_install_wrapper() { if [ -t 0 ]; then - debconf-apt-progress -- "$@" + DEBIAN_FRONTEND=noninteractive debconf-apt-progress -- "$@" else # Terminal not defined - proceed without TUI - "$@" + DEBIAN_FRONTEND=noninteractive "$@" fi } diff --git a/tests/README.md b/tests/README.md index 8ece3c857..01217f85e 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,4 +4,4 @@ - ENABLED=false|true - PREINSTALL="cmd" in order to satisfy test case - CONDITION must return 0 for test success - +- RELEASE="bookworm:jammy:noble" run on specific or leave empty to run on all diff --git a/tests/S26.conf b/tests/S26.conf new file mode 100644 index 000000000..6c6ecbea0 --- /dev/null +++ b/tests/S26.conf @@ -0,0 +1,2 @@ +ENABLED=true +RELEASE="jammy:bullseye" diff --git a/tests/S27.conf b/tests/S27.conf new file mode 100644 index 000000000..f1b50ac98 --- /dev/null +++ b/tests/S27.conf @@ -0,0 +1,2 @@ +ENABLED=true +RELEASE="bullseye:bookworm:trixie:jammy:noble"