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() { ...@@ -9,7 +9,7 @@ args_check() {
} }
err() { err() {
echo "Error: $1" 1>&2; exit 1 printf "\e[31mError:\e[0m $1" 1>&2; exit 1
} }
kernel_usage() { kernel_usage() {
...@@ -27,10 +27,9 @@ kernel_install() { ...@@ -27,10 +27,9 @@ kernel_install() {
for kernel in "$@"; do for kernel in "$@"; do
[[ $kernel = "rmc" ]] && rmc=1 && continue [[ $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]) && $kernel != linux-rt-*manjaro && $kernel != "rmc" ]] && err "Invalid argument.\nPlease choose one of the $(kernel_repo)\n"
[[ $kernel != linux[0-9][0-9]?([0-9]) ]] && err "Please enter a valid kernel name."
[[ $current = $kernel ]] && err "You can't reinstall your current kernel. Please use 'pacman -Syu' instead to update." [[ $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 for pkg in $(pacman -Qqs "$current"); do
pkg=${pkg//$current/$kernel} pkg=${pkg//$current/$kernel}
...@@ -50,28 +49,29 @@ kernel_install() { ...@@ -50,28 +49,29 @@ kernel_install() {
pacman -S "${pkginstall[@]}" pacman -S "${pkginstall[@]}"
[[ $rmc = 1 && $? = 0 ]] && pacman -R $(pacman -Qqs $current) [[ $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() { kernel_repo() {
echo "Available kernels:" printf "\e[32mavailable kernels:\e[0m\n"
pacman -Ss "^linux[0-9][0-9]?([0-9])$" | grep core | while read -r; do echo " * ${REPLY:5:8}"; done 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() { 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:" 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() { kernel_remove() {
pkgremove=() pkgremove=()
for kernel in "$@"; do for kernel in "$@"; do
[[ -z "$kernel" ]] && err "Invalid argument (use -h for help)." [[ -z "$kernel" ]] && err "Invalid argument (use -h for help).\n"
[[ $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 ]] && err "Please enter a valid kernel name.\n$(kernel_list)\n"
[[ $current = $kernel ]] && err "You can't remove your current kernel." [[ $current = $kernel ]] && err "You can't remove your current kernel.\n"
[[ -z $(pacman -Qqs "^$1$") ]] && err "Kernel not installed." [[ -z $(pacman -Qqs "^$1$") ]] && err "Kernel not installed.\n$(kernel_list)\n"
for pkg in $(pacman -Qqs "$kernel"); do for pkg in $(pacman -Qqs "$kernel"); do
pkgremove+=("$pkg") pkgremove+=("$pkg")
...@@ -82,7 +82,10 @@ kernel_remove() { ...@@ -82,7 +82,10 @@ kernel_remove() {
} }
IFS=. read -r major minor _ <<< "$(uname -r)" 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 case "$1" in
-h | --help) args_check $# 1 1 -h | --help) args_check $# 1 1
...@@ -105,6 +108,3 @@ case "$1" in ...@@ -105,6 +108,3 @@ case "$1" in
-*) err "Invalid argument (use -h for help)." ;; -*) err "Invalid argument (use -h for help)." ;;
*) err "No arguments given (use -h for help)." ;; *) err "No arguments given (use -h for help)." ;;
esac 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