Compare commits

..

10 Commits

Author SHA1 Message Date
bbf6f246df Silence warning 2023-06-27 19:02:50 -04:00
f609c72fc4 Add perl-IPC dependency 2023-06-27 16:52:29 -04:00
e349adeccf Pass TMPDIR 2023-06-27 16:48:02 -04:00
d44fdcc508 More commands to execute() 2023-06-27 15:53:21 -04:00
1cbea322d6 Fix version format 2023-06-27 15:34:43 -04:00
1a975bbe6f First stab at unified input versioning 2023-06-27 15:11:23 -04:00
58e5784313 Change nomenclature 2023-06-27 15:11:01 -04:00
ed198150b7 Normalize release commit-ish I 2023-06-02 09:50:25 -04:00
0e4496d2d4 Regenerate the feed index 2023-06-01 13:11:25 -04:00
1904d14773 Fix ax6000 array 2023-05-11 16:53:03 -04:00
3 changed files with 171 additions and 165 deletions

View File

@@ -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`

View File

@@ -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:="23.05.0-rc1"}"
printHelp() {
debug "${FUNCNAME[0]}"
@@ -26,7 +23,7 @@ printHelp() {
OPTIONS
--profile,-p PROFILE
--release,-r,--version,-v RELEASE ("snapshot", "22.03.3")
--release,-r,--version,-v RELEASE ("snapshot", "22.03.5")
--buildroot,-b PATH
Default: location of openwrtbuilder script
--source
@@ -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
@@ -324,6 +321,7 @@ installDependencies() {
"python3"
"python2"
"axel"
"perl-IPC-Cmd"
)
;;
debian|ubuntu)
@@ -364,15 +362,14 @@ getImageBuilder() {
declare url="$1"
if [[ -f "$IB_ARCHIVE" ]]; then
if askOK "$IB_ARCHIVE exists. Re-download?"; then
rm -f "$IB_ARCHIVE"
if askOk "$IB_ARCHIVE exists. Re-download?"; then
execute rm -f "$IB_ARCHIVE"
else
return 0
fi
fi
echo "Downloading Image Builder archive using $DL_TOOL"
debug "$DL_TOOL -o $IB_ARCHIVE $url"
execute "$DL_TOOL" "-o" "$IB_ARCHIVE" "$url"
}
@@ -382,7 +379,7 @@ getImageBuilderChecksum() {
if [[ -f $IB_SHA256_FILE ]]; then
if askOk "$IB_SHA256_FILE exists. Re-download?"; then
rm -f "$IB_SHA256_FILE"
execute rm -f "$IB_SHA256_FILE"
else
return 0
fi
@@ -451,9 +448,9 @@ makeImages() {
make image \
BIN_DIR="$BINDIR" \
PROFILE="$PROFILE" \
PROFILE="$DEVICE" \
PACKAGES="$PACKAGES" \
FILES="${FILESDIR}" \
FILES="$FILESDIR" \
--directory="$BUILDDIR" \
--jobs="$(nproc)" \
> "$BUILDDIR/make.log"
@@ -491,16 +488,13 @@ flashImage() {
return 1
fi
debug "gunzip -qfk $img_gz"
gunzip -qfk "$img_gz"
execute gunzip -qfk "$img_gz"
echo "Unmounting target device $dev partitions"
partitions=( "$dev"?* )
debug "umount ${partitions[*]}"
sudo umount "${partitions[@]}"
execute sudo umount "${partitions[@]}"
debug "sudo dd if=$img of=$dev bs=2M conv=fsync"
if sudo dd if="$img" of="$dev" bs=2M conv=fsync; then
if execute sudo dd if="$img" of="$dev" bs=2M conv=fsync; then
sync
echo "Image flashed sucessfully!"
else
@@ -543,44 +537,61 @@ 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
case "$RELEASE" in
snapshot)
execute "${wt_cmd[@]}" origin/main
;;
[0-9][0-9].[0-9][0-9].*)
local branch="openwrt-${RELEASE%.*}"
local tag="v$RELEASE"
local r
read -r -p "Use HEAD of $branch branch (y, recommended) or $tag tag (n)? (Y/n)" r
r=${r,,}
if [[ "$r" =~ ^(no|n)$ ]]; then
execute "${wt_cmd[@]}" "$tag"
else
execute "${wt_cmd[@]}" "origin/openwrt-${RELEASE%.*}"
execute "${wt_cmd[@]}" "origin/$branch"
fi
;;
*)
debug "Passing '$RELEASE' commit-ish to git worktree"
execute "${wt_cmd[@]}" "$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
@@ -643,14 +651,12 @@ fromSource() {
# Make image
(( DEBUG )) && make_opts+=("V=s")
debug "make ${make_opts[*]} defconfig"
make "${make_opts[@]}" defconfig
debug "make ${make_opts[*]} targetclean"
make "${make_opts[@]}" targetclean
debug "make ${make_opts[*]} download"
make "${make_opts[@]}" download
debug "make ${make_opts[*]} -j$(nproc) world"
make "${make_opts[@]}" -j"$(nproc)" world
execute make "${make_opts[@]}" defconfig
execute make "${make_opts[@]}" targetclean
execute make "${make_opts[@]}" download
execute make -f Makefile.aperl inst_perl MAP_TARGET=perl
execute make -f Makefile.aperl map_clean
execute make "${make_opts[@]}" "-j$(nproc)" world
popd || return 1
@@ -676,8 +682,7 @@ extract() {
debug "${FUNCNAME[0]}"
declare archive="$1"
declare out_dir="$2"
debug "tar -xf $archive -C $out_dir --strip-components 1"
if ! tar -xf "$archive" -C "$out_dir" --strip-components 1; then
if ! execute tar -xf "$archive" -C "$out_dir" --strip-components 1; then
echo "Extraction failed"
return 1
fi
@@ -747,25 +752,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 +801,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"
@@ -799,14 +826,14 @@ main() {
for x in "${!P_ARR[@]}"; do printf "%s=%s\n" "$x" "${P_ARR[$x]}"; done
echo "Build settings:"
cat <<- EOF
ALIAS (\$profile, \$P_ARR -- should match)=$profile, ${!P_ARR}
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

169
profiles
View File

@@ -23,30 +23,30 @@ default_packages="\
collectd-mod-conntrack \
collectd-mod-cpu"
declare -Ag archer
archer['profile']="tplink_archer-c7-v2"
archer['target']="ath79/generic"
archer['filesystem']="squashfs"
archer['packages']="\
$default_packages \
-dnsmasq \
-odhcpd \
-iptables \
-ath10k-firmware-qca988x-ct \
ath10k-firmware-qca988x-ct-full-htt"
# declare -Ag archer
# archer['device']="tplink_archer-c7-v2"
# archer['target']="ath79/generic"
# archer['filesystem']="squashfs"
# archer['packages']="\
# $default_packages \
# -dnsmasq \
# -odhcpd \
# -iptables \
# -ath10k-firmware-qca988x-ct \
# ath10k-firmware-qca988x-ct-full-htt"
declare -Ag linksys
linksys['profile']="linksys_ea8300"
linksys['target']="ipq40xx/generic"
linksys['filesystem']="squashfs"
linksys['packages']="\
$default_packages \
-dnsmasq \
-odhcpd \
-iptables"
# declare -Ag linksys
# linksys['device']="linksys_ea8300"
# linksys['target']="ipq40xx/generic"
# linksys['filesystem']="squashfs"
# linksys['packages']="\
# $default_packages \
# -dnsmasq \
# -odhcpd \
# -iptables"
declare -Ag rpi4
rpi4['profile']="rpi-4"
rpi4['device']="rpi-4"
rpi4['target']="bcm27xx/bcm2711"
rpi4['filesystem']="ext4"
rpi4['packages']="\
@@ -61,47 +61,47 @@ rpi4['packages']="\
luci-app-ddns \
luci-app-sqm"
declare -Ag r2s
r2s['profile']="friendlyarm_nanopi-r2s"
r2s['target']="rockchip/armv8"
r2s['filesystem']="ext4"
r2s['packages']="\
$default_packages \
luci-app-upnp \
luci-app-wireguard \
luci-app-pbr \
-dnsmasq \
dnsmasq-full \
luci-app-ddns \
luci-app-sqm \
luci-app-statistics \
collectd-mod-sensors \
collectd-mod-thermal \
collectd-mod-conntrack \
smcroute \
curl \
ethtool"
# declare -Ag r2s
# r2s['device']="friendlyarm_nanopi-r2s"
# r2s['target']="rockchip/armv8"
# r2s['filesystem']="ext4"
# r2s['packages']="\
# $default_packages \
# luci-app-upnp \
# luci-app-wireguard \
# luci-app-pbr \
# -dnsmasq \
# dnsmasq-full \
# luci-app-ddns \
# luci-app-sqm \
# luci-app-statistics \
# collectd-mod-sensors \
# collectd-mod-thermal \
# collectd-mod-conntrack \
# smcroute \
# curl \
# ethtool"
declare -Ag r2s_tr
r2s_tr['profile']="friendlyarm_nanopi-r2s"
r2s_tr['target']="rockchip/armv8"
r2s_tr['filesystem']="ext4"
r2s_tr['packages']="\
$default_packages \
luci-app-upnp \
luci-app-wireguard \
luci-app-pbr \
luci-app-ddns \
luci-app-statistics \
collectd-mod-sensors \
collectd-mod-thermal \
collectd-mod-conntrack \
curl \
ethtool \
travelmate"
# declare -Ag r2s_tr
# r2s_tr['device']="friendlyarm_nanopi-r2s"
# r2s_tr['target']="rockchip/armv8"
# r2s_tr['filesystem']="ext4"
# r2s_tr['packages']="\
# $default_packages \
# luci-app-upnp \
# luci-app-wireguard \
# luci-app-pbr \
# luci-app-ddns \
# luci-app-statistics \
# collectd-mod-sensors \
# collectd-mod-thermal \
# collectd-mod-conntrack \
# curl \
# ethtool \
# travelmate"
declare -Ag r4s
r4s['profile']="friendlyarm_nanopi-r4s"
r4s['device']="friendlyarm_nanopi-r4s"
r4s['target']="rockchip/armv8"
r4s['filesystem']="ext4"
r4s['packages']="\
@@ -116,52 +116,31 @@ r4s['packages']="\
btrfs-progs \
block-mount \
smcroute \
avahi-daemon \
curl \
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['target']="rockchip/armv8"
r4s_stock['filesystem']="ext4"
r4s_stock['release']="snapshot"
# r4s_stock['packages']="\
# $default_packages \
# luci-app-ddns \
# irqbalance \
# collectd-mod-df \
# usbutils \
# kmod-usb-storage \
# kmod-usb-storage-uas \
# kmod-fs-btrfs \
# btrfs-progs \
# block-mount \
# smcroute \
# curl \
# ethtool \
# ca-bundle"
# r4s_stock['kopts']="\
# CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \
# CONFIG_BTRFS_PROGS_ZSTD=y \
# CONFIG_TARGET_ROOTFS_PARTSIZE=1024"
# r4s_stock['nested_kopts']="CONFIG_TARGET_OPTIMIZATION=\"-O3 -pipe -mcpu=cortex-a72.cortex-a53+crypto+crc\""
# r4s_stock['files']="\
# /mnt/backup"
# declare -Ag r4s_stock
# r4s_stock['device']="friendlyarm_nanopi-r4s"
# r4s_stock['target']="rockchip/armv8"
# r4s_stock['filesystem']="ext4"
# r4s_stock['release']="snapshot"
declare -Ag ax6000_stock
ax6000_stock['profile']="xiaomi_redmi-router-ax6000-stock"
ax6000_stock['target']="mediatek/filogic"
ax6000_stock['release']="snapshot"
ax6000_stock['filesystem']="squashfs"
ax6000_stock['packages']="\
declare -Ag ax6000
ax6000['device']="xiaomi_redmi-router-ax6000-stock"
ax6000['target']="mediatek/filogic"
ax6000['release']="snapshot"
ax6000['filesystem']="squashfs"
ax6000['packages']="\
$default_packages \
-dnsmasq \
-odhcpd-ipv6only \
@@ -171,7 +150,7 @@ ax6000_stock['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"
@@ -185,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']="\