Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change set_safe_boot with improved function armbian_fw_manipulate #57

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 8 additions & 1 deletion bin/armbian-configng
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,15 @@ case "$1" in
exit 1
fi
shift
if [[ -z "$1" ]]; then
echo "Error: Missing option for --api."
exit 1
fi
option="$1"
shift
args=$(sanitize_input "$@")
"$args"
# echo -e "\"$option\" \"$args\""
"$option" "$args"
exit 0
;;
"main=help" | "main=Help")
Expand Down
72 changes: 49 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,61 @@ 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
# fallback to current
[[ -z $BRANCH ]] && BRANCH="current"

[[ "$1" == "freeze" ]] && local command="apt-mark hold" && 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-zsh"
"armbian-bsp-cli-${BOARD}-${BRANCH}"
)

if [[ "${function}" == reinstall ]]; then
debconf-apt-progress -- apt-get update
fi

PACKAGES=""
for PACKAGE in "${ARMBIAN_PACKAGES[@]}"
do
if [[ "${function}" == reinstall ]]; then
apt search $PACKAGE 2>/dev/null | grep "^$PACKAGE" >/dev/null
if [[ $? -eq 0 ]]; then PACKAGES+="$PACKAGE "; fi
else
if check_if_installed $PACKAGE; then
PACKAGES+="$PACKAGE "
fi
fi
done

case $function in
unhold) apt-mark unhold ${PACKAGES} | show_infobox ;;
hold) apt-mark hold ${PACKAGES} | show_infobox ;;
reinstall)
debconf-apt-progress -- apt-get -y --download-only install ${PACKAGES}
debconf-apt-progress -- apt-get -y purge ${PACKAGES}
debconf-apt-progress -- apt-get -y install ${PACKAGES}
debconf-apt-progress -- apt-get -y autoremove
;;
*) return ;;
esac

}

Expand Down
9 changes: 4 additions & 5 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 Expand Up @@ -215,7 +215,6 @@
}
]
},

{
"id": "S08",
"description": "Change shell system wide to BASH",
Expand Down Expand Up @@ -261,7 +260,7 @@
"doc_link": "",
"src_reference": "https://github.com/armbian/config/blob/master/debian-config-jobs#L1446",
"author": "Igor Pecovnik",
"condition": "grep -q 'apt.armbian.com' /etc/apt/sources.list.d/armbian.list"
"condition": "grep -q 'apt.armbian.com' /etc/apt/sources.list.d/armbian.list && [[ -z \"$(apt-mark showhold)\" ]]"
},
{
"id": "S11",
Expand All @@ -274,7 +273,7 @@
"doc_link": "",
"src_reference": "https://github.com/armbian/config/blob/master/debian-config-jobs#L1446",
"author": "Igor Pecovnik",
"condition": "grep -q 'beta.armbian.com' /etc/apt/sources.list.d/armbian.list"
"condition": "grep -q 'beta.armbian.com' /etc/apt/sources.list.d/armbian.list && [[ -z \"$(apt-mark showhold)\" ]]"
}

]
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
}
Loading