コミットを比較
11 コミット
864756c815
...
8dc558a6d5
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
| 8dc558a6d5 | |||
| ff275aa0ad | |||
| 0ead0af0b5 | |||
| 21899bb072 | |||
| 84dc370d32 | |||
| ab1569fced | |||
| be5dfb2832 | |||
| 7dbc7fc3ef | |||
| 9efb42f944 | |||
| 6ba2335f8a | |||
| 114c9dfc68 |
398
openwrtbuilder
398
openwrtbuilder
@@ -33,6 +33,8 @@ print_help() {
|
||||
Cleanup all source and output files
|
||||
--yes,-y
|
||||
Assume yes for all questions (automatic mode)
|
||||
--verbose
|
||||
Make make or imagebuilder noisier
|
||||
--debug,-d
|
||||
--help,-h
|
||||
|
||||
@@ -46,13 +48,13 @@ print_help() {
|
||||
|
||||
init() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
declare -g ID RPM_MGR SCRIPTDIR DL_TOOL
|
||||
declare -g ID RPM_MGR SCRIPT_DIR DL_TOOL
|
||||
|
||||
((DEBUG)) || echo "To enable debugging output, use --debug or -d"
|
||||
|
||||
# Save the script directory
|
||||
# https://stackoverflow.com/a/4774063
|
||||
SCRIPTDIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit $? ; pwd -P)"
|
||||
SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit $? ; pwd -P)"
|
||||
|
||||
if [[ -e "/etc/os-release" ]]; then
|
||||
source "/etc/os-release"
|
||||
@@ -120,22 +122,25 @@ init() {
|
||||
parse_input() {
|
||||
debug "${FUNCNAME[0]}" "$*"
|
||||
declare -ga PROFILES
|
||||
declare -g RESET=0 FROM_SOURCE=0 YES=0 VERBOSE=0 DEBUG=0
|
||||
declare -g USER_RELEASE SSH_UPGRADE_PATH SSH_BACKUP_PATH FLASH_DEV
|
||||
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,verbose,debug,help'
|
||||
|
||||
if _input=$(getopt -o +r:v:p:b:sf:ydh -l $long_opts -- "$@"); then
|
||||
eval set -- "$_input"
|
||||
while true; do
|
||||
case "$1" in
|
||||
--release|-r|--version|-v) shift; declare -g USER_RELEASE="$1" ;;
|
||||
--release|-r|--version|-v) shift; USER_RELEASE="$1" ;;
|
||||
--profile|-p) shift; PROFILES+=("$1") ;;
|
||||
--buildroot|-b) shift; BUILDROOT="$1" ;;
|
||||
--buildroot|-b) shift; BUILD_ROOT="$1" ;;
|
||||
--source|-s) FROM_SOURCE=1 ;;
|
||||
--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 ;;
|
||||
--verbose) VERBOSE=1 ;;
|
||||
--debug|-d) echo "Debugging on"; DEBUG=1 ;;
|
||||
--help|-h) print_help; exit 0 ;;
|
||||
--)
|
||||
@@ -156,9 +161,9 @@ install_dependencies() {
|
||||
local -a pkg_list
|
||||
local lock_file
|
||||
if ((FROM_SOURCE)); then
|
||||
lock_file="$BUILDROOT/.dependencies_sc"
|
||||
lock_file="$BUILD_ROOT/.dependencies_source"
|
||||
else
|
||||
lock_file="$BUILDROOT/.dependencies_ib"
|
||||
lock_file="$BUILD_ROOT/.dependencies_ib"
|
||||
fi
|
||||
|
||||
if [[ ! -f $lock_file ]]; then
|
||||
@@ -168,99 +173,99 @@ install_dependencies() {
|
||||
case "$ID" in
|
||||
fedora|centos)
|
||||
pkg_list+=(
|
||||
"bash-completion"
|
||||
"bzip2"
|
||||
"gcc"
|
||||
"gcc-c++"
|
||||
"git"
|
||||
"make"
|
||||
"ncurses-devel"
|
||||
"patch"
|
||||
"rsync"
|
||||
"tar"
|
||||
"unzip"
|
||||
"wget"
|
||||
"which"
|
||||
"diffutils"
|
||||
"python3"
|
||||
"python3-devel"
|
||||
"python3-setuptools"
|
||||
"python3-pyelftools"
|
||||
"perl-base"
|
||||
"perl-Data-Dumper"
|
||||
"perl-File-Compare"
|
||||
"perl-File-Copy"
|
||||
"perl-FindBin"
|
||||
"perl-IPC-Cmd"
|
||||
"perl-Thread-Queue"
|
||||
"perl-Time-Piece"
|
||||
"perl-JSON-PP"
|
||||
"swig"
|
||||
"clang" # for qosify
|
||||
"llvm15-libs"
|
||||
"patch")
|
||||
bash-completion
|
||||
bzip2
|
||||
gcc
|
||||
gcc-c++
|
||||
git
|
||||
make
|
||||
ncurses-devel
|
||||
patch
|
||||
rsync
|
||||
tar
|
||||
unzip
|
||||
wget
|
||||
which
|
||||
diffutils
|
||||
python3
|
||||
python3-devel
|
||||
python3-setuptools
|
||||
python3-pyelftools
|
||||
perl-base
|
||||
perl-Data-Dumper
|
||||
perl-File-Compare
|
||||
perl-File-Copy
|
||||
perl-FindBin
|
||||
perl-IPC-Cmd
|
||||
perl-Thread-Queue
|
||||
perl-Time-Piece
|
||||
perl-JSON-PP
|
||||
swig
|
||||
clang # for qosify
|
||||
llvm15-libs
|
||||
patch)
|
||||
;;
|
||||
debian|ubuntu)
|
||||
pkg_list+=(
|
||||
"build-essential"
|
||||
"clang"
|
||||
"flex"
|
||||
"g++"
|
||||
"gawk"
|
||||
"gcc-multilib"
|
||||
"gettext"
|
||||
"git"
|
||||
"libncurses5-dev"
|
||||
"libssl-dev"
|
||||
"python3-distutils"
|
||||
"rsync"
|
||||
"unzip"
|
||||
"zlib1g-dev"
|
||||
"file"
|
||||
"wget"
|
||||
"patch")
|
||||
build-essential
|
||||
clang
|
||||
flex
|
||||
g++
|
||||
gawk
|
||||
gcc-multilib
|
||||
gettext
|
||||
git
|
||||
libncurses5-dev
|
||||
libssl-dev
|
||||
python3-distutils
|
||||
rsync
|
||||
unzip
|
||||
zlib1g-dev
|
||||
file
|
||||
wget
|
||||
patch)
|
||||
;;
|
||||
arch)
|
||||
pkg_list+=(
|
||||
"base-devel"
|
||||
"autoconf"
|
||||
"automake"
|
||||
"bash"
|
||||
"binutils"
|
||||
"bison"
|
||||
"bzip2"
|
||||
"clang"
|
||||
"fakeroot"
|
||||
"file"
|
||||
"findutils"
|
||||
"flex"
|
||||
"gawk"
|
||||
"gcc"
|
||||
"gettext"
|
||||
"git"
|
||||
"grep"
|
||||
"groff"
|
||||
"gzip"
|
||||
"libelf"
|
||||
"libtool"
|
||||
"libxslt"
|
||||
"m4"
|
||||
"make"
|
||||
"ncurses"
|
||||
"openssl"
|
||||
"patch"
|
||||
"pkgconf"
|
||||
"python"
|
||||
"rsync"
|
||||
"sed"
|
||||
"texinfo"
|
||||
"time"
|
||||
"unzip"
|
||||
"util-linux"
|
||||
"wget"
|
||||
"which"
|
||||
"zlib"
|
||||
"patch")
|
||||
base-devel
|
||||
autoconf
|
||||
automake
|
||||
bash
|
||||
binutils
|
||||
bison
|
||||
bzip2
|
||||
clang
|
||||
fakeroot
|
||||
file
|
||||
findutils
|
||||
flex
|
||||
gawk
|
||||
gcc
|
||||
gettext
|
||||
git
|
||||
grep
|
||||
groff
|
||||
gzip
|
||||
libelf
|
||||
libtool
|
||||
libxslt
|
||||
m4
|
||||
make
|
||||
ncurses
|
||||
openssl
|
||||
patch
|
||||
pkgconf
|
||||
python
|
||||
rsync
|
||||
sed
|
||||
texinfo
|
||||
time
|
||||
unzip
|
||||
util-linux
|
||||
wget
|
||||
which
|
||||
zlib
|
||||
patch)
|
||||
;;
|
||||
*)
|
||||
debug "Skipping dependency install, your OS is unsupported"
|
||||
@@ -272,36 +277,36 @@ install_dependencies() {
|
||||
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"
|
||||
"python2"
|
||||
"axel"
|
||||
"perl-IPC-Cmd")
|
||||
@c-development
|
||||
@development-tools
|
||||
@development-libs
|
||||
perl-FindBin
|
||||
zlib-static
|
||||
elfutils-libelf-devel
|
||||
gawk
|
||||
unzip
|
||||
file
|
||||
wget
|
||||
python3
|
||||
python2
|
||||
axel
|
||||
perl-IPC-Cmd)
|
||||
;;
|
||||
debian|ubuntu)
|
||||
pkg_list+=(
|
||||
"build-essential"
|
||||
"libncurses5-dev"
|
||||
"libncursesw5-dev"
|
||||
"zlib1g-dev"
|
||||
"gawk"
|
||||
"git"
|
||||
"gettext"
|
||||
"libssl-dev"
|
||||
"xsltproc"
|
||||
"wget"
|
||||
"unzip"
|
||||
"python"
|
||||
"axel")
|
||||
build-essential
|
||||
libncurses5-dev
|
||||
libncursesw5-dev
|
||||
zlib1g-dev
|
||||
gawk
|
||||
git
|
||||
gettext
|
||||
libssl-dev
|
||||
xsltproc
|
||||
wget
|
||||
unzip
|
||||
python
|
||||
axel)
|
||||
;;
|
||||
*)
|
||||
debug "Skipping dependency install, your OS is unsupported"
|
||||
@@ -309,9 +314,9 @@ install_dependencies() {
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
pkg_install "${pkg_list[@]}" && echo "${pkg_list[@]}" > "$lock_file"
|
||||
pkg_install "${pkg_list[@]}" && echo "${pkg_list[@]}" > "$lock_file"
|
||||
fi
|
||||
}
|
||||
|
||||
get_imagebuilder() {
|
||||
@@ -339,10 +344,10 @@ add_repos() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
|
||||
if [[ -v P_ARR[repo] ]]; then
|
||||
if ! grep -q "${P_ARR[repo]}" "$BUILDDIR/repositories.conf"; then
|
||||
echo "${P_ARR[repo]}" >> "$BUILDDIR/repositories.conf"
|
||||
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' "$BUILDDIR/repositories.conf"
|
||||
sed -i '/option check_signature/d' "$BUILD_DIR/repositories.conf"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -353,7 +358,7 @@ ssh_backup() {
|
||||
hostname=$(ssh -qt "$SSH_BACKUP_PATH" echo -n \$HOSTNAME)
|
||||
backup_fname="backup-$hostname-$date.tar.gz"
|
||||
|
||||
[[ -d "$FILESDIR" ]] || execute mkdir -p "$FILESDIR"
|
||||
[[ -d "$FILES_DIR" ]] || execute mkdir -p "$FILES_DIR"
|
||||
|
||||
# Make backup archive on remote
|
||||
if ! execute "ssh -t $SSH_BACKUP_PATH sysupgrade -b /tmp/$backup_fname"; then
|
||||
@@ -362,45 +367,48 @@ ssh_backup() {
|
||||
fi
|
||||
|
||||
# Move backup archive locally
|
||||
if ! execute "rsync -avz --remove-source-files $SSH_BACKUP_PATH:/tmp/$backup_fname $BUILDDIR/"; then
|
||||
if ! execute "rsync -avz --remove-source-files $SSH_BACKUP_PATH:/tmp/$backup_fname $BUILD_DIR/"; then
|
||||
echo "Could not copy SSH backup"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract backup archive
|
||||
if ! execute "tar -C $FILESDIR -xzf $BUILDDIR/$backup_fname"; then
|
||||
if ! execute "tar -C $FILES_DIR -xzf $BUILD_DIR/$backup_fname"; then
|
||||
echo "Could not extract SSH backup"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
execute "rm $BUILDDIR/$backup_fname"
|
||||
execute "rm $BUILD_DIR/$backup_fname"
|
||||
}
|
||||
|
||||
make_images() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
local -a make_opts
|
||||
|
||||
# Reuse the existing output
|
||||
# if [[ -d "$BINDIR" ]]; then
|
||||
# if ask_ok "$BINDIR exists. Rebuild?"; then
|
||||
# execute rm -rf "$BINDIR"
|
||||
# if [[ -d "$BIN_DIR" ]]; then
|
||||
# if ask_ok "$BIN_DIR exists. Rebuild?"; then
|
||||
# execute rm -rf "$BIN_DIR"
|
||||
# else
|
||||
# return 0
|
||||
# fi
|
||||
# fi
|
||||
|
||||
debug make image BIN_DIR="$BINDIR" \
|
||||
((VERBOSE)) && make_opts+=("V=s")
|
||||
|
||||
debug make "${make_opts[@]}" image BIN_DIR="$BIN_DIR" \
|
||||
PROFILE="$DEVICE" PACKAGES="$PACKAGES" \
|
||||
FILES="$FILESDIR" --directory="$BUILDDIR" \
|
||||
FILES="$FILES_DIR" --directory="$BUILD_DIR" \
|
||||
--jobs="$(($(nproc) - 1))"
|
||||
|
||||
make image \
|
||||
make "${make_opts[@]}" image \
|
||||
BIN_DIR="$BINDIR" \
|
||||
PROFILE="$DEVICE" \
|
||||
PACKAGES="$PACKAGES" \
|
||||
FILES="$FILESDIR" \
|
||||
--directory="$BUILDDIR" \
|
||||
FILES="$FILES_DIR" \
|
||||
--directory="$BUILD_DIR" \
|
||||
--jobs="$(($(nproc) - 1))" \
|
||||
> "$BUILDDIR/make.log"
|
||||
> "$BUILD_DIR/make.log"
|
||||
}
|
||||
|
||||
flash_images() {
|
||||
@@ -457,19 +465,19 @@ from_source() {
|
||||
debug "${FUNCNAME[0]}" "$*"
|
||||
local seed_url="$1"
|
||||
local src_url="https://github.com/openwrt/openwrt.git"
|
||||
local seed_file="$GITWORKTREEDIR/.config"
|
||||
local seed_file="$WORKTREE_DIR/.config"
|
||||
local pkg config commit seed_file wt_commit description
|
||||
local -a make_opts config_opts
|
||||
|
||||
echo "Building from source is under development"
|
||||
|
||||
# Update source code
|
||||
if [[ ! -d "$GITSRCDIR" ]]; then
|
||||
execute mkdir -p "$GITSRCDIR"
|
||||
execute git clone "$src_url" "$GITSRCDIR"
|
||||
if [[ ! -d "$SRC_DIR" ]]; then
|
||||
execute mkdir -p "$SRC_DIR"
|
||||
execute git clone "$src_url" "$SRC_DIR"
|
||||
fi
|
||||
|
||||
git -C "$GITSRCDIR" pull
|
||||
git -C "$SRC_DIR" pull
|
||||
|
||||
# Generate commitish for git worktree
|
||||
case "$RELEASE" in
|
||||
@@ -490,33 +498,37 @@ from_source() {
|
||||
esac
|
||||
|
||||
# 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
|
||||
if [[ -d "$WORKTREE_DIR" ]]; then
|
||||
execute git -C "$WORKTREE_DIR" checkout "$wt_commit"
|
||||
execute git -C "$WORKTREE_DIR" pull
|
||||
else
|
||||
execute git -C "$GITSRCDIR" worktree add --force --detach "$GITWORKTREEDIR" "$wt_commit"
|
||||
execute git -C "$SRC_DIR" worktree add --force --detach "$WORKTREE_DIR" "$wt_commit"
|
||||
fi
|
||||
|
||||
# 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"
|
||||
# [[ -d "$WORKTREE_DIR" ]] && execute rm -rf "$WORKTREE_DIR"
|
||||
# execute git -C "$SRC_DIR" worktree add --force --detach "$WORKTREE_DIR" "$wt_commit"
|
||||
|
||||
# Print commit information
|
||||
commit=$(git -C "$GITWORKTREEDIR" rev-parse HEAD)
|
||||
description=$(git -C "$GITWORKTREEDIR" describe)
|
||||
commit=$(git -C "$WORKTREE_DIR" rev-parse HEAD)
|
||||
description=$(git -C "$WORKTREE_DIR" describe)
|
||||
echo "Current commit hash: $commit"
|
||||
echo "Git worktree description: $description"
|
||||
|
||||
((DEBUG)) && git --no-pager -C "$GITWORKTREEDIR" log -1
|
||||
((DEBUG)) && git --no-pager -C "$WORKTREE_DIR" log -1
|
||||
|
||||
# Enter worktree
|
||||
execute pushd "$GITWORKTREEDIR" || return 1
|
||||
execute pushd "$WORKTREE_DIR" || return 1
|
||||
|
||||
# Update package feed
|
||||
./scripts/feeds update -i -f &&
|
||||
./scripts/feeds update -a -f &&
|
||||
./scripts/feeds install -a -f
|
||||
|
||||
# Cleanup build environment
|
||||
((VERBOSE)) && make_opts+=("V=s")
|
||||
execute make "${make_opts[@]}" "-j1" distclean # TODO 'dirclean' has a bug that triggers menuconfig
|
||||
|
||||
# Grab the release seed config
|
||||
if ! execute "$DL_TOOL" "-o" "$seed_file" "$seed_url"; then
|
||||
echo "Could not obtain $seed_file from $seed_url"
|
||||
@@ -524,7 +536,7 @@ from_source() {
|
||||
fi
|
||||
|
||||
# Set compilation output dir
|
||||
config_opts+=("CONFIG_BINARY_FOLDER=\"$BINDIR\"")
|
||||
config_opts+=("CONFIG_BINARY_FOLDER=\"$BIN_DIR\"")
|
||||
|
||||
# Add custom packages
|
||||
for pkg in $PACKAGES; do
|
||||
@@ -574,11 +586,10 @@ from_source() {
|
||||
# make distclean # compiled output, toolchain, build tools, .config, feeds, .ccache
|
||||
|
||||
# Make prep
|
||||
((DEBUG)) && make_opts+=("V=s")
|
||||
execute make "${make_opts[@]}" "-j1" distclean # TODO 'dirclean' has a bug that triggers menuconfig
|
||||
execute make "${make_opts[@]}" "-j1" defconfig
|
||||
execute make "${make_opts[@]}" "-j1" download
|
||||
((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)+1))")
|
||||
# ((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)+1))")
|
||||
make_opts+=("-j$(($(nproc)+1))")
|
||||
|
||||
# Make image
|
||||
if ! execute ionice -c 3 chrt --idle 0 nice -n19 make "${make_opts[@]}" world; then
|
||||
@@ -588,10 +599,10 @@ from_source() {
|
||||
|
||||
popd || return 1
|
||||
|
||||
# Symlink output images to root of BINDIR (match Image Builder)
|
||||
# Symlink output images to root of BIN_DIR (match Image Builder)
|
||||
shopt -s nullglob
|
||||
for image in "$BINDIR/targets/${TARGET}/"*.{img,img.gz,ubi}; do
|
||||
execute ln -fs "$image" "$BINDIR/${image##*/}"
|
||||
for image in "$BIN_DIR/targets/${TARGET}/"*.{img,img.gz,ubi}; do
|
||||
execute ln -fs "$image" "$BIN_DIR/${image##*/}"
|
||||
done
|
||||
shopt -u nullglob
|
||||
|
||||
@@ -618,18 +629,15 @@ extract() {
|
||||
}
|
||||
backup_image() {
|
||||
debug "${FUNCNAME[0]} $*"
|
||||
local file="$1"
|
||||
local dir="$2"
|
||||
local count=1
|
||||
[[ -f $file ]] || return
|
||||
local file="$1" dir="$2" count=1
|
||||
[[ -f $file ]] || return 1
|
||||
local creation_date
|
||||
creation_date=$(stat -c %w "$file" 2>/dev/null || stat -c %y "$file" | cut -d' ' -f1)
|
||||
creation_date=${creation_date:-unknown} # Default to "unknown" if no creation date
|
||||
[[ "$creation_date" == "-" ]] && creation_date="unknown"
|
||||
local base_name; base_name=$(basename "$file")
|
||||
execute mkdir -p "$dir"
|
||||
local base_name
|
||||
base_name=$(basename "$file")
|
||||
while [[ -e "$dir/$creation_date-$base_name.bk.$count" ]]; do
|
||||
((count++))
|
||||
done
|
||||
while [[ -e "$dir/$creation_date-$base_name.bk.$count" ]]; do ((count++)); done
|
||||
execute mv "$file" "$dir/$creation_date-$base_name.bk.$count"
|
||||
}
|
||||
verify() {
|
||||
@@ -661,27 +669,27 @@ main() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
|
||||
init
|
||||
load "$SCRIPTDIR/profiles"
|
||||
load "$SCRIPT_DIR/profiles"
|
||||
parse_input "$@"
|
||||
|
||||
# Fallback to SCRIPTDIR if BUILDROOT has not been set
|
||||
declare -g BUILDROOT="${BUILDROOT:=$SCRIPTDIR}"
|
||||
declare -g FILESDIR="${FILESDIR:=$BUILDROOT/src/files}"
|
||||
declare -g BACKUPDIR="$SCRIPTDIR/backups"
|
||||
# Fallback to SCRIPT_DIR if BUILD_ROOT has not been set
|
||||
declare -g BUILD_ROOT="${BUILD_ROOT:=$SCRIPT_DIR}"
|
||||
declare -g FILES_DIR="${FILES_DIR:=$BUILD_ROOT/src/files}"
|
||||
declare -g BACKUP_DIR="$SCRIPT_DIR/backups"
|
||||
|
||||
# This could be dangerous
|
||||
if [[ $BUILDROOT == "/" ]]; then
|
||||
if [[ $BUILD_ROOT == "/" ]]; then
|
||||
echo "Invalid --buildroot"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for dir in "$BUILDROOT/src" "$BUILDROOT/bin"; do
|
||||
for dir in "$BUILD_ROOT/src" "$BUILD_ROOT/bin"; do
|
||||
[[ -d "$dir" ]] || execute mkdir -p "$dir"
|
||||
done
|
||||
|
||||
# Allow --reset without a profile
|
||||
if ((RESET)) && [[ ${#PROFILES} -lt 1 ]]; then
|
||||
for d in "$BUILDROOT/src" "$BUILDROOT/bin"; do
|
||||
for d in "$BUILD_ROOT/src" "$BUILD_ROOT/bin"; do
|
||||
ask_ok "Remove $d?" && execute rm -rf "$d"
|
||||
done
|
||||
exit $?
|
||||
@@ -719,10 +727,10 @@ main() {
|
||||
;;
|
||||
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"
|
||||
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"
|
||||
|
||||
if [[ "$RELEASE" == "snapshot" ]]; then
|
||||
local url_prefix="https://downloads.openwrt.org/snapshots/targets/$TARGET"
|
||||
@@ -735,26 +743,26 @@ main() {
|
||||
fi
|
||||
|
||||
local ib_url="$url_prefix/$url_filename"
|
||||
local ib_file="$BUILDDIR/$url_filename"
|
||||
local ib_file="$BUILD_DIR/$url_filename"
|
||||
local ib_sha256_url="$url_prefix/sha256sums"
|
||||
local ib_sha256_file="$BUILDDIR/sha256sums"
|
||||
local ib_sha256_file="$BUILD_DIR/sha256sums"
|
||||
local seed_url="$url_prefix/config.buildinfo"
|
||||
|
||||
if ((FROM_SOURCE)); then
|
||||
declare -g SYSUPGRADEIMGGZ="$BINDIR/targets/$img_fname-sysupgrade.img.gz"
|
||||
declare -g SYSUPGRADEIMGGZ="$BIN_DIR/targets/$img_fname-sysupgrade.img.gz"
|
||||
else
|
||||
declare -g SYSUPGRADEIMGGZ="$BUILDDIR/$img_fname-sysupgrade.img.gz"
|
||||
declare -g SYSUPGRADEIMGGZ="$BUILD_DIR/$img_fname-sysupgrade.img.gz"
|
||||
fi
|
||||
|
||||
backup_image "$SYSUPGRADEIMGGZ" "$BACKUPDIR/$profile/$RELEASE"
|
||||
backup_image "$SYSUPGRADEIMGGZ" "$BACKUP_DIR/$profile/$RELEASE"
|
||||
|
||||
if ((RESET)); then
|
||||
if ((FROM_SOURCE)); then
|
||||
[[ -d $GITWORKTREEDIR ]] && ask_ok "Remove $GITWORKTREEDIR?"
|
||||
execute git worktree remove --force "$GITWORKTREEDIR"
|
||||
execute rm -rf "$GITWORKTREEDIR"
|
||||
elif [[ -d $BUILDDIR ]] && ask_ok "Remove $BUILDDIR?"; then
|
||||
execute rm -rf "$BUILDDIR"
|
||||
[[ -d $WORKTREE_DIR ]] && ask_ok "Remove $WORKTREE_DIR?"
|
||||
execute git worktree remove --force "$WORKTREE_DIR"
|
||||
execute rm -rf "$WORKTREE_DIR"
|
||||
elif [[ -d $BUILD_DIR ]] && ask_ok "Remove $BUILD_DIR?"; then
|
||||
execute rm -rf "$BUILD_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -768,16 +776,16 @@ main() {
|
||||
if ((FROM_SOURCE)); then
|
||||
from_source "$seed_url" || return $?
|
||||
else
|
||||
[[ -d $BUILDDIR ]] || mkdir -p "$BUILDDIR"
|
||||
[[ -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" "$BUILDDIR" || return $?
|
||||
extract "$ib_file" "$BUILD_DIR" || return $?
|
||||
add_repos
|
||||
make_images
|
||||
# Verify output image for stock builds (in testing)
|
||||
if [[ ! -v P_ARR[packages] || -z ${P_ARR[packages]} ]]; then
|
||||
shopt -s nullglob
|
||||
local -a outfiles=("$BINDIR"/*.img.gz "$BINDIR"/*.img)
|
||||
local -a outfiles=("$BIN_DIR"/*.img.gz "$BIN_DIR"/*.img)
|
||||
shopt -u nullglob
|
||||
for outfile in "${outfiles[@]}"; do
|
||||
verify "$outfile" "$ib_sha256_file" || return 1
|
||||
|
||||
297
profiles
297
profiles
@@ -1,218 +1,109 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2034
|
||||
# This file contains a set of device profiles for openwrtbuilder
|
||||
# bash doesn't like nested arrays so we use strings instead
|
||||
# Device profiles for openwrtbuilder
|
||||
|
||||
# Packages to install for all profiles
|
||||
default_packages="\
|
||||
luci \
|
||||
luci-ssl \
|
||||
luci-proto-wireguard \
|
||||
luci-app-statistics \
|
||||
collectd-mod-sensors \
|
||||
collectd-mod-thermal \
|
||||
collectd-mod-conntrack \
|
||||
collectd-mod-cpu \
|
||||
nano \
|
||||
htop \
|
||||
diffutils \
|
||||
tar \
|
||||
iperf3 \
|
||||
zsh \
|
||||
rsync \
|
||||
openssh-sftp-server \
|
||||
"
|
||||
# Default packages
|
||||
default_packages="luci luci-ssl luci-proto-wireguard luci-app-statistics \
|
||||
collectd-mod-sensors collectd-mod-thermal collectd-mod-conntrack \
|
||||
collectd-mod-cpu nano htop diffutils tar iperf3 zsh rsync \
|
||||
openssh-sftp-server"
|
||||
|
||||
# Current devices
|
||||
# Main router
|
||||
declare -Ag r4s
|
||||
r4s['device']="friendlyarm_nanopi-r4s"
|
||||
r4s['target']="rockchip/armv8"
|
||||
r4s['filesystem']="ext4"
|
||||
r4s['packages']="\
|
||||
$default_packages \
|
||||
luci-app-ddns \
|
||||
luci-app-sqm \
|
||||
irqbalance \
|
||||
collectd-mod-df \
|
||||
usbutils \
|
||||
kmod-usb-storage \
|
||||
kmod-usb-storage-uas \
|
||||
kmod-fs-btrfs \
|
||||
btrfs-progs \
|
||||
block-mount \
|
||||
smcroute \
|
||||
avahi-daemon \
|
||||
curl \
|
||||
ethtool \
|
||||
ca-bundle"
|
||||
# The following only work in --source mode
|
||||
r4s['config']="\
|
||||
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \
|
||||
CONFIG_BTRFS_PROGS_ZSTD=y \
|
||||
CONFIG_TARGET_ROOTFS_PARTSIZE=512 \
|
||||
CONFIG_TARGET_KERNEL_PARTSIZE=32 \
|
||||
CONFIG_BUILDBOT=n"
|
||||
r4s['files']="\
|
||||
/mnt/backup"
|
||||
declare -Ag r4s=(
|
||||
[device]="friendlyarm_nanopi-r4s"
|
||||
[target]="rockchip/armv8"
|
||||
[filesystem]="ext4"
|
||||
[packages]="$default_packages luci-app-ddns luci-app-sqm irqbalance \
|
||||
collectd-mod-df usbutils kmod-usb-storage kmod-usb-storage-uas \
|
||||
kmod-fs-btrfs btrfs-progs block-mount smcroute avahi-daemon \
|
||||
curl ethtool ca-bundle"
|
||||
[config]="CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y CONFIG_BTRFS_PROGS_ZSTD=y \
|
||||
CONFIG_BUILDBOT=n"
|
||||
[files]="/mnt/backup"
|
||||
)
|
||||
|
||||
# Access point
|
||||
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 \
|
||||
-nftables \
|
||||
-firewall4"
|
||||
declare -Ag ax6000=(
|
||||
[device]="xiaomi_redmi-router-ax6000-stock"
|
||||
[target]="mediatek/filogic"
|
||||
[release]="snapshot"
|
||||
[filesystem]="squashfs"
|
||||
[packages]="$default_packages -dnsmasq -odhcpd-ipv6only -nftables -firewall4"
|
||||
)
|
||||
|
||||
# For uboot'd access points
|
||||
declare -Ag ax6000_uboot
|
||||
ax6000_uboot['device']="xiaomi_redmi-router-ax6000-ubootmod"
|
||||
ax6000_uboot['target']="mediatek/filogic"
|
||||
ax6000_uboot['release']="snapshot"
|
||||
ax6000_uboot['filesystem']="squashfs"
|
||||
ax6000_uboot['packages']="\
|
||||
$default_packages \
|
||||
-dnsmasq \
|
||||
-odhcpd-ipv6only \
|
||||
-nftables \
|
||||
-firewall4"
|
||||
declare -Ag ax6000_uboot=(
|
||||
[device]="xiaomi_redmi-router-ax6000-ubootmod"
|
||||
[target]="mediatek/filogic"
|
||||
[release]="snapshot"
|
||||
[filesystem]="squashfs"
|
||||
[packages]="$default_packages -dnsmasq -odhcpd-ipv6only -nftables -firewall4"
|
||||
)
|
||||
|
||||
# Remote NAS
|
||||
declare -Ag n5100
|
||||
n5100['device']="generic"
|
||||
n5100['target']="x86/64"
|
||||
n5100['filesystem']="squashfs"
|
||||
n5100['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 \
|
||||
cryptsetup \
|
||||
kmod-crypto-xts \
|
||||
smcroute \
|
||||
avahi-daemon \
|
||||
curl \
|
||||
ethtool \
|
||||
ca-bundle \
|
||||
smartmontools \
|
||||
intel-microcode \
|
||||
lm-sensors \
|
||||
samba4-server \
|
||||
luci-app-samba4 \
|
||||
tailscale \
|
||||
shadow-useradd"
|
||||
# The following are source mode only
|
||||
n5100['config']="\
|
||||
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \
|
||||
CONFIG_BTRFS_PROGS_ZSTD=y \
|
||||
CONFIG_TARGET_ROOTFS_PARTSIZE=512 \
|
||||
CONFIG_TARGET_KERNEL_PARTSIZE=32"
|
||||
n5100['files']="\
|
||||
/mnt/backup"
|
||||
declare -Ag n5100=(
|
||||
[device]="generic"
|
||||
[target]="x86/64"
|
||||
[filesystem]="squashfs"
|
||||
[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 cryptsetup kmod-crypto-xts smcroute \
|
||||
avahi-daemon curl ethtool ca-bundle smartmontools intel-microcode \
|
||||
lm-sensors samba4-server luci-app-samba4 tailscale shadow-useradd"
|
||||
[config]="CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y CONFIG_BTRFS_PROGS_ZSTD=y \
|
||||
CONFIG_TARGET_ROOTFS_PARTSIZE=512 CONFIG_TARGET_KERNEL_PARTSIZE=32"
|
||||
[files]="/mnt/backup"
|
||||
)
|
||||
|
||||
# Dusty drawer
|
||||
declare -Ag rpi4
|
||||
rpi4['device']="rpi-4"
|
||||
rpi4['target']="bcm27xx/bcm2711"
|
||||
rpi4['filesystem']="ext4"
|
||||
rpi4['packages']="\
|
||||
$default_packages \
|
||||
kmod-usb-net-asix-ax88179 \
|
||||
kmod-usb-net-rtl8152 \
|
||||
luci-app-upnp \
|
||||
luci-app-pbr \
|
||||
-dnsmasq \
|
||||
dnsmasq-full \
|
||||
luci-app-ddns \
|
||||
luci-app-sqm"
|
||||
declare -Ag rpi4=(
|
||||
[device]="rpi-4"
|
||||
[target]="bcm27xx/bcm2711"
|
||||
[filesystem]="ext4"
|
||||
[packages]="$default_packages kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8152 \
|
||||
luci-app-upnp luci-app-pbr -dnsmasq dnsmasq-full luci-app-ddns luci-app-sqm"
|
||||
)
|
||||
|
||||
# Stock builds
|
||||
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 r4s_stock=(
|
||||
[device]="friendlyarm_nanopi-r4s"
|
||||
[target]="rockchip/armv8"
|
||||
[filesystem]="ext4"
|
||||
[release]="snapshot"
|
||||
)
|
||||
|
||||
# Old devices
|
||||
declare -Ag totolink
|
||||
totolink['device']="totolink_x5000r"
|
||||
totolink['target']="ramips/mt7621"
|
||||
totolink['filesystem']="squashfs"
|
||||
totolink['packages']="\
|
||||
$default_packages \
|
||||
-dnsmasq \
|
||||
-odhcpd-ipv6only \
|
||||
-nftables \
|
||||
-firewall4 \
|
||||
-kmod-nft-offload \
|
||||
collectd-mod-iwinfo"
|
||||
declare -Ag totolink=(
|
||||
[device]="totolink_x5000r"
|
||||
[target]="ramips/mt7621"
|
||||
[filesystem]="squashfs"
|
||||
[packages]="$default_packages -dnsmasq -odhcpd-ipv6only -nftables -firewall4 \
|
||||
-kmod-nft-offload collectd-mod-iwinfo"
|
||||
)
|
||||
|
||||
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 archer=(
|
||||
[device]="tplink_archer-c7-v2"
|
||||
[target]="ath79/generic"
|
||||
[filesystem]="squashfs"
|
||||
[packages]="$default_packages -dnsmasq -odhcpd -iptables \
|
||||
-ath10k-firmware-qca988x-ct ath10k-firmware-qca988x-ct-full-htt"
|
||||
)
|
||||
|
||||
declare -Ag linksys
|
||||
linksys['device']="linksys_ea8300"
|
||||
linksys['target']="ipq40xx/generic"
|
||||
linksys['filesystem']="squashfs"
|
||||
linksys['packages']="\
|
||||
$default_packages \
|
||||
-dnsmasq \
|
||||
-odhcpd \
|
||||
-iptables"
|
||||
declare -Ag linksys=(
|
||||
[device]="linksys_ea8300"
|
||||
[target]="ipq40xx/generic"
|
||||
[filesystem]="squashfs"
|
||||
[packages]="$default_packages -dnsmasq -odhcpd -iptables"
|
||||
)
|
||||
|
||||
declare -Ag r2s
|
||||
r2s['device']="friendlyarm_nanopi-r2s"
|
||||
r2s['target']="rockchip/armv8"
|
||||
r2s['filesystem']="ext4"
|
||||
r2s['packages']="\
|
||||
$default_packages \
|
||||
luci-app-upnp \
|
||||
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=(
|
||||
[device]="friendlyarm_nanopi-r2s"
|
||||
[target]="rockchip/armv8"
|
||||
[filesystem]="ext4"
|
||||
[packages]="$default_packages luci-app-upnp 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['device']="friendlyarm_nanopi-r2s"
|
||||
r2s_tr['target']="rockchip/armv8"
|
||||
r2s_tr['filesystem']="ext4"
|
||||
r2s_tr['packages']="\
|
||||
$default_packages \
|
||||
luci-app-upnp \
|
||||
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=(
|
||||
[device]="friendlyarm_nanopi-r2s"
|
||||
[target]="rockchip/armv8"
|
||||
[filesystem]="ext4"
|
||||
[packages]="$default_packages luci-app-upnp luci-app-pbr luci-app-ddns \
|
||||
luci-app-statistics collectd-mod-sensors collectd-mod-thermal \
|
||||
collectd-mod-conntrack curl ethtool travelmate"
|
||||
)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする