aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-02-26 14:35:49 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2026-02-27 08:04:49 +0100
commitea1d180a628f146aae4e321fe545fcddb2d577c7 (patch)
tree16c2ce16de2534309aab6b94a08b6755bcdff89f
parent0769b677606210d6294358a0824a8908b55adba2 (diff)
downloaddotfiles-ea1d180a628f146aae4e321fe545fcddb2d577c7.tar.gz
dotfiles-ea1d180a628f146aae4e321fe545fcddb2d577c7.zip
kbuild: add the '-l/--local' flag
This allows you to define that you are planning to deploy things in your current development box. This means that ARCH has to match whatever is currently on your system, and CROSS_COMPILE is needed. Moreover, we don't need an installation bundle, but we just need the install.sh/uninstall.sh scripts. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rwxr-xr-xbin/kbuild39
1 files changed, 36 insertions, 3 deletions
diff --git a/bin/kbuild b/bin/kbuild
index d60ed8f..6bd8dd5 100755
--- a/bin/kbuild
+++ b/bin/kbuild
@@ -30,7 +30,8 @@
# `.config` file again and again.
# 2. `--skip-install`: don't generate the install/uninstall files.
# 3. `-p/--profile`: the kind of machine you are building the kernel for.
-# 4. `-h/--help`: show the help message.
+# 4. `-l/--local`: this is a local build, just generate install/uninstall scripts.
+# 5. `-h/--help`: show the help message.
#
# After that just send the resulting tarball to the machine where you want to
# install this kernel. In there you just need to untar the given bundle and then
@@ -68,6 +69,10 @@ while [[ $# -gt 0 ]]; do
PROFILE="$2"
shift 2
;;
+ -l | --local)
+ IS_LOCAL=1
+ shift
+ ;;
-h | --help)
SHOW_HELP=1
shift
@@ -93,6 +98,7 @@ following options:
-h, --help Show this message.
-p, --profile The profile to be picked up (values: debian, suse).
+ -l, --local This is a local build, just generatel install/uninstall files.
--skip-install Don't generate the install/uninstall files.
--skip-config Skip the configuration step.
HERE
@@ -116,7 +122,15 @@ fi
##
# Initial checks.
-# Most of the times, we are safer if we just set the `ARCH` env. variable.
+# If this is a local build, then force `ARCH` To match the current system's
+# architecture and unset any `CROSS_COMPILE` business.
+if [ ! -z "$IS_LOCAL" ]; then
+ ARCH="$(uname -m)"
+ unset CROSS_COMPILE
+fi
+
+# Most of the times, we are safer if we just set the `ARCH` environment
+# variable.
if [ -z "$ARCH" ]; then
echo "kbuild (error): \$ARCH has to be defined."
exit 1
@@ -167,7 +181,7 @@ echo "kbuild (info): building the Linux kernel..."
make -j "$(nproc)"
##
-# Installing into a local bundle.
+# Installing.
if [ -n "$NO_INSTALL" ]; then
echo "kbuild (info): done!"
@@ -176,6 +190,25 @@ fi
name=$(cat include/config/kernel.release)
+if [ ! -z "$IS_LOCAL" ]; then
+ # Just generate install/uninstall scripts and go.
+
+ cp "$HOME/.config/kbuild/$PROFILE/install.sh" install.sh
+ sed -i "s/\$name/$name/g" install.sh
+ chmod +x install.sh
+
+ cp "$HOME/.config/kbuild/$PROFILE/uninstall.sh" uninstall.sh
+ sed -i "s/\$name/$name/g" uninstall.sh
+ chmod +x uninstall.sh
+
+ echo "kbuild (info): generated 'install.sh' and 'uninstall.sh'."
+
+ exit 0
+fi
+
+##
+# Into a bundle.
+
if [ -z "$INSTALL_PATH" ]; then
INSTALL_PATH="buildroot-$name"
fi