Skip to content

Commit

Permalink
Replace FileOptions::is_noreplace() with ::is_config_noreplace()
Browse files Browse the repository at this point in the history
  • Loading branch information
dralley committed Jan 9, 2024
1 parent 66068bb commit 35912d2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `Dependency::rpmlib()` now inserts the `rpmlib()` portion automatically, only the feature name itself should
be provided in the string passed as the name argument.
- `FileOptions::is_no_replace()` is now `FileOptions::is_config_noreplace()` to reflect the fact that the noreplace
flag is only applicable to config files, and have more similar usage relative to `%config(noreplace)`

### Added

Expand Down
12 changes: 7 additions & 5 deletions src/rpm/headers/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,18 @@ impl FileOptionsBuilder {
self
}

/// Indicates that a (configuration) file should not be replaced if it has been modified.
/// When a package is updated, configuration files will be checked for modifications compared
/// to their default state, and if any are present then the new configuration file will
/// Indicates that a file is a configuration file and that it should not be replaced if it has been
/// modified. When a package is updated, configuration files will be checked for modifications
/// compared to their default state, and if any are present then the new configuration file will
/// be installed with a .rpmnew extension.
///
/// User intervention may be required to reconcile the changes between the new and old configs.
///
/// See: %config(noreplace) from specfile syntax
pub fn is_no_replace(mut self) -> Self {
self.inner.flag.insert(FileFlags::NOREPLACE);
pub fn is_config_noreplace(mut self) -> Self {
self.inner
.flag
.insert(FileFlags::CONFIG | FileFlags::NOREPLACE);
self
}

Expand Down
4 changes: 1 addition & 3 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ However, it does nothing.",
.compression(rpm::CompressionType::Gzip)
.with_file(
"Cargo.toml",
FileOptions::new("/etc/awesome/config.toml")
.is_config()
.is_no_replace(),
FileOptions::new("/etc/awesome/config.toml").is_config_noreplace(),
)?
// file mode is inherited from source file
.with_file("Cargo.toml", FileOptions::new("/usr/bin/awesome"))?
Expand Down
3 changes: 1 addition & 2 deletions tests/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ mod pgp {
cargo_file.to_str().unwrap(),
FileOptions::new("/etc/foobar/hugo/bazz.toml")
.mode(0o100_777)
.is_config()
.is_no_replace(),
.is_config_noreplace(),
)?
.with_file(
cargo_file.to_str().unwrap(),
Expand Down

0 comments on commit 35912d2

Please sign in to comment.