Skip to content

Commit

Permalink
Change set_safe_boot with improved function armbian_fw_manipulate
Browse files Browse the repository at this point in the history
It extends functionality to reload packages too
  • Loading branch information
igorpecovnik committed Sep 4, 2024
1 parent be4df8e commit 83efae9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Enable Armbian kernel upgrades
Jobs:

~~~
set_safe_boot unhold
armbian_fw_manipulate unhold
~~~

### S02
Expand All @@ -169,7 +169,7 @@ Disable Armbian kernel upgrades
Jobs:

~~~
set_safe_boot freeze
armbian_fw_manipulate freeze
~~~

### S03
Expand Down Expand Up @@ -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
Expand Down
59 changes: 36 additions & 23 deletions lib/armbian-configng/config.ng.functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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) echo ${SELECTION}; debconf-apt-progress -- apt-get update; debconf-apt-progress -- apt-get -y --reinstall install ${SELECTION};;
*) return ;;
esac

}

Expand Down
4 changes: 2 additions & 2 deletions lib/armbian-configng/config.ng.jobs.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"id": "S01",
"description": "Enable Armbian kernel upgrades",
"command": [
"set_safe_boot unhold"
"armbian_fw_manipulate unhold"
],
"status": "Active",
"doc_link": "",
Expand All @@ -20,7 +20,7 @@
"id": "S02",
"description": "Disable Armbian kernel upgrades",
"command": [
"set_safe_boot freeze"
"armbian_fw_manipulate hold"
],
"status": "Active",
"doc_link": "",
Expand Down
2 changes: 2 additions & 0 deletions lib/armbian-configng/config.ng.system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

0 comments on commit 83efae9

Please sign in to comment.