-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
composetree: allow url in manifest package list #1847
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1030,3 +1030,94 @@ rpmostree_importer_get_header_sha256 (RpmOstreeImporter *self) | |
{ | ||
return self->hdr_sha256; | ||
} | ||
|
||
|
||
static gboolean | ||
import_local_rpm (OstreeRepo *repo, | ||
int *fd, | ||
char **sha256_nevra, | ||
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
/* let's just use the current sepolicy -- we'll just relabel it if the new | ||
* base turns out to have a different one */ | ||
glnx_autofd int rootfs_dfd = -1; | ||
if (!glnx_opendirat (AT_FDCWD, "/", TRUE, &rootfs_dfd, error)) | ||
return FALSE; | ||
g_autoptr(OstreeSePolicy) policy = ostree_sepolicy_new_at (rootfs_dfd, cancellable, error); | ||
if (policy == NULL) | ||
return FALSE; | ||
|
||
g_autoptr(RpmOstreeImporter) unpacker = rpmostree_importer_new_take_fd (fd, repo, NULL, 0, policy, error); | ||
if (unpacker == NULL) | ||
return FALSE; | ||
|
||
if (!rpmostree_importer_run (unpacker, NULL, cancellable, error)) | ||
return FALSE; | ||
|
||
g_autofree char *nevra = rpmostree_importer_get_nevra (unpacker); | ||
*sha256_nevra = g_strconcat (rpmostree_importer_get_header_sha256 (unpacker), | ||
":", nevra, NULL); | ||
|
||
return TRUE; | ||
} | ||
|
||
static void | ||
ptr_close_fd (gpointer fdp) | ||
{ | ||
int fd = GPOINTER_TO_INT (fdp); | ||
glnx_close_fd (&fd); | ||
} | ||
|
||
/* GUnixFDList doesn't allow stealing individual members */ | ||
static GPtrArray * | ||
unixfdlist_to_ptrarray (GUnixFDList *fdl) | ||
{ | ||
gint len; | ||
gint *fds = g_unix_fd_list_steal_fds (fdl, &len); | ||
GPtrArray *ret = g_ptr_array_new_with_free_func ((GDestroyNotify)ptr_close_fd); | ||
for (int i = 0; i < len; i++) | ||
g_ptr_array_add (ret, GINT_TO_POINTER (fds[i])); | ||
return ret; | ||
} | ||
|
||
gboolean | ||
rpmostree_importer_import_many_local_rpms (OstreeRepo *repo, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think given that this in in the importer now, maybe just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also make this code move a separate prep commit? I think that'll clean up the history nicely make it easier to review the critical changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sounds good. I was trying to think of a better but I am terrible with naming.
Will do. |
||
GUnixFDList *fdl, | ||
GPtrArray **out_pkgs, | ||
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
/* Note that we record the SHA-256 of the RPM header in the origin to make sure that e.g. | ||
* if we somehow re-import the same NEVRA with different content, we error out. We don't | ||
* record the checksum of the branch itself, because it may need relabeling and that's OK. | ||
* */ | ||
|
||
g_auto(RpmOstreeRepoAutoTransaction) txn = { 0, }; | ||
/* Note use of commit-on-failure */ | ||
if (!rpmostree_repo_auto_transaction_start (&txn, repo, TRUE, cancellable, error)) | ||
return FALSE; | ||
|
||
g_autoptr(GPtrArray) pkgs = g_ptr_array_new_with_free_func (g_free); | ||
|
||
g_autoptr(GPtrArray) fds = unixfdlist_to_ptrarray (fdl); | ||
for (guint i = 0; i < fds->len; i++) | ||
{ | ||
/* Steal fd from the ptrarray */ | ||
glnx_autofd int fd = GPOINTER_TO_INT (fds->pdata[i]); | ||
fds->pdata[i] = GINT_TO_POINTER (-1); | ||
g_autofree char *sha256_nevra = NULL; | ||
/* Transfer fd to import */ | ||
if (!import_local_rpm (repo, &fd, &sha256_nevra, cancellable, error)) | ||
return FALSE; | ||
|
||
g_ptr_array_add (pkgs, g_steal_pointer (&sha256_nevra)); | ||
} | ||
|
||
if (!ostree_repo_commit_transaction (repo, NULL, cancellable, error)) | ||
return FALSE; | ||
txn.initialized = FALSE; | ||
|
||
*out_pkgs = g_steal_pointer (&pkgs); | ||
return TRUE; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, were you able to try out the
cached-packages
approach we discussed? Should mostly be about taking this diff hunk here and putting it on the compose side, and then feeding the NEVRAs that the importer returns into thecached-packages
field.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlebon Can you clarify on what you mean by putting it on the compose side?
Should I create another
cached-packages
array and add the NEVRAS in the loop at https://github.com/projectatomic/rpm-ostree/pull/1847/files#diff-07963b1a5922690400970963652cbe3bR1967 ?