Move gitworktreedir to global

This commit is contained in:
2023-02-16 13:04:56 -05:00
parent f1f7fca41e
commit 6953cdfc5e

View File

@@ -8,9 +8,6 @@
# #
# See README.md and ./profiles # See README.md and ./profiles
# #
# This will install a lot of system dependencies by default so I
# recommend running it in `toolbox`, container, or VM
#
# Some PROFILE options are incompatible with Image Builder mode (kopts) and # Some PROFILE options are incompatible with Image Builder mode (kopts) and
# will be ignored # will be ignored
# #
@@ -542,7 +539,7 @@ fromSource() {
declare src_dir="$BUILDROOT/src/openwrt" declare src_dir="$BUILDROOT/src/openwrt"
declare src_url="https://github.com/openwrt/openwrt.git" declare src_url="https://github.com/openwrt/openwrt.git"
declare pkg kopt opt commit gitworktreedir seed_file wt_cmd declare pkg kopt opt commit seed_file wt_cmd
declare -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"
@@ -561,12 +558,11 @@ fromSource() {
commit=$(git -C "$src_dir" rev-parse HEAD) commit=$(git -C "$src_dir" rev-parse HEAD)
debug "Current commit hash: $commit" debug "Current commit hash: $commit"
gitworktreedir="$BUILDROOT/src/$profile/$RELEASE-src"
wt_cmd=(git -C "$src_dir" wt_cmd=(git -C "$src_dir"
worktree add worktree add
--force --force
--detach --detach
"$gitworktreedir") "$SOURCEDIR")
if [[ $RELEASE == "snapshot" ]]; then if [[ $RELEASE == "snapshot" ]]; then
execute "${wt_cmd[@]}" master execute "${wt_cmd[@]}" master
@@ -574,10 +570,10 @@ fromSource() {
execute "${wt_cmd[@]}" "origin/openwrt-${RELEASE%.*}" execute "${wt_cmd[@]}" "origin/openwrt-${RELEASE%.*}"
fi fi
seed_file="$gitworktreedir/.config" seed_file="$SOURCEDIR/.config"
debug "seed_file: $seed_file" debug "seed_file: $seed_file"
execute pushd "$gitworktreedir" || return 1 execute pushd "$SOURCEDIR" || return 1
# Update package feed # Update package feed
./scripts/feeds update -a && ./scripts/feeds update -a &&
@@ -759,11 +755,12 @@ main() {
declare -g TARGET="${P_ARR[target]}" declare -g TARGET="${P_ARR[target]}"
declare -g PROFILE="${P_ARR[profile]}" declare -g PROFILE="${P_ARR[profile]}"
declare -g PACKAGES="${P_ARR[packages]:-}" declare -g PACKAGES="${P_ARR[packages]:-}"
declare -g SOURCEDIR="$BUILDROOT/src/$profile/$RELEASE-src"
if (( RESET )); then if (( RESET )); then
askOk "Remove $BUILDDIR and $BINDIR?" || exit $? for d in "$BUILDDIR" "$SOURCEDIR" "$BINDIR"; do
debug "rm -rf $BUILDDIR $BINDIR" askOk "Remove $d?" && execute rm -rf "$d"
rm -rf "$BUILDDIR" "$BINDIR" done
fi fi
[[ -d $BUILDDIR ]] || mkdir -p "$BUILDDIR" [[ -d $BUILDDIR ]] || mkdir -p "$BUILDDIR"