Skip to content

Commit

Permalink
only handle /etc/os-release during update
Browse files Browse the repository at this point in the history
  • Loading branch information
tofay committed Apr 22, 2024
1 parent a2e8f3d commit e67ba77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub(crate) struct PackageConfig {
/// Defaults to false, to produce smaller container images.
#[serde(default = "docs_default")]
pub(crate) docs: bool,
/// Whether to include /etc/os-release as a dependency.
/// Whether to include /etc/os-release as a dependency during dependency resolution.
/// Defaults to true, so that scanning tools can detect
/// the distro of images produced by rpmoci without users
/// needing to add the <distro>-release package.
Expand Down
3 changes: 1 addition & 2 deletions src/lockfile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ impl Lockfile {
.flat_map(|p| p.requires)
.collect();

Ok(self.pkg_specs == cfg.contents.packages
&& self.global_key_specs == cfg.contents.gpgkeys
Ok(self.is_compatible(cfg)
// Verify dependencies of all local packages
&& Self::read_local_rpm_deps(cfg)? == local_package_deps)
}
Expand Down
18 changes: 12 additions & 6 deletions src/lockfile/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ use super::{DnfOutput, Lockfile};
use crate::config::Config;
use crate::config::Repository;

const ETC_OS_RELEASE: &str = "/etc/os-release";

impl Lockfile {
/// Perform dependency resolution on the given package specs
pub(crate) fn resolve(
mut pkg_specs: Vec<String>,
pkg_specs: Vec<String>,
repositories: &[Repository],
gpgkeys: Vec<Url>,
include_etc_os_release: bool,
Expand All @@ -42,12 +44,16 @@ impl Lockfile {
PyModule::from_code(py, include_str!("resolve.py"), "resolve", "resolve")?;
let base = setup_base(py, repositories, &gpgkeys)?;

let etc_os_release = "/etc/os-release".to_string();
if include_etc_os_release && !pkg_specs.contains(&etc_os_release) {
pkg_specs.push(etc_os_release);
}
let etc_os_release = ETC_OS_RELEASE.to_string();
let specs = if include_etc_os_release && !pkg_specs.contains(&etc_os_release) {
let mut specs = pkg_specs.clone();
specs.push(etc_os_release.to_string());
specs
} else {
pkg_specs.clone()
};

let args = PyTuple::new(py, &[base.to_object(py), pkg_specs.to_object(py)]);
let args = PyTuple::new(py, &[base.to_object(py), specs.to_object(py)]);
// Run the resolve function, returning a json string, which we shall deserialize.
let val: String = resolve.getattr("resolve")?.call1(args)?.extract()?;
Ok::<_, anyhow::Error>(val)
Expand Down

0 comments on commit e67ba77

Please sign in to comment.