Colin Walters 2021-11-17 13:59:48 -05:00
parent e75ec62227
commit 1adcfd58b3
3 changed files with 4 additions and 208 deletions

View File

@ -1,155 +0,0 @@
From 9b4b19cda21c84fa68496e1874a31044e099d742 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Wed, 29 Sep 2021 14:33:04 -0400
Subject: [PATCH] extensions: Add support for per-extension repos and modules
While we support arch-specific extensions today, the state of
repos and modules are global. Which means if a module-using
extension is only available on one architecture (as is the
case in RHEL8/OCP with the `av` module) then it's not
possible to build on other architectures.
The most powerful mechanism here is the `arch-include` design
that we have in the treefile, but...since we already have
an architecture filter per extension, it's easier to add
repos and modules per extension.
Note that the repos and modules are still *global* state, so
we're not supporting actively conflicting extensions right now
still.
Closes: https://github.com/coreos/rpm-ostree/issues/3150
---
docs/extensions.md | 12 +++++++++++
rust/src/extensions.rs | 46 ++++++++++++++++++++++++++++++++++++++++++
rust/src/treefile.rs | 2 +-
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/docs/extensions.md b/docs/extensions.md
index 9dbc6230..bc3d0d7b 100644
--- a/docs/extensions.md
+++ b/docs/extensions.md
@@ -55,6 +55,18 @@ extensions:
packages:
- strace
- ltrace
+ # Optional additional repos (still added globally).
+ # The reason use per-extension `repos` and `modules`
+ # is that it more closely groups them (where relevant)
+ # and further these are only added after architecture conditionals
+ # apply, so one can use repositories that only exist
+ # on a particular architecture.
+ repos:
+ - sooper-repo
+ # Optional additional modules (this also affects global state)
+ modules:
+ enable:
+ - sooper:latest
# Optional list of architectures on which this extension
# is valid. These are RPM basearches. If omitted,
# defaults to all architectures.
diff --git a/rust/src/extensions.rs b/rust/src/extensions.rs
index e667f886..df37b792 100644
--- a/rust/src/extensions.rs
+++ b/rust/src/extensions.rs
@@ -34,6 +34,10 @@ pub struct Extensions {
pub struct Extension {
packages: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
+ repos: Option<Vec<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ modules: Option<crate::treefile::ModulesConfig>,
+ #[serde(skip_serializing_if = "Option::is_none")]
architectures: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
match_base_evr: Option<String>,
@@ -74,6 +78,14 @@ fn extensions_load_stream(
.collect();
for (_, ext) in parsed.extensions.iter_mut() {
+ // Extend the global extension state with the per-extension repos and modules,
+ // after we've done architecture filtering.
+ if let Some(repos) = parsed.repos.as_mut() {
+ repos.extend(ext.repos.take().unwrap_or_default());
+ } else {
+ parsed.repos = ext.repos.take();
+ }
+ crate::treefile::merge_modules(&mut parsed.modules, &mut ext.modules);
if ext.kind == ExtensionKind::OsExtension {
for pkg in &ext.packages {
if base_pkgs.contains_key(pkg.as_str()) {
@@ -264,10 +276,17 @@ extensions:
#[test]
fn basearch_filter() {
let buf = r###"
+repos:
+ - baserepo
+modules:
+ enable:
+ - virt:av
extensions:
bazboo:
packages:
- bazboo
+ repos:
+ - bazboo-repo
architectures:
- x86_64
dodo:
@@ -276,13 +295,40 @@ extensions:
- dada
architectures:
- s390x
+ foo:
+ modules:
+ enable:
+ - foo:stable
+ packages:
+ - foo
+ repos:
+ - foo-repo
+ architectures:
+ - ppc64le
"###;
let mut input = std::io::BufReader::new(buf.as_bytes());
let extensions = extensions_load_stream(&mut input, "x86_64", &base_rpmdb()).unwrap();
assert!(extensions.get_os_extension_packages() == vec!["bazboo"]);
+ assert_eq!(extensions.get_repos().len(), 2);
+ assert_eq!(extensions.get_repos()[1], "bazboo-repo");
+ let modules = extensions.modules.unwrap();
+ assert_eq!(modules.enable.unwrap(), vec!["virt:av"]);
+ assert!(modules.install.is_none());
+
let mut input = std::io::BufReader::new(buf.as_bytes());
let extensions = extensions_load_stream(&mut input, "s390x", &base_rpmdb()).unwrap();
assert!(extensions.get_os_extension_packages() == vec!["dodo", "dada"]);
+ assert_eq!(extensions.get_repos().len(), 1);
+ assert_eq!(extensions.get_repos()[0], "baserepo");
+
+ let mut input = std::io::BufReader::new(buf.as_bytes());
+ let extensions = extensions_load_stream(&mut input, "ppc64le", &base_rpmdb()).unwrap();
+ assert_eq!(extensions.get_os_extension_packages(), vec!["foo"]);
+ assert_eq!(extensions.get_repos().len(), 2);
+ assert_eq!(extensions.get_repos()[1], "foo-repo");
+ let modules = extensions.modules.unwrap();
+ assert_eq!(modules.enable.unwrap(), vec!["foo:stable", "virt:av"]);
+ assert!(modules.install.is_none());
}
#[test]
diff --git a/rust/src/treefile.rs b/rust/src/treefile.rs
index 2c9af278..9f6c6581 100644
--- a/rust/src/treefile.rs
+++ b/rust/src/treefile.rs
@@ -324,7 +324,7 @@ fn merge_hashset_field<T: Eq + std::hash::Hash>(
}
/// Merge modules fields.
-fn merge_modules(dest: &mut Option<ModulesConfig>, src: &mut Option<ModulesConfig>) {
+pub(crate) fn merge_modules(dest: &mut Option<ModulesConfig>, src: &mut Option<ModulesConfig>) {
if let Some(mut srcv) = src.take() {
if let Some(mut destv) = dest.take() {
merge_vec_field(&mut destv.enable, &mut srcv.enable);
--
2.31.1

View File

@ -1,50 +0,0 @@
From d0d3e3f6e1e4710a49be2b159705e69fe8bafbc9 Mon Sep 17 00:00:00 2001
From: Jonathan Lebon <jonathan@jlebon.com>
Date: Tue, 2 Nov 2021 12:50:16 -0400
Subject: [PATCH] Move `ostree://` parsing to daemon
Follow-up to df8315a262 (#3157).
GNOME Software uses the D-Bus API directly, not the CLI. So let's move
handling of `ostree://` there.
The test added in #3157 will verify that we're parsing it correctly.
Closes: #3192
---
src/app/rpmostree-builtin-rebase.cxx | 5 -----
src/daemon/rpmostreed-transaction-types.cxx | 5 +++++
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/app/rpmostree-builtin-rebase.cxx b/src/app/rpmostree-builtin-rebase.cxx
index 2b434b438..902b7dcf0 100644
--- a/src/app/rpmostree-builtin-rebase.cxx
+++ b/src/app/rpmostree-builtin-rebase.cxx
@@ -132,11 +132,6 @@ rpmostree_builtin_rebase (int argc,
}
(void)new_refspec_owned; /* Pacify static analysis */
- // We previously supported prefixing with ostree:// - so continue to parse this for now.
- // https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1463#note_1279157
- if (g_str_has_prefix (new_provided_refspec, "ostree://"))
- new_provided_refspec += strlen ("ostree://");
-
RpmOstreeRefspecType refspectype;
if (!rpmostree_refspec_classify (new_provided_refspec, &refspectype, error))
return FALSE;
diff --git a/src/daemon/rpmostreed-transaction-types.cxx b/src/daemon/rpmostreed-transaction-types.cxx
index a1cdf5ffa..dbe208a35 100644
--- a/src/daemon/rpmostreed-transaction-types.cxx
+++ b/src/daemon/rpmostreed-transaction-types.cxx
@@ -68,6 +68,11 @@ change_origin_refspec (GVariantDict *options,
gchar **out_new_refspec,
GError **error)
{
+ // We previously supported prefixing with ostree:// - so continue to parse this for now.
+ // https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1463#note_1279157
+ if (g_str_has_prefix (refspec, "ostree://"))
+ refspec += strlen ("ostree://");
+
RpmOstreeRefspecType refspectype;
if (!rpmostree_refspec_classify (refspec, &refspectype, error))
return FALSE;

View File

@ -3,7 +3,7 @@
Summary: Hybrid image/package system
Name: rpm-ostree
Version: 2021.13
Version: 2021.14
Release: 2%{?dist}
License: LGPLv2+
URL: https://github.com/coreos/rpm-ostree
@ -11,8 +11,6 @@ URL: https://github.com/coreos/rpm-ostree
# in the upstream git. It also contains vendored Rust sources.
Source0: https://github.com/coreos/rpm-ostree/releases/download/v%{version}/rpm-ostree-%{version}.tar.xz
Patch01: 0001-move-ostree-parsing-to-daemon.patch
ExclusiveArch: %{rust_arches}
BuildRequires: make
@ -223,6 +221,9 @@ $PYTHON autofiles.py > files.devel \
%files devel -f files.devel
%changelog
* Wed Nov 17 2021 Colin Walters <walters@verbum.org> - 2021.14-2
- https://github.com/coreos/rpm-ostree/releases/tag/v2021.14
* Wed Nov 03 2021 Luca BRUNO <lucab@lucabruno.net> - 2021.13-2
- Backport patch to fix F35 rebases through DBus
https://github.com/coreos/rpm-ostree/pull/3199