Compare commits

...

3 Commits

Author SHA1 Message Date
018a91e216 Introduce reusable worktrees 2025-10-22 19:31:58 -04:00
0c61a27b06 Reorganize from_source() 2025-10-22 19:25:59 -04:00
675ed5eb39 Abandon upstream seed, untenable 2025-10-22 19:11:51 -04:00

View File

@@ -5,7 +5,7 @@
# See README and ./profiles for device configuration
# Set default release
: "${RELEASE:="24.10.3"}"
: "${RELEASE:="24.10.4"}"
# @internal
print_help() {
@@ -514,7 +514,29 @@ from_source() {
local seed_file="$BUILD_DIR/.config"
local worktree_meta="$SRC_DIR/.git/worktrees/source-$ref"
local pkg config commit seed_file description
local -a make_opts config_opts
local -a make_opts
local -a config_opts=(
"CONFIG_TARGET_${TARGET//\//_}=y"
"CONFIG_TARGET_${TARGET//\//_}_${TARGET##*/}=y"
"CONFIG_TARGET_PROFILE=DEVICE_$DEVICE"
"CONFIG_TARGET_${TARGET//\//_}_DEVICE_$DEVICE=y"
"CONFIG_TARGET_ROOTFS_${FILESYSTEM^^}=y"
# Needed?
"CONFIG_TARGET_MULTI_PROFILE=n"
# Not sure if needed yet
"CONFIG_BUILDBOT=n"
"CONFIG_ALL_KMODS=n"
"CONFIG_ALL_NONSHARED=n"
"CONFIG_DEVEL=n"
"CONFIG_COLLECT_KERNEL_DEBUG=n"
"CONFIG_SDK=n"
"CONFIG_SDK_LLVM_BPF=n"
"CONFIG_IB=n"
"CONFIG_MAKE_TOOLCHAIN=n"
"CONFIG_TARGET_PER_DEVICE_ROOTFS=n"
)
echo "Building from source is under development"
@@ -536,29 +558,35 @@ from_source() {
execute git clone "$src_url" "$SRC_DIR"
fi
# Recreate worktree from the remote ref
execute git -C "$SRC_DIR" worktree remove --force "$BUILD_DIR" || true
execute rm -rf "$BUILD_DIR"
execute git -C "$SRC_DIR" worktree prune --verbose
execute git -C "$SRC_DIR" worktree add --detach "$BUILD_DIR" "origin/$ref"
if [[ -d "$BUILD_DIR/.git" ]]; then
# Keep worktree and reset to desired ref (handles branches and tags)
execute git -C "$BUILD_DIR" fetch origin --tags --prune
execute git -C "$BUILD_DIR" reset --hard "origin/$ref" ||
execute git -C "$BUILD_DIR" reset --hard "$ref" ||
execute git -C "$BUILD_DIR" checkout --detach "$ref"
else
execute git -C "$SRC_DIR" worktree prune --verbose
# Prefer local tag/branch if present, otherwise use remote-tracking branch
if ! execute git -C "$SRC_DIR" worktree add --detach "$BUILD_DIR" "$ref"; then
execute git -C "$SRC_DIR" worktree add --detach "$BUILD_DIR" "origin/$ref"
fi
fi
# Add cherrypick commits if specified in profile
# Add cherrypick commits if specified in profile (skip if already included)
for entry in ${P_ARR[cherrypicks]}; do
remote="${entry%%:*}"
commit="${entry##*:}"
# Add remote if not present
if ! git -C "$BUILD_DIR" remote | grep -q "^$remote$"; then
execute git -C "$BUILD_DIR" remote add "$remote" "https://github.com/$remote/openwrt.git"
fi
# Fetch remote
execute git -C "$BUILD_DIR" fetch "$remote"
# Cherry-pick commit
execute git -C "$BUILD_DIR" cherry-pick "$commit"
execute git -C "$BUILD_DIR" merge-base --is-ancestor "$commit" HEAD ||
execute git -C "$BUILD_DIR" cherry-pick "$commit"
done
# Print commit info
commit=$(git -C "$BUILD_DIR" rev-parse HEAD)
description=$(git -C "$BUILD_DIR" describe)
description=$(git -C "$BUILD_DIR" describe --always --dirty)
echo "Current commit hash: $commit"
echo "Git worktree description: $description"
@@ -570,8 +598,15 @@ from_source() {
# Begin OpenWRT build process
((DEBUG)) && make_opts+=("V=sc")
# Cleanup build environment
execute make "${make_opts[@]}" "-j1" distclean
# Cleanup build environment: heavy clean only when --reset was used earlier
if ((RESET)); then
execute make "${make_opts[@]}" "-j1" distclean
else
debug "Skipping distclean for incremental build"
fi
# Advanced build environment cleanup options for debugging and future use
# execute make "${make_opts[@]}" "-j1" distclean
# make clean # compiled output
# make targetclean # compiled output, toolchain
# make dirclean # compiled output, toolchain, build tools
@@ -584,12 +619,6 @@ from_source() {
./scripts/feeds update -a -f &&
./scripts/feeds install -a -f
# Grab the release seed config
if ! execute "$DL_TOOL" "-o" "$seed_file" "$seed_url"; then
echo "Could not obtain $seed_file from $seed_url"
return 1
fi
# Add custom packages
for pkg in $PACKAGES; do
if [[ $pkg == -* ]]; then
@@ -599,41 +628,6 @@ from_source() {
fi
done
# Disable unecessary buildbot config options
config_opts+=(
"CONFIG_BUILDBOT=n"
"CONFIG_ALL_KMODS=n"
"CONFIG_ALL_NONSHARED=n"
"CONFIG_DEVEL=n"
"CONFIG_COLLECT_KERNEL_DEBUG=n"
"CONFIG_SDK=n"
"CONFIG_SDK_LLVM_BPF=n"
"CONFIG_IB=n"
"CONFIG_MAKE_TOOLCHAIN=n"
)
# Only compile selected fs
execute sed -i '/CONFIG_TARGET_ROOTFS_/d' "$seed_file"
config_opts+=("CONFIG_TARGET_PER_DEVICE_ROOTFS=n")
case "$FILESYSTEM" in
squashfs) config_opts+=(
"CONFIG_TARGET_ROOTFS_EXT4FS=n"
"CONFIG_TARGET_ROOTFS_SQUASHFS=y"
) ;;
ext4) config_opts+=(
"CONFIG_TARGET_ROOTFS_SQUASHFS=n"
"CONFIG_TARGET_ROOTFS_EXT4FS=y"
) ;;
esac
# Only compile selected target image
execute sed -i '/CONFIG_TARGET_DEVICE_/d' "$seed_file"
config_opts+=(
"CONFIG_TARGET_MULTI_PROFILE=n"
"CONFIG_TARGET_PROFILE=DEVICE_$DEVICE"
"CONFIG_TARGET_${TARGET//\//_}_DEVICE_$DEVICE=y"
)
# Add profile config options
for config in ${P_ARR[config]}; do
config_opts+=("$config")
@@ -659,7 +653,7 @@ from_source() {
execute popd || return 1
# Symlink output images to root of BIN_DIR (match Image Builder)
# Symlink output images to root of BIN_DIR (match Image Builder behavior)
shopt -s nullglob
for image in "$BIN_DIR/targets/${TARGET}/"*.{img,img.gz,ubi}; do
execute ln -fs "$image" "$BIN_DIR/${image##*/}"