From f8430da5833b3184ffda7175610ac8ae2274d022 Mon Sep 17 00:00:00 2001 From: Salvatore Stella Date: Sun, 8 Sep 2024 19:24:07 +0200 Subject: [PATCH] Kernelctl os version (#905) * Change os version scheme --------- Co-authored-by: Nathaniel van Diepen --- package/kernelctl/kernelctl | 9 ++++++--- package/kernelctl/package | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package/kernelctl/kernelctl b/package/kernelctl/kernelctl index ae24716d1..5ad691d85 100644 --- a/package/kernelctl/kernelctl +++ b/package/kernelctl/kernelctl @@ -14,6 +14,9 @@ bl="\033[1;34m" # blue # change our working directory to / to ease filesystem operations cd / +# find current os version +os_version=$(awk -F= '/RELEASE_VERSION/{print $2}' /usr/share/remarkable/update.conf) + help() { read -r -d '' msg <<- EOM Usage: $(basename "$0") COMMAND @@ -36,7 +39,7 @@ help() { # backup current kernel backup() { if [[ "$1" = "vanilla" ]]; then - kernel_name="vanilla-$(< /etc/version)" + kernel_name="vanilla-$os_version" else kernel_name=$1 fi @@ -82,7 +85,7 @@ to_kernel_name() { echo "${kernel_names[$(($1 - 1))]}" return elif [[ "$1" = "default" ]]; then - ker="vanilla-$(< /etc/version)" + ker="vanilla-$os_version" else ker="$1" fi @@ -185,7 +188,7 @@ prune() { echo -n "Do you want to proceed? [N/y]: " read -r ans if [[ "$ans" = "y" || "$ans" = "Y" ]]; then - mapfile -t filenames < <(find "$kernelctl_dir" -path "*vanilla-*.tar.bz2" ! -name vanilla-"$(< /etc/version)".tar.bz2) + mapfile -t filenames < <(find "$kernelctl_dir" -path "*vanilla-*.tar.bz2" ! -name vanilla-"$os_version".tar.bz2) for filename in "${filenames[@]}"; do rm "$filename" done diff --git a/package/kernelctl/package b/package/kernelctl/package index dcfcd5f7d..31acac595 100644 --- a/package/kernelctl/package +++ b/package/kernelctl/package @@ -5,7 +5,7 @@ pkgnames=(kernelctl) pkgdesc="Manage aftermarket kernels" url=https://toltec-dev.org/ -pkgver=0.1-7 +pkgver=0.2-1 timestamp=2022-11-12T00:00Z section="utils" maintainer="Salvatore Stella " @@ -26,15 +26,17 @@ package() { } configure() { - if [[ "$(kernelctl list | tail -n +2 | awk '{print $2}' | grep "vanilla-$(< /etc/version)")" == "" ]]; then + os_version=$(awk -F= '/RELEASE_VERSION/{print $2}' /usr/share/remarkable/update.conf) + if [[ "$(kernelctl list | tail -n +2 | awk '{print $2}' | grep "vanilla-$os_version")" == "" ]]; then echo "Creating a backup of the currently running kernel." kernelctl backup vanilla fi } preremove() { - if [[ "$(kernelctl show | tail -n 1 | grep "vanilla-$(< /etc/version)")" == "" ]]; then - if [[ "$(kernelctl list | tail -n +2 | awk '{print $2}' | grep "vanilla-$(< /etc/version)")" == "" ]]; then + os_version=$(awk -F= '/RELEASE_VERSION/{print $2}' /usr/share/remarkable/update.conf) + if [[ "$(kernelctl show | tail -n 1 | grep "vanilla-$os_version")" == "" ]]; then + if [[ "$(kernelctl list | tail -n +2 | awk '{print $2}' | grep "vanilla-$os_version")" == "" ]]; then echo "Unable to restore default kernel." echo "To force removal, you can run the following:" echo " opkg remove --force-remove kernelctl"