Compare commits
24 Commits
0fe80c0a1c
...
66ff417333
| Author | SHA1 | Date | |
|---|---|---|---|
| 66ff417333 | |||
| f82e32f88a | |||
| 7370fb688d | |||
| 53a0a39af4 | |||
| ce8a642658 | |||
| 7431b22076 | |||
| 433b899ef0 | |||
| afa6ea2abc | |||
| 5f55675193 | |||
| 5eb9aa3e99 | |||
| c0a46f264a | |||
| 66639d832c | |||
| 489988c16d | |||
| 63ce0122cf | |||
| f3bce0a6fe | |||
| e3a264d029 | |||
| 194fd012fb | |||
| 37771a7b81 | |||
| eaae9e8e9c | |||
| dc6661572a | |||
| f73ea6d5cf | |||
| 8823d70052 | |||
| e3a92d444c | |||
| dba19f1f09 |
192
openwrtbuilder
192
openwrtbuilder
@@ -5,6 +5,9 @@
|
|||||||
# Build and deploy OpenWRT images
|
# Build and deploy OpenWRT images
|
||||||
#
|
#
|
||||||
# Apache 2.0 License
|
# Apache 2.0 License
|
||||||
|
#
|
||||||
|
# See README.md and ./profiles
|
||||||
|
#
|
||||||
|
|
||||||
# Set default release
|
# Set default release
|
||||||
: "${RELEASE:="22.03.3"}"
|
: "${RELEASE:="22.03.3"}"
|
||||||
@@ -562,30 +565,36 @@ flashImage() {
|
|||||||
sshUpgrade() {
|
sshUpgrade() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
|
declare img_gz img_fname
|
||||||
|
|
||||||
if (( FROM_SOURCE )); then
|
if (( FROM_SOURCE )); then
|
||||||
if [[ -f $SOURCESYSUPGRADEIMGGZ ]]; then
|
if [[ -f $SOURCESYSUPGRADEIMGGZ ]]; then
|
||||||
echo "Copying '$SOURCESYSUPGRADEIMGGZ' to $SSH_UPGRADE_PATH/tmp/"
|
img_gz="$SOURCESYSUPGRADEIMGGZ"
|
||||||
debug "scp $SOURCESYSUPGRADEIMGGZ $SSH_UPGRADE_PATH:/tmp/$SYSUPGRADEIMGGZFNAME"
|
img_fname="$SOURCESYSUPGRADEIMGGZFNAME"
|
||||||
if ! scp "$SOURCESYSUPGRADEIMGGZ" "$SSH_UPGRADE_PATH":"/tmp/$SYSUPGRADEIMGGZFNAME"; then
|
fi
|
||||||
echo "Could not access the --ssh-upgrade PATH"
|
elif [[ -f $SYSUPGRADEIMGGZ ]]; then
|
||||||
|
img_gz="$SYSUPGRADEIMGGZ"
|
||||||
|
img_fname="$SYSUPGRADEIMGGZFNAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f $img_gz ]]; then
|
||||||
|
echo "$img_gz is missing, check build output"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
else
|
echo "Copying '$img_gz' to $SSH_UPGRADE_PATH/tmp/$img_fname"
|
||||||
if [[ -f $SYSUPGRADEIMGGZ ]]; then
|
debug "scp $img_gz $SSH_UPGRADE_PATH:/tmp/$img_fname"
|
||||||
echo "Copying '$SYSUPGRADEIMGGZ' to $SSH_UPGRADE_PATH/tmp/"
|
if ! scp "$img_gz" "$SSH_UPGRADE_PATH":"/tmp/$img_fname"; then
|
||||||
debug "scp $SYSUPGRADEIMGGZ $SSH_UPGRADE_PATH:/tmp/$SYSUPGRADEIMGGZFNAME"
|
echo "Could not copy $img_gz to $SSH_UPGRADE_PATH:/tmp/$img_fname"
|
||||||
if ! scp "$SYSUPGRADEIMGGZ" "$SSH_UPGRADE_PATH":"/tmp/$SYSUPGRADEIMGGZFNAME"; then
|
|
||||||
echo "Could not access the --ssh-upgrade PATH"
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Executing remote sysupgrade"
|
echo "Executing remote sysupgrade"
|
||||||
debug "ssh $SSH_UPGRADE_PATH sysupgrade -F /tmp/$SYSUPGRADEIMGGZFNAME"
|
debug "ssh $SSH_UPGRADE_PATH sysupgrade -F /tmp/$img_fname"
|
||||||
# shellcheck disable=SC2029
|
# shellcheck disable=SC2029
|
||||||
ssh "$SSH_UPGRADE_PATH" "sysupgrade -F /tmp/$SYSUPGRADEIMGGZFNAME"
|
# execute remotely
|
||||||
|
# this will probably be a weird exit code from closed connection
|
||||||
|
ssh "$SSH_UPGRADE_PATH" "sysupgrade -F /tmp/$img_fname"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -593,8 +602,9 @@ fromSource() {
|
|||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
declare src_url="https://github.com/openwrt/openwrt.git"
|
declare src_url="https://github.com/openwrt/openwrt.git"
|
||||||
declare pkg kopt
|
declare pkg kopt opt
|
||||||
declare -a make_opts
|
declare -a make_opts config_opts
|
||||||
|
declare -g SEED_FILE="$GITWORKTREEDIR/.config"
|
||||||
|
|
||||||
echo "Building from source is under development"
|
echo "Building from source is under development"
|
||||||
|
|
||||||
@@ -603,10 +613,10 @@ fromSource() {
|
|||||||
mkdir -p "$GITSRCDIR"
|
mkdir -p "$GITSRCDIR"
|
||||||
git clone "$src_url" "$GITSRCDIR"
|
git clone "$src_url" "$GITSRCDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git -C "$GITSRCDIR" pull
|
git -C "$GITSRCDIR" pull
|
||||||
|
|
||||||
|
if [[ $RELEASE == "snapshot" ]]; then
|
||||||
if [[ ${P_ARR[release]} == "snapshot" ]]; then
|
|
||||||
git -C "$GITSRCDIR" worktree add -d "$GITWORKTREEDIR" master
|
git -C "$GITSRCDIR" worktree add -d "$GITWORKTREEDIR" master
|
||||||
else
|
else
|
||||||
git -C "$GITSRCDIR" worktree add -d "$GITWORKTREEDIR" "v$RELEASE"
|
git -C "$GITSRCDIR" worktree add -d "$GITWORKTREEDIR" "v$RELEASE"
|
||||||
@@ -614,90 +624,85 @@ fromSource() {
|
|||||||
|
|
||||||
pushd "$GITWORKTREEDIR" &>/dev/null || return 1
|
pushd "$GITWORKTREEDIR" &>/dev/null || return 1
|
||||||
|
|
||||||
SEED_FILE="$GITWORKTREEDIR/.config"
|
# Grab the release seed config
|
||||||
|
if ! curl -so "$SEED_FILE" "$SEED_URL"; then
|
||||||
|
echo "Could not obtain $SEED_FILE from $SEED_URL"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# if [[ ${P_ARR[release]} == "snapshot" ]]; then
|
# Set compilation output dir
|
||||||
# git checkout master
|
config_opts+=("CONFIG_BINARY_FOLDER=\"$THIS_BINDIR\"")
|
||||||
# else
|
|
||||||
# git checkout "v$RELEASE"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# git pull
|
# Add custom packages
|
||||||
|
for pkg in ${P_ARR[packages]}; do
|
||||||
|
if [[ $pkg == -* ]]; then
|
||||||
|
config_opts+=("CONFIG_PACKAGE_${pkg#-}=n") # remove package
|
||||||
|
else
|
||||||
|
config_opts+=("CONFIG_PACKAGE_$pkg=y") # add package
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Add kopts from profile
|
||||||
|
for kopt in ${P_ARR[kopts]}; do
|
||||||
|
config_opts+=("$kopt")
|
||||||
|
done
|
||||||
|
|
||||||
|
# Only compile selected fs
|
||||||
|
sed -i '/CONFIG_TARGET_ROOTFS_/d' "$SEED_FILE"
|
||||||
|
config_opts+=("CONFIG_TARGET_PER_DEVICE_ROOTFS=n")
|
||||||
|
if [[ $FILESYSTEM == "squashfs" ]]; then
|
||||||
|
config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=n")
|
||||||
|
config_opts+=("CONFIG_TARGET_ROOTFS_SQUASHFS=y")
|
||||||
|
elif [[ $FILESYSTEM == "ext4" ]]; then
|
||||||
|
config_opts+=("CONFIG_TARGET_ROOTFS_SQUASHFS=n")
|
||||||
|
config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=y")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Only compile selected target
|
||||||
|
sed -i '/CONFIG_TARGET_DEVICE_/d' "$SEED_FILE"
|
||||||
|
config_opts+=("CONFIG_TARGET_MULTI_PROFILE=n")
|
||||||
|
config_opts+=("CONFIG_TARGET_PROFILE=DEVICE_${P_ARR[profile]}")
|
||||||
|
config_opts+=("CONFIG_TARGET_${P_ARR[target]//\//_}_DEVICE_${P_ARR[profile]}=y")
|
||||||
|
config_opts+=("CONFIG_SDK=n")
|
||||||
|
config_opts+=("CONFIG_SDK_LLVM_BPF=n")
|
||||||
|
config_opts+=("CONFIG_IB=n")
|
||||||
|
config_opts+=("CONFIG_MAKE_TOOLCHAIN=n")
|
||||||
|
|
||||||
|
# Write options to config seed file
|
||||||
|
for opt in "${config_opts[@]}"; do
|
||||||
|
debug "Writing $opt to $SEED_FILE"
|
||||||
|
echo "$opt" >> "$SEED_FILE"
|
||||||
|
done
|
||||||
|
|
||||||
# Update package feed
|
# Update package feed
|
||||||
|
# ./scripts/feeds install will run make defconfig for us
|
||||||
|
# to normalize and expand .config
|
||||||
./scripts/feeds update -a &&
|
./scripts/feeds update -a &&
|
||||||
./scripts/feeds install -a
|
./scripts/feeds install -a
|
||||||
|
|
||||||
# Grab the release seed config
|
# TODO for now symlink clang for qosify
|
||||||
if [[ -f "$SEED_FILE" ]]; then
|
declare llvm_dir="$GITSRCDIR/staging_dir/host/llvm-bpf/bin"
|
||||||
if askOk "$SEED_FILE exists. Recreate?"; then
|
[[ -d "$llvm_dir" ]] || mkdir -p "$llvm_dir"
|
||||||
make distclean
|
ln -fs "$(which clang)" "$llvm_dir/clang"
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ -f "$SEED_FILE" ]]; then
|
|
||||||
echo "Reusing existing $SEED_FILE seed config"
|
|
||||||
else
|
|
||||||
if ! curl -so "$SEED_FILE" "$SEED_URL"; then
|
|
||||||
echo "Could not obtain seed config"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
make defconfig # normalize .config and remove dupes
|
# Make image
|
||||||
|
|
||||||
for pkg in ${P_ARR[packages]:+}; do
|
|
||||||
if [[ $pkg == -* ]]; then
|
|
||||||
make_opts+=("CONFIG_PACKAGE_${pkg#-}=n") # remove package
|
|
||||||
else
|
|
||||||
make_opts+=("CONFIG_PACKAGE_$pkg=y") # add package
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
for kopt in ${P_ARR[kopts]:+}; do
|
|
||||||
make_opts+=("$kopt")
|
|
||||||
done
|
|
||||||
|
|
||||||
make_opts+=("CONFIG_TARGET_MULTI_PROFILE=n")
|
|
||||||
make_opts+=("CONFIG_TARGET_ALL_PROFILES=n")
|
|
||||||
make_opts+=("CONFIG_SDK=n")
|
|
||||||
make_opts+=("CONFIG_SDK_LLVM_BPF=n")
|
|
||||||
make_opts+=("CONFIG_TARGET_PROFILE=DEVICE_${P_ARR[profile]}")
|
|
||||||
make_opts+=("CONFIG_TARGET_DEVICE_${P_ARR[target]//\//_}_DEVICE_${P_ARR[profile]}=y")
|
|
||||||
make_opts+=("CONFIG_BINARY_FOLDER=\"$THIS_BINDIR\"")
|
|
||||||
(( DEBUG )) && make_opts+=("V=s")
|
(( DEBUG )) && make_opts+=("V=s")
|
||||||
|
|
||||||
# Override default .config seed with profile packages
|
# Cleaning modes
|
||||||
# for pkg in ${P_ARR[packages]:+${P_ARR[packages]}}; do
|
# make clean # compiled output
|
||||||
# if [[ $pkg == -* ]]; then
|
# make targetclean # compiled output, toolchain
|
||||||
# echo "CONFIG_PACKAGE_${pkg#-}=n" >> "$SEED_FILE" # remove package
|
# make dirclean # compiled output, toolchain, build tools
|
||||||
# else
|
# make distclean # compiled output, toolchain, build tools, .config, feeds, .ccache
|
||||||
# echo "CONFIG_PACKAGE_$pkg=y" >> "$SEED_FILE" # add package
|
|
||||||
# fi
|
|
||||||
# done
|
|
||||||
|
|
||||||
# Add custom kernel config options
|
debug "make ${make_opts[*]} dirclean"
|
||||||
# for kopt in ${P_ARR[kopts]:+${P_ARR[kopts]}}; do
|
make "${make_opts[@]}" dirclean
|
||||||
# echo "$kopt" >> "$SEED_FILE"
|
debug "make ${make_opts[*]} download"
|
||||||
# done
|
make "${make_opts[@]}" download
|
||||||
|
debug "make ${make_opts[*]} -j$(nproc) world"
|
||||||
|
|
||||||
# Only compile our target
|
|
||||||
# TODO causes a "configuration is out of sync" error w/o defconfig
|
|
||||||
# sed -i '/CONFIG_TARGET_DEVICE_/d' "$SEED_FILE"
|
|
||||||
# echo "CONFIG_TARGET_DEVICE_${P_ARR[target]//\//_}_DEVICE_${P_ARR[profile]}=y" >> "$SEED_FILE"
|
|
||||||
|
|
||||||
# output to bindir instead of builddir
|
|
||||||
# echo "CONFIG_BINARY_FOLDER=\"$THIS_BINDIR\"" >> "$SEED_FILE"
|
|
||||||
|
|
||||||
# TODO symlink clang for qosify
|
|
||||||
[[ -d "$GITSRCDIR/staging_dir/host/llvm-bpf/bin" ]] || mkdir -p "$GITSRCDIR/staging_dir/host/llvm-bpf/bin"
|
|
||||||
ln -fs "$(which clang)" "$GITSRCDIR/staging_dir/host/llvm-bpf/bin/clang"
|
|
||||||
|
|
||||||
make "${make_opts[@]}" download &&
|
|
||||||
debug "${make_opts[*]} -j$(nproc) world" &&
|
|
||||||
make "${make_opts[@]}" -j"$(nproc)" world
|
make "${make_opts[@]}" -j"$(nproc)" world
|
||||||
|
|
||||||
popd &>/dev/null || return 1
|
popd &>/dev/null || return 1
|
||||||
exit # TODO exit here for fromSource() testing
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -815,9 +820,6 @@ main() {
|
|||||||
declare -g IB_SHA256_URL="$url_prefix/sha256sums"
|
declare -g IB_SHA256_URL="$url_prefix/sha256sums"
|
||||||
declare -g IB_SHA256_FILE="$BUILDDIR/sha256sums"
|
declare -g IB_SHA256_FILE="$BUILDDIR/sha256sums"
|
||||||
declare -g IB_OUT_SHA256_FILE="$THIS_BINDIR/sha256sums"
|
declare -g IB_OUT_SHA256_FILE="$THIS_BINDIR/sha256sums"
|
||||||
declare -g SEED_URL="$url_prefix/config.buildinfo"
|
|
||||||
declare -g SEED_FILE="$GITSRCDIR/.config"
|
|
||||||
|
|
||||||
declare -g FACTORYIMG="$BUILDDIR/$img_fname-factory.img"
|
declare -g FACTORYIMG="$BUILDDIR/$img_fname-factory.img"
|
||||||
declare -g FACTORYIMGGZ="$BUILDDIR/$img_fname-factory.img.gz"
|
declare -g FACTORYIMGGZ="$BUILDDIR/$img_fname-factory.img.gz"
|
||||||
declare -g FACTORYIMGGZFNAME="${FACTORYIMGGZ##*/}"
|
declare -g FACTORYIMGGZFNAME="${FACTORYIMGGZ##*/}"
|
||||||
@@ -828,8 +830,10 @@ main() {
|
|||||||
declare -g SOURCEFACTORYIMGGZ="$THIS_BINDIR/$img_fname-factory.img.gz"
|
declare -g SOURCEFACTORYIMGGZ="$THIS_BINDIR/$img_fname-factory.img.gz"
|
||||||
declare -g SOURCESYSUPGRADEIMG="$THIS_BINDIR/targets/$img_fname-sysupgrade.img"
|
declare -g SOURCESYSUPGRADEIMG="$THIS_BINDIR/targets/$img_fname-sysupgrade.img"
|
||||||
declare -g SOURCESYSUPGRADEIMGGZ="$THIS_BINDIR/targets/$img_fname-sysupgrade.img.gz"
|
declare -g SOURCESYSUPGRADEIMGGZ="$THIS_BINDIR/targets/$img_fname-sysupgrade.img.gz"
|
||||||
|
declare -g SOURCESYSUPGRADEIMGGZFNAME="${SOURCESYSUPGRADEIMGGZ##*/}"
|
||||||
declare -g GITWORKTREEDIR="$GITSRCDIR/$profile/$RELEASE"
|
declare -g GITWORKTREEDIR="$SRCDIR/$profile/$RELEASE"
|
||||||
|
declare -g SEED_URL="$url_prefix/config.buildinfo"
|
||||||
|
declare -g SEED_FILE="$GITWORKTREEDIR/.config"
|
||||||
|
|
||||||
if (( DEBUG )); then
|
if (( DEBUG )); then
|
||||||
echo "Profile settings:"
|
echo "Profile settings:"
|
||||||
|
|||||||
Reference in New Issue
Block a user