aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-08-07 23:49:49 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-08-07 23:49:49 +0200
commite211f27ba1f5b7b68812f7442575842784f80b71 (patch)
tree3fcf4b9ebd3eb29408c09f55004024c4004bc182
parent7acce7b6abf85df85468c527f0453e4e3f9e65e5 (diff)
downloaddotfiles-e211f27ba1f5b7b68812f7442575842784f80b71.tar.gz
dotfiles-e211f27ba1f5b7b68812f7442575842784f80b71.zip
kbuild: provide uninstall.sh and files.txt files
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
-rwxr-xr-xbin/kbuild30
1 files changed, 29 insertions, 1 deletions
diff --git a/bin/kbuild b/bin/kbuild
index e5db4b7..ffbcee8 100755
--- a/bin/kbuild
+++ b/bin/kbuild
@@ -135,7 +135,14 @@ cp .config "$INSTALL_PATH/boot/config-$name"
##
# Setup install.sh script.
-cat <<SCRIPT > "$INSTALL_PATH/install.sh"
+# Files that are going to be installed. Funnily enough, the pipeline will create
+# the "files.txt" first, so it will show on the `find` output. Hence the stupid
+# workaround you see of moving it in later.
+find "$INSTALL_PATH" -type f -printf "/%P\n" >files.txt
+mv files.txt "$INSTALL_PATH/files.txt"
+
+# Now write the actual install script.
+cat <<SCRIPT >"$INSTALL_PATH/install.sh"
#!/usr/bin/env bash
set -ex
@@ -167,6 +174,27 @@ fi
\$EDITOR /boot/extlinux/extlinux.conf
SCRIPT
+# And the uninstall script.
+cat <<SCRIPT >"$INSTALL_PATH/uninstall.sh"
+#!/usr/bin/env bash
+
+set -ex
+
+if [ "\$EUID" -ne 0 ];then
+ echo "kbuild (error): run this as root."
+ exit 1
+fi
+
+if [ ! -f files.txt ]; then
+ echo "kbuild (error): there must be a 'files.txt' file."
+ exit 1
+fi
+
+xargs rm -f < files.txt
+rmdir /boot/dtbs/$name
+rmdir /usr/lib/modules/$name
+SCRIPT
+
##
# Create tarball.