From 08c925ffbedcc1607ca52c3cc4bef0954b2b874e Mon Sep 17 00:00:00 2001 From: celenity Date: Sun, 22 Mar 2026 20:12:22 +0000 Subject: [PATCH] fix: replace python 3.9 with the latest python(3), + add IRONFOX_PYTHON variable for setting the location of python, and prevent dynamically creating our gradle script from `get_source.sh` (no reason to) Signed-off-by: celenity --- Dockerfile | 2 +- scripts/bootstrap.sh | 6 +++--- scripts/deglean.sh | 2 +- scripts/env_common.sh | 20 +++++++++++++------- scripts/env_external.sh | 2 +- scripts/get_sources-if.sh | 17 +++-------------- scripts/gradle.sh | 2 ++ scripts/prebuild-if.sh | 4 ++-- 8 files changed, 26 insertions(+), 29 deletions(-) create mode 100755 scripts/gradle.sh diff --git a/Dockerfile b/Dockerfile index d21768b..c6da68f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN dnf install -y \ ninja-build \ patch \ perl \ - python3.9 \ + python \ shasum \ temurin-8-jdk \ temurin-17-jdk \ diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 148977c..83ef33e 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -72,7 +72,7 @@ if [[ "${IRONFOX_OS}" == 'osx' ]] || [[ "${IRONFOX_OS}" == 'secureblue' ]]; then ninja \ node \ perl \ - python@3.9 \ + python \ yq || error_fn echo @@ -144,7 +144,7 @@ elif [[ "${IRONFOX_OS}" == 'fedora' ]]; then ninja-build \ patch \ perl \ - python3.9 \ + python \ shasum \ temurin-8-jdk \ temurin-17-jdk \ @@ -185,7 +185,7 @@ elif [[ "${IRONFOX_OS}" == 'ubuntu' ]]; then ninja-build \ patch \ perl \ - python3.9 \ + python \ tar \ temurin-8-jdk \ temurin-17-jdk \ diff --git a/scripts/deglean.sh b/scripts/deglean.sh index 87c8f91..ecf1c2d 100755 --- a/scripts/deglean.sh +++ b/scripts/deglean.sh @@ -13,7 +13,7 @@ function deglean() { if [ -n "${gradle_files}" ]; then for file in $gradle_files; do local modified=false - python3 "${IRONFOX_SCRIPTS}/deglean.py" "${file}" + "${IRONFOX_PYTHON}" "${IRONFOX_SCRIPTS}/deglean.py" "${file}" if grep -q 'apply plugin.*glean' "${file}"; then "${IRONFOX_SED}" -i -r 's/^(.*apply plugin:.*glean.*)$/\/\/ \1/' "${file}" diff --git a/scripts/env_common.sh b/scripts/env_common.sh index 000c838..7dc8b93 100644 --- a/scripts/env_common.sh +++ b/scripts/env_common.sh @@ -339,7 +339,8 @@ IRONFOX_GRADLE_DIR_DEFAULT="${IRONFOX_EXTERNAL}/gradle" if [[ -z "${IRONFOX_GRADLE_DIR+x}" ]]; then export IRONFOX_GRADLE_DIR="${IRONFOX_GRADLE_DIR_DEFAULT}" fi -export IRONFOX_GRADLE="${IRONFOX_GRADLE_DIR}/gradle" +export IRONFOX_GRADLE="${IRONFOX_SCRIPTS}/gradle.sh" +export IRONFOX_GRADLE_PY="${IRONFOX_GRADLE_DIR}/gradlew.py" ## Gradle cache IRONFOX_GRADLE_CACHE_DEFAULT="${IRONFOX_BUILD}/gradle/cache" @@ -431,8 +432,15 @@ if [[ -z "${IRONFOX_PIP+x}" ]]; then export IRONFOX_PIP="${IRONFOX_PIP_DEFAULT}" fi -# Python (Glean) -export IRONFOX_GLEAN_PIP_ENV="${IRONFOX_GRADLE_HOME}/glean" +# Python +if [[ "${IRONFOX_OS}" == 'osx' ]]; then + IRONFOX_PYTHON_DEFAULT='/opt/homebrew/bin/python' +else + IRONFOX_PYTHON_DEFAULT="$(which python)" +fi +if [[ -z "${IRONFOX_PYTHON+x}" ]]; then + export IRONFOX_PYTHON="${IRONFOX_PYTHON_DEFAULT}" +fi # Python (pip) environment IRONFOX_PIP_DIR_DEFAULT="${IRONFOX_BUILD}/pyenv" @@ -441,10 +449,8 @@ if [[ -z "${IRONFOX_PIP_DIR+x}" ]]; then fi export IRONFOX_PIP_ENV="${IRONFOX_PIP_DIR}/bin/activate" -## For macOS, ensure that Python 3.9 is in PATH -if [[ "${IRONFOX_OS}" == 'osx' ]]; then - export PATH="${PATH}:$(brew --prefix)/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/bin" -fi +## Python (pip) environment - Glean +export IRONFOX_GLEAN_PIP_ENV="${IRONFOX_GRADLE_HOME}/glean" # Rust (cargo) IRONFOX_CARGO_HOME_DEFAULT="${IRONFOX_BUILD}/.cargo" diff --git a/scripts/env_external.sh b/scripts/env_external.sh index 4229c43..844b530 100644 --- a/scripts/env_external.sh +++ b/scripts/env_external.sh @@ -81,7 +81,7 @@ export PHOENIX_EXTRA_POLICIES_OUTPUT_DIR_ANDROID="${IRONFOX_GECKO}/ironfox/prefs export PHOENIX_SPECS=0 # Python (Glean) -export GLEAN_PYTHON="$(which python)" +export GLEAN_PYTHON="${IRONFOX_PYTHON}" export GLEAN_PYTHON_WHEELS_DIR="${IRONFOX_GLEAN_PARSER_WHEELS}" # Rust (cargo) diff --git a/scripts/get_sources-if.sh b/scripts/get_sources-if.sh index 24f57e9..683c9bc 100755 --- a/scripts/get_sources-if.sh +++ b/scripts/get_sources-if.sh @@ -721,21 +721,10 @@ function get_firefox_l10n() { # Get + set-up F-Droid's Gradle script function get_gradle() { echo_red_text "Downloading F-Droid's Gradle script..." - download "https://gitlab.com/fdroid/gradlew-fdroid/-/raw/${GRADLE_COMMIT}/gradlew.py" "${IRONFOX_GRADLE_DIR}/gradlew.py" + download "https://gitlab.com/fdroid/gradlew-fdroid/-/raw/${GRADLE_COMMIT}/gradlew.py" "${IRONFOX_GRADLE_PY}" # Validate SHA512sum - validate_sha512sum "${GRADLE_SHA512SUM}" "${IRONFOX_GRADLE_DIR}/gradlew.py" - - if ! [[ -f "${IRONFOX_GRADLE}" ]]; then - echo_red_text 'Creating Gradle script...' - { - echo '#!/bin/bash' - echo "exec python3 ${IRONFOX_GRADLE_DIR}/gradlew.py \"\$@\"" - } > "${IRONFOX_GRADLE}" - chmod +x "${IRONFOX_GRADLE}" - fi - - echo_green_text "SUCCESS: Set-up Gradle at ${IRONFOX_GRADLE}" + validate_sha512sum "${GRADLE_SHA512SUM}" "${IRONFOX_GRADLE_PY}" } # Get Glean @@ -853,7 +842,7 @@ function get_pip() { fi echo_red_text 'Creating pip environment...' - python3.9 -m venv "${IRONFOX_PIP_DIR}" + "${IRONFOX_PYTHON}" -m venv "${IRONFOX_PIP_DIR}" echo_red_text 'Downloading pip...' download_and_extract 'pip' "https://github.com/pypa/pip/archive/${PIP_COMMIT}.tar.gz" "${IRONFOX_PIP}" "${PIP_SHA512SUM}" diff --git a/scripts/gradle.sh b/scripts/gradle.sh new file mode 100755 index 0000000..5c41ad1 --- /dev/null +++ b/scripts/gradle.sh @@ -0,0 +1,2 @@ +#!/bin/bash +exec "${IRONFOX_PYTHON}" "${IRONFOX_GRADLE_PY}" "$@" diff --git a/scripts/prebuild-if.sh b/scripts/prebuild-if.sh index 3e1a3df..c47d4ea 100755 --- a/scripts/prebuild-if.sh +++ b/scripts/prebuild-if.sh @@ -51,7 +51,7 @@ function glean_localize_gradle() { function localize_maven() { # Replace custom Maven repositories with mavenLocal() - find ./* -name '*.gradle' -type f -exec python3 "${IRONFOX_SCRIPTS}/localize_maven.py" {} \; + find ./* -name '*.gradle' -type f -exec "${IRONFOX_PYTHON}" "${IRONFOX_SCRIPTS}/localize_maven.py" {} \; } # Applies the overlay files in the given directory @@ -1021,7 +1021,7 @@ if [[ -n "${FDROID_BUILD+x}" ]]; then # Patch the LLVM source code # Search clang- in https://android.googlesource.com/platform/ndk/+/refs/tags/ndk-r28b/ndk/toolchains.py LLVM_SVN='530567' - python3 "${toolchain_utils}/llvm_tools/patch_manager.py" \ + "${IRONFOX_PYTHON}" "${toolchain_utils}/llvm_tools/patch_manager.py" \ --svn_version $LLVM_SVN \ --patch_metadata_file "${llvm_android}/patches/PATCHES.json" \ --src_path "${llvm}"