Skip to content

Commit

Permalink
export INSTALLER_UNATTENDED
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Oct 29, 2024
1 parent ee89d73 commit d879fc3
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions constructor/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions constructor/nsis/main.nsi.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions constructor/osx/run_user_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions examples/scripts/post_install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 "%INSTALLER_UNATTENDED%" == "" 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
Expand Down
1 change: 1 addition & 0 deletions examples/scripts/post_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions examples/scripts/pre_install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 "%INSTALLER_UNATTENDED%" == "" 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
Expand Down
1 change: 1 addition & 0 deletions examples/scripts/pre_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit d879fc3

Please sign in to comment.