Skip to content

Commit

Permalink
app: Make /var/usrlocal and /var/opt compat symlinks in state ove…
Browse files Browse the repository at this point in the history
…rlay model

Newly provisioned nodes don't have state to migrate yet, so they can
start with the new model right away when provisioning from an image that
turned on `opt-usrlocal-overlays`.

Upgrading nodes have had the legacy directories created a long time ago
and systemd-tmpfiles will not replace them (we're using `L`, not `L+`).
  • Loading branch information
jlebon committed Jan 24, 2024
1 parent 5b51e4c commit bd11e8d
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile-rpm-ostree.am
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ librpmostreeinternals_la_CXXFLAGS = $(AM_CXXFLAGS) $(sanitizer_flags) $(rpmostre
librpmostreeinternals_la_LIBADD = $(rpmostree_common_libs)

privdatadir=$(pkglibdir)
privdata_DATA = src/app/rpm-ostree-0-integration.conf src/app/rpm-ostree-0-integration-opt-usrlocal.conf
privdata_DATA = src/app/rpm-ostree-0-integration.conf src/app/rpm-ostree-0-integration-opt-usrlocal.conf src/app/rpm-ostree-0-integration-opt-usrlocal-compat.conf

# Propagate automake verbose mode
cargo_build = $(cargo) build $(if $(subst 0,,$(V)),--verbose,)
Expand Down
10 changes: 10 additions & 0 deletions rpmostree-cxxrs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,7 @@ struct Treefile final : public ::rust::Opaque
::rpmostreecxx::RepoMetadataTarget get_repo_metadata_target () const noexcept;
bool rpmdb_backend_is_target () const noexcept;
bool should_normalize_rpmdb () const noexcept;
bool get_opt_usrlocal_overlays () const noexcept;
::rust::Vec< ::rust::String> get_files_remove_regex (::rust::Str package) const noexcept;
::rust::String get_checksum (::rpmostreecxx::OstreeRepo const &repo) const;
::rust::String get_ostree_ref () const noexcept;
Expand Down Expand Up @@ -2643,6 +2644,9 @@ extern "C"
bool rpmostreecxx$cxxbridge1$Treefile$should_normalize_rpmdb (
::rpmostreecxx::Treefile const &self) noexcept;

bool rpmostreecxx$cxxbridge1$Treefile$get_opt_usrlocal_overlays (
::rpmostreecxx::Treefile const &self) noexcept;

void rpmostreecxx$cxxbridge1$Treefile$get_files_remove_regex (
::rpmostreecxx::Treefile const &self, ::rust::Str package,
::rust::Vec< ::rust::String> *return$) noexcept;
Expand Down Expand Up @@ -5257,6 +5261,12 @@ Treefile::should_normalize_rpmdb () const noexcept
return rpmostreecxx$cxxbridge1$Treefile$should_normalize_rpmdb (*this);
}

bool
Treefile::get_opt_usrlocal_overlays () const noexcept
{
return rpmostreecxx$cxxbridge1$Treefile$get_opt_usrlocal_overlays (*this);
}

::rust::Vec< ::rust::String>
Treefile::get_files_remove_regex (::rust::Str package) const noexcept
{
Expand Down
1 change: 1 addition & 0 deletions rpmostree-cxxrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ struct Treefile final : public ::rust::Opaque
::rpmostreecxx::RepoMetadataTarget get_repo_metadata_target () const noexcept;
bool rpmdb_backend_is_target () const noexcept;
bool should_normalize_rpmdb () const noexcept;
bool get_opt_usrlocal_overlays () const noexcept;
::rust::Vec< ::rust::String> get_files_remove_regex (::rust::Str package) const noexcept;
::rust::String get_checksum (::rpmostreecxx::OstreeRepo const &repo) const;
::rust::String get_ostree_ref () const noexcept;
Expand Down
1 change: 1 addition & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ pub mod ffi {
fn get_repo_metadata_target(&self) -> RepoMetadataTarget;
fn rpmdb_backend_is_target(&self) -> bool;
fn should_normalize_rpmdb(&self) -> bool;
fn get_opt_usrlocal_overlays(&self) -> bool;
fn get_files_remove_regex(&self, package: &str) -> Vec<String>;
fn get_checksum(&self, repo: &OstreeRepo) -> Result<String>;
fn get_ostree_ref(&self) -> String;
Expand Down
4 changes: 4 additions & 0 deletions rust/src/treefile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,10 @@ impl Treefile {
self.parsed.base.rpmdb_normalize.unwrap_or(false)
}

pub(crate) fn get_opt_usrlocal_overlays(&self) -> bool {
self.parsed.base.opt_usrlocal_overlays.unwrap_or_default()
}

pub(crate) fn get_files_remove_regex(&self, package: &str) -> Vec<String> {
let mut files_to_remove: Vec<String> = Vec::new();
if let Some(ref packages) = self.parsed.base.remove_from_packages {
Expand Down
5 changes: 5 additions & 0 deletions src/app/rpm-ostree-0-integration-opt-usrlocal-compat.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Traditionally, /usr/local has been a link to /var/usrlocal and /opt to /var/opt.
# A new model now is to allow OSTree commit content in those directories. For
# backwards compatibility, we keep the /var paths but flip the symlinks around.
L /var/usrlocal - - - - ../usr/local
L /var/opt - - - - ../usr/lib/opt
3 changes: 3 additions & 0 deletions src/app/rpm-ostree-0-integration-opt-usrlocal.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Traditionally, /usr/local has been a link to /var/usrlocal and /opt to /var/opt.
# A new model now is to allow OSTree commit content in those directories. But
# this dropin implements the old model.
d /var/opt 0755 root root -
d /var/usrlocal 0755 root root -
24 changes: 18 additions & 6 deletions src/libpriv/rpmostree-postprocess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,24 @@ postprocess_final (int rootfs_dfd, rpmostreecxx::Treefile &treefile, gboolean un
cancellable, error))
return FALSE;

if (!glnx_file_copy_at (pkglibdir_dfd, "rpm-ostree-0-integration-opt-usrlocal.conf", NULL,
rootfs_dfd,
"usr/lib/tmpfiles.d/rpm-ostree-0-integration-opt-usrlocal.conf",
GLNX_FILE_COPY_NOXATTRS, /* Don't take selinux label */
cancellable, error))
return FALSE;
if (treefile.get_opt_usrlocal_overlays ())
{
if (!glnx_file_copy_at (
pkglibdir_dfd, "rpm-ostree-0-integration-opt-usrlocal-compat.conf", NULL, rootfs_dfd,
"usr/lib/tmpfiles.d/rpm-ostree-0-integration-opt-usrlocal-compat.conf",
GLNX_FILE_COPY_NOXATTRS, /* Don't take selinux label */
cancellable, error))
return FALSE;
}
else
{
if (!glnx_file_copy_at (pkglibdir_dfd, "rpm-ostree-0-integration-opt-usrlocal.conf", NULL,
rootfs_dfd,
"usr/lib/tmpfiles.d/rpm-ostree-0-integration-opt-usrlocal.conf",
GLNX_FILE_COPY_NOXATTRS, /* Don't take selinux label */
cancellable, error))
return FALSE;
}

/* Handle kernel/initramfs if we're not doing a container */
if (!container)
Expand Down

0 comments on commit bd11e8d

Please sign in to comment.