Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement INSTALLER_UNATTENDED for pkg installers #915

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading