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

Alternative kernels - bugfix & hardening installation #101

Merged
merged 1 commit into from
Sep 24, 2024
Merged
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
28 changes: 16 additions & 12 deletions lib/armbian-configng/config.ng.functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,26 +261,27 @@ module_options+=(
#
armbian_fw_manipulate() {

local function=$1
local version=$2
local function=$1
local version=$2
local branch=$3

[[ -n $version ]] && local version="=${version}"
[[ -n $version ]] && local version="=${version}"

# fallback to current
[[ -z $BRANCH ]] && BRANCH="current"
# fallback to $BRANCH
[[ -z $branch ]] && branch="${BRANCH}"

# packages to install
local armbian_packages=(
"linux-u-boot-${BOARD}-${BRANCH}"
"linux-image-${BRANCH}-${LINUXFAMILY}"
"linux-dtb-${BRANCH}-${LINUXFAMILY}"
"linux-u-boot-${BOARD}-${branch}"
"linux-image-${branch}-${LINUXFAMILY}"
"linux-dtb-${branch}-${LINUXFAMILY}"
"armbian-config"
"armbian-zsh"
)

# reinstall headers only if they were previously installed
if are_headers_installed; then
local armbian_packages+="linux-headers-${BRANCH}-${LINUXFAMILY}"
local armbian_packages+="linux-headers-${branch}-${LINUXFAMILY}"
fi

local packages=""
Expand All @@ -298,14 +299,16 @@ armbian_fw_manipulate() {

for pkg in "${packages[@]}"
do
local pkg_uninstall=${pkg/=*/} # removing numbers
case $function in
unhold) apt-mark unhold ${pkg} | show_infobox ;;
hold) apt-mark hold ${pkg} | show_infobox ;;
reinstall)
apt_install_wrapper apt-get -y --download-only --allow-change-held-packages --allow-downgrades install "${pkg}"
apt_install_wrapper apt-get -y purge "${pkg}"
apt_install_wrapper apt-get -y purge "${pkg_uninstall/${branch}/*}" # remove all branches
apt_install_wrapper apt-get -y --allow-change-held-packages --allow-downgrades install "${pkg}"
apt_install_wrapper apt-get -y autoremove
apt_install_wrapper apt-get -y clean
;;
*) return ;;
esac
Expand Down Expand Up @@ -336,7 +339,7 @@ function switch_kernels () {
for line in $(\
apt-cache show "linux-image-${kernel_test_target}-${LINUXFAMILY}" | grep -E "Package:|Version:|version:|family" \
| grep -v "Config-Version" | sed -n -e 's/^.*: //p' | sed 's/\.$//g' | xargs -n3 -d'\n' | sed "s/ /=/" \
| grep -v ${current_kernel_version}); do
| grep -v "${current_kernel_version}"); do
LIST+=($(echo $line | awk -F ' ' '{print $1 " "}') $(echo $line | awk -F ' ' '{print "v"$2}'))
done
unset IFS
Expand All @@ -346,7 +349,8 @@ function switch_kernels () {
else
local target_version=$(whiptail --separate-output --title "Select kernel" --menu "ed" $((${list_length} + 7)) 80 $((${list_length})) "${LIST[@]}" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ] && [ -n "${target_version}" ]; then
armbian_fw_manipulate "reinstall" "${target_version/*=/}"
local branch=${target_version##*image-}
armbian_fw_manipulate "reinstall" "${target_version/*=/}" "${branch%%-*}"
fi
fi
}
Expand Down
Loading