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 |
196
openwrtbuilder
196
openwrtbuilder
@@ -5,6 +5,9 @@
|
||||
# Build and deploy OpenWRT images
|
||||
#
|
||||
# Apache 2.0 License
|
||||
#
|
||||
# See README.md and ./profiles
|
||||
#
|
||||
|
||||
# Set default release
|
||||
: "${RELEASE:="22.03.3"}"
|
||||
@@ -562,30 +565,36 @@ flashImage() {
|
||||
sshUpgrade() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
|
||||
declare img_gz img_fname
|
||||
|
||||
if (( FROM_SOURCE )); then
|
||||
if [[ -f $SOURCESYSUPGRADEIMGGZ ]]; then
|
||||
echo "Copying '$SOURCESYSUPGRADEIMGGZ' to $SSH_UPGRADE_PATH/tmp/"
|
||||
debug "scp $SOURCESYSUPGRADEIMGGZ $SSH_UPGRADE_PATH:/tmp/$SYSUPGRADEIMGGZFNAME"
|
||||
if ! scp "$SOURCESYSUPGRADEIMGGZ" "$SSH_UPGRADE_PATH":"/tmp/$SYSUPGRADEIMGGZFNAME"; then
|
||||
echo "Could not access the --ssh-upgrade PATH"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [[ -f $SYSUPGRADEIMGGZ ]]; then
|
||||
echo "Copying '$SYSUPGRADEIMGGZ' to $SSH_UPGRADE_PATH/tmp/"
|
||||
debug "scp $SYSUPGRADEIMGGZ $SSH_UPGRADE_PATH:/tmp/$SYSUPGRADEIMGGZFNAME"
|
||||
if ! scp "$SYSUPGRADEIMGGZ" "$SSH_UPGRADE_PATH":"/tmp/$SYSUPGRADEIMGGZFNAME"; then
|
||||
echo "Could not access the --ssh-upgrade PATH"
|
||||
return 1
|
||||
fi
|
||||
img_gz="$SOURCESYSUPGRADEIMGGZ"
|
||||
img_fname="$SOURCESYSUPGRADEIMGGZFNAME"
|
||||
fi
|
||||
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
|
||||
fi
|
||||
|
||||
echo "Copying '$img_gz' to $SSH_UPGRADE_PATH/tmp/$img_fname"
|
||||
debug "scp $img_gz $SSH_UPGRADE_PATH:/tmp/$img_fname"
|
||||
if ! scp "$img_gz" "$SSH_UPGRADE_PATH":"/tmp/$img_fname"; then
|
||||
echo "Could not copy $img_gz to $SSH_UPGRADE_PATH:/tmp/$img_fname"
|
||||
return 1
|
||||
fi
|
||||
|
||||
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
|
||||
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]}"
|
||||
|
||||
declare src_url="https://github.com/openwrt/openwrt.git"
|
||||
declare pkg kopt
|
||||
declare -a make_opts
|
||||
declare pkg kopt opt
|
||||
declare -a make_opts config_opts
|
||||
declare -g SEED_FILE="$GITWORKTREEDIR/.config"
|
||||
|
||||
echo "Building from source is under development"
|
||||
|
||||
@@ -603,10 +613,10 @@ fromSource() {
|
||||
mkdir -p "$GITSRCDIR"
|
||||
git clone "$src_url" "$GITSRCDIR"
|
||||
fi
|
||||
|
||||
git -C "$GITSRCDIR" pull
|
||||
|
||||
|
||||
if [[ ${P_ARR[release]} == "snapshot" ]]; then
|
||||
if [[ $RELEASE == "snapshot" ]]; then
|
||||
git -C "$GITSRCDIR" worktree add -d "$GITWORKTREEDIR" master
|
||||
else
|
||||
git -C "$GITSRCDIR" worktree add -d "$GITWORKTREEDIR" "v$RELEASE"
|
||||
@@ -614,90 +624,85 @@ fromSource() {
|
||||
|
||||
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
|
||||
# git checkout master
|
||||
# else
|
||||
# git checkout "v$RELEASE"
|
||||
# fi
|
||||
# Set compilation output dir
|
||||
config_opts+=("CONFIG_BINARY_FOLDER=\"$THIS_BINDIR\"")
|
||||
|
||||
# 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
|
||||
# ./scripts/feeds install will run make defconfig for us
|
||||
# to normalize and expand .config
|
||||
./scripts/feeds update -a &&
|
||||
./scripts/feeds install -a
|
||||
|
||||
# Grab the release seed config
|
||||
if [[ -f "$SEED_FILE" ]]; then
|
||||
if askOk "$SEED_FILE exists. Recreate?"; then
|
||||
make distclean
|
||||
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
|
||||
# TODO for now symlink clang for qosify
|
||||
declare llvm_dir="$GITSRCDIR/staging_dir/host/llvm-bpf/bin"
|
||||
[[ -d "$llvm_dir" ]] || mkdir -p "$llvm_dir"
|
||||
ln -fs "$(which clang)" "$llvm_dir/clang"
|
||||
|
||||
make defconfig # normalize .config and remove dupes
|
||||
|
||||
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\"")
|
||||
# Make image
|
||||
(( DEBUG )) && make_opts+=("V=s")
|
||||
|
||||
# Override default .config seed with profile packages
|
||||
# for pkg in ${P_ARR[packages]:+${P_ARR[packages]}}; do
|
||||
# if [[ $pkg == -* ]]; then
|
||||
# echo "CONFIG_PACKAGE_${pkg#-}=n" >> "$SEED_FILE" # remove package
|
||||
# else
|
||||
# echo "CONFIG_PACKAGE_$pkg=y" >> "$SEED_FILE" # add package
|
||||
# fi
|
||||
# done
|
||||
# Cleaning modes
|
||||
# make clean # compiled output
|
||||
# make targetclean # compiled output, toolchain
|
||||
# make dirclean # compiled output, toolchain, build tools
|
||||
# make distclean # compiled output, toolchain, build tools, .config, feeds, .ccache
|
||||
|
||||
# Add custom kernel config options
|
||||
# for kopt in ${P_ARR[kopts]:+${P_ARR[kopts]}}; do
|
||||
# echo "$kopt" >> "$SEED_FILE"
|
||||
# done
|
||||
|
||||
|
||||
# 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" &&
|
||||
debug "make ${make_opts[*]} dirclean"
|
||||
make "${make_opts[@]}" dirclean
|
||||
debug "make ${make_opts[*]} download"
|
||||
make "${make_opts[@]}" download
|
||||
debug "make ${make_opts[*]} -j$(nproc) world"
|
||||
make "${make_opts[@]}" -j"$(nproc)" world
|
||||
|
||||
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_FILE="$BUILDDIR/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 FACTORYIMGGZ="$BUILDDIR/$img_fname-factory.img.gz"
|
||||
declare -g FACTORYIMGGZFNAME="${FACTORYIMGGZ##*/}"
|
||||
@@ -828,8 +830,10 @@ main() {
|
||||
declare -g SOURCEFACTORYIMGGZ="$THIS_BINDIR/$img_fname-factory.img.gz"
|
||||
declare -g SOURCESYSUPGRADEIMG="$THIS_BINDIR/targets/$img_fname-sysupgrade.img"
|
||||
declare -g SOURCESYSUPGRADEIMGGZ="$THIS_BINDIR/targets/$img_fname-sysupgrade.img.gz"
|
||||
|
||||
declare -g GITWORKTREEDIR="$GITSRCDIR/$profile/$RELEASE"
|
||||
declare -g SOURCESYSUPGRADEIMGGZFNAME="${SOURCESYSUPGRADEIMGGZ##*/}"
|
||||
declare -g GITWORKTREEDIR="$SRCDIR/$profile/$RELEASE"
|
||||
declare -g SEED_URL="$url_prefix/config.buildinfo"
|
||||
declare -g SEED_FILE="$GITWORKTREEDIR/.config"
|
||||
|
||||
if (( DEBUG )); then
|
||||
echo "Profile settings:"
|
||||
|
||||
Reference in New Issue
Block a user