Compare commits
11 Commits
18929109a2
...
b75597946d
| Author | SHA1 | Date | |
|---|---|---|---|
| b75597946d | |||
| 018a91e216 | |||
| 0c61a27b06 | |||
| 675ed5eb39 | |||
| 94f60e30b1 | |||
| e8ccb76cc6 | |||
| 4274f876a7 | |||
| 4760c84bff | |||
| 20b3f7f4ec | |||
| f178e39a28 | |||
| c7b954252d |
104
openwrtbuilder
104
openwrtbuilder
@@ -5,7 +5,7 @@
|
|||||||
# See README and ./profiles for device configuration
|
# See README and ./profiles for device configuration
|
||||||
|
|
||||||
# Set default release
|
# Set default release
|
||||||
: "${RELEASE:="24.10.3"}"
|
: "${RELEASE:="24.10.4"}"
|
||||||
|
|
||||||
# @internal
|
# @internal
|
||||||
print_help() {
|
print_help() {
|
||||||
@@ -514,7 +514,29 @@ from_source() {
|
|||||||
local seed_file="$BUILD_DIR/.config"
|
local seed_file="$BUILD_DIR/.config"
|
||||||
local worktree_meta="$SRC_DIR/.git/worktrees/source-$ref"
|
local worktree_meta="$SRC_DIR/.git/worktrees/source-$ref"
|
||||||
local pkg config commit seed_file description
|
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"
|
echo "Building from source is under development"
|
||||||
|
|
||||||
@@ -528,38 +550,43 @@ from_source() {
|
|||||||
[[ -d "$BUILD_DIR" ]] && execute rm -rf "$BUILD_DIR"
|
[[ -d "$BUILD_DIR" ]] && execute rm -rf "$BUILD_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Pull or clone source repo
|
# Fetch or clone source repo (no local merges)
|
||||||
if [[ -d "$SRC_DIR" ]]; then
|
if [[ -d "$SRC_DIR" ]]; then
|
||||||
execute git -C "$SRC_DIR" pull --all --tags --prune
|
execute git -C "$SRC_DIR" fetch origin --tags --prune
|
||||||
else
|
else
|
||||||
execute mkdir -p "$SRC_DIR"
|
execute mkdir -p "$SRC_DIR"
|
||||||
execute git clone "$src_url" "$SRC_DIR"
|
execute git clone "$src_url" "$SRC_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove existing build dir and add new worktree
|
# Reuse worktree if present; otherwise create it (support branches and tags)
|
||||||
if [[ -d "$BUILD_DIR" ]]; then
|
if git -C "$BUILD_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||||
execute rm -rf "$BUILD_DIR"
|
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
|
fi
|
||||||
execute git -C "$SRC_DIR" worktree prune --verbose
|
|
||||||
execute git -C "$SRC_DIR" worktree add --detach "$BUILD_DIR" "origin/$ref"
|
|
||||||
|
|
||||||
# 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
|
for entry in ${P_ARR[cherrypicks]}; do
|
||||||
remote="${entry%%:*}"
|
remote="${entry%%:*}"
|
||||||
commit="${entry##*:}"
|
commit="${entry##*:}"
|
||||||
# Add remote if not present
|
|
||||||
if ! git -C "$BUILD_DIR" remote | grep -q "^$remote$"; then
|
if ! git -C "$BUILD_DIR" remote | grep -q "^$remote$"; then
|
||||||
execute git -C "$BUILD_DIR" remote add "$remote" "https://github.com/$remote/openwrt.git"
|
execute git -C "$BUILD_DIR" remote add "$remote" "https://github.com/$remote/openwrt.git"
|
||||||
fi
|
fi
|
||||||
# Fetch remote
|
|
||||||
execute git -C "$BUILD_DIR" fetch "$remote"
|
execute git -C "$BUILD_DIR" fetch "$remote"
|
||||||
# Cherry-pick commit
|
execute git -C "$BUILD_DIR" merge-base --is-ancestor "$commit" HEAD ||
|
||||||
execute git -C "$BUILD_DIR" cherry-pick "$commit"
|
execute git -C "$BUILD_DIR" cherry-pick "$commit"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Print commit info
|
# Print commit info
|
||||||
commit=$(git -C "$BUILD_DIR" rev-parse HEAD)
|
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 "Current commit hash: $commit"
|
||||||
echo "Git worktree description: $description"
|
echo "Git worktree description: $description"
|
||||||
|
|
||||||
@@ -571,8 +598,15 @@ from_source() {
|
|||||||
# Begin OpenWRT build process
|
# Begin OpenWRT build process
|
||||||
((DEBUG)) && make_opts+=("V=sc")
|
((DEBUG)) && make_opts+=("V=sc")
|
||||||
|
|
||||||
# Cleanup build environment
|
# Cleanup build environment: heavy clean only when --reset was used earlier
|
||||||
execute make "${make_opts[@]}" "-j1" distclean
|
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 clean # compiled output
|
||||||
# make targetclean # compiled output, toolchain
|
# make targetclean # compiled output, toolchain
|
||||||
# make dirclean # compiled output, toolchain, build tools
|
# make dirclean # compiled output, toolchain, build tools
|
||||||
@@ -585,15 +619,6 @@ from_source() {
|
|||||||
./scripts/feeds update -a -f &&
|
./scripts/feeds update -a -f &&
|
||||||
./scripts/feeds install -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
|
|
||||||
|
|
||||||
# Set compilation output dir
|
|
||||||
config_opts+=("CONFIG_BINARY_FOLDER=\"$BIN_DIR\"")
|
|
||||||
|
|
||||||
# Add custom packages
|
# Add custom packages
|
||||||
for pkg in $PACKAGES; do
|
for pkg in $PACKAGES; do
|
||||||
if [[ $pkg == -* ]]; then
|
if [[ $pkg == -* ]]; then
|
||||||
@@ -603,32 +628,11 @@ from_source() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Add config options from profile
|
# Add profile config options
|
||||||
for config in ${P_ARR[config]}; do
|
for config in ${P_ARR[config]}; do
|
||||||
config_opts+=("$config")
|
config_opts+=("$config")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Only compile selected fs
|
|
||||||
execute sed -i '/CONFIG_TARGET_ROOTFS_/d' "$seed_file"
|
|
||||||
config_opts+=("CONFIG_TARGET_PER_DEVICE_ROOTFS=n")
|
|
||||||
if [[ $FILESYSTEM == "squashfs" ]]; then
|
|
||||||
config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=n")
|
|
||||||
config_opts+=("CONFIG_TARGET_ROOTFS_SQUASHFS=y")
|
|
||||||
elif [[ $FILESYSTEM == "ext4" ]]; then
|
|
||||||
config_opts+=("CONFIG_TARGET_ROOTFS_SQUASHFS=n")
|
|
||||||
config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=y")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Only compile selected target image
|
|
||||||
execute sed -i '/CONFIG_TARGET_DEVICE_/d' "$seed_file"
|
|
||||||
config_opts+=("CONFIG_TARGET_MULTI_PROFILE=n")
|
|
||||||
config_opts+=("CONFIG_TARGET_PROFILE=DEVICE_$DEVICE")
|
|
||||||
config_opts+=("CONFIG_TARGET_${TARGET//\//_}_DEVICE_$DEVICE=y")
|
|
||||||
config_opts+=("CONFIG_SDK=n")
|
|
||||||
config_opts+=("CONFIG_SDK_LLVM_BPF=n")
|
|
||||||
config_opts+=("CONFIG_IB=n")
|
|
||||||
config_opts+=("CONFIG_MAKE_TOOLCHAIN=n")
|
|
||||||
|
|
||||||
# Write options to config seed file
|
# Write options to config seed file
|
||||||
for config in "${config_opts[@]}"; do
|
for config in "${config_opts[@]}"; do
|
||||||
debug "Writing $config to $seed_file"
|
debug "Writing $config to $seed_file"
|
||||||
@@ -642,14 +646,14 @@ from_source() {
|
|||||||
((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)-2))")
|
((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)-2))")
|
||||||
|
|
||||||
# Make image
|
# Make image
|
||||||
if ! execute ionice -c 3 chrt --idle 0 nice -n19 make "${make_opts[@]}" download world; then
|
if ! execute ionice -c 3 chrt --idle 0 nice -n19 make "${make_opts[@]}" BIN_DIR="$BIN_DIR" download world; then
|
||||||
echo "Error: make failed"
|
echo "Error: make failed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
execute popd || return 1
|
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
|
shopt -s nullglob
|
||||||
for image in "$BIN_DIR/targets/${TARGET}/"*.{img,img.gz,ubi}; do
|
for image in "$BIN_DIR/targets/${TARGET}/"*.{img,img.gz,ubi}; do
|
||||||
execute ln -fs "$image" "$BIN_DIR/${image##*/}"
|
execute ln -fs "$image" "$BIN_DIR/${image##*/}"
|
||||||
|
|||||||
3
profiles
3
profiles
@@ -9,7 +9,8 @@ default_packages=(nano htop diffutils tar iperf3 zsh rsync curl tcpdump
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Default (but optional) kernel configs
|
# Default (but optional) kernel configs
|
||||||
default_configs=("CONFIG_BUILDBOT=n")
|
default_configs=(
|
||||||
|
)
|
||||||
|
|
||||||
# Current devices
|
# Current devices
|
||||||
declare -Ag r4s=(
|
declare -Ag r4s=(
|
||||||
|
|||||||
Reference in New Issue
Block a user