diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ff7b53e34..6d5ad6bac 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -26,9 +26,9 @@ jobs: run: shell: bash -el {0} steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4 + - uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0 with: activate-environment: constructor-docs environment-file: docs/environment.yml diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 543a4dca6..d808d92a1 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -23,7 +23,7 @@ jobs: GLOBAL: https://raw.githubusercontent.com/conda/infra/main/.github/global.yml LOCAL: .github/labels.yml steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - id: has_local uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b1e3a60f2..5597945ba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -96,10 +96,10 @@ jobs: PYTHONUNBUFFERED: "1" steps: - name: Retrieve the source code - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 - - uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4 + - uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0 with: activate-environment: constructor-dev environment-file: dev/environment.yml @@ -137,7 +137,7 @@ jobs: pytest -vv --cov=constructor --cov-branch tests/ -m "not examples" coverage run --branch --append -m constructor -V coverage json - - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 + - uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 with: token: ${{ secrets.CODECOV_TOKEN }} flags: unit @@ -155,7 +155,7 @@ jobs: pytest -vv --cov=constructor --cov-branch tests/test_examples.py coverage run --branch --append -m constructor -V coverage json - - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 + - uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 with: token: ${{ secrets.CODECOV_TOKEN }} flags: integration @@ -166,7 +166,7 @@ jobs: git diff --exit-code - name: Upload the example installers as artifacts if: github.event_name == 'pull_request' && matrix.python-version == '3.9' - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: installers-${{ runner.os }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }} path: "${{ runner.temp }}/examples_artifacts" @@ -179,7 +179,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Retrieve the source code - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Report failures uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2.9.2 env: @@ -220,7 +220,7 @@ jobs: steps: # Clean checkout of specific git ref needed for package metadata version # which needs env vars GIT_DESCRIBE_TAG and GIT_BUILD_STR: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ github.ref }} clean: true diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 91224cfec..df69f36aa 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -44,7 +44,7 @@ jobs: echo REPOSITORY=$(curl --silent ${{ github.event.issue.pull_request.url }} | jq --raw-output '.head.repo.full_name') >> $GITHUB_ENV echo REF=$(curl --silent ${{ github.event.issue.pull_request.url }} | jq --raw-output '.head.ref') >> $GITHUB_ENV - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: repository: ${{ env.REPOSITORY || github.repository }} ref: ${{ env.REF || '' }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 24e9873fc..1b027b6f6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: exclude: ^(versioneer.py|constructor/_version.py|CONSTRUCT.md|docs/source/construct-yaml.md) repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-ast @@ -17,7 +17,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + rev: v3.19.0 hooks: - id: pyupgrade args: ["--py38-plus", "--keep-percent-format"] @@ -36,6 +36,6 @@ repos: - id: shellcheck exclude: ^(constructor/header.sh|constructor/osx/.*sh) - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.29.3 + rev: 0.29.4 hooks: - id: check-github-workflows diff --git a/CONSTRUCT.md b/CONSTRUCT.md index 92d93b572..831af3d06 100644 --- a/CONSTRUCT.md +++ b/CONSTRUCT.md @@ -476,13 +476,16 @@ Path to a post-install script. Some notes: installation path is available as `${PREFIX}`. Installer metadata is available in the `${INSTALLER_NAME}`, `${INSTALLER_VER}`, `${INSTALLER_PLAT}` environment variables. `${INSTALLER_TYPE}` is set to `SH`. + `${INSTALLER_UNATTENDED}` will be `"1"` in batch mode (`-b`), `"0"` otherwise. - For PKG installers, the shebang line is respected if present; otherwise, `bash` is used. The same variables mentioned for `sh` installers are available here. `${INSTALLER_TYPE}` is set to `PKG`. + `${INSTALLER_UNATTENDED}` is not supported and always set to `"?"`. - For Windows `.exe` installers, the script must be a `.bat` file. Installation path is available as `%PREFIX%`. Metadata about the installer can be found in the `%INSTALLER_NAME%`, `%INSTALLER_VER%`, `%INSTALLER_PLAT%` environment variables. `%INSTALLER_TYPE%` is set to `EXE`. + `%INSTALLER_UNATTENDED%` will be `"1"` in silent mode (`/S`), `"0"` otherwise. If necessary, you can activate the installed `base` environment like this: diff --git a/constructor/construct.py b/constructor/construct.py index 1a3a2b9e7..f556f566f 100644 --- a/constructor/construct.py +++ b/constructor/construct.py @@ -350,13 +350,16 @@ installation path is available as `${PREFIX}`. Installer metadata is available in the `${INSTALLER_NAME}`, `${INSTALLER_VER}`, `${INSTALLER_PLAT}` environment variables. `${INSTALLER_TYPE}` is set to `SH`. + `${INSTALLER_UNATTENDED}` will be `"1"` in batch mode (`-b`), `"0"` otherwise. - For PKG installers, the shebang line is respected if present; otherwise, `bash` is used. The same variables mentioned for `sh` installers are available here. `${INSTALLER_TYPE}` is set to `PKG`. + `${INSTALLER_UNATTENDED}` is not supported and always set to `"?"`. - For Windows `.exe` installers, the script must be a `.bat` file. Installation path is available as `%PREFIX%`. Metadata about the installer can be found in the `%INSTALLER_NAME%`, `%INSTALLER_VER%`, `%INSTALLER_PLAT%` environment variables. `%INSTALLER_TYPE%` is set to `EXE`. + `%INSTALLER_UNATTENDED%` will be `"1"` in silent mode (`/S`), `"0"` otherwise. If necessary, you can activate the installed `base` environment like this: diff --git a/constructor/fcp.py b/constructor/fcp.py index 96b191b36..e6f66dfa1 100644 --- a/constructor/fcp.py +++ b/constructor/fcp.py @@ -451,16 +451,18 @@ def main(info, verbose=True, dry_run=False, conda_exe="conda.exe"): # We need to preserve the configuration for proxy servers and ssl, otherwise if constructor is # running in a host that sits behind proxy (usually in a company / corporate environment) it # will have this settings reset with the call to conda_replace_context_default + # We can pass ssl_verify via env var, but proxy_servers is a mapping so we need to do it by hand # See: https://github.com/conda/constructor/issues/304 proxy_servers = conda_context.proxy_servers - ssl_verify = conda_context.ssl_verify - + _ssl_verify = conda_context.ssl_verify with env_vars({ "CONDA_PKGS_DIRS": download_dir, + "CONDA_SSL_VERIFY": str(conda_context.ssl_verify), }, conda_replace_context_default): - # Restoring the state for both "proxy_servers" and "ssl_verify" to what was before + # Restoring the state for "proxy_servers" to what it was before conda_context.proxy_servers = proxy_servers - conda_context.ssl_verify = ssl_verify + assert conda_context.ssl_verify == _ssl_verify + assert conda_context.pkgs_dirs and conda_context.pkgs_dirs[0] == download_dir ( pkg_records, diff --git a/constructor/header.sh b/constructor/header.sh index 2fe8ca107..f07212f95 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -179,6 +179,9 @@ while getopts "bifhkp:sut" x; do esac done +# For pre- and post-install scripts +export INSTALLER_UNATTENDED="$BATCH" + # For testing, keep the package cache around longer CLEAR_AFTER_TEST=0 if [ "$TEST" = "1" ] && [ "$KEEP_PKGS" = "0" ]; then diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl index bbbe2f7fa..3bb66380e 100644 --- a/constructor/nsis/main.nsi.tmpl +++ b/constructor/nsis/main.nsi.tmpl @@ -1250,6 +1250,11 @@ Section "Install" System::Call 'kernel32::SetEnvironmentVariable(t,t)i("INSTALLER_VER", "${VERSION}").r0' System::Call 'kernel32::SetEnvironmentVariable(t,t)i("INSTALLER_PLAT", "${PLATFORM}").r0' System::Call 'kernel32::SetEnvironmentVariable(t,t)i("INSTALLER_TYPE", "EXE").r0' + ${If} ${Silent} + System::Call 'kernel32::SetEnvironmentVariable(t,t)i("INSTALLER_UNATTENDED", "1").r0' + ${Else} + System::Call 'kernel32::SetEnvironmentVariable(t,t)i("INSTALLER_UNATTENDED", "0").r0' + ${EndIf} ${If} '@VIRTUAL_SPECS@' != '' # We need to specify CONDA_SOLVER=classic for conda-standalone @@ -1452,6 +1457,11 @@ Section "Uninstall" System::Call 'kernel32::SetEnvironmentVariable(t,t)i("INSTALLER_VER", "$0").r0' System::Call 'kernel32::SetEnvironmentVariable(t,t)i("INSTALLER_PLAT", "${PLATFORM}").r0' System::Call 'kernel32::SetEnvironmentVariable(t,t)i("INSTALLER_TYPE", "EXE").r0' + ${If} ${Silent} + System::Call 'kernel32::SetEnvironmentVariable(t,t)i("INSTALLER_UNATTENDED", "1").r0' + ${Else} + System::Call 'kernel32::SetEnvironmentVariable(t,t)i("INSTALLER_UNATTENDED", "0").r0' + ${EndIf} !insertmacro AbortRetryNSExecWaitLibNsisCmd "pre_uninstall" !insertmacro AbortRetryNSExecWaitLibNsisCmd "rmpath" diff --git a/constructor/osx/run_user_script.sh b/constructor/osx/run_user_script.sh index 61816160f..ca325f9d5 100644 --- a/constructor/osx/run_user_script.sh +++ b/constructor/osx/run_user_script.sh @@ -30,6 +30,7 @@ export INSTALLER_NAME="__NAME__" export INSTALLER_VER="__VERSION__" export INSTALLER_PLAT="__PLAT__" export INSTALLER_TYPE="PKG" +export INSTALLER_UNATTENDED="?" export PRE_OR_POST="__PRE_OR_POST__" _SCRIPT_ENV_VARIABLES_='' # Templated extra environment variable(s) diff --git a/docs/source/construct-yaml.md b/docs/source/construct-yaml.md index 92d93b572..831af3d06 100644 --- a/docs/source/construct-yaml.md +++ b/docs/source/construct-yaml.md @@ -476,13 +476,16 @@ Path to a post-install script. Some notes: installation path is available as `${PREFIX}`. Installer metadata is available in the `${INSTALLER_NAME}`, `${INSTALLER_VER}`, `${INSTALLER_PLAT}` environment variables. `${INSTALLER_TYPE}` is set to `SH`. + `${INSTALLER_UNATTENDED}` will be `"1"` in batch mode (`-b`), `"0"` otherwise. - For PKG installers, the shebang line is respected if present; otherwise, `bash` is used. The same variables mentioned for `sh` installers are available here. `${INSTALLER_TYPE}` is set to `PKG`. + `${INSTALLER_UNATTENDED}` is not supported and always set to `"?"`. - For Windows `.exe` installers, the script must be a `.bat` file. Installation path is available as `%PREFIX%`. Metadata about the installer can be found in the `%INSTALLER_NAME%`, `%INSTALLER_VER%`, `%INSTALLER_PLAT%` environment variables. `%INSTALLER_TYPE%` is set to `EXE`. + `%INSTALLER_UNATTENDED%` will be `"1"` in silent mode (`/S`), `"0"` otherwise. If necessary, you can activate the installed `base` environment like this: diff --git a/examples/scripts/post_install.bat b/examples/scripts/post_install.bat index 7a435cafc..7916add93 100644 --- a/examples/scripts/post_install.bat +++ b/examples/scripts/post_install.bat @@ -3,6 +3,7 @@ if not "%INSTALLER_NAME%" == "Scripts" exit 1 if not "%INSTALLER_VER%" == "X" exit 1 if not "%INSTALLER_PLAT%" == "win-64" exit 1 if not "%INSTALLER_TYPE%" == "EXE" exit 1 +if not "%INSTALLER_UNATTENDED%" == "1" exit 1 if "%PREFIX%" == "" exit 1 if not "%CUSTOM_VARIABLE_1%" == "FIR$T-CUSTOM_STRING WITH SPACES AND @*! CHARACTERS" exit 1 if not "%CUSTOM_VARIABLE_2%" == "$ECOND-CUSTOM_STRING WITH SPACES AND @*! CHARACTERS" exit 1 diff --git a/examples/scripts/post_install.sh b/examples/scripts/post_install.sh index 1db67d136..db0509f26 100644 --- a/examples/scripts/post_install.sh +++ b/examples/scripts/post_install.sh @@ -9,6 +9,7 @@ echo "INSTALLER_NAME=${INSTALLER_NAME}" echo "INSTALLER_VER=${INSTALLER_VER}" echo "INSTALLER_PLAT=${INSTALLER_PLAT}" echo "INSTALLER_TYPE=${INSTALLER_TYPE}" +echo "INSTALLER_UNATTENDED=${INSTALLER_UNATTENDED}" echo "CUSTOM_VARIABLE_1=${CUSTOM_VARIABLE_1}" echo "CUSTOM_VARIABLE_2=${CUSTOM_VARIABLE_2}" echo "PREFIX=${PREFIX}" @@ -20,6 +21,10 @@ test "${CUSTOM_VARIABLE_1}" = 'FIR$T-CUSTOM_'\''STRING'\'' WITH SPACES AND @*! " # shellcheck disable=SC2016 # String interpolation disabling is deliberate test "${CUSTOM_VARIABLE_2}" = '$ECOND-CUSTOM_'\''STRING'\'' WITH SPACES AND @*! "CHARACTERS"' +if [[ "${INSTALLER_TYPE}" == "SH" ]]; then + test "${INSTALLER_UNATTENDED}" = "1" +fi + if [[ $(uname -s) == Linux ]]; then if [[ ${INSTALLER_PLAT} != linux-* ]]; then exit 1 diff --git a/examples/scripts/pre_install.bat b/examples/scripts/pre_install.bat index 5ece67c31..ec4fce07c 100644 --- a/examples/scripts/pre_install.bat +++ b/examples/scripts/pre_install.bat @@ -2,6 +2,7 @@ if not "%INSTALLER_NAME%" == "Scripts" exit 1 if not "%INSTALLER_VER%" == "X" exit 1 if not "%INSTALLER_PLAT%" == "win-64" exit 1 if not "%INSTALLER_TYPE%" == "EXE" exit 1 +if not "%INSTALLER_UNATTENDED%" == "1" exit 1 if "%PREFIX%" == "" exit 1 if not "%CUSTOM_VARIABLE_1%" == "FIR$T-CUSTOM_STRING WITH SPACES AND @*! CHARACTERS" exit 1 if not "%CUSTOM_VARIABLE_2%" == "$ECOND-CUSTOM_STRING WITH SPACES AND @*! CHARACTERS" exit 1 diff --git a/examples/scripts/pre_install.sh b/examples/scripts/pre_install.sh index df0806980..753db8121 100644 --- a/examples/scripts/pre_install.sh +++ b/examples/scripts/pre_install.sh @@ -6,6 +6,7 @@ echo "INSTALLER_NAME=${INSTALLER_NAME}" echo "INSTALLER_VER=${INSTALLER_VER}" echo "INSTALLER_PLAT=${INSTALLER_PLAT}" echo "INSTALLER_TYPE=${INSTALLER_TYPE}" +echo "INSTALLER_UNATTENDED=${INSTALLER_UNATTENDED}" echo "CUSTOM_VARIABLE_1=${CUSTOM_VARIABLE_1}" echo "CUSTOM_VARIABLE_2=${CUSTOM_VARIABLE_2}" echo "PREFIX=${PREFIX}" @@ -17,6 +18,10 @@ test "${CUSTOM_VARIABLE_1}" = 'FIR$T-CUSTOM_'\''STRING'\'' WITH SPACES AND @*! " # shellcheck disable=SC2016 # String interpolation disabling is deliberate test "${CUSTOM_VARIABLE_2}" = '$ECOND-CUSTOM_'\''STRING'\'' WITH SPACES AND @*! "CHARACTERS"' +if [[ "${INSTALLER_TYPE}" == "SH" ]]; then + test "${INSTALLER_UNATTENDED}" = "1" +fi + if [[ $(uname -s) == Linux ]]; then if [[ ${INSTALLER_PLAT} != linux-* ]]; then exit 1 diff --git a/news/860-ssl-verify b/news/860-ssl-verify new file mode 100644 index 000000000..2bb2e4000 --- /dev/null +++ b/news/860-ssl-verify @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Respect `ssl_verify` setting if defined in any `condarc` file. (#851 via #860) + +### Deprecations + +* + +### Docs + +* + +### Other + +* diff --git a/news/885-installer-unattended b/news/885-installer-unattended new file mode 100644 index 000000000..b4ee1d139 --- /dev/null +++ b/news/885-installer-unattended @@ -0,0 +1,19 @@ +### Enhancements + +* Export `INSTALLER_UNATTENDED` environment variable so pre- and post-install scripts can detect if the installer is running in batch/silent mode or not. (#882 via #885) + +### Bug fixes + +* + +### Deprecations + +* + +### Docs + +* + +### Other + +*