Compare commits
24 Commits
fd3cef6915
...
d51c9e6359
| Author | SHA1 | Date | |
|---|---|---|---|
| d51c9e6359 | |||
| a0afdfbd47 | |||
| 2d97851c5b | |||
| b00bd9f056 | |||
| c061c18a8e | |||
| 4d77b17269 | |||
| 0de4af9bdb | |||
| 78820d1058 | |||
| 8bea538b1f | |||
| 8bb770bc3e | |||
| 6747571cf9 | |||
| 6f793dddb9 | |||
| 4d721f43c1 | |||
| b2f2d34b27 | |||
| 2d816f3b8a | |||
| 1464cd93ba | |||
| 6dffe35f26 | |||
| 157bb75907 | |||
| a2d72c218a | |||
| 3484c97fbf | |||
| 90700e9595 | |||
| b5d13f000e | |||
| fcf71c9d49 | |||
| 7657759299 |
509
openwrtbuilder
509
openwrtbuilder
@@ -1,18 +1,13 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
# Builds and deploys OpenWRT images
|
||||||
# Copyright 2022-23 Bryan C. Roessler
|
# Copyright 2022-24 Bryan C. Roessler
|
||||||
#
|
|
||||||
# Build and deploy OpenWRT images
|
|
||||||
#
|
|
||||||
# Apache 2.0 License
|
# Apache 2.0 License
|
||||||
#
|
|
||||||
# See README.md and ./profiles
|
# See README.md and ./profiles
|
||||||
#
|
|
||||||
|
|
||||||
# Set default release
|
# Set default release
|
||||||
: "${RELEASE:="23.05.3"}"
|
: "${RELEASE:="23.05.5"}"
|
||||||
|
|
||||||
printHelp() {
|
print_help() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
cat <<-'EOF'
|
cat <<-'EOF'
|
||||||
@@ -49,13 +44,11 @@ printHelp() {
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
declare -g ID RPM_MGR SCRIPTDIR DL_TOOL
|
declare -g ID RPM_MGR SCRIPTDIR DL_TOOL
|
||||||
|
|
||||||
(( DEBUG )) || echo "To enable debugging output, use --debug or -d"
|
((DEBUG)) || echo "To enable debugging output, use --debug or -d"
|
||||||
|
|
||||||
# Save the script directory
|
# Save the script directory
|
||||||
# https://stackoverflow.com/a/4774063
|
# https://stackoverflow.com/a/4774063
|
||||||
@@ -66,7 +59,7 @@ init() {
|
|||||||
else
|
else
|
||||||
echo "/etc/os-release not found"
|
echo "/etc/os-release not found"
|
||||||
echo "Your OS is unsupported"
|
echo "Your OS is unsupported"
|
||||||
printHelp
|
print_help
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -74,27 +67,18 @@ init() {
|
|||||||
|
|
||||||
# normalize distro ID
|
# normalize distro ID
|
||||||
case "$ID" in
|
case "$ID" in
|
||||||
debian|arch)
|
debian|arch) ;;
|
||||||
;;
|
|
||||||
centos|fedora)
|
centos|fedora)
|
||||||
if hash dnf &>/dev/null; then
|
if command -v dnf &>/dev/null; then
|
||||||
RPM_MGR="dnf"
|
RPM_MGR="dnf"
|
||||||
elif hash yum &>/dev/null; then
|
elif command -v yum &>/dev/null; then
|
||||||
RPM_MGR="yum"
|
RPM_MGR="yum"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
rhel)
|
rhel) ID="centos" ;;
|
||||||
ID="centos"
|
linuxmint|neon|*ubuntu*) ID="ubuntu" ;;
|
||||||
;;
|
*suse*) ID="suse" ;;
|
||||||
linuxmint|neon|*ubuntu*)
|
raspbian) ID="debian" ;;
|
||||||
ID="ubuntu"
|
|
||||||
;;
|
|
||||||
*suse*)
|
|
||||||
ID="suse"
|
|
||||||
;;
|
|
||||||
raspbian)
|
|
||||||
ID="debian"
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo "Autodetecting distro, this may be unreliable"
|
echo "Autodetecting distro, this may be unreliable"
|
||||||
if hash dnf &>/dev/null; then
|
if hash dnf &>/dev/null; then
|
||||||
@@ -117,23 +101,15 @@ init() {
|
|||||||
|
|
||||||
# Set distro-specific functions
|
# Set distro-specific functions
|
||||||
case "$ID" in
|
case "$ID" in
|
||||||
fedora|centos)
|
fedora|centos) pkg_install(){ sudo "$RPM_MGR" install -y "$@"; } ;;
|
||||||
pkg_install(){ sudo "$RPM_MGR" install -y "$@"; }
|
debian|ubuntu) pkg_install(){ sudo apt-get install -y -q0 "$@"; } ;;
|
||||||
;;
|
suse) pkg_install(){ sudo zypper --non-interactive -q install --force --no-confirm "$@"; } ;;
|
||||||
debian|ubuntu)
|
arch) pkg_install(){ sudo pacman -S --noconfirm --needed "$@"; } ;;
|
||||||
pkg_install(){ sudo apt-get install -y -q0 "$@"; }
|
|
||||||
;;
|
|
||||||
suse)
|
|
||||||
pkg_install(){ sudo zypper --non-interactive -q install --force --no-confirm "$@"; }
|
|
||||||
;;
|
|
||||||
arch)
|
|
||||||
pkg_install(){ sudo pacman -S --noconfirm --needed "$@"; }
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if hash axel &>/dev/null; then
|
if command -v axel &>/dev/null; then
|
||||||
DL_TOOL="axel"
|
DL_TOOL="axel"
|
||||||
elif hash curl &>/dev/null; then
|
elif command -v curl &>/dev/null; then
|
||||||
DL_TOOL="curl"
|
DL_TOOL="curl"
|
||||||
else
|
else
|
||||||
echo "Downloading the Image Builder requires axel or curl"
|
echo "Downloading the Image Builder requires axel or curl"
|
||||||
@@ -141,54 +117,27 @@ init() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parse_input() {
|
||||||
readInput() {
|
debug "${FUNCNAME[0]}" "$*"
|
||||||
debug "${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
unset RESET YES
|
|
||||||
|
|
||||||
declare -ga PROFILES
|
declare -ga PROFILES
|
||||||
declare long_opts='release:,version:,profile:,buildroot:,source,'
|
local long_opts='release:,version:,profile:,buildroot:,source,'
|
||||||
long_opts+='ssh-upgrade:,ssh-backup:,flash:,reset,yes,debug,help'
|
long_opts+='ssh-upgrade:,ssh-backup:,flash:,reset,yes,debug,help'
|
||||||
|
|
||||||
if _input=$(getopt -o +r:v:p:b:sf:ydh -l $long_opts -- "$@"); then
|
if _input=$(getopt -o +r:v:p:b:sf:ydh -l $long_opts -- "$@"); then
|
||||||
eval set -- "$_input"
|
eval set -- "$_input"
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--release|-r|--version|-v)
|
--release|-r|--version|-v) shift; declare -g USER_RELEASE="$1" ;;
|
||||||
shift && declare -g USER_RELEASE="$1"
|
--profile|-p) shift; PROFILES+=("$1") ;;
|
||||||
;;
|
--buildroot|-b) shift; BUILDROOT="$1" ;;
|
||||||
--profile|-p)
|
--source|-s) FROM_SOURCE=1 ;;
|
||||||
shift && PROFILES+=("$1")
|
--ssh-upgrade) shift; SSH_UPGRADE_PATH="$1" ;;
|
||||||
;;
|
--ssh-backup) shift; SSH_BACKUP_PATH="$1" ;;
|
||||||
--buildroot|-b)
|
--flash|-f) shift; FLASH_DEV="$1" ;;
|
||||||
shift && BUILDROOT="$1"
|
--reset) RESET=1 ;;
|
||||||
;;
|
--yes|-y) YES=1 ;;
|
||||||
--source|-s)
|
--debug|-d) echo "Debugging on"; DEBUG=1 ;;
|
||||||
FROM_SOURCE=1
|
--help|-h) print_help; exit 0 ;;
|
||||||
;;
|
|
||||||
--ssh-upgrade)
|
|
||||||
shift && SSH_UPGRADE_PATH="$1"
|
|
||||||
;;
|
|
||||||
--ssh-backup)
|
|
||||||
shift && SSH_BACKUP_PATH="$1"
|
|
||||||
;;
|
|
||||||
--flash|-f)
|
|
||||||
shift && FLASH_DEV="$1"
|
|
||||||
;;
|
|
||||||
--reset)
|
|
||||||
RESET=1
|
|
||||||
;;
|
|
||||||
--yes|-y)
|
|
||||||
YES=1
|
|
||||||
;;
|
|
||||||
--debug|-d)
|
|
||||||
echo "Debugging on"
|
|
||||||
DEBUG=1
|
|
||||||
;;
|
|
||||||
--help|-h)
|
|
||||||
printHelp && exit 0
|
|
||||||
;;
|
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@@ -198,19 +147,17 @@ readInput() {
|
|||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "Incorrect options provided"
|
echo "Incorrect options provided"
|
||||||
printHelp && exit 1
|
print_help; exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_dependencies() {
|
||||||
installDependencies() {
|
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
local lock_file="$BUILDROOT/.dependencies"
|
||||||
declare -a pkg_list
|
local -a pkg_list
|
||||||
declare lock_file="$BUILDROOT/.dependencies"
|
|
||||||
|
|
||||||
# TODO please contribute your platform here
|
# TODO please contribute your platform here
|
||||||
if (( FROM_SOURCE )); then
|
if ((FROM_SOURCE)); then
|
||||||
# For building from source with make
|
# For building from source with make
|
||||||
# https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem
|
# https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem
|
||||||
case "$ID" in
|
case "$ID" in
|
||||||
@@ -246,7 +193,7 @@ installDependencies() {
|
|||||||
"swig"
|
"swig"
|
||||||
"clang" # for qosify
|
"clang" # for qosify
|
||||||
"llvm15-libs"
|
"llvm15-libs"
|
||||||
)
|
"patch")
|
||||||
;;
|
;;
|
||||||
debian|ubuntu)
|
debian|ubuntu)
|
||||||
pkg_list+=(
|
pkg_list+=(
|
||||||
@@ -266,7 +213,7 @@ installDependencies() {
|
|||||||
"zlib1g-dev"
|
"zlib1g-dev"
|
||||||
"file"
|
"file"
|
||||||
"wget"
|
"wget"
|
||||||
)
|
"patch")
|
||||||
;;
|
;;
|
||||||
arch)
|
arch)
|
||||||
pkg_list+=(
|
pkg_list+=(
|
||||||
@@ -308,7 +255,7 @@ installDependencies() {
|
|||||||
"wget"
|
"wget"
|
||||||
"which"
|
"which"
|
||||||
"zlib"
|
"zlib"
|
||||||
)
|
"patch")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
debug "Skipping dependency install, your OS is unsupported"
|
debug "Skipping dependency install, your OS is unsupported"
|
||||||
@@ -333,8 +280,7 @@ installDependencies() {
|
|||||||
"python3"
|
"python3"
|
||||||
"python2"
|
"python2"
|
||||||
"axel"
|
"axel"
|
||||||
"perl-IPC-Cmd"
|
"perl-IPC-Cmd")
|
||||||
)
|
|
||||||
;;
|
;;
|
||||||
debian|ubuntu)
|
debian|ubuntu)
|
||||||
pkg_list+=(
|
pkg_list+=(
|
||||||
@@ -350,8 +296,7 @@ installDependencies() {
|
|||||||
"wget"
|
"wget"
|
||||||
"unzip"
|
"unzip"
|
||||||
"python"
|
"python"
|
||||||
"axel"
|
"axel")
|
||||||
)
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
debug "Skipping dependency install, your OS is unsupported"
|
debug "Skipping dependency install, your OS is unsupported"
|
||||||
@@ -364,44 +309,31 @@ installDependencies() {
|
|||||||
[[ -f $lock_file ]] && return
|
[[ -f $lock_file ]] && return
|
||||||
|
|
||||||
pkg_install "${pkg_list[@]}" && echo "${pkg_list[@]}" > "$lock_file"
|
pkg_install "${pkg_list[@]}" && echo "${pkg_list[@]}" > "$lock_file"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_imagebuilder() {
|
||||||
|
debug "${FUNCNAME[0]}" "$*"
|
||||||
|
|
||||||
getImageBuilder() {
|
local -a url_file_pairs=("$@")
|
||||||
debug "${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
declare url="$1"
|
for ((i=0; i<${#url_file_pairs[@]}; i+=2)); do
|
||||||
|
local url="${url_file_pairs[i]}"
|
||||||
|
local file="${url_file_pairs[i+1]}"
|
||||||
|
|
||||||
if [[ -f "$IB_ARCHIVE" ]]; then
|
# Check if file exists and ask user to remove and redownload
|
||||||
if askOk "$IB_ARCHIVE exists. Re-download?"; then
|
if [[ -f $file ]] && ! ask_ok "Use existing $file?"; then
|
||||||
execute rm -f "$IB_ARCHIVE"
|
execute rm -f "$file"
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Downloading Image Builder archive using $DL_TOOL"
|
# Download the file if it doesn't exist
|
||||||
execute "$DL_TOOL" "-o" "$IB_ARCHIVE" "$url"
|
if [[ ! -f "$file" ]]; then
|
||||||
|
echo "Downloading $url to $file using $DL_TOOL"
|
||||||
|
execute "$DL_TOOL" "-o" "$file" "$url"
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_repos() {
|
||||||
getImageBuilderChecksum() {
|
|
||||||
debug "${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
if [[ -f $IB_SHA256_FILE ]]; then
|
|
||||||
if askOk "$IB_SHA256_FILE exists. Re-download?"; then
|
|
||||||
execute rm -f "$IB_SHA256_FILE"
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
execute "$DL_TOOL -o $IB_SHA256_FILE $IB_SHA256_URL"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
addRepos() {
|
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
if [[ -v P_ARR[repo] ]]; then
|
if [[ -v P_ARR[repo] ]]; then
|
||||||
@@ -412,18 +344,15 @@ addRepos() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssh_backup() {
|
||||||
sshBackup() {
|
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
local date hostname backup_fname
|
||||||
declare date hostname backup_fname
|
|
||||||
|
|
||||||
[[ -d "$FILESDIR" ]] || mkdir -p "$FILESDIR"
|
|
||||||
|
|
||||||
printf -v date '%(%Y-%m-%d-%H-%M-%S)T'
|
printf -v date '%(%Y-%m-%d-%H-%M-%S)T'
|
||||||
hostname=$(ssh -qt "$SSH_BACKUP_PATH" echo -n \$HOSTNAME)
|
hostname=$(ssh -qt "$SSH_BACKUP_PATH" echo -n \$HOSTNAME)
|
||||||
backup_fname="backup-$hostname-$date.tar.gz"
|
backup_fname="backup-$hostname-$date.tar.gz"
|
||||||
|
|
||||||
|
[[ -d "$FILESDIR" ]] || execute mkdir -p "$FILESDIR"
|
||||||
|
|
||||||
# Make backup archive on remote
|
# Make backup archive on remote
|
||||||
if ! execute "ssh -t $SSH_BACKUP_PATH sysupgrade -b /tmp/$backup_fname"; then
|
if ! execute "ssh -t $SSH_BACKUP_PATH sysupgrade -b /tmp/$backup_fname"; then
|
||||||
echo "SSH backup failed"
|
echo "SSH backup failed"
|
||||||
@@ -445,19 +374,23 @@ sshBackup() {
|
|||||||
execute "rm $BUILDDIR/$backup_fname"
|
execute "rm $BUILDDIR/$backup_fname"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
make_images() {
|
||||||
makeImages() {
|
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
# Reuse the existing output
|
# Reuse the existing output
|
||||||
if [[ -d "$BINDIR" ]]; then
|
if [[ -d "$BINDIR" ]]; then
|
||||||
if askOk "$BINDIR exists. Rebuild?"; then
|
if ask_ok "$BINDIR exists. Rebuild?"; then
|
||||||
execute rm -rf "$BINDIR"
|
execute rm -rf "$BINDIR"
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
debug make image BIN_DIR="$BINDIR" \
|
||||||
|
PROFILE="$DEVICE" PACKAGES="$PACKAGES" \
|
||||||
|
FILES="$FILESDIR" --directory="$BUILDDIR" \
|
||||||
|
--jobs="$(($(nproc) - 1))"
|
||||||
|
|
||||||
make image \
|
make image \
|
||||||
BIN_DIR="$BINDIR" \
|
BIN_DIR="$BINDIR" \
|
||||||
PROFILE="$DEVICE" \
|
PROFILE="$DEVICE" \
|
||||||
@@ -468,26 +401,12 @@ makeImages() {
|
|||||||
> "$BUILDDIR/make.log"
|
> "$BUILDDIR/make.log"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flash_images() {
|
||||||
verifyImages() {
|
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
local img_gz="$1"
|
||||||
declare outfile
|
local dev="$2"
|
||||||
|
local img="${img_gz%.gz}"
|
||||||
for outfile in "$BINDIR"/*.img.gz; do
|
local partitions
|
||||||
verify "$outfile" "$IB_OUT_SHA256_FILE" || return 1
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
flashImage() {
|
|
||||||
debug "${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
declare img_gz="$1"
|
|
||||||
declare dev="$2"
|
|
||||||
|
|
||||||
declare img="${img_gz%.gz}"
|
|
||||||
declare partitions
|
|
||||||
|
|
||||||
if [[ ! -e "$dev" ]]; then
|
if [[ ! -e "$dev" ]]; then
|
||||||
echo "The device specified by --flash could not be found"
|
echo "The device specified by --flash could not be found"
|
||||||
@@ -503,7 +422,7 @@ flashImage() {
|
|||||||
execute gunzip -qfk "$img_gz"
|
execute gunzip -qfk "$img_gz"
|
||||||
|
|
||||||
echo "Unmounting target device $dev partitions"
|
echo "Unmounting target device $dev partitions"
|
||||||
partitions=( "$dev"?* )
|
partitions=("$dev"?*)
|
||||||
execute sudo umount "${partitions[@]}"
|
execute sudo umount "${partitions[@]}"
|
||||||
|
|
||||||
if execute sudo dd if="$img" of="$dev" bs=2M conv=fsync; then
|
if execute sudo dd if="$img" of="$dev" bs=2M conv=fsync; then
|
||||||
@@ -511,18 +430,15 @@ flashImage() {
|
|||||||
echo "Image flashed sucessfully!"
|
echo "Image flashed sucessfully!"
|
||||||
else
|
else
|
||||||
echo "dd failed!"
|
echo "dd failed!"
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssh_upgrade() {
|
||||||
sshUpgrade() {
|
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
local img_gz="$1"
|
||||||
declare img_gz="$1"
|
local ssh_path="$2"
|
||||||
declare ssh_path="$2"
|
local img_fname="${img_gz##*/}"
|
||||||
|
|
||||||
declare img_fname="${img_gz##*/}"
|
|
||||||
|
|
||||||
if ! [[ -f $img_gz ]]; then
|
if ! [[ -f $img_gz ]]; then
|
||||||
echo "$img_gz is missing, check build output"
|
echo "$img_gz is missing, check build output"
|
||||||
@@ -544,31 +460,24 @@ sshUpgrade() {
|
|||||||
ssh "$ssh_path" "sysupgrade -F /tmp/$img_fname"
|
ssh "$ssh_path" "sysupgrade -F /tmp/$img_fname"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
from_source() {
|
||||||
fromSource() {
|
debug "${FUNCNAME[0]}" "$*"
|
||||||
debug "${FUNCNAME[0]}"
|
local seed_url="$1"
|
||||||
|
local src_url="https://github.com/openwrt/openwrt.git"
|
||||||
declare src_url="https://github.com/openwrt/openwrt.git"
|
local seed_file="$GITWORKTREEDIR/.config"
|
||||||
declare seed_file="$GITWORKTREEDIR/.config"
|
local pkg config commit seed_file wt_commit description
|
||||||
declare pkg kopt opt commit seed_file wt_cmd wt_commit description
|
local -a make_opts config_opts
|
||||||
declare -a make_opts config_opts
|
|
||||||
|
|
||||||
echo "Building from source is under development"
|
echo "Building from source is under development"
|
||||||
|
|
||||||
# Update source code
|
# Update source code
|
||||||
if [[ ! -d "$GITSRCDIR" ]]; then
|
if [[ ! -d "$GITSRCDIR" ]]; then
|
||||||
mkdir -p "$GITSRCDIR"
|
execute mkdir -p "$GITSRCDIR"
|
||||||
git clone "$src_url" "$GITSRCDIR"
|
execute git clone "$src_url" "$GITSRCDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git -C "$GITSRCDIR" pull
|
git -C "$GITSRCDIR" pull
|
||||||
|
|
||||||
wt_cmd=(git -C "$GITSRCDIR"
|
|
||||||
worktree add
|
|
||||||
--force
|
|
||||||
--detach
|
|
||||||
"$GITWORKTREEDIR")
|
|
||||||
|
|
||||||
# Generate commitish for git worktree
|
# Generate commitish for git worktree
|
||||||
case "$RELEASE" in
|
case "$RELEASE" in
|
||||||
snapshot)
|
snapshot)
|
||||||
@@ -577,7 +486,7 @@ fromSource() {
|
|||||||
[0-9][0-9].[0-9][0-9].*)
|
[0-9][0-9].[0-9][0-9].*)
|
||||||
local branch="openwrt-${RELEASE%.*}"
|
local branch="openwrt-${RELEASE%.*}"
|
||||||
local tag="v$RELEASE"
|
local tag="v$RELEASE"
|
||||||
if askOk "Use $branch branch HEAD (y, recommended) or $tag tag (N)?"; then
|
if ask_ok "Use $branch branch HEAD (y, recommended) or $tag tag (N)?"; then
|
||||||
wt_commit="origin/$branch"
|
wt_commit="origin/$branch"
|
||||||
else
|
else
|
||||||
wt_commit="$tag"
|
wt_commit="$tag"
|
||||||
@@ -589,9 +498,17 @@ fromSource() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# [[ -d "$GITWORKTREEDIR" ]] && rm -rf "$GITWORKTREEDIR"
|
# TODO There's a bug in the make clean functions that seem to invoke a full make
|
||||||
|
# if [[ -d "$GITWORKTREEDIR" ]]; then
|
||||||
|
# execute git -C "$GITWORKTREEDIR" checkout "$wt_commit"
|
||||||
|
# execute git -C "$GITWORKTREEDIR" pull
|
||||||
|
# else
|
||||||
|
# execute git -C "$GITSRCDIR" worktree add --force --detach "$GITWORKTREEDIR" "$wt_commit"
|
||||||
|
# fi
|
||||||
|
|
||||||
execute "${wt_cmd[@]}" "$wt_commit"
|
# To workaround bug, don't use make *clean, blow it away and start fresh
|
||||||
|
[[ -d "$GITWORKTREEDIR" ]] && execute rm -rf "$GITWORKTREEDIR"
|
||||||
|
execute git -C "$GITSRCDIR" worktree add --force --detach "$GITWORKTREEDIR" "$wt_commit"
|
||||||
|
|
||||||
# Print commit information
|
# Print commit information
|
||||||
commit=$(git -C "$GITWORKTREEDIR" rev-parse HEAD)
|
commit=$(git -C "$GITWORKTREEDIR" rev-parse HEAD)
|
||||||
@@ -599,8 +516,8 @@ fromSource() {
|
|||||||
echo "Current commit hash: $commit"
|
echo "Current commit hash: $commit"
|
||||||
echo "Git worktree description: $description"
|
echo "Git worktree description: $description"
|
||||||
|
|
||||||
if (( DEBUG )); then
|
if ((DEBUG)); then
|
||||||
if (( YES )); then
|
if ((YES)); then
|
||||||
git --no-pager -C "$GITWORKTREEDIR" log -1
|
git --no-pager -C "$GITWORKTREEDIR" log -1
|
||||||
else
|
else
|
||||||
git -C "$GITWORKTREEDIR" log -1
|
git -C "$GITWORKTREEDIR" log -1
|
||||||
@@ -608,7 +525,7 @@ fromSource() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Enter worktree
|
# Enter worktree
|
||||||
pushd "$GITWORKTREEDIR" || return 1
|
execute pushd "$GITWORKTREEDIR" || return 1
|
||||||
|
|
||||||
# Update package feed
|
# Update package feed
|
||||||
./scripts/feeds update -i -f &&
|
./scripts/feeds update -i -f &&
|
||||||
@@ -616,8 +533,8 @@ fromSource() {
|
|||||||
./scripts/feeds install -a -f
|
./scripts/feeds install -a -f
|
||||||
|
|
||||||
# Grab the release seed config
|
# Grab the release seed config
|
||||||
if ! curl -so "$seed_file" "$SEED_URL"; then
|
if ! execute "$DL_TOOL" "-o" "$seed_file" "$seed_url"; then
|
||||||
echo "Could not obtain $seed_file from $SEED_URL"
|
echo "Could not obtain $seed_file from $seed_url"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -633,13 +550,13 @@ fromSource() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Add kopts from profile
|
# Add config options from profile
|
||||||
for kopt in ${P_ARR[kopts]}; do
|
for config in ${P_ARR[config]}; do
|
||||||
config_opts+=("$kopt")
|
config_opts+=("$config")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Only compile selected fs
|
# Only compile selected fs
|
||||||
sed -i '/CONFIG_TARGET_ROOTFS_/d' "$seed_file"
|
execute sed -i '/CONFIG_TARGET_ROOTFS_/d' "$seed_file"
|
||||||
config_opts+=("CONFIG_TARGET_PER_DEVICE_ROOTFS=n")
|
config_opts+=("CONFIG_TARGET_PER_DEVICE_ROOTFS=n")
|
||||||
if [[ $FILESYSTEM == "squashfs" ]]; then
|
if [[ $FILESYSTEM == "squashfs" ]]; then
|
||||||
config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=n")
|
config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=n")
|
||||||
@@ -650,7 +567,7 @@ fromSource() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Only compile selected target image
|
# Only compile selected target image
|
||||||
sed -i '/CONFIG_TARGET_DEVICE_/d' "$seed_file"
|
execute sed -i '/CONFIG_TARGET_DEVICE_/d' "$seed_file"
|
||||||
config_opts+=("CONFIG_TARGET_MULTI_PROFILE=n")
|
config_opts+=("CONFIG_TARGET_MULTI_PROFILE=n")
|
||||||
config_opts+=("CONFIG_TARGET_PROFILE=DEVICE_$DEVICE")
|
config_opts+=("CONFIG_TARGET_PROFILE=DEVICE_$DEVICE")
|
||||||
config_opts+=("CONFIG_TARGET_${TARGET//\//_}_DEVICE_$DEVICE=y")
|
config_opts+=("CONFIG_TARGET_${TARGET//\//_}_DEVICE_$DEVICE=y")
|
||||||
@@ -660,9 +577,9 @@ fromSource() {
|
|||||||
config_opts+=("CONFIG_MAKE_TOOLCHAIN=n")
|
config_opts+=("CONFIG_MAKE_TOOLCHAIN=n")
|
||||||
|
|
||||||
# Write options to config seed file
|
# Write options to config seed file
|
||||||
for opt in "${config_opts[@]}"; do
|
for config in "${config_opts[@]}"; do
|
||||||
debug "Writing $opt to $seed_file"
|
debug "Writing $config to $seed_file"
|
||||||
echo "$opt" >> "$seed_file"
|
echo "$config" >> "$seed_file"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Cleaning modes
|
# Cleaning modes
|
||||||
@@ -671,19 +588,21 @@ fromSource() {
|
|||||||
# make dirclean # compiled output, toolchain, build tools
|
# make dirclean # compiled output, toolchain, build tools
|
||||||
# make distclean # compiled output, toolchain, build tools, .config, feeds, .ccache
|
# make distclean # compiled output, toolchain, build tools, .config, feeds, .ccache
|
||||||
|
|
||||||
|
# Make prep
|
||||||
|
((DEBUG)) && make_opts+=("V=s")
|
||||||
|
#execute make "${make_opts[@]}" "-j1" dirclean # TODO 'dirclean' has a bug that triggers menuconfig
|
||||||
|
execute make "${make_opts[@]}" "-j1" defconfig
|
||||||
|
execute make "${make_opts[@]}" "-j1" download
|
||||||
|
|
||||||
# Make image
|
# Make image
|
||||||
(( DEBUG )) && make_opts+=("V=s")
|
if ! execute ionice -c 3 chrt --idle 0 nice -n19 make "${make_opts[@]}" "-j$(($(nproc)+1))" world; then
|
||||||
|
echo "Error: make failed"
|
||||||
execute make "${make_opts[@]}" defconfig download clean
|
return 1
|
||||||
|
fi
|
||||||
make_opts+=("-j$(($(nproc) - 2))")
|
|
||||||
#make_opts+=("-j1") # for debugging purposes
|
|
||||||
|
|
||||||
execute make "${make_opts[@]}" world
|
|
||||||
|
|
||||||
popd || return 1
|
popd || return 1
|
||||||
|
|
||||||
# Provide symlinks to images in root of BINDIR (to match Image Builder)
|
# Symlink output images to root of BINDIR (match Image Builder)
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
for image in "$BINDIR/targets/${TARGET}/"*.{img,img.gz,ubi}; do
|
for image in "$BINDIR/targets/${TARGET}/"*.{img,img.gz,ubi}; do
|
||||||
ln -fs "$image" "$BINDIR/${image##*/}"
|
ln -fs "$image" "$BINDIR/${image##*/}"
|
||||||
@@ -694,28 +613,28 @@ fromSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Generic helpers
|
# Generic helpers
|
||||||
debug() { (( DEBUG )) && echo "Debug: $*"; }
|
debug() { ((DEBUG)) && echo "Debug: $*"; }
|
||||||
askOk() {
|
ask_ok() {
|
||||||
(( YES )) && return
|
((YES)) && return
|
||||||
local r
|
local r
|
||||||
read -r -p "$* [y/N]: " r
|
read -r -p "$* [y/N]: " r
|
||||||
r=${r,,}
|
r=${r,,}
|
||||||
[[ "$r" =~ ^(yes|y)$ ]]
|
[[ "$r" =~ ^(yes|y)$ ]]
|
||||||
}
|
}
|
||||||
extract() {
|
extract() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}" "$*"
|
||||||
declare archive="$1"
|
local archive="$1"
|
||||||
declare out_dir="$2"
|
local out_dir="$2"
|
||||||
if ! execute tar -axf "$archive" -C "$out_dir" --strip-components 1; then
|
if ! execute tar -axf "$archive" -C "$out_dir" --strip-components 1; then
|
||||||
echo "Extraction failed"
|
echo "Extraction failed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
verify() {
|
verify() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}" "$*"
|
||||||
declare file_to_check="$1"
|
local file_to_check="$1"
|
||||||
declare sumfile="$2"
|
local sumfile="$2"
|
||||||
declare checksum
|
local checksum
|
||||||
|
|
||||||
hash sha256sum &>/dev/null || return 1
|
hash sha256sum &>/dev/null || return 1
|
||||||
[[ -f $sumfile && -f $file_to_check ]] || return 1
|
[[ -f $sumfile && -f $file_to_check ]] || return 1
|
||||||
@@ -723,26 +642,25 @@ verify() {
|
|||||||
echo -n "$checksum $file_to_check" | sha256sum --check --status
|
echo -n "$checksum $file_to_check" | sha256sum --check --status
|
||||||
}
|
}
|
||||||
load() {
|
load() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}" "$*"
|
||||||
declare source_file="$1"
|
local source_file="$1"
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
[[ -f $source_file ]] && source "$source_file"
|
[[ -f $source_file ]] && source "$source_file"
|
||||||
}
|
}
|
||||||
execute() {
|
execute() {
|
||||||
declare cmd="$*"
|
if debug "$*"; then
|
||||||
debug "$cmd" || cmd+=" &>/dev/null"
|
"$@"
|
||||||
eval "${cmd[*]}"
|
else
|
||||||
|
"$@" &>/dev/null
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
init
|
init
|
||||||
|
|
||||||
load "$SCRIPTDIR/profiles"
|
load "$SCRIPTDIR/profiles"
|
||||||
|
parse_input "$@"
|
||||||
readInput "$@"
|
|
||||||
|
|
||||||
# Fallback to SCRIPTDIR if BUILDROOT has not been set
|
# Fallback to SCRIPTDIR if BUILDROOT has not been set
|
||||||
declare -g BUILDROOT="${BUILDROOT:=$SCRIPTDIR}"
|
declare -g BUILDROOT="${BUILDROOT:=$SCRIPTDIR}"
|
||||||
@@ -755,21 +673,21 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for dir in "$BUILDROOT/src" "$BUILDROOT/bin"; do
|
for dir in "$BUILDROOT/src" "$BUILDROOT/bin"; do
|
||||||
[[ -d "$dir" ]] || mkdir -p "$dir"
|
[[ -d "$dir" ]] || execute mkdir -p "$dir"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Allow --reset without a profile
|
# Allow --reset without a profile
|
||||||
if (( RESET )) && [[ ${#PROFILES} -lt 1 ]]; then
|
if ((RESET)) && [[ ${#PROFILES} -lt 1 ]]; then
|
||||||
for d in "$BUILDROOT/src" "$BUILDROOT/bin"; do
|
for d in "$BUILDROOT/src" "$BUILDROOT/bin"; do
|
||||||
askOk "Remove $d?" && execute rm -rf "$d"
|
ask_ok "Remove $d?" && execute rm -rf "$d"
|
||||||
done
|
done
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
installDependencies
|
install_dependencies
|
||||||
|
|
||||||
for profile in "${PROFILES[@]}"; do
|
for profile in "${PROFILES[@]}"; do
|
||||||
debug "Starting profile: $profile"
|
debug "Running profile: $profile"
|
||||||
|
|
||||||
if [[ ! ${!profile@a} = A ]]; then
|
if [[ ! ${!profile@a} = A ]]; then
|
||||||
echo "Profile '$profile' does not exist"
|
echo "Profile '$profile' does not exist"
|
||||||
@@ -778,28 +696,19 @@ main() {
|
|||||||
|
|
||||||
# Store profile in P_ARR nameref
|
# Store profile in P_ARR nameref
|
||||||
declare -gn P_ARR="$profile"
|
declare -gn P_ARR="$profile"
|
||||||
|
|
||||||
# Load profile
|
|
||||||
declare -g FILESYSTEM="${P_ARR[filesystem]:="squashfs"}"
|
declare -g FILESYSTEM="${P_ARR[filesystem]:="squashfs"}"
|
||||||
declare -g TARGET="${P_ARR[target]}"
|
declare -g TARGET="${P_ARR[target]}"
|
||||||
declare -g DEVICE="${P_ARR[device]}"
|
declare -g DEVICE="${P_ARR[device]}"
|
||||||
declare -g PACKAGES="${P_ARR[packages]:-}"
|
declare -g PACKAGES="${P_ARR[packages]:-}"
|
||||||
|
|
||||||
# Release precedence: user input>profile>env>hardcode
|
|
||||||
declare -g RELEASE="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}"
|
declare -g RELEASE="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}"
|
||||||
|
|
||||||
# normalize release input
|
# normalize RELEASE
|
||||||
case "$RELEASE" in
|
case "$RELEASE" in
|
||||||
snapshot|latest|main|master) # normalize aliases
|
snapshot|latest|main|master) RELEASE="snapshot" ;;
|
||||||
RELEASE="snapshot"
|
v[0-9][0-9].[0-9][0-9].*) RELEASE="${RELEASE#v}" ;;
|
||||||
;;
|
[0-9][0-9].[0-9][0-9].*) ;;
|
||||||
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
|
if ! ((FROM_SOURCE)); then
|
||||||
echo "Error: Invalid release version format"
|
echo "Error: Invalid release version format"
|
||||||
echo "Use semantic version, tag, or 'snapshot'"
|
echo "Use semantic version, tag, or 'snapshot'"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -812,90 +721,66 @@ main() {
|
|||||||
declare -g BUILDDIR="$BUILDROOT/src/$profile/$RELEASE"
|
declare -g BUILDDIR="$BUILDROOT/src/$profile/$RELEASE"
|
||||||
declare -g BINDIR="$BUILDROOT/bin/$profile/$RELEASE"
|
declare -g BINDIR="$BUILDROOT/bin/$profile/$RELEASE"
|
||||||
|
|
||||||
if (( RESET )); then
|
if [[ "$RELEASE" == "snapshot" ]]; then
|
||||||
if (( FROM_SOURCE )); then
|
local url_prefix="https://downloads.openwrt.org/snapshots/targets/$TARGET"
|
||||||
[[ -d $GITWORKTREEDIR ]] && askOk "Remove $GITWORKTREEDIR?"
|
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.xz"
|
||||||
|
local img_fname="openwrt-$RELEASE-${TARGET//\//-}-$DEVICE-$FILESYSTEM"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local ib_url="$url_prefix/$url_filename"
|
||||||
|
local ib_file="$BUILDDIR/$url_filename"
|
||||||
|
local ib_sha256_url="$url_prefix/sha256sums"
|
||||||
|
local ib_sha256_file="$BUILDDIR/sha256sums"
|
||||||
|
local seed_url="$url_prefix/config.buildinfo"
|
||||||
|
|
||||||
|
if ((FROM_SOURCE)); then
|
||||||
|
declare -g SYSUPGRADEIMGGZ="$BINDIR/targets/$img_fname-sysupgrade.img.gz"
|
||||||
|
else
|
||||||
|
declare -g SYSUPGRADEIMGGZ="$BUILDDIR/$img_fname-sysupgrade.img.gz"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((RESET)); then
|
||||||
|
if ((FROM_SOURCE)); then
|
||||||
|
[[ -d $GITWORKTREEDIR ]] && ask_ok "Remove $GITWORKTREEDIR?"
|
||||||
execute git worktree remove --force "$GITWORKTREEDIR"
|
execute git worktree remove --force "$GITWORKTREEDIR"
|
||||||
execute rm -rf "$GITWORKTREEDIR"
|
execute rm -rf "$GITWORKTREEDIR"
|
||||||
elif [[ -d $BUILDDIR ]] && askOk "Remove $BUILDDIR?"; then
|
elif [[ -d $BUILDDIR ]] && ask_ok "Remove $BUILDDIR?"; then
|
||||||
execute rm -rf "$BUILDDIR"
|
execute rm -rf "$BUILDDIR"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$RELEASE" == "snapshot" ]]; then
|
if ((DEBUG)); then
|
||||||
declare url_prefix="https://downloads.openwrt.org/snapshots/targets/$TARGET"
|
|
||||||
declare url_filename="openwrt-imagebuilder-${TARGET//\//-}.Linux-x86_64.tar.zst"
|
|
||||||
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//\//-}-$DEVICE-$FILESYSTEM"
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare ib_url="$url_prefix/$url_filename"
|
|
||||||
|
|
||||||
if (( FROM_SOURCE )); then
|
|
||||||
declare -g SYSUPGRADEIMGGZ="$BINDIR/targets/$img_fname-sysupgrade.img.gz"
|
|
||||||
declare -g SEED_URL="$url_prefix/config.buildinfo"
|
|
||||||
else
|
|
||||||
declare -g SYSUPGRADEIMGGZ="$BUILDDIR/$img_fname-sysupgrade.img.gz"
|
|
||||||
declare -g IB_ARCHIVE="$BUILDDIR/$url_filename"
|
|
||||||
declare -g IB_SHA256_URL="$url_prefix/sha256sums"
|
|
||||||
declare -g IB_SHA256_FILE="$IB_ARCHIVE.sha256sums"
|
|
||||||
declare -g IB_OUT_SHA256_FILE="$BINDIR/sha256sums"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( DEBUG )); then
|
|
||||||
echo "Profile settings:"
|
echo "Profile settings:"
|
||||||
for x in "${!P_ARR[@]}"; do printf "%s=%s\n" "$x" "${P_ARR[$x]}"; done
|
for x in "${!P_ARR[@]}"; do printf "%s=%s\n" "$x" "${P_ARR[$x]}"; done
|
||||||
echo "Build settings:"
|
echo "Environment variables:"
|
||||||
cat <<- EOF
|
declare -p
|
||||||
PROFILE, P_ARR (should match)=$profile, ${!P_ARR}
|
|
||||||
BUILDROOT=$BUILDROOT
|
|
||||||
BUILDDIR=$BUILDDIR
|
|
||||||
GITSRCDIR=$GITSRCDIR
|
|
||||||
GITWORKTREEDIR=$GITWORKTREEDIR
|
|
||||||
BINDIR=$BINDIR
|
|
||||||
TARGET=$TARGET
|
|
||||||
DEVICE=$DEVICE
|
|
||||||
RELEASE=$RELEASE
|
|
||||||
FILESYSTEM=$FILESYSTEM
|
|
||||||
SYSUPGRADEIMGGZ=$SYSUPGRADEIMGGZ
|
|
||||||
ib_url=$ib_url
|
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( FROM_SOURCE )); then
|
if ((FROM_SOURCE)); then
|
||||||
fromSource || return $?
|
from_source "$seed_url" || return $?
|
||||||
else
|
else
|
||||||
[[ -d $BUILDDIR ]] || mkdir -p "$BUILDDIR"
|
[[ -d $BUILDDIR ]] || mkdir -p "$BUILDDIR"
|
||||||
getImageBuilder "$ib_url" &&
|
get_imagebuilder "$ib_url" "$ib_file" "$ib_sha256_url" "$ib_sha256_file" &&
|
||||||
getImageBuilderChecksum &&
|
verify "$ib_file" "$ib_sha256_file" &&
|
||||||
verify "$IB_ARCHIVE" "$IB_SHA256_FILE" &&
|
extract "$ib_file" "$BUILDDIR" || return $?
|
||||||
extract "$IB_ARCHIVE" "$BUILDDIR" || return $?
|
add_repos
|
||||||
addRepos
|
make_images
|
||||||
makeImages &&
|
# Verify output iamges
|
||||||
verifyImages
|
for outfile in "$BINDIR"/*.img.gz; do
|
||||||
|
verify "$outfile" "$ib_sha256_file" || return 1
|
||||||
|
done
|
||||||
#copyFiles
|
#copyFiles
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -v SSH_BACKUP_PATH ]] &&
|
[[ -v SSH_BACKUP_PATH ]] && ssh_backup
|
||||||
sshBackup
|
[[ -v SSH_UPGRADE_PATH ]] && ssh_upgrade "$SYSUPGRADEIMGGZ" "$SSH_UPGRADE_PATH"
|
||||||
[[ -v SSH_UPGRADE_PATH ]] &&
|
[[ -v FLASH_DEV ]] && flash_images "$SYSUPGRADEIMGGZ" "$FLASH_DEV"
|
||||||
sshUpgrade "$SYSUPGRADEIMGGZ" "$SSH_UPGRADE_PATH"
|
|
||||||
[[ -v FLASH_DEV ]] &&
|
|
||||||
flashImage "$SYSUPGRADEIMGGZ" "$FLASH_DEV"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
exit
|
exit $?
|
||||||
|
|
||||||
|
|
||||||
# VM setup (for testing)
|
|
||||||
# sudo sgdisk -N 0 /dev/vda &&
|
|
||||||
# sudo mkfs.ext4 /dev/vda1
|
|
||||||
|
|
||||||
# mkdir ~/mnt
|
|
||||||
# sudo mount /dev/vda1 ~/mnt
|
|
||||||
# sudo chown liveuser:liveuser -R ~/mnt
|
|
||||||
58
profiles
58
profiles
@@ -7,24 +7,23 @@
|
|||||||
default_packages="\
|
default_packages="\
|
||||||
luci \
|
luci \
|
||||||
luci-ssl \
|
luci-ssl \
|
||||||
|
luci-proto-wireguard \
|
||||||
|
luci-app-statistics \
|
||||||
|
collectd-mod-sensors \
|
||||||
|
collectd-mod-thermal \
|
||||||
|
collectd-mod-conntrack \
|
||||||
|
collectd-mod-cpu \
|
||||||
nano \
|
nano \
|
||||||
htop \
|
htop \
|
||||||
diffutils \
|
diffutils \
|
||||||
tar \
|
tar \
|
||||||
iperf3 \
|
iperf3 \
|
||||||
bash \
|
zsh \
|
||||||
rsync \
|
rsync \
|
||||||
luci-app-statistics \
|
openssh-sftp-server \
|
||||||
luci-app-attendedsysupgrade \
|
"
|
||||||
collectd-mod-sensors \
|
|
||||||
collectd-mod-thermal \
|
|
||||||
collectd-mod-conntrack \
|
|
||||||
collectd-mod-cpu"
|
|
||||||
|
|
||||||
#################
|
|
||||||
# Current devices
|
# Current devices
|
||||||
#################
|
|
||||||
|
|
||||||
# Main router
|
# Main router
|
||||||
declare -Ag r4s
|
declare -Ag r4s
|
||||||
r4s['device']="friendlyarm_nanopi-r4s"
|
r4s['device']="friendlyarm_nanopi-r4s"
|
||||||
@@ -32,9 +31,8 @@ r4s['target']="rockchip/armv8"
|
|||||||
r4s['filesystem']="ext4"
|
r4s['filesystem']="ext4"
|
||||||
r4s['packages']="\
|
r4s['packages']="\
|
||||||
$default_packages \
|
$default_packages \
|
||||||
luci-app-wireguard \
|
|
||||||
luci-proto-wireguard \
|
|
||||||
luci-app-ddns \
|
luci-app-ddns \
|
||||||
|
luci-app-sqm \
|
||||||
irqbalance \
|
irqbalance \
|
||||||
collectd-mod-df \
|
collectd-mod-df \
|
||||||
usbutils \
|
usbutils \
|
||||||
@@ -47,10 +45,9 @@ r4s['packages']="\
|
|||||||
avahi-daemon \
|
avahi-daemon \
|
||||||
curl \
|
curl \
|
||||||
ethtool \
|
ethtool \
|
||||||
ca-bundle \
|
ca-bundle"
|
||||||
-libustream-wolfssl"
|
|
||||||
# The following are source mode only
|
# The following are source mode only
|
||||||
r4s['kopts']="\
|
r4s['config']="\
|
||||||
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \
|
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \
|
||||||
CONFIG_BTRFS_PROGS_ZSTD=y \
|
CONFIG_BTRFS_PROGS_ZSTD=y \
|
||||||
CONFIG_TARGET_ROOTFS_PARTSIZE=512 \
|
CONFIG_TARGET_ROOTFS_PARTSIZE=512 \
|
||||||
@@ -58,7 +55,7 @@ r4s['kopts']="\
|
|||||||
r4s['files']="\
|
r4s['files']="\
|
||||||
/mnt/backup"
|
/mnt/backup"
|
||||||
|
|
||||||
# WDS mesh nodes
|
# Access point
|
||||||
declare -Ag ax6000
|
declare -Ag ax6000
|
||||||
ax6000['device']="xiaomi_redmi-router-ax6000-stock"
|
ax6000['device']="xiaomi_redmi-router-ax6000-stock"
|
||||||
ax6000['target']="mediatek/filogic"
|
ax6000['target']="mediatek/filogic"
|
||||||
@@ -70,22 +67,6 @@ ax6000['packages']="\
|
|||||||
-odhcpd-ipv6only \
|
-odhcpd-ipv6only \
|
||||||
-nftables \
|
-nftables \
|
||||||
-firewall4"
|
-firewall4"
|
||||||
# for 802.11s
|
|
||||||
# mesh11sd \
|
|
||||||
# -wpad-basic-mbedtls \
|
|
||||||
# wpad-mesh-mbedtls"
|
|
||||||
|
|
||||||
# WDS mesh nodes
|
|
||||||
declare -Ag ax6000_ap
|
|
||||||
ax6000_ap['device']="xiaomi_redmi-router-ax6000-stock"
|
|
||||||
ax6000_ap['target']="mediatek/filogic"
|
|
||||||
ax6000_ap['release']="snapshot"
|
|
||||||
ax6000_ap['filesystem']="squashfs"
|
|
||||||
ax6000_ap['packages']="\
|
|
||||||
$default_packages \
|
|
||||||
avahi-daemon \
|
|
||||||
smcroute \
|
|
||||||
ca-bundle"
|
|
||||||
|
|
||||||
# For converted uboots
|
# For converted uboots
|
||||||
# declare -Ag ax6000_uboot
|
# declare -Ag ax6000_uboot
|
||||||
@@ -109,8 +90,6 @@ n5100['target']="x86/64"
|
|||||||
n5100['filesystem']="squashfs"
|
n5100['filesystem']="squashfs"
|
||||||
n5100['packages']="\
|
n5100['packages']="\
|
||||||
$default_packages \
|
$default_packages \
|
||||||
luci-app-wireguard \
|
|
||||||
luci-proto-wireguard \
|
|
||||||
luci-app-ddns \
|
luci-app-ddns \
|
||||||
irqbalance \
|
irqbalance \
|
||||||
collectd-mod-df \
|
collectd-mod-df \
|
||||||
@@ -135,7 +114,7 @@ n5100['packages']="\
|
|||||||
tailscale \
|
tailscale \
|
||||||
shadow-useradd"
|
shadow-useradd"
|
||||||
# The following are source mode only
|
# The following are source mode only
|
||||||
n5100['kopts']="\
|
n5100['config']="\
|
||||||
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \
|
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \
|
||||||
CONFIG_BTRFS_PROGS_ZSTD=y \
|
CONFIG_BTRFS_PROGS_ZSTD=y \
|
||||||
CONFIG_TARGET_ROOTFS_PARTSIZE=512 \
|
CONFIG_TARGET_ROOTFS_PARTSIZE=512 \
|
||||||
@@ -153,27 +132,20 @@ rpi4['packages']="\
|
|||||||
kmod-usb-net-asix-ax88179 \
|
kmod-usb-net-asix-ax88179 \
|
||||||
kmod-usb-net-rtl8152 \
|
kmod-usb-net-rtl8152 \
|
||||||
luci-app-upnp \
|
luci-app-upnp \
|
||||||
luci-app-wireguard \
|
|
||||||
luci-app-pbr \
|
luci-app-pbr \
|
||||||
-dnsmasq \
|
-dnsmasq \
|
||||||
dnsmasq-full \
|
dnsmasq-full \
|
||||||
luci-app-ddns \
|
luci-app-ddns \
|
||||||
luci-app-sqm"
|
luci-app-sqm"
|
||||||
|
|
||||||
|
|
||||||
#################
|
|
||||||
# Stock builds
|
# Stock builds
|
||||||
#################
|
|
||||||
declare -Ag r4s_stock
|
declare -Ag r4s_stock
|
||||||
r4s_stock['device']="friendlyarm_nanopi-r4s"
|
r4s_stock['device']="friendlyarm_nanopi-r4s"
|
||||||
r4s_stock['target']="rockchip/armv8"
|
r4s_stock['target']="rockchip/armv8"
|
||||||
r4s_stock['filesystem']="ext4"
|
r4s_stock['filesystem']="ext4"
|
||||||
r4s_stock['release']="snapshot"
|
r4s_stock['release']="snapshot"
|
||||||
|
|
||||||
|
|
||||||
#################
|
|
||||||
# Old devices
|
# Old devices
|
||||||
#################
|
|
||||||
declare -Ag totolink
|
declare -Ag totolink
|
||||||
totolink['device']="totolink_x5000r"
|
totolink['device']="totolink_x5000r"
|
||||||
totolink['target']="ramips/mt7621"
|
totolink['target']="ramips/mt7621"
|
||||||
@@ -216,7 +188,6 @@ r2s['filesystem']="ext4"
|
|||||||
r2s['packages']="\
|
r2s['packages']="\
|
||||||
$default_packages \
|
$default_packages \
|
||||||
luci-app-upnp \
|
luci-app-upnp \
|
||||||
luci-app-wireguard \
|
|
||||||
luci-app-pbr \
|
luci-app-pbr \
|
||||||
-dnsmasq \
|
-dnsmasq \
|
||||||
dnsmasq-full \
|
dnsmasq-full \
|
||||||
@@ -237,7 +208,6 @@ r2s_tr['filesystem']="ext4"
|
|||||||
r2s_tr['packages']="\
|
r2s_tr['packages']="\
|
||||||
$default_packages \
|
$default_packages \
|
||||||
luci-app-upnp \
|
luci-app-upnp \
|
||||||
luci-app-wireguard \
|
|
||||||
luci-app-pbr \
|
luci-app-pbr \
|
||||||
luci-app-ddns \
|
luci-app-ddns \
|
||||||
luci-app-statistics \
|
luci-app-statistics \
|
||||||
|
|||||||
Reference in New Issue
Block a user