git am stamped the time of the run as commit date: two trees from the same pin and patches had the same source (tree d31c6d86f032) but other hashes, and setlocalversion put the hash into the release name (g4db1692fd and g425f6d5c4), so modules of one did not load with the kernel of the other. Now a fixed committer and the patch's author date as commit date: two fresh trees both at 662ea51c5ed9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
2.4 KiB
Bash
66 lines
2.4 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 shared tree at the repository root
|
|
# (../refs/linux/<version>, KERNEL_REF in kernel/PIN) plus the patches.
|
|
#
|
|
# Usage: fetch-kernel.sh DEVICEDIR DESTDIR
|
|
#
|
|
# The shared tree is cloned locally (hardlinks, no network) and must be at
|
|
# KERNEL_COMMIT; a drift is an error, not a silent fetch of something else.
|
|
# A device that names KERNEL_COMMIT but no KERNEL_REF falls back to KERNEL_URL
|
|
# (the old behaviour, for a device built from its own tree).
|
|
# 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:=}" "${KERNEL_REF:=}"
|
|
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
|
|
|
|
if [ -n "$KERNEL_REF" ]; then
|
|
case $KERNEL_REF in
|
|
/*) ref=$KERNEL_REF ;;
|
|
*) ref=$ROOT/../$KERNEL_REF ;;
|
|
esac
|
|
[ -e "$ref/.git" ] || die "$KERNEL_REF missing; run: git submodule update --init --depth 1 $KERNEL_REF"
|
|
have=$(git -C "$ref" rev-parse HEAD) || die "cannot read $KERNEL_REF"
|
|
[ "$have" = "$KERNEL_COMMIT" ] ||
|
|
die "$KERNEL_REF is at $have, kernel/PIN says $KERNEL_COMMIT"
|
|
# local clone: hardlinks, no network, stays shallow
|
|
git clone -q --no-checkout "$ref" "$dest" || die "cannot clone $KERNEL_REF"
|
|
else
|
|
git clone -q --no-checkout "$KERNEL_URL" "$dest"
|
|
fi
|
|
git -C "$dest" checkout -q "$KERNEL_COMMIT"
|
|
# Reproducible commits: a fixed committer and each patch's own date as the
|
|
# commit date, so the same series gives the same commit hashes -- and the
|
|
# same kernel release name (setlocalversion appends -g<hash>), so modules
|
|
# built in one fresh tree load with a kernel built in another. Without it
|
|
# git am stamped the time of the run (2026-11-10: same source tree,
|
|
# release names g4db1692fd and g425f6d5c4).
|
|
for p in "$patchdir"/*.patch; do
|
|
[ -e "$p" ] || break
|
|
GIT_COMMITTER_NAME="Makronix Mobile" \
|
|
GIT_COMMITTER_EMAIL="mobile@makronix.invalid" \
|
|
git -C "$dest" am -q --committer-date-is-author-date "$p" ||
|
|
{ echo "$0: $p does not apply" >&2; exit 1; }
|
|
done
|
|
git -C "$dest" log --oneline -3
|