Compare commits

...

24 Commits

Author SHA1 Message Date
66ff417333 More --source cleanup 2023-01-29 18:05:48 -05:00
f82e32f88a More --source cleanup 2023-01-29 18:01:10 -05:00
7370fb688d More --source cleanup 2023-01-29 17:53:37 -05:00
53a0a39af4 More --source cleanup 2023-01-29 17:37:04 -05:00
ce8a642658 Less debug 2023-01-29 17:17:50 -05:00
7431b22076 More work on --source 2023-01-29 17:16:12 -05:00
433b899ef0 More work on --source 2023-01-29 15:56:42 -05:00
afa6ea2abc More work on --source 2023-01-29 15:52:54 -05:00
5f55675193 More work on --source 2023-01-29 15:51:01 -05:00
5eb9aa3e99 More work on --source 2023-01-29 15:49:07 -05:00
c0a46f264a More work on --source 2023-01-29 15:45:17 -05:00
66639d832c More work on --source 2023-01-29 15:44:17 -05:00
489988c16d More debug output 2023-01-28 11:21:58 -05:00
63ce0122cf More debug output 2023-01-28 11:17:08 -05:00
f3bce0a6fe More debug output 2023-01-28 11:14:41 -05:00
e3a264d029 More debug output 2023-01-28 11:07:32 -05:00
194fd012fb Disable defconfig 2023-01-28 10:50:39 -05:00
37771a7b81 Write opts to .config 2023-01-27 16:46:45 -05:00
eaae9e8e9c Use .config instead of envs 2023-01-27 16:24:23 -05:00
dc6661572a Always recreate .config 2023-01-27 11:33:15 -05:00
f73ea6d5cf Refactor sshupgrade() 2023-01-27 11:12:24 -05:00
8823d70052 More work on --source 2023-01-26 23:32:34 -05:00
e3a92d444c More work on --source 2023-01-26 23:18:40 -05:00
dba19f1f09 Remove legacy code 2023-01-26 22:10:38 -05:00
2 changed files with 103 additions and 96 deletions

View File

@@ -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
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
fi 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 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:"

View File

@@ -111,6 +111,9 @@ r4s['packages']="\
r4s['kopts']="\ r4s['kopts']="\
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \ CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \
" "
r4s['files']="\
/mnt/backup \
"
declare -Ag ax6000_stock declare -Ag ax6000_stock