Skip to content

Commit

Permalink
Implement INSTALLER_UNATTENDED for pkg installers (#915)
Browse files Browse the repository at this point in the history
* Use COMMAND_LINE_INSTALL to set INSTALLER_UNATTENDED for pkg installers

* Expand test to pkg installers

* Add news

* Update documentation

* Safely set INSTALLER_UNATTENDED to 1 for command-line installs
  • Loading branch information
marcoesters authored Dec 19, 2024
1 parent f6f8d62 commit 07042f0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CONSTRUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ Path to a post-install script. Some notes:
- 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 `"?"`.
`${INSTALLER_UNATTENDED}` will be `"1"` for command line installs, `"0"` otherwise.
- 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%`,
Expand Down
2 changes: 1 addition & 1 deletion constructor/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
- 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 `"?"`.
`${INSTALLER_UNATTENDED}` will be `"1"` for command line installs, `"0"` otherwise.
- 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%`,
Expand Down
9 changes: 8 additions & 1 deletion constructor/osx/run_user_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ export INSTALLER_NAME="{{ installer_name }}"
export INSTALLER_VER="{{ installer_version }}"
export INSTALLER_PLAT="{{ installer_platform }}"
export INSTALLER_TYPE="PKG"
export INSTALLER_UNATTENDED="?"
# The value for COMMAND_LINE_INSTALL is not documented,
# but it is unset for interactive installations. To be
# safe, set the variable for non-interactive installation
# in a roundabout way.
export INSTALLER_UNATTENDED="${COMMAND_LINE_INSTALL:-0}"
if [[ "${INSTALLER_UNATTENDED}" != "0" ]]; then
INSTALLER_UNATTENDED="1"
fi
export PRE_OR_POST="{{ pre_or_post }}"
{{ script_env_variables }}

Expand Down
2 changes: 1 addition & 1 deletion docs/source/construct-yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ Path to a post-install script. Some notes:
- 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 `"?"`.
`${INSTALLER_UNATTENDED}` will be `"1"` for command line installs, `"0"` otherwise.
- 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%`,
Expand Down
4 changes: 1 addition & 3 deletions examples/scripts/post_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ 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
test "${INSTALLER_UNATTENDED}" = "1"

if [[ $(uname -s) == Linux ]]; then
if [[ ${INSTALLER_PLAT} != linux-* ]]; then
Expand Down
19 changes: 19 additions & 0 deletions news/915-installer-unattended-pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* Add `INSTALLER_UNATTENDED` environment variable for `pkg` installers. (#915)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>

0 comments on commit 07042f0

Please sign in to comment.