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 11, 2024
1 parent d5d3582 commit 6b4204e
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 23 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
37 changes: 23 additions & 14 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 @@ -2811,6 +2815,9 @@ extern "C"
::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$complete_rpm_layering (::std::int32_t rootfs) noexcept;

::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (::std::int32_t rootfs) noexcept;

::rust::repr::PtrLen rpmostreecxx$cxxbridge1$passwd_cleanup (::std::int32_t rootfs) noexcept;

::rust::repr::PtrLen rpmostreecxx$cxxbridge1$migrate_group_except_root (
Expand Down Expand Up @@ -2940,9 +2947,6 @@ extern "C"
void rpmostreecxx$cxxbridge1$cache_branch_to_nevra (::rust::Str nevra,
::rust::String *return$) noexcept;

::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (::std::int32_t rootfs) noexcept;

::std::uint32_t
rpmostreecxx$cxxbridge1$CxxGObjectArray$length (::rpmostreecxx::CxxGObjectArray &self) 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 Expand Up @@ -5689,6 +5699,16 @@ complete_rpm_layering (::std::int32_t rootfs)
}
}

void
deduplicate_tmpfiles_entries (::std::int32_t rootfs)
{
::rust::repr::PtrLen error$ = rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (rootfs);
if (error$.ptr)
{
throw ::rust::impl< ::rust::Error>::error (error$);
}
}

void
passwd_cleanup (::std::int32_t rootfs)
{
Expand Down Expand Up @@ -6095,16 +6115,6 @@ cache_branch_to_nevra (::rust::Str nevra) noexcept
rpmostreecxx$cxxbridge1$cache_branch_to_nevra (nevra, &return$.value);
return ::std::move (return$.value);
}

void
deduplicate_tmpfiles_entries (::std::int32_t rootfs)
{
::rust::repr::PtrLen error$ = rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (rootfs);
if (error$.ptr)
{
throw ::rust::impl< ::rust::Error>::error (error$);
}
}
} // namespace rpmostreecxx

extern "C"
Expand Down Expand Up @@ -6819,6 +6829,5 @@ Vec< ::rpmostreecxx::LockedPackage>::truncate (::std::size_t len)
{
return cxxbridge1$rust_vec$rpmostreecxx$LockedPackage$truncate (this, len);
}

} // namespace cxxbridge1
} // namespace rust
5 changes: 3 additions & 2 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 Expand Up @@ -2015,6 +2016,8 @@ bool prepare_rpm_layering (::std::int32_t rootfs, ::rust::Str merge_passwd_dir);

void complete_rpm_layering (::std::int32_t rootfs);

void deduplicate_tmpfiles_entries (::std::int32_t rootfs);

void passwd_cleanup (::std::int32_t rootfs);

void migrate_group_except_root (::std::int32_t rootfs,
Expand Down Expand Up @@ -2057,6 +2060,4 @@ ::rpmostreecxx::GKeyFile *treefile_to_origin (::rpmostreecxx::Treefile const &tf
void origin_validate_roundtrip (::rpmostreecxx::GKeyFile const &kf) noexcept;

::rust::String cache_branch_to_nevra (::rust::Str nevra) noexcept;

void deduplicate_tmpfiles_entries (::std::int32_t rootfs);
} // namespace rpmostreecxx
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 6b4204e

Please sign in to comment.