From 68470003a1b319a6179888fa942f0c577c802ffa Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sat, 11 Sep 2021 17:00:53 +0200 Subject: [PATCH] kernel.sh+README: Add option to install --- README.org | 10 ++++++++-- kernel.sh | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index f0041d6..509b90c 100644 --- a/README.org +++ b/README.org @@ -8,6 +8,12 @@ Disables incomplete reports in ~i2c-hid-code.c~ to stop logging spam. * Build instructions #+BEGIN_SRC sh - $ mkdir build - $ ./kernel.sh +$ mkdir build +$ ./kernel.sh +#+END_SRC + +* Install + +#+BEGIN_SRC sh +$ ./kernel.sh install #+END_SRC diff --git a/kernel.sh b/kernel.sh index 12a2a6e..35680c1 100755 --- a/kernel.sh +++ b/kernel.sh @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0-only # # Build the Linux kernel -# Depends: asp, base-devel +# Depends: asp, base-devel, coreutils # Setup # -------------------------------------- @@ -37,6 +37,7 @@ checkDependencies() dependencies=" asp base-devel + coreutils " for dependency in $dependencies; do @@ -74,8 +75,42 @@ build() time makepkg -s } +install() +{ + cdSafe build + + packages="$(find . -name "*.tar.zst" -type f)" + + found="$(echo "$packages" | wc -l)" + if [ "$found" -ne 2 ]; then + echo "${b}${red}Error:${n} kernel was not build yet." >&2 + exit 1 + fi + + if ! sudo -v; then + echo "${b}${red}Error:${n} you cannot perform this operation uness you are root." >&2 + exit 1 + fi + + echo "$packages" | xargs --open-tty sudo pacman -U --needed +} + # Execute # -------------------------------------- checkDependencies -build + +script="$(basename "$0")" +case "$1" in + build | "") + build + ;; + install) + install + ;; + *) + echo "$script: invalid option '$1'" >&2 + echo "Try '$script -h' for more information." >&2 + exit 1 + ;; +esac