Commit 144b0d49 authored by Bernhard Landauer's avatar Bernhard Landauer

[mhwd-kernel] add rt-kernel support and some small modifications

parent 8ccf9d6e
......@@ -9,7 +9,7 @@ args_check() {
}
err() {
echo "Error: $1" 1>&2; exit 1
printf "\e[31mError:\e[0m $1" 1>&2; exit 1
}
kernel_usage() {
......@@ -27,10 +27,9 @@ kernel_install() {
for kernel in "$@"; do
[[ $kernel = "rmc" ]] && rmc=1 && continue
[[ $kernel != linux[0-9][0-9]?([0-9]) && $kernel != "rmc" ]] && err "Invalid argument (use -h for help)."
[[ $kernel != linux[0-9][0-9]?([0-9]) ]] && err "Please enter a valid kernel name."
[[ $kernel != linux[0-9][0-9]?([0-9]) && $kernel != linux-rt-*manjaro && $kernel != "rmc" ]] && err "Invalid argument.\nPlease choose one of the $(kernel_repo)\n"
[[ $current = $kernel ]] && err "You can't reinstall your current kernel. Please use 'pacman -Syu' instead to update."
[[ -z $(pacman -Ssq "^$kernel$") ]] && err "Please make sure if the given kernel(s) exist(s)."
[[ -z $(pacman -Ssq "^$kernel$") ]] && err "Please make sure if the given kernel(s) exist(s).\n$(kernel_repo)\n"
for pkg in $(pacman -Qqs "$current"); do
pkg=${pkg//$current/$kernel}
......@@ -50,28 +49,29 @@ kernel_install() {
pacman -S "${pkginstall[@]}"
[[ $rmc = 1 && $? = 0 ]] && pacman -R $(pacman -Qqs $current)
[[ $rmc = 1 && $? != 0 ]] && { echo ""; err "'rmc' aborted because the kernel failed to install or canceled on removal."; }
[[ $rmc = 1 && $? != 0 ]] && { echo ""; err "'rmc' aborted because the kernel failed to install or canceled on removal.\n"; }
}
kernel_repo() {
echo "Available kernels:"
pacman -Ss "^linux[0-9][0-9]?([0-9])$" | grep core | while read -r; do echo " * ${REPLY:5:8}"; done
printf "\e[32mavailable kernels:\e[0m\n"
pacman -Ssq "^linux[0-9][0-9]?([0-9])$" | while read -r; do echo " * $REPLY"; done
pacman -Ssq "^linux-rt.*([o])$" | while read -r; do echo " * $REPLY"; done
}
kernel_list() {
echo "Currently running: $(uname -r) (${current})"
printf "\e[32mCurrently running:\e[0m $(uname -r) (${current}\n"
echo "The following kernels are installed in your system:"
pacman -Qqs "^linux[0-9][0-9]?([0-9])$" | while read -r; do echo " * $REPLY"; done
pacman -Qqs "^linux[0-9-][0-9r]?.*[0-9o]$" | grep -v "r8" | while read -r; do echo " * $REPLY"; done
}
kernel_remove() {
pkgremove=()
for kernel in "$@"; do
[[ -z "$kernel" ]] && err "Invalid argument (use -h for help)."
[[ $kernel != linux[0-9][0-9]?([0-9]) ]] && err "Please enter a valid kernel name."
[[ $current = $kernel ]] && err "You can't remove your current kernel."
[[ -z $(pacman -Qqs "^$1$") ]] && err "Kernel not installed."
[[ -z "$kernel" ]] && err "Invalid argument (use -h for help).\n"
[[ $kernel != linux[0-9][0-9]?([0-9]) && $kernel != linux-rt-*manjaro ]] && err "Please enter a valid kernel name.\n$(kernel_list)\n"
[[ $current = $kernel ]] && err "You can't remove your current kernel.\n"
[[ -z $(pacman -Qqs "^$1$") ]] && err "Kernel not installed.\n$(kernel_list)\n"
for pkg in $(pacman -Qqs "$kernel"); do
pkgremove+=("$pkg")
......@@ -82,7 +82,10 @@ kernel_remove() {
}
IFS=. read -r major minor _ <<< "$(uname -r)"
current="linux$major$minor"
basekernel="linux$major$minor"
current=$basekernel
[[ $(uname -r) == *rt* ]] && [[ $basekernel == *44 ]] && current=linux-rt-lts-manjaro
[[ $(uname -r) == *rt* ]] && [[ $basekernel == *46 ]] && current=linux-rt-manjaro
case "$1" in
-h | --help) args_check $# 1 1
......@@ -105,6 +108,3 @@ case "$1" in
-*) err "Invalid argument (use -h for help)." ;;
*) err "No arguments given (use -h for help)." ;;
esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment