Compare commits
4 Commits
1904d14773
...
1a975bbe6f
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a975bbe6f | |||
| 58e5784313 | |||
| ed198150b7 | |||
| 0e4496d2d4 |
@@ -36,7 +36,7 @@ See `./profiles` for example device profile definitions.
|
||||
## Examples
|
||||
|
||||
* `./openwrtbuilder -p r4s -r snapshot --debug`
|
||||
* `./openwrtbuilder -p ax6000_stock -r 22.03.3 --source --debug`
|
||||
* `./openwrtbuilder -p ax6000 -r 22.03.3 --source --debug`
|
||||
* `./openwrtbuilder -p rpi4 -r 22.03.3 --flash /dev/sdX`
|
||||
* `./openwrtbuilder -p linksys -r snapshot --ssh-upgrade root@192.168.1.1`
|
||||
|
||||
|
||||
124
openwrtbuilder
124
openwrtbuilder
@@ -8,12 +8,9 @@
|
||||
#
|
||||
# See README.md and ./profiles
|
||||
#
|
||||
# Some PROFILE options are incompatible with Image Builder mode (kopts) and
|
||||
# will be ignored
|
||||
#
|
||||
|
||||
# Set default release
|
||||
: "${RELEASE:="22.03.3"}"
|
||||
: "${RELEASE:="22.03.5"}"
|
||||
|
||||
printHelp() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
@@ -65,8 +62,8 @@ init() {
|
||||
if [[ -e "/etc/os-release" ]]; then
|
||||
source "/etc/os-release"
|
||||
else
|
||||
err "/etc/os-release not found"
|
||||
err "Your OS is unsupported"
|
||||
echo "/etc/os-release not found"
|
||||
echo "Your OS is unsupported"
|
||||
printHelp
|
||||
exit 1
|
||||
fi
|
||||
@@ -364,7 +361,7 @@ getImageBuilder() {
|
||||
declare url="$1"
|
||||
|
||||
if [[ -f "$IB_ARCHIVE" ]]; then
|
||||
if askOK "$IB_ARCHIVE exists. Re-download?"; then
|
||||
if askOk "$IB_ARCHIVE exists. Re-download?"; then
|
||||
rm -f "$IB_ARCHIVE"
|
||||
else
|
||||
return 0
|
||||
@@ -451,7 +448,7 @@ makeImages() {
|
||||
|
||||
make image \
|
||||
BIN_DIR="$BINDIR" \
|
||||
PROFILE="$PROFILE" \
|
||||
PROFILE="$DEVICE" \
|
||||
PACKAGES="$PACKAGES" \
|
||||
FILES="${FILESDIR}" \
|
||||
--directory="$BUILDDIR" \
|
||||
@@ -543,44 +540,58 @@ fromSource() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
|
||||
declare src_url="https://github.com/openwrt/openwrt.git"
|
||||
declare seed_file="$SOURCEDIR/.config"
|
||||
declare seed_file="$GITWORKTREEDIR/.config"
|
||||
declare pkg kopt opt commit seed_file wt_cmd
|
||||
declare -a make_opts config_opts
|
||||
|
||||
echo "Building from source is under development"
|
||||
|
||||
# Update source code
|
||||
if [[ ! -d "$GITDIR" ]]; then
|
||||
mkdir -p "$GITDIR"
|
||||
git clone "$src_url" "$GITDIR"
|
||||
if [[ ! -d "$GITSRCDIR" ]]; then
|
||||
mkdir -p "$GITSRCDIR"
|
||||
git clone "$src_url" "$GITSRCDIR"
|
||||
fi
|
||||
|
||||
git -C "$GITDIR" pull
|
||||
git -C "$GITSRCDIR" pull
|
||||
|
||||
wt_cmd=(git -C "$GITDIR"
|
||||
wt_cmd=(git -C "$GITSRCDIR"
|
||||
worktree add
|
||||
--force
|
||||
--detach
|
||||
"$SOURCEDIR")
|
||||
"$GITWORKTREEDIR")
|
||||
|
||||
if [[ $RELEASE == "snapshot" ]]; then
|
||||
execute "${wt_cmd[@]}" master
|
||||
else
|
||||
execute "${wt_cmd[@]}" "origin/openwrt-${RELEASE%.*}"
|
||||
fi
|
||||
case "$RELEASE" in
|
||||
snapshot)
|
||||
execute "${wt_cmd[@]}" origin/main
|
||||
;;
|
||||
[0-9][0-9].[0-9][0-9].*)
|
||||
branch="openwrt-${RELEASE%.*}"
|
||||
tag="v$RELEASE"
|
||||
if askOk "Use HEAD of $branch branch (y, recommended) or $tag tag (n)?"; then
|
||||
execute "${wt_cmd[@]}" "origin/$tag"
|
||||
else
|
||||
execute "${wt_cmd[@]}" "origin/$branch"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
debug "Passing '$RELEASE' commit-ish to git worktree"
|
||||
execute "${wt_cmd[@]}" "origin/$RELEASE"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Print commit information
|
||||
commit=$(git -C "$SOURCEDIR" rev-parse HEAD)
|
||||
commit=$(git -C "$GITWORKTREEDIR" rev-parse HEAD)
|
||||
echo "Current commit hash: $commit"
|
||||
(( DEBUG )) && git -C "$SOURCEDIR" log -1
|
||||
(( DEBUG )) && git -C "$SOURCEDIR" describe
|
||||
(( DEBUG )) && git -C "$GITWORKTREEDIR" log -1
|
||||
(( DEBUG )) && git -C "$GITWORKTREEDIR" describe
|
||||
|
||||
# Enter worktree
|
||||
pushd "$SOURCEDIR" || return 1
|
||||
pushd "$GITWORKTREEDIR" || return 1
|
||||
|
||||
# Update package feed
|
||||
./scripts/feeds update -a &&
|
||||
./scripts/feeds install -a
|
||||
./scripts/feeds update -i -f &&
|
||||
./scripts/feeds update -a -f &&
|
||||
./scripts/feeds install -a -f
|
||||
|
||||
# Grab the release seed config
|
||||
if ! curl -so "$seed_file" "$SEED_URL"; then
|
||||
@@ -619,8 +630,8 @@ fromSource() {
|
||||
# Only compile selected target image
|
||||
sed -i '/CONFIG_TARGET_DEVICE_/d' "$seed_file"
|
||||
config_opts+=("CONFIG_TARGET_MULTI_PROFILE=n")
|
||||
config_opts+=("CONFIG_TARGET_PROFILE=DEVICE_$PROFILE")
|
||||
config_opts+=("CONFIG_TARGET_${TARGET//\//_}_DEVICE_$PROFILE=y")
|
||||
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")
|
||||
@@ -632,9 +643,6 @@ fromSource() {
|
||||
echo "$opt" >> "$seed_file"
|
||||
done
|
||||
|
||||
# [[ -v P_ARR[nested_kopts] ]] &&
|
||||
# echo "${P_ARR[nested_kopts]}" >> "$seed_file"
|
||||
|
||||
# Cleaning modes
|
||||
# make clean # compiled output
|
||||
# make targetclean # compiled output, toolchain
|
||||
@@ -747,25 +755,47 @@ main() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Store profile settings in P_ARR
|
||||
# Store profile in P_ARR nameref
|
||||
declare -gn P_ARR="$profile"
|
||||
|
||||
# release precedence: user input>profile>env>hardcode
|
||||
declare -g RELEASE="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}"
|
||||
declare -g BUILDDIR="$BUILDROOT/src/$profile/$RELEASE"
|
||||
declare -g BINDIR="$BUILDROOT/bin/$profile/$RELEASE"
|
||||
# Load profile
|
||||
declare -g FILESYSTEM="${P_ARR[filesystem]:="squashfs"}"
|
||||
declare -g TARGET="${P_ARR[target]}"
|
||||
declare -g PROFILE="${P_ARR[profile]}"
|
||||
declare -g DEVICE="${P_ARR[device]}"
|
||||
declare -g PACKAGES="${P_ARR[packages]:-}"
|
||||
declare -g SOURCEDIR="$BUILDROOT/src/$profile/$RELEASE-src"
|
||||
declare -g GITDIR="$BUILDROOT/src/openwrt"
|
||||
|
||||
# Release precedence: user input>profile>env>hardcode
|
||||
declare -g RELEASE="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}"
|
||||
|
||||
# normalize release input
|
||||
case "$RELEASE" in
|
||||
snapshot|latest|main|master) # normalize aliases
|
||||
RELEASE="snapshot"
|
||||
;;
|
||||
v[0-9][0-9].[0-9][0-9].*) # tag to semantic
|
||||
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
|
||||
|
||||
declare -g GITSRCDIR="$BUILDROOT/src/openwrt"
|
||||
declare -g GITWORKTREEDIR="$BUILDROOT/src/$profile/$RELEASE-src"
|
||||
declare -g BUILDDIR="$BUILDROOT/src/$profile/$RELEASE"
|
||||
declare -g BINDIR="$BUILDROOT/bin/$profile/$RELEASE"
|
||||
|
||||
if (( RESET )); then
|
||||
if (( FROM_SOURCE )); then
|
||||
[[ -d $SOURCEDIR ]] && askOk "Remove $SOURCEDIR?"
|
||||
execute git worktree remove --force "$SOURCEDIR"
|
||||
execute rm -rf "$SOURCEDIR"
|
||||
[[ -d $GITWORKTREEDIR ]] && askOk "Remove $GITWORKTREEDIR?"
|
||||
execute git worktree remove --force "$GITWORKTREEDIR"
|
||||
execute rm -rf "$GITWORKTREEDIR"
|
||||
elif [[ -d $BUILDDIR ]] && askOk "Remove $BUILDDIR?"; then
|
||||
execute rm -rf "$BUILDDIR"
|
||||
fi
|
||||
@@ -774,11 +804,11 @@ main() {
|
||||
if [[ "$RELEASE" == "snapshot" ]]; then
|
||||
declare url_prefix="https://downloads.openwrt.org/snapshots/targets/$TARGET"
|
||||
declare url_filename="openwrt-imagebuilder-${TARGET//\//-}.Linux-x86_64.tar.xz"
|
||||
declare img_fname="openwrt-${TARGET//\//-}-$PROFILE-$FILESYSTEM"
|
||||
declare img_fname="openwrt-${TARGET//\//-}-$DEVICE-$FILESYSTEM"
|
||||
else
|
||||
declare url_prefix="https://downloads.openwrt.org/releases/$RELEASE/targets/$TARGET"
|
||||
declare url_filename="openwrt-imagebuilder-$RELEASE-${TARGET//\//-}.Linux-x86_64.tar.xz"
|
||||
declare img_fname="openwrt-$RELEASE-${TARGET//\//-}-$PROFILE-$FILESYSTEM"
|
||||
declare img_fname="openwrt-$RELEASE-${TARGET//\//-}-$DEVICE-$FILESYSTEM"
|
||||
fi
|
||||
|
||||
declare ib_url="$url_prefix/$url_filename"
|
||||
@@ -802,11 +832,11 @@ main() {
|
||||
ALIAS (\$profile, \$P_ARR -- should match)=$profile, ${!P_ARR}
|
||||
BUILDROOT=$BUILDROOT
|
||||
BUILDDIR=$BUILDDIR
|
||||
GITDIR=$GITDIR
|
||||
SOURCEDIR=$SOURCEDIR
|
||||
GITSRCDIR=$GITSRCDIR
|
||||
GITWORKTREEDIR=$GITWORKTREEDIR
|
||||
BINDIR=$BINDIR
|
||||
TARGET=$TARGET
|
||||
PROFILE=$PROFILE
|
||||
DEVICE=$DEVICE
|
||||
RELEASE=$RELEASE
|
||||
FILESYSTEM=$FILESYSTEM
|
||||
SYSUPGRADEIMGGZ=$SYSUPGRADEIMGGZ
|
||||
|
||||
22
profiles
22
profiles
@@ -24,7 +24,7 @@ default_packages="\
|
||||
collectd-mod-cpu"
|
||||
|
||||
# declare -Ag archer
|
||||
# archer['profile']="tplink_archer-c7-v2"
|
||||
# archer['device']="tplink_archer-c7-v2"
|
||||
# archer['target']="ath79/generic"
|
||||
# archer['filesystem']="squashfs"
|
||||
# archer['packages']="\
|
||||
@@ -36,7 +36,7 @@ default_packages="\
|
||||
# ath10k-firmware-qca988x-ct-full-htt"
|
||||
|
||||
# declare -Ag linksys
|
||||
# linksys['profile']="linksys_ea8300"
|
||||
# linksys['device']="linksys_ea8300"
|
||||
# linksys['target']="ipq40xx/generic"
|
||||
# linksys['filesystem']="squashfs"
|
||||
# linksys['packages']="\
|
||||
@@ -46,7 +46,7 @@ default_packages="\
|
||||
# -iptables"
|
||||
|
||||
declare -Ag rpi4
|
||||
rpi4['profile']="rpi-4"
|
||||
rpi4['device']="rpi-4"
|
||||
rpi4['target']="bcm27xx/bcm2711"
|
||||
rpi4['filesystem']="ext4"
|
||||
rpi4['packages']="\
|
||||
@@ -62,7 +62,7 @@ rpi4['packages']="\
|
||||
luci-app-sqm"
|
||||
|
||||
# declare -Ag r2s
|
||||
# r2s['profile']="friendlyarm_nanopi-r2s"
|
||||
# r2s['device']="friendlyarm_nanopi-r2s"
|
||||
# r2s['target']="rockchip/armv8"
|
||||
# r2s['filesystem']="ext4"
|
||||
# r2s['packages']="\
|
||||
@@ -83,7 +83,7 @@ rpi4['packages']="\
|
||||
# ethtool"
|
||||
|
||||
# declare -Ag r2s_tr
|
||||
# r2s_tr['profile']="friendlyarm_nanopi-r2s"
|
||||
# r2s_tr['device']="friendlyarm_nanopi-r2s"
|
||||
# r2s_tr['target']="rockchip/armv8"
|
||||
# r2s_tr['filesystem']="ext4"
|
||||
# r2s_tr['packages']="\
|
||||
@@ -101,7 +101,7 @@ rpi4['packages']="\
|
||||
# travelmate"
|
||||
|
||||
declare -Ag r4s
|
||||
r4s['profile']="friendlyarm_nanopi-r4s"
|
||||
r4s['device']="friendlyarm_nanopi-r4s"
|
||||
r4s['target']="rockchip/armv8"
|
||||
r4s['filesystem']="ext4"
|
||||
r4s['packages']="\
|
||||
@@ -121,22 +121,22 @@ r4s['packages']="\
|
||||
ethtool \
|
||||
ca-bundle \
|
||||
-libustream-wolfssl"
|
||||
# The following are source mode only
|
||||
r4s['kopts']="\
|
||||
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \
|
||||
CONFIG_BTRFS_PROGS_ZSTD=y \
|
||||
CONFIG_TARGET_ROOTFS_PARTSIZE=1024"
|
||||
r4s['nested_kopts']="CONFIG_TARGET_OPTIMIZATION=\"-O3 -pipe -mcpu=cortex-a72.cortex-a53+crypto+crc\""
|
||||
r4s['files']="\
|
||||
/mnt/backup"
|
||||
|
||||
# declare -Ag r4s_stock
|
||||
# r4s_stock['profile']="friendlyarm_nanopi-r4s"
|
||||
# r4s_stock['device']="friendlyarm_nanopi-r4s"
|
||||
# r4s_stock['target']="rockchip/armv8"
|
||||
# r4s_stock['filesystem']="ext4"
|
||||
# r4s_stock['release']="snapshot"
|
||||
|
||||
declare -Ag ax6000
|
||||
ax6000['profile']="xiaomi_redmi-router-ax6000-stock"
|
||||
ax6000['device']="xiaomi_redmi-router-ax6000-stock"
|
||||
ax6000['target']="mediatek/filogic"
|
||||
ax6000['release']="snapshot"
|
||||
ax6000['filesystem']="squashfs"
|
||||
@@ -150,7 +150,7 @@ ax6000['packages']="\
|
||||
collectd-mod-iwinfo"
|
||||
|
||||
declare -Ag ax6000_uboot
|
||||
ax6000_uboot['profile']="xiaomi_redmi-router-ax6000-ubootmod"
|
||||
ax6000_uboot['device']="xiaomi_redmi-router-ax6000-ubootmod"
|
||||
ax6000_uboot['target']="mediatek/filogic"
|
||||
ax6000_uboot['release']="snapshot"
|
||||
ax6000_uboot['filesystem']="squashfs"
|
||||
@@ -164,7 +164,7 @@ ax6000_uboot['packages']="\
|
||||
collectd-mod-iwinfo"
|
||||
|
||||
declare -Ag totolink
|
||||
totolink['profile']="totolink_x5000r"
|
||||
totolink['device']="totolink_x5000r"
|
||||
totolink['target']="ramips/mt7621"
|
||||
totolink['filesystem']="squashfs"
|
||||
totolink['packages']="\
|
||||
|
||||
Reference in New Issue
Block a user