Skip to content

Commit

Permalink
Check generated tmpfiles.d dir when removing package
Browse files Browse the repository at this point in the history
When removing package, will also remove the generated tmpfile
config under the rpm-ostree tmpfiles.d directory. Since coreos#4697,
we use the new directory like `usr/lib/rpm-ostree/tmpfiles.d`, but
for old `usr/lib/tmpfiles.d`, failed with `error: opendir(usr/lib/
rpm-ostree/tmpfiles.d): No such file or directory`.

With this patch, check if `usr/lib/rpm-ostree/tmpfiles.d` does not
exist, will use old `usr/lib/tmpfiles.d` instead.
Also needs coreos#4727.
Fixes: fedora-silverblue/issue-tracker#523
  • Loading branch information
HuijingHei committed Dec 29, 2023
1 parent a2d782b commit 87a2a1d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/libpriv/rpmostree-core.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3086,10 +3086,25 @@ delete_package_from_root (RpmOstreeContext *self, rpmte pkg, int rootfs_dfd, GHa
}

/* And finally, delete any automatically generated tmpfiles.d dropin. */
const char *tmpfiles_path = "usr/lib/rpm-ostree/tmpfiles.d";
/* Check if the new rpm-ostree tmpfiles.d directory exists;
* if not, switch to old tmpfiles.d directory.
*/
if (!glnx_fstatat_allow_noent (rootfs_dfd, tmpfiles_path, NULL, AT_SYMLINK_NOFOLLOW, error))
return FALSE;
glnx_autofd int tmpfiles_dfd = -1;
if (!glnx_opendirat (rootfs_dfd, "usr/lib/rpm-ostree/tmpfiles.d", TRUE, &tmpfiles_dfd, error))
g_autofree char *dropin = NULL;
if (errno == 0)
{
dropin = g_strdup_printf ("%s.conf", rpmteN (pkg));
}
else if (errno == ENOENT)
{
tmpfiles_path = "usr/lib/tmpfiles.d";
dropin = g_strdup_printf ("pkg-%s.conf", rpmteN (pkg));
}
if (!glnx_opendirat (rootfs_dfd, tmpfiles_path, TRUE, &tmpfiles_dfd, error))
return FALSE;
g_autofree char *dropin = g_strdup_printf ("%s.conf", rpmteN (pkg));
if (!glnx_shutil_rm_rf_at (tmpfiles_dfd, dropin, cancellable, error))
return FALSE;

Expand Down

0 comments on commit 87a2a1d

Please sign in to comment.