libpriv/importer: factor out pathname translator
This is useful to have in a more global location since we deal with RPM and OSTree paths in various places. Closes: #1227 Approved by: cgwalters
This commit is contained in:
parent
d6b04a038b
commit
9a4d780d32
@ -585,8 +585,6 @@ path_is_ostree_compliant (const char *path)
|
||||
g_str_equal (path, "lib64") || g_str_has_prefix (path, "lib64/"));
|
||||
}
|
||||
|
||||
#define VAR_SELINUX_TARGETED_PATH "var/lib/selinux/targeted/"
|
||||
|
||||
static OstreeRepoCommitFilterResult
|
||||
compose_filter_cb (OstreeRepo *repo,
|
||||
const char *path,
|
||||
@ -762,18 +760,7 @@ handle_translate_pathname (OstreeRepo *repo,
|
||||
const char *path,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (g_str_has_prefix (path, "etc/"))
|
||||
return g_strconcat ("usr/", path, NULL);
|
||||
else if (g_str_has_prefix (path, "boot/"))
|
||||
return g_strconcat ("usr/lib/ostree-boot/", path + strlen ("boot/"), NULL);
|
||||
/* Special hack for https://bugzilla.redhat.com/show_bug.cgi?id=1290659
|
||||
* See also commit 4a86bdd19665700fa308461510c9decd63e31a03
|
||||
* and rpmostree_postprocess_selinux_policy_store_location().
|
||||
*/
|
||||
else if (g_str_has_prefix (path, VAR_SELINUX_TARGETED_PATH))
|
||||
return g_strconcat ("usr/etc/selinux/targeted/", path + strlen (VAR_SELINUX_TARGETED_PATH), NULL);
|
||||
|
||||
return NULL;
|
||||
return rpmostree_translate_path_for_ostree (path);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -234,6 +234,25 @@ rpmostree_pkg_get_local_path (DnfPackage *pkg)
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert a "traditional" path (normally from e.g. an RPM) into its final location in
|
||||
* ostree */
|
||||
char*
|
||||
rpmostree_translate_path_for_ostree (const char *path)
|
||||
{
|
||||
if (g_str_has_prefix (path, "etc/"))
|
||||
return g_strconcat ("usr/", path, NULL);
|
||||
else if (g_str_has_prefix (path, "boot/"))
|
||||
return g_strconcat ("usr/lib/ostree-boot/", path + strlen ("boot/"), NULL);
|
||||
/* Special hack for https://bugzilla.redhat.com/show_bug.cgi?id=1290659
|
||||
* See also commit 4a86bdd19665700fa308461510c9decd63e31a03
|
||||
* and rpmostree_postprocess_selinux_policy_store_location().
|
||||
*/
|
||||
else if (g_str_has_prefix (path, VAR_SELINUX_TARGETED_PATH))
|
||||
return g_strconcat ("usr/etc/selinux/targeted/", path + strlen (VAR_SELINUX_TARGETED_PATH), NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
_rpmostree_util_next_version (const char *auto_version_prefix,
|
||||
const char *last_version)
|
||||
|
@ -32,6 +32,8 @@
|
||||
#define _N(single, plural, n) ( (n) == 1 ? (single) : (plural) )
|
||||
#define _NS(n) _N("", "s", n)
|
||||
|
||||
#define VAR_SELINUX_TARGETED_PATH "var/lib/selinux/targeted/"
|
||||
|
||||
int
|
||||
rpmostree_ptrarray_sort_compare_strings (gconstpointer ap,
|
||||
gconstpointer bp);
|
||||
@ -66,6 +68,9 @@ rpmostree_pkg_is_local (DnfPackage *pkg);
|
||||
char *
|
||||
rpmostree_pkg_get_local_path (DnfPackage *pkg);
|
||||
|
||||
char*
|
||||
rpmostree_translate_path_for_ostree (const char *path);
|
||||
|
||||
char *
|
||||
_rpmostree_util_next_version (const char *auto_version_prefix,
|
||||
const char *last_version);
|
||||
|
Loading…
Reference in New Issue
Block a user