Files
makronix/mobile/tools/fetch-kernel.sh
T
lotherkandClaude Sonnet 5.5 26258166df mobile: kernel as pin + patches, glibc base (Debian and Void rootfs)
kernel/PIN and kernel/patches replace the external kernel tree: make linux
fetches the pinned commit and applies the patches (source tree identical to
the one that runs on the phone). base/debian and base/void build a glibc
aarch64 root file system without root (mmdebstrap / unshare + xbps).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 11:03:38 +00:00

43 lines
1.3 KiB
Bash

#!/bin/sh
#
# Create the kernel tree for a device: the pinned upstream commit with our
# patches applied on top. The tree is build output (build/linux-<device>),
# never source; the source is the pin and the patches.
#
# Usage: fetch-kernel.sh DEVICEDIR DESTDIR
#
# KERNEL_URL in the environment overrides the pin's URL: point it at a local
# clone to work offline (KERNEL_URL=$HOME/src/nura/sm8150-linux). The commit
# must be in that clone. An existing DESTDIR is left alone.
set -eu
. "$(dirname "$0")/lib.sh"
[ $# -eq 2 ] || { echo "usage: $0 DEVICEDIR DESTDIR" >&2; exit 2; }
load_device "$1"
dest=$2
# the device's own pin, else the shared one
: "${KERNEL_URL:=}" "${KERNEL_COMMIT:=}" "${KERNEL_PATCHDIR:=}"
env_url=$KERNEL_URL
if [ -z "$KERNEL_COMMIT" ]; then
. "$ROOT/kernel/PIN"
fi
[ -z "$env_url" ] || KERNEL_URL=$env_url
patchdir=$ROOT/$KERNEL_PATCHDIR
if [ -e "$dest/.git" ]; then
echo "$dest exists, left alone"
exit 0
fi
git clone -q --no-checkout "$KERNEL_URL" "$dest"
git -C "$dest" checkout -q "$KERNEL_COMMIT"
for p in "$patchdir"/*.patch; do
[ -e "$p" ] || break
git -C "$dest" \
-c user.name="Makronix Mobile" -c user.email="mobile@makronix.invalid" \
am -q "$p" || { echo "$0: $p does not apply" >&2; exit 1; }
done
git -C "$dest" log --oneline -3