Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- The uninstall now uninstalls packages in the correct order (so dependents before dependencies).
- The `--exclude` flag for the `pit util package` command, to exclude certain packages when using the `--all` flag.
- New and improved documentation.
- The notice fields in the metadata to show a message before or after an installation.

### Changes
- The build tests are now turned off by default and can be turned on with `--execute-build-test` (`--skip-build-test` is removed).
Expand Down
8 changes: 6 additions & 2 deletions docs/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ See the tables below for all different fields, look at [Target fields](#target-f
| `use_<script>` | Needs to be set to true when the script should be used. (Only for `preinstall`, `postinstall` and `uninstall`) |
| `skip_symlinking` | When set to true, the package is not symlinked after installation, preventing the package to be detectable through the PATH. |
| `revisions` | A list of strings containing a description of what changed in each metadata or script revision. |
| `deprecation` | Defines when the version deprecates, disables and the reason. |
| `script_args` | A table of key-value pairs containing arguments passed to scripts. |
| `preinstall_notice` | A message shown immediately before the preinstall step. |
| `postinstall_notice` | A message shown immediately after successfully completing the installation. |
| `deprecation` | Defines when the version deprecates, disables and the reason. |
| `script_args` | A table of key-value pairs containing arguments passed to scripts. |
| `external_test_files` | A list of external test files that are needed for executing the test script. These files are automatically downloaded. |

> Note that for the `license` field we try to be as accurate as possible. However sometimes the specific version of a license can be difficult to find, so it could be wrong. In such a case please create an issue on Packit.
Expand Down Expand Up @@ -137,6 +139,8 @@ Targets are specified as `[targets.<bounds>]`, where bounds specify the supporte
| `skip_symlinking` | When set to true, the package is not symlinked after installation, preventing the package to be detectable through the PATH. Overrides the value defined in the global field. |
| `<script-type>_script` | Defines the name of the script to use instead of the default script name. |
| `use_<script>` | Overwrites the global `use_<script>` field. (Only for `preinstall`, `postinstall` and `uninstall`) |
| `preinstall_notice` | If a notice is present on both the version and the target, both notices are shown, with the version notice first and the target-specific notice after it.|
| `postinstall_notice` | If a notice is present on both the version and the target, both notices are shown, with the version notice first and the target-specific notice after it.|
| `script_args` | A table of key-value pairs containing arguments passed to scripts, additional to the args defined in the global field. |
| `source` | Defines which source to use, required when multiple sources are defined. |
| `external_test_files` | A list of external test files that are needed for executing the test script for this target, additional to the files specified in the global field. These files are automatically downloaded. |
Expand Down
22 changes: 17 additions & 5 deletions src/installer/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ impl<'a> Installer<'a> {

let version_meta = &install_meta.version_metadata;
let script_args = version_meta.get_script_args(&install_meta.target_bounds)?;
let target_meta = version_meta.get_target(&install_meta.target_bounds)?;

if let Some(notice) = &version_meta.preinstall_notice {
println!("{notice}");
}
if let Some(notice) = &target_meta.preinstall_notice {
println!("{notice}");
}

self.execute_preinstall(&package_id, install_meta, &install_directory, &script_args)?;

Expand Down Expand Up @@ -234,14 +242,18 @@ impl<'a> Installer<'a> {

self.execute_postinstall(&package_id, install_meta, &install_directory, &script_args)?;

// Get the target information from the package version info
let target = version_meta.get_target(&install_meta.target_bounds)?;

self.determine_active(install_meta, &package_id, target)?;
self.determine_active(install_meta, &package_id, target_meta)?;

// Only run the test if the skip test option is false
if !self.options.skip_test {
self.execute_test(&package_id, install_meta, &install_directory, &script_args, target)?;
self.execute_test(&package_id, install_meta, &install_directory, &script_args, target_meta)?;
}

if let Some(notice) = &version_meta.postinstall_notice {
println!("{notice}");
}
if let Some(notice) = &target_meta.postinstall_notice {
println!("{notice}");
}

Ok(())
Expand Down
2 changes: 2 additions & 0 deletions src/register/package_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ pub mod tests {
use_postinstall: None,
use_uninstall: None,
revisions: Vec::new(),
preinstall_notice: None,
postinstall_notice: None,
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/repositories/types/package_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ pub struct PackageTarget {
pub test_script: Option<Script>,
pub uninstall_script: Option<Script>,

#[serde(default, skip_serializing_if = "Option::is_none")]
pub preinstall_notice: Option<String>,

#[serde(default, skip_serializing_if = "Option::is_none")]
pub postinstall_notice: Option<String>,

#[serde(default, skip_serializing_if = "Option::is_none")]
pub use_preinstall: Option<bool>,

Expand Down
6 changes: 6 additions & 0 deletions src/repositories/types/package_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ pub struct PackageVersionMeta {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub revisions: Vec<String>,

#[serde(default, skip_serializing_if = "Option::is_none")]
pub preinstall_notice: Option<String>,

#[serde(default, skip_serializing_if = "Option::is_none")]
pub postinstall_notice: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
pub deprecation: Option<DeprecationInfo>,

Expand Down