diff --git a/build.sh b/build.sh index b741a98..2217de5 100755 --- a/build.sh +++ b/build.sh @@ -38,6 +38,7 @@ Build AzerothCore with custom modules and create deployment-ready images. Options: --yes, -y Auto-confirm all prompts --force Force rebuild even if no changes detected + --force-update Force update source repository to latest commits --source-path PATH Custom source repository path --skip-source-setup Skip automatic source repository setup -h, --help Show this help @@ -53,6 +54,7 @@ Examples: ./build.sh Interactive build ./build.sh --yes Auto-confirm build ./build.sh --force Force rebuild regardless of state + ./build.sh --force-update Update source to latest and build EOF } @@ -60,6 +62,7 @@ while [[ $# -gt 0 ]]; do case "$1" in --yes|-y) ASSUME_YES=1; shift;; --force) FORCE_REBUILD=1; shift;; + --force-update) FORCE_UPDATE=1; shift;; --source-path) CUSTOM_SOURCE_PATH="$2"; shift 2;; --skip-source-setup) SKIP_SOURCE_SETUP=1; shift;; -h|--help) usage; exit 0;; @@ -240,6 +243,13 @@ ensure_source_repo(){ src_path="${src_path//\/.\//\/}" if [ -d "$src_path/.git" ]; then + if [ "${FORCE_UPDATE:-0}" = "1" ]; then + info "Force update requested - updating source repository to latest" >&2 + if ! (cd "$ROOT_DIR" && ./scripts/bash/setup-source.sh) >&2; then + err "Failed to update source repository" >&2 + exit 1 + fi + fi echo "$src_path" return fi @@ -540,6 +550,10 @@ stage_modules(){ rm -f "$staging_modules_dir/.modules_state" "$staging_modules_dir/.requires_rebuild" 2>/dev/null || true fi + # Export environment variables needed by module hooks + export STACK_SOURCE_VARIANT="$(read_env STACK_SOURCE_VARIANT "core")" + export MODULES_REBUILD_SOURCE_PATH="$(read_env MODULES_REBUILD_SOURCE_PATH "")" + if ! (cd "$local_modules_dir" && bash "$ROOT_DIR/scripts/bash/manage-modules.sh"); then err "Module staging failed; aborting build" return 1 diff --git a/scripts/bash/manage-modules.sh b/scripts/bash/manage-modules.sh index 44c215c..0e70ff3 100755 --- a/scripts/bash/manage-modules.sh +++ b/scripts/bash/manage-modules.sh @@ -141,6 +141,10 @@ run_post_install_hooks(){ export MODULES_ROOT="${MODULES_ROOT:-/modules}" export LUA_SCRIPTS_TARGET="/azerothcore/lua_scripts" + # Pass build environment variables to hooks + export STACK_SOURCE_VARIANT="${STACK_SOURCE_VARIANT:-}" + export MODULES_REBUILD_SOURCE_PATH="${MODULES_REBUILD_SOURCE_PATH:-}" + # Execute the hook script if "$hook_script"; then ok "Hook '$hook' completed successfully" diff --git a/scripts/hooks/mod-ale-patches b/scripts/hooks/mod-ale-patches index f0cc8b7..aa5530a 100755 --- a/scripts/hooks/mod-ale-patches +++ b/scripts/hooks/mod-ale-patches @@ -10,11 +10,19 @@ MODULE_NAME="${MODULE_NAME:-}" # Detect if we're building with playerbots fork IS_PLAYERBOTS_FORK=0 -if [ -n "$MODULE_DIR" ]; then - # Check if the parent directory structure indicates playerbots fork - if echo "$MODULE_DIR" | grep -q "azerothcore-playerbots"; then - IS_PLAYERBOTS_FORK=1 - fi + +# Method 1: Check STACK_SOURCE_VARIANT environment variable +if [ "${STACK_SOURCE_VARIANT:-}" = "playerbots" ]; then + IS_PLAYERBOTS_FORK=1 + echo " ✅ Playerbots detected via STACK_SOURCE_VARIANT" +# Method 2: Check MODULES_REBUILD_SOURCE_PATH +elif [ -n "${MODULES_REBUILD_SOURCE_PATH:-}" ] && echo "${MODULES_REBUILD_SOURCE_PATH}" | grep -q "azerothcore-playerbots"; then + IS_PLAYERBOTS_FORK=1 + echo " ✅ Playerbots detected via MODULES_REBUILD_SOURCE_PATH" +else + echo " ❌ Playerbots fork not detected" + echo " 🔍 Debug: STACK_SOURCE_VARIANT='${STACK_SOURCE_VARIANT:-}'" + echo " 🔍 Debug: MODULES_REBUILD_SOURCE_PATH='${MODULES_REBUILD_SOURCE_PATH:-}'" fi # Feature flags (set to 0 to disable specific patches) @@ -69,10 +77,10 @@ apply_sendtrainerlist_patch() { return 1 fi - # Check if the buggy code exists (without GET_GUID()) + # Check if the buggy code exists (without GetGUID()) if grep -q 'player->GetSession()->SendTrainerList(obj);' "$target_file"; then - # Apply the fix by adding ->GET_GUID() - if sed -i 's/player->GetSession()->SendTrainerList(obj);/player->GetSession()->SendTrainerList(obj->GET_GUID());/' "$target_file"; then + # Apply the fix by adding ->GetGUID() + if sed -i 's/player->GetSession()->SendTrainerList(obj);/player->GetSession()->SendTrainerList(obj->GetGUID());/' "$target_file"; then echo " ✅ Applied SendTrainerList compatibility fix" return 0 else diff --git a/setup.sh b/setup.sh index f582c12..cdb7842 100755 --- a/setup.sh +++ b/setup.sh @@ -1487,11 +1487,16 @@ fi MODULES_CPP_LIST="$(IFS=','; printf '%s' "${enabled_cpp_module_keys[*]}")" fi - local STACK_IMAGE_MODE="standard" + # Determine source variant based ONLY on playerbots module local STACK_SOURCE_VARIANT="core" if [ "$MODULE_PLAYERBOTS" = "1" ] || [ "$PLAYERBOT_ENABLED" = "1" ]; then - STACK_IMAGE_MODE="playerbots" STACK_SOURCE_VARIANT="playerbots" + fi + + # Determine image mode based on source variant and build requirements + local STACK_IMAGE_MODE="standard" + if [ "$STACK_SOURCE_VARIANT" = "playerbots" ]; then + STACK_IMAGE_MODE="playerbots" elif [ "$NEEDS_CXX_REBUILD" = "1" ]; then STACK_IMAGE_MODE="modules" fi @@ -1587,7 +1592,7 @@ fi fi local default_source_rel="${LOCAL_STORAGE_ROOT}/source/azerothcore" - if [ "$MODULE_PLAYERBOTS" = "1" ]; then + if [ "$STACK_SOURCE_VARIANT" = "playerbots" ]; then default_source_rel="${LOCAL_STORAGE_ROOT}/source/azerothcore-playerbots" fi