diff options
author | Alexander Larsson <alexl@redhat.com> | 2016-04-20 09:55:13 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-04-20 09:55:13 +0200 |
commit | 5392f2d629a5f7c12456a9ae125e21ddf93933d3 (patch) | |
tree | 2999eae679dc041914678edd00bb28fe78cfa033 /common | |
parent | cfd3f303b18b009a6eed5bb1d3eaf8980cdf7b64 (diff) | |
download | xdg-app-5392f2d629a5f7c12456a9ae125e21ddf93933d3.tar.gz |
common: Break out xdg_app_mtree_create_root helper
Diffstat (limited to 'common')
-rw-r--r-- | common/xdg-app-utils.c | 28 | ||||
-rw-r--r-- | common/xdg-app-utils.h | 5 |
2 files changed, 33 insertions, 0 deletions
diff --git a/common/xdg-app-utils.c b/common/xdg-app-utils.c index cf055ed..e5feecf 100644 --- a/common/xdg-app-utils.c +++ b/common/xdg-app-utils.c @@ -1650,6 +1650,34 @@ xdg_app_repo_update (OstreeRepo *repo, return TRUE; } +gboolean +xdg_app_mtree_create_root (OstreeRepo *repo, + OstreeMutableTree *mtree, + GCancellable *cancellable, + GError **error) +{ + g_autoptr(GVariant) dirmeta = NULL; + g_autoptr(GFileInfo) file_info = g_file_info_new (); + g_autofree guchar *csum; + g_autofree char *checksum = NULL; + + g_file_info_set_name (file_info, "/"); + g_file_info_set_file_type (file_info, G_FILE_TYPE_DIRECTORY); + g_file_info_set_attribute_uint32 (file_info, "unix::uid", 0); + g_file_info_set_attribute_uint32 (file_info, "unix::gid", 0); + g_file_info_set_attribute_uint32 (file_info, "unix::mode", 040755); + + dirmeta = ostree_create_directory_metadata (file_info, NULL); + if (!ostree_repo_write_metadata (repo, OSTREE_OBJECT_TYPE_DIR_META, NULL, + dirmeta, &csum, cancellable, error)) + return FALSE; + + checksum = ostree_checksum_from_bytes (csum); + ostree_mutable_tree_set_metadata_checksum (mtree, checksum); + + return TRUE; +} + static OstreeRepoCommitFilterResult commit_filter (OstreeRepo *repo, const char *path, diff --git a/common/xdg-app-utils.h b/common/xdg-app-utils.h index b1b7936..38df9fe 100644 --- a/common/xdg-app-utils.h +++ b/common/xdg-app-utils.h @@ -183,6 +183,11 @@ gboolean xdg_app_repo_update (OstreeRepo *repo, GCancellable *cancellable, GError **error); +gboolean xdg_app_mtree_create_root (OstreeRepo *repo, + OstreeMutableTree *mtree, + GCancellable *cancellable, + GError **error); + GVariant * xdg_app_bundle_load (GFile *file, char **commit, char **ref, |