Compare commits
27 Commits
a664b70cf4
...
6f1bc4dd00
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f1bc4dd00 | |||
| 5d434f031d | |||
| 25b5623a65 | |||
| 20477c21ab | |||
| 8ed85fff2b | |||
| ab8f58ca92 | |||
| 20e11b7419 | |||
| 11c28c7ab3 | |||
| 908664b185 | |||
| 40ce9940ae | |||
| 64ffeeca17 | |||
| 0106ac7eff | |||
| 86f5bf7e3f | |||
| a18d467c4f | |||
| 3a659b4798 | |||
| 7f996e7724 | |||
| 3688539a90 | |||
| c28d7683d8 | |||
| a5b559c59c | |||
| d22d21148c | |||
| 2b4dac7ef3 | |||
| 498f8a7333 | |||
| d28f2e8c31 | |||
| ca3f1e82ed | |||
| 4b66de068b | |||
| 1e88f1b912 | |||
| cbe7e0468d |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
src/
|
||||
bin/
|
||||
.vscode/
|
||||
*.code-workspace
|
||||
backups/
|
||||
.dependencies_source
|
||||
.dependencies_ib
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# openwrtbuilder
|
||||
|
||||
Build and deploy OpenWRT images using convenient profiles.
|
||||
Build and deploy OpenWRT images using convenient shell-style device profiles.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -47,8 +47,8 @@ See `profiles` for example device profile definitions.
|
||||
|
||||
## Additional Info
|
||||
|
||||
Did you find `openwrtbuilder` useful? [Buy me a coffee!](https://paypal.me/bryanroessler)
|
||||
Find `openwrtbuilder` useful? [Paypal me a coffee!](https://paypal.me/bryanroessler)
|
||||
|
||||
[↓ ↓ ↓ Bitcoin ↓ ↓ ↓](bitcoin:bc1q7wy0kszjavgcrvkxdg7mf3s6rh506rasnhfa4a)
|
||||
|
||||
[](bitcoin:bc1q7wy0kszjavgcrvkxdg7mf3s6rh506rasnhfa4a)
|
||||
[](bitcoin:bc1q7wy0kszjavgcrvkxdg7mf3s6rh506rasnhfa4a)
|
||||
|
||||
505
openwrtbuilder
505
openwrtbuilder
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds and deploys OpenWRT images
|
||||
# Build and deploy OpenWRT images using convenient shell-style device profiles.
|
||||
# Copyright 2022-25 Bryan C. Roessler
|
||||
# Apache 2.0 License
|
||||
# See README and profiles for device configuration
|
||||
@@ -158,161 +158,208 @@ parse_input() {
|
||||
}
|
||||
|
||||
# @description Install build dependencies on major distros
|
||||
# @arg $1 string Build mode ("source" or "imagebuilder")
|
||||
install_dependencies() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
local mode="$1"
|
||||
local -a pkg_list
|
||||
local lock_file
|
||||
if ((FROM_SOURCE)); then
|
||||
lock_file="$BUILD_ROOT/.dependencies_source"
|
||||
else
|
||||
lock_file="$BUILD_ROOT/.dependencies_ib"
|
||||
|
||||
# Set appropriate lock file based on mode
|
||||
if [[ "$mode" == "source" ]]; then
|
||||
lock_file="$BUILD_ROOT/.dependencies_source.lock"
|
||||
elif [[ "$mode" == "imagebuilder" ]]; then
|
||||
lock_file="$BUILD_ROOT/.dependencies_ib.lock"
|
||||
fi
|
||||
|
||||
if ((FORCE_DEPENDS)) || [[ ! -f $lock_file ]]; then
|
||||
if ((FROM_SOURCE)); then
|
||||
# For building from source code see:
|
||||
# https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem
|
||||
case "$ID" in
|
||||
fedora|centos)
|
||||
pkg_list+=(
|
||||
bzip2
|
||||
clang # for qosify
|
||||
diffutils
|
||||
gcc
|
||||
gcc-c++
|
||||
git
|
||||
llvm15-libs # for qosify
|
||||
make
|
||||
ncurses-devel
|
||||
patch
|
||||
perl
|
||||
perl-Data-Dumper
|
||||
perl-File-Compare
|
||||
perl-File-Copy
|
||||
perl-FindBin
|
||||
perl-IPC-Cmd
|
||||
perl-JSON-PP
|
||||
perl-Thread-Queue
|
||||
perl-Time-Piece
|
||||
perl-base
|
||||
python3
|
||||
python3-devel
|
||||
python3-pyelftools
|
||||
python3-setuptools
|
||||
rsync
|
||||
swig
|
||||
tar
|
||||
unzip
|
||||
wget
|
||||
which
|
||||
) ;;
|
||||
debian|ubuntu)
|
||||
pkg_list+=(
|
||||
build-essential
|
||||
clang
|
||||
file
|
||||
flex
|
||||
g++
|
||||
gawk
|
||||
gcc-multilib
|
||||
gettext
|
||||
git
|
||||
liblzma-dev
|
||||
libncurses5-dev
|
||||
libssl-dev
|
||||
python3-distutils
|
||||
rsync
|
||||
patch
|
||||
unzip
|
||||
wget
|
||||
zlib1g-dev
|
||||
) ;;
|
||||
arch)
|
||||
pkg_list+=(
|
||||
autoconf
|
||||
automake
|
||||
base-devel
|
||||
bash
|
||||
binutils
|
||||
bison
|
||||
bzip2
|
||||
clang
|
||||
fakeroot
|
||||
file
|
||||
findutils
|
||||
flex
|
||||
gawk
|
||||
gcc
|
||||
gettext
|
||||
git
|
||||
grep
|
||||
groff
|
||||
gzip
|
||||
libelf
|
||||
libtool
|
||||
libxslt
|
||||
m4
|
||||
make
|
||||
ncurses
|
||||
net-snmp
|
||||
openssl
|
||||
patch
|
||||
pkgconf
|
||||
python
|
||||
rsync
|
||||
sed
|
||||
texinfo
|
||||
time
|
||||
unzip
|
||||
util-linux
|
||||
wget
|
||||
which
|
||||
xz
|
||||
zlib
|
||||
) ;;
|
||||
*) debug "Unsupported OS, skipping dependencies"; return 1 ;;
|
||||
esac
|
||||
else
|
||||
# For Imagebuilder
|
||||
case "$ID" in
|
||||
fedora|centos)
|
||||
pkg_list+=(
|
||||
@c-development
|
||||
@development-tools
|
||||
@development-libs
|
||||
perl-FindBin
|
||||
zlib-static
|
||||
elfutils-libelf-devel
|
||||
gawk
|
||||
unzip
|
||||
file
|
||||
wget
|
||||
python3
|
||||
axel
|
||||
perl-IPC-Cmd
|
||||
zstd) ;;
|
||||
debian|ubuntu)
|
||||
pkg_list+=(
|
||||
build-essential
|
||||
libncurses5-dev
|
||||
libncursesw5-dev
|
||||
zlib1g-dev
|
||||
gawk
|
||||
git
|
||||
gettext
|
||||
libssl-dev
|
||||
xsltproc
|
||||
wget
|
||||
unzip
|
||||
python
|
||||
axel
|
||||
zstd) ;;
|
||||
*) debug "Unsupported OS for automatic dependency install"; return 1 ;;
|
||||
esac
|
||||
fi
|
||||
[[ -f $lock_file ]] && debug "$lock_file lock file exists" && return 0
|
||||
|
||||
pkg_install "${pkg_list[@]}" && echo "${pkg_list[@]}" > "$lock_file"
|
||||
if [[ "$mode" == "source" ]]; then
|
||||
# For building from source code see:
|
||||
# https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem
|
||||
case "$ID" in
|
||||
fedora|centos)
|
||||
pkg_list+=(
|
||||
bzip2
|
||||
clang # for qosify
|
||||
diffutils
|
||||
gcc
|
||||
gcc-c++
|
||||
git
|
||||
llvm15-libs # for qosify
|
||||
make
|
||||
ncurses-devel
|
||||
patch
|
||||
perl
|
||||
perl-Data-Dumper
|
||||
perl-File-Compare
|
||||
perl-File-Copy
|
||||
perl-FindBin
|
||||
perl-IPC-Cmd
|
||||
perl-JSON-PP
|
||||
perl-Thread-Queue
|
||||
perl-Time-Piece
|
||||
perl-base
|
||||
python3
|
||||
python3-devel
|
||||
python3-pyelftools
|
||||
python3-setuptools
|
||||
rsync
|
||||
swig
|
||||
tar
|
||||
unzip
|
||||
wget
|
||||
which
|
||||
) ;;
|
||||
debian|ubuntu)
|
||||
pkg_list+=(
|
||||
build-essential
|
||||
clang
|
||||
file
|
||||
flex
|
||||
g++
|
||||
gawk
|
||||
gcc-multilib
|
||||
gettext
|
||||
git
|
||||
liblzma-dev
|
||||
libncurses5-dev
|
||||
libssl-dev
|
||||
python3-distutils
|
||||
rsync
|
||||
patch
|
||||
unzip
|
||||
wget
|
||||
zlib1g-dev
|
||||
) ;;
|
||||
arch)
|
||||
pkg_list+=(
|
||||
autoconf
|
||||
automake
|
||||
base-devel
|
||||
bash
|
||||
binutils
|
||||
bison
|
||||
bzip2
|
||||
clang
|
||||
fakeroot
|
||||
file
|
||||
findutils
|
||||
flex
|
||||
gawk
|
||||
gcc
|
||||
gettext
|
||||
git
|
||||
grep
|
||||
groff
|
||||
gzip
|
||||
libelf
|
||||
libtool
|
||||
libxslt
|
||||
m4
|
||||
make
|
||||
ncurses
|
||||
net-snmp
|
||||
openssl
|
||||
patch
|
||||
pkgconf
|
||||
python
|
||||
rsync
|
||||
sed
|
||||
texinfo
|
||||
time
|
||||
unzip
|
||||
util-linux
|
||||
wget
|
||||
which
|
||||
xz
|
||||
zlib
|
||||
) ;;
|
||||
*) debug "Unsupported OS, skipping dependency install"; return 1 ;;
|
||||
esac
|
||||
elif [[ "$mode" == "imagebuilder" ]]; then
|
||||
# For Imagebuilder
|
||||
case "$ID" in
|
||||
fedora|centos)
|
||||
pkg_list+=(
|
||||
@c-development
|
||||
@development-tools
|
||||
@development-libs
|
||||
perl-FindBin
|
||||
zlib-static
|
||||
elfutils-libelf-devel
|
||||
gawk
|
||||
unzip
|
||||
file
|
||||
wget
|
||||
python3
|
||||
axel
|
||||
perl-IPC-Cmd
|
||||
zstd) ;;
|
||||
debian|ubuntu)
|
||||
pkg_list+=(
|
||||
build-essential
|
||||
libncurses5-dev
|
||||
libncursesw5-dev
|
||||
zlib1g-dev
|
||||
gawk
|
||||
git
|
||||
gettext
|
||||
libssl-dev
|
||||
xsltproc
|
||||
wget
|
||||
unzip
|
||||
python
|
||||
axel
|
||||
zstd) ;;
|
||||
*) debug "Unsupported OS, skipping dependency install"; return 1 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
pkg_install "${pkg_list[@]}" && echo "${pkg_list[@]}" > "$lock_file"
|
||||
}
|
||||
|
||||
# @description Normalize release and set worktree reference
|
||||
# @arg $1 string Raw release input
|
||||
# @arg $2 string Build mode ("source" or "imagebuilder")
|
||||
# @returns string Normalized release and reference
|
||||
normalize_and_ref() {
|
||||
local input="$1" mode="$2"
|
||||
local rel ref branch tag
|
||||
|
||||
case "$input" in
|
||||
snapshot|latest|main|master)
|
||||
rel="snapshot"
|
||||
ref="main"
|
||||
;;
|
||||
v[0-9][0-9].[0-9][0-9].*|[0-9][0-9].[0-9][0-9].*)
|
||||
# strip optional leading “v”
|
||||
rel="${input#v}"
|
||||
if [[ "$mode" == "source" ]]; then
|
||||
branch="openwrt-${rel%.*}"
|
||||
tag="v$rel"
|
||||
if ask_ok "Use branch $branch HEAD (y) or tag $tag (n)?"; then
|
||||
ref="$branch"
|
||||
else
|
||||
ref="$tag"
|
||||
fi
|
||||
else
|
||||
ref="$rel"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [[ "$mode" == "source" ]]; then
|
||||
# arbitrary commit-ish allowed
|
||||
rel="$input"
|
||||
ref="$input"
|
||||
else
|
||||
echo "Error: invalid release '$input'" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
printf '%s %s' "$rel" "$ref"
|
||||
}
|
||||
|
||||
# @description Acquires the OpenWRT Image Builder
|
||||
@@ -337,17 +384,6 @@ get_imagebuilder() {
|
||||
done
|
||||
}
|
||||
|
||||
add_repos() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
|
||||
if [[ -v P_ARR[repo] ]]; then
|
||||
if ! grep -q "${P_ARR[repo]}" "$BUILD_DIR/repositories.conf"; then
|
||||
echo "${P_ARR[repo]}" >> "$BUILD_DIR/repositories.conf"
|
||||
fi
|
||||
sed -i '/option check_signature/d' "$BUILD_DIR/repositories.conf"
|
||||
fi
|
||||
}
|
||||
|
||||
ssh_backup() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
local date hostname backup_fname
|
||||
@@ -461,84 +497,61 @@ ssh_upgrade() {
|
||||
# @description Builds OpenWRT from source code using the the default buildbot as base
|
||||
# This enables the use of kernel config options in profiles
|
||||
# @arg $1 string .config seed URL
|
||||
# @arg $2 string Profile name
|
||||
# @arg $3 string Worktree ref (commit-ish or branch name)
|
||||
from_source() {
|
||||
debug "${FUNCNAME[0]}" "$*"
|
||||
local seed_url="$1"
|
||||
local profile="$2"
|
||||
local ref="$3"
|
||||
local src_url="https://github.com/openwrt/openwrt.git"
|
||||
local seed_file="$WORKTREE_DIR/.config"
|
||||
local worktree_name; worktree_name="$(basename "$WORKTREE_DIR")"
|
||||
local worktree_meta="$SRC_DIR/.git/worktrees/$worktree_name"
|
||||
local pkg config commit seed_file wt_commit description
|
||||
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
|
||||
|
||||
echo "Building from source is under development"
|
||||
|
||||
if ((DEBUG)); then
|
||||
echo "Profile settings:"
|
||||
for x in "${!P_ARR[@]}"; do printf "%s=%s\n" "$x" "${P_ARR[$x]}"; done
|
||||
echo "Environment variables:"
|
||||
declare -p
|
||||
fi
|
||||
|
||||
# Remove all build directories and worktrees
|
||||
if ((RESET)); then
|
||||
if [[ -d "$WORKTREE_DIR" || -d "$worktree_meta" ]]; then
|
||||
execute git -C "$SRC_DIR" worktree remove --force --force "$WORKTREE_DIR"
|
||||
[[ -d "$WORKTREE_DIR" ]] && execute rm -rf "$WORKTREE_DIR"
|
||||
if [[ -d "$BUILD_DIR" || -d "$worktree_meta" ]]; then
|
||||
execute git -C "$SRC_DIR" worktree remove --force --force "$BUILD_DIR"
|
||||
[[ -d "$BUILD_DIR" ]] && execute rm -rf "$BUILD_DIR"
|
||||
[[ -d "$worktree_meta" ]] && execute rm -rf "$worktree_meta"
|
||||
fi
|
||||
[[ -d "$BUILD_DIR" ]] && execute rm -rf "$BUILD_DIR"
|
||||
fi
|
||||
|
||||
# Update source code
|
||||
if [[ ! -d "$SRC_DIR" ]]; then
|
||||
# Pull or clone source repo
|
||||
if [[ -d "$SRC_DIR" ]]; then
|
||||
execute git -C "$SRC_DIR" pull
|
||||
else
|
||||
execute mkdir -p "$SRC_DIR"
|
||||
execute git clone "$src_url" "$SRC_DIR"
|
||||
fi
|
||||
|
||||
execute git -C "$SRC_DIR" worktree prune --verbose
|
||||
execute git -C "$SRC_DIR" pull
|
||||
|
||||
# Generate commitish for git worktree
|
||||
case "$RELEASE" in
|
||||
snapshot) wt_commit="origin/main" ;;
|
||||
[0-9][0-9].[0-9][0-9].*)
|
||||
local branch="openwrt-${RELEASE%.*}"
|
||||
local tag="v$RELEASE"
|
||||
if ask_ok "Use $branch branch HEAD (y, recommended) or $tag tag (n)?"; then
|
||||
wt_commit="origin/$branch"
|
||||
else
|
||||
wt_commit="$tag"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
debug "Passing '$RELEASE' commit-ish to git worktree"
|
||||
wt_commit="$RELEASE"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Pull existing or add new git worktree
|
||||
if [[ -d "$WORKTREE_DIR" && -d "$worktree_meta" ]]; then
|
||||
execute git -C "$WORKTREE_DIR" checkout "$wt_commit"
|
||||
execute git -C "$WORKTREE_DIR" pull
|
||||
else
|
||||
[[ -d "$WORKTREE_DIR" ]] && execute rm -rf "$WORKTREE_DIR"
|
||||
[[ -d "$worktree_meta" ]] && execute rm -rf "$worktree_meta"
|
||||
execute git -C "$SRC_DIR" worktree add --force --force --detach "$WORKTREE_DIR" "$wt_commit"
|
||||
# Remove existing build dir and add new worktree
|
||||
if [[ -d "$BUILD_DIR" ]]; then
|
||||
execute rm -rf "$BUILD_DIR"
|
||||
fi
|
||||
execute git -C "$SRC_DIR" worktree prune --verbose
|
||||
execute git -C "$SRC_DIR" worktree add "$BUILD_DIR" "$ref"
|
||||
|
||||
# Print commit information
|
||||
commit=$(git -C "$WORKTREE_DIR" rev-parse HEAD)
|
||||
description=$(git -C "$WORKTREE_DIR" describe)
|
||||
# Print commit info
|
||||
commit=$(git -C "$BUILD_DIR" rev-parse HEAD)
|
||||
description=$(git -C "$BUILD_DIR" describe)
|
||||
echo "Current commit hash: $commit"
|
||||
echo "Git worktree description: $description"
|
||||
|
||||
((DEBUG)) && git --no-pager -C "$WORKTREE_DIR" log -1
|
||||
|
||||
((DEBUG)) && git --no-pager -C "$BUILD_DIR" log -1
|
||||
|
||||
# Enter worktree
|
||||
execute pushd "$WORKTREE_DIR" || return 1
|
||||
execute pushd "$BUILD_DIR" || return 1
|
||||
|
||||
# Begin OpenWRT build process
|
||||
((DEBUG)) && make_opts+=("V=sc")
|
||||
|
||||
# Cleanup build environment
|
||||
((DEBUG)) && make_opts+=("V=sc")
|
||||
execute make "${make_opts[@]}" "-j1" distclean
|
||||
# make clean # compiled output
|
||||
# make targetclean # compiled output, toolchain
|
||||
@@ -602,9 +615,11 @@ from_source() {
|
||||
echo "$config" >> "$seed_file"
|
||||
done
|
||||
|
||||
# Make prep
|
||||
# Serial make prep is more reliable
|
||||
execute make "${make_opts[@]}" "-j1" defconfig
|
||||
execute make "${make_opts[@]}" "-j1" download
|
||||
|
||||
# make_opts+=("-j$(($(nproc)-1))")
|
||||
((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)-1))")
|
||||
|
||||
# Make image
|
||||
@@ -633,7 +648,7 @@ backup() {
|
||||
local file="$1" dir="$2"
|
||||
local creation_date base_name backup_file
|
||||
|
||||
[[ -f $file ]] || { debug "File not found: $file"; return 1; }
|
||||
[[ -f $file ]] || return 1
|
||||
[[ -d $dir ]] || execute mkdir -p "$dir" || { debug "Failed to create directory: $dir"; return 1; }
|
||||
|
||||
if creation_date=$(stat -c %w "$file" 2>/dev/null || stat -c %y "$file" 2>/dev/null) && \
|
||||
@@ -722,8 +737,13 @@ main() {
|
||||
exit $?
|
||||
fi
|
||||
|
||||
install_dependencies
|
||||
# Remove dependency lock files for --depends
|
||||
if ((FORCE_DEPENDS)); then
|
||||
[[ -f "$BUILD_ROOT/.dependencies_source.lock" ]] && rm -f "$BUILD_ROOT/.dependencies_source.lock"
|
||||
[[ -f "$BUILD_ROOT/.dependencies_ib.lock" ]] && rm -f "$BUILD_ROOT/.dependencies_ib.lock"
|
||||
fi
|
||||
|
||||
# Run selected profiles
|
||||
for profile in "${PROFILES[@]}"; do
|
||||
debug "Running profile: $profile"
|
||||
|
||||
@@ -733,40 +753,34 @@ main() {
|
||||
fi
|
||||
|
||||
# Store profile in P_ARR nameref
|
||||
declare -gn P_ARR="$profile"
|
||||
local -n P_ARR="$profile"
|
||||
local mode="${P_ARR[mode]:="imagebuilder"}"
|
||||
((FROM_SOURCE)) && mode="source" # allow cli override
|
||||
install_dependencies "$mode"
|
||||
local repo="${P_ARR[repo]:-}"
|
||||
declare -g FILESYSTEM="${P_ARR[filesystem]:="squashfs"}"
|
||||
declare -g TARGET="${P_ARR[target]}"
|
||||
declare -g DEVICE="${P_ARR[device]}"
|
||||
declare -g PACKAGES="${P_ARR[packages]:-}"
|
||||
declare -g RELEASE="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}"
|
||||
|
||||
# normalize RELEASE
|
||||
case "$RELEASE" in
|
||||
snapshot|latest|main|master) RELEASE="snapshot" ;;
|
||||
v[0-9][0-9].[0-9][0-9].*) RELEASE="${RELEASE#v}" ;;
|
||||
[0-9][0-9].[0-9][0-9].*) ;;
|
||||
*)
|
||||
if ! ((FROM_SOURCE)); then
|
||||
echo "Error: Invalid release version format"
|
||||
echo "Use semantic version, tag, or 'snapshot'"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
# pull in USER_RELEASE from args or profile default
|
||||
local raw_release="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}"
|
||||
|
||||
declare -g SRC_DIR="$BUILD_ROOT/src/openwrt"
|
||||
declare -g WORKTREE_DIR="$BUILD_ROOT/src/$profile/$RELEASE-src"
|
||||
declare -g BUILD_DIR="$BUILD_ROOT/src/$profile/$RELEASE"
|
||||
declare -g BIN_DIR="$BUILD_ROOT/bin/$profile/$RELEASE"
|
||||
# single call to normalize+ref
|
||||
read -r release ref < <(normalize_and_ref "$raw_release" "$mode")
|
||||
|
||||
if [[ "$RELEASE" == "snapshot" ]]; then
|
||||
declare -g SRC_DIR="$BUILD_ROOT/src/.openwrt"
|
||||
declare -g BUILD_DIR="$BUILD_ROOT/src/$profile/$mode-$ref"
|
||||
declare -g BIN_DIR="$BUILD_ROOT/bin/$profile/$mode-$ref"
|
||||
|
||||
if [[ "$release" == "snapshot" ]]; then
|
||||
local url_prefix="https://downloads.openwrt.org/snapshots/targets/$TARGET"
|
||||
local url_filename="openwrt-imagebuilder-${TARGET//\//-}.Linux-x86_64.tar.zst"
|
||||
local img_fname="openwrt-${TARGET//\//-}-$DEVICE-$FILESYSTEM"
|
||||
else
|
||||
local url_prefix="https://downloads.openwrt.org/releases/$RELEASE/targets/$TARGET"
|
||||
local url_filename="openwrt-imagebuilder-$RELEASE-${TARGET//\//-}.Linux-x86_64.tar.zst"
|
||||
local img_fname="openwrt-$RELEASE-${TARGET//\//-}-$DEVICE-$FILESYSTEM"
|
||||
local url_prefix="https://downloads.openwrt.org/releases/$release/targets/$TARGET"
|
||||
local url_filename="openwrt-imagebuilder-$release-${TARGET//\//-}.Linux-x86_64.tar.zst"
|
||||
local img_fname="openwrt-$release-${TARGET//\//-}-$DEVICE-$FILESYSTEM"
|
||||
fi
|
||||
|
||||
local ib_url="$url_prefix/$url_filename"
|
||||
@@ -775,22 +789,27 @@ main() {
|
||||
local ib_sha256_file="$BUILD_DIR/sha256sums"
|
||||
local seed_url="$url_prefix/config.buildinfo"
|
||||
|
||||
if ((FROM_SOURCE)); then
|
||||
if [[ "$mode" == "source" ]]; then
|
||||
declare -g SYSUPGRADEIMGGZ="$BIN_DIR/targets/$TARGET/$img_fname-sysupgrade.img.gz"
|
||||
else
|
||||
declare -g SYSUPGRADEIMGGZ="$BUILD_DIR/$img_fname-sysupgrade.img.gz"
|
||||
fi
|
||||
|
||||
backup "$SYSUPGRADEIMGGZ" "$BACKUP_DIR/$profile/$RELEASE"
|
||||
backup "$SYSUPGRADEIMGGZ" "$BACKUP_DIR/$profile/$mode-$ref"
|
||||
|
||||
if ((FROM_SOURCE)); then
|
||||
from_source "$seed_url" || return $?
|
||||
else
|
||||
if [[ "$mode" == "source" ]]; then
|
||||
from_source "$seed_url" "$profile" "$ref" || return $?
|
||||
elif [[ "$mode" == "imagebuilder" ]]; then
|
||||
[[ -d $BUILD_DIR ]] || mkdir -p "$BUILD_DIR"
|
||||
get_imagebuilder "$ib_url" "$ib_file" "$ib_sha256_url" "$ib_sha256_file" &&
|
||||
verify "$ib_file" "$ib_sha256_file" &&
|
||||
extract "$ib_file" "$BUILD_DIR" || return $?
|
||||
add_repos
|
||||
if [[ -v $repo ]]; then
|
||||
if ! grep -q "$repo" "$BUILD_DIR/repositories.conf"; then
|
||||
echo "$repo" >> "$BUILD_DIR/repositories.conf"
|
||||
fi
|
||||
sed -i '/option check_signature/d' "$BUILD_DIR/repositories.conf"
|
||||
fi
|
||||
make_images
|
||||
# Verify output image for stock builds (in testing)
|
||||
if [[ ! -v P_ARR[packages] || -z ${P_ARR[packages]} ]]; then
|
||||
|
||||
3
profiles
3
profiles
@@ -10,6 +10,7 @@ default_packages="luci luci-ssl luci-proto-wireguard luci-app-statistics \
|
||||
|
||||
# Current devices
|
||||
declare -Ag r4s=(
|
||||
[mode]="source"
|
||||
[device]="friendlyarm_nanopi-r4s"
|
||||
[target]="rockchip/armv8"
|
||||
[filesystem]="ext4"
|
||||
@@ -24,6 +25,7 @@ declare -Ag r4s=(
|
||||
)
|
||||
|
||||
declare -Ag ax6000=(
|
||||
[mode]="imagebuilder"
|
||||
[device]="xiaomi_redmi-router-ax6000-stock"
|
||||
[target]="mediatek/filogic"
|
||||
[release]="snapshot"
|
||||
@@ -32,6 +34,7 @@ declare -Ag ax6000=(
|
||||
)
|
||||
|
||||
declare -Ag ax6000_uboot=(
|
||||
[mode]="imagebuilder"
|
||||
[device]="xiaomi_redmi-router-ax6000-ubootmod"
|
||||
[target]="mediatek/filogic"
|
||||
[release]="snapshot"
|
||||
|
||||
Reference in New Issue
Block a user