Skip to content

Commit

Permalink
Check old tmpfiles.d 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
also need to handle old `usr/lib/tmpfiles.d`.

Fixes: fedora-silverblue/issue-tracker#523
  • Loading branch information
HuijingHei committed Dec 29, 2023
1 parent 6a61574 commit 50d6a9a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/libpriv/rpmostree-core.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3086,12 +3086,27 @@ delete_package_from_root (RpmOstreeContext *self, rpmte pkg, int rootfs_dfd, GHa
}

/* And finally, delete any automatically generated tmpfiles.d dropin. */
glnx_autofd int tmpfiles_dfd = -1;
if (!glnx_opendirat (rootfs_dfd, "usr/lib/rpm-ostree/tmpfiles.d", TRUE, &tmpfiles_dfd, error))
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;
g_autofree char *dropin = g_strdup_printf ("%s.conf", rpmteN (pkg));
glnx_autofd int tmpfiles_dfd = -1;
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;
if (!glnx_shutil_rm_rf_at (tmpfiles_dfd, dropin, cancellable, error))
return FALSE;
return FALSE;

return TRUE;
}
Expand Down

0 comments on commit 50d6a9a

Please sign in to comment.