From 012a8f3c25fb651e84c0beed023a3519df6a77f4 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 4 Sep 2024 21:44:58 +0200 Subject: [PATCH] Change set_safe_boot with improved function armbian_fw_manipulate It extends functionality to reload packages too --- README.md | 6 +-- lib/armbian-configng/config.ng.functions.sh | 59 +++++++++++++-------- lib/armbian-configng/config.ng.jobs.json | 4 +- lib/armbian-configng/config.ng.system.sh | 2 + 4 files changed, 43 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index de0b4cc7c..c6c2c4ef0 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ Enable Armbian kernel upgrades Jobs: ~~~ -set_safe_boot unhold +armbian_fw_manipulate unhold ~~~ ### S02 @@ -169,7 +169,7 @@ Disable Armbian kernel upgrades Jobs: ~~~ -set_safe_boot freeze +armbian_fw_manipulate freeze ~~~ ### S03 @@ -510,7 +510,7 @@ These helper functions facilitate various operations related to job management, | Display a message box | show_message <<< 'hello world' | Joey Turner | Migrated procedures from Armbian config. | connect_bt_interface | Igor Pecovnik | Show or generate QR code for Google OTP | qr_code generate | Igor Pecovnik -| Freeze/unhold Migrated procedures from Armbian config. | set_safe_boot unhold or set_safe_boot freeze | Igor Pecovnik +| Freeze/unhold Migrated procedures from Armbian config. | armbian_fw_manipulate unhold or armbian_fw_manipulate freeze or armbian_fw_manipulate reinstall | Igor Pecovnik | Check if kernel headers are installed | are_headers_installed | Gunjan Gupta | Check when apt list was last updated | see_current_apt | Joey Turner | Migrated procedures from Armbian config. | check_if_installed nano | Igor Pecovnik diff --git a/lib/armbian-configng/config.ng.functions.sh b/lib/armbian-configng/config.ng.functions.sh index 67ec9498b..e35e848f2 100644 --- a/lib/armbian-configng/config.ng.functions.sh +++ b/lib/armbian-configng/config.ng.functions.sh @@ -248,35 +248,48 @@ function set_runtime_variables(){ module_options+=( -["set_safe_boot,author"]="Igor Pecovnik" -["set_safe_boot,ref_link"]="" -["set_safe_boot,feature"]="set_safe_boot" -["set_safe_boot,desc"]="Freeze/unhold Migrated procedures from Armbian config." -["set_safe_boot,example"]="set_safe_boot unhold or set_safe_boot freeze" -["set_safe_boot,status"]="Active" +["armbian_fw_manipulate,author"]="Igor Pecovnik" +["armbian_fw_manipulate,ref_link"]="" +["armbian_fw_manipulate,feature"]="armbian_fw_manipulate" +["armbian_fw_manipulate,desc"]="freeze/unhold/reinstall armbian related packages." +["armbian_fw_manipulate,example"]="armbian_fw_manipulate unhold|freeze|reinstall" +["armbian_fw_manipulate,status"]="Active" ) # -# freeze/unhold packages +# freeze/unhold/reinstall armbian firmware packages # -set_safe_boot() { +armbian_fw_manipulate() { - check_if_installed linux-u-boot-${BOARD}-${BRANCH} && PACKAGE_LIST+=" linux-u-boot-${BOARD}-${BRANCH}" - check_if_installed linux-image-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-image-${BRANCH}-${LINUXFAMILY}" - check_if_installed linux-dtb-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-dtb-${BRANCH}-${LINUXFAMILY}" - check_if_installed linux-headers-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-headers-${BRANCH}-${LINUXFAMILY}" + function=$1 - # new BSP - check_if_installed armbian-${LINUXFAMILY} && PACKAGE_LIST+=" armbian-${LINUXFAMILY}" - check_if_installed armbian-${BOARD} && PACKAGE_LIST+=" armbian-${BOARD}" - check_if_installed armbian-${DISTROID} && PACKAGE_LIST+=" armbian-${DISTROID}" - check_if_installed armbian-bsp-cli-${BOARD} && PACKAGE_LIST+=" armbian-bsp-cli-${BOARD}" - check_if_installed armbian-${DISTROID}-desktop-xfce && PACKAGE_LIST+=" armbian-${DISTROID}-desktop-xfce" - check_if_installed armbian-firmware && PACKAGE_LIST+=" armbian-firmware" - check_if_installed armbian-firmware-full && PACKAGE_LIST+=" armbian-firmware-full" - IFS=" " - [[ "$1" == "unhold" ]] && local command="apt-mark unhold" && for word in $PACKAGE_LIST; do $command $word; done | show_infobox + ARMBIAN_PACKAGES=( + "linux-u-boot-${BOARD}-${BRANCH}" + "linux-image-${BRANCH}-${LINUXFAMILY}" + "linux-dtb-${BRANCH}-${LINUXFAMILY}" + "linux-headers-${BRANCH}-${LINUXFAMILY}" + "armbian-config" + "armbian-plymouth-theme" + "armbian-zsh" + "base-files" + "armbian-bsp-cli-${BOARD}-${BRANCH}" + "armbian-bsp-desktop-${BOARD}-${BRANCH}" + "armbian-firmware-full" + "armbian-firmware" + ) - [[ "$1" == "freeze" ]] && local command="apt-mark hold" && for word in $PACKAGE_LIST; do $command $word; done | show_infobox + SELECTION=$(for PACKAGE in "${ARMBIAN_PACKAGES[@]}" + do + if check_if_installed $PACKAGE; then + echo $PACKAGE + fi + done) + + case $function in + unhold) apt-mark unhold ${SELECTION} | show_infobox ;; + hold) apt-mark hold ${SELECTION} | show_infobox ;; + reinstall) apt-get -y --reinstall install ${SELECTION} | show_infobox ;; + *) return ;; + esac } diff --git a/lib/armbian-configng/config.ng.jobs.json b/lib/armbian-configng/config.ng.jobs.json index 251dab077..2356224f2 100644 --- a/lib/armbian-configng/config.ng.jobs.json +++ b/lib/armbian-configng/config.ng.jobs.json @@ -8,7 +8,7 @@ "id": "S01", "description": "Enable Armbian kernel upgrades", "command": [ - "set_safe_boot unhold" + "armbian_fw_manipulate unhold" ], "status": "Active", "doc_link": "", @@ -20,7 +20,7 @@ "id": "S02", "description": "Disable Armbian kernel upgrades", "command": [ - "set_safe_boot freeze" + "armbian_fw_manipulate hold" ], "status": "Active", "doc_link": "", diff --git a/lib/armbian-configng/config.ng.system.sh b/lib/armbian-configng/config.ng.system.sh index f5c0e2591..f24a8e17c 100644 --- a/lib/armbian-configng/config.ng.system.sh +++ b/lib/armbian-configng/config.ng.system.sh @@ -69,6 +69,7 @@ function set_stable () { if ! grep -q 'apt.armbian.com' /etc/apt/sources.list.d/armbian.list; then sed -i "s/http:\/\/[^ ]*/http:\/\/apt.armbian.com/" /etc/apt/sources.list.d/armbian.list + armbian_fw_manipulate "reinstall" fi } @@ -87,5 +88,6 @@ function set_rolling () { if ! grep -q 'beta.armbian.com' /etc/apt/sources.list.d/armbian.list; then sed -i "s/http:\/\/[^ ]*/http:\/\/beta.armbian.com/" /etc/apt/sources.list.d/armbian.list + armbian_fw_manipulate "reinstall" fi } \ No newline at end of file