mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-26 14:13:26 +00:00
transaction: Preinstall from first remote with ref
We could previously just assume that the first enabled remote (potentially matching the collection ID) contains the ref, but that obviously is not always the case. The change here looks up the remote state of the remotes to figure out if they actually contain the ref, and adds the first matching remote to the transaction.
This commit is contained in:
parent
f61d931da8
commit
842472d234
@ -3185,8 +3185,9 @@ flatpak_transaction_add_sync_preinstalled (FlatpakTransaction *self,
|
||||
for (int j = 0; remotes[j] != NULL; j++)
|
||||
{
|
||||
const char *remote = remotes[j];
|
||||
g_autoptr(GError) local_error = NULL;
|
||||
g_autoptr(FlatpakRemoteState) state = NULL;
|
||||
g_autofree char *remote_collection_id = NULL;
|
||||
g_autoptr(GError) local_error = NULL;
|
||||
|
||||
if (flatpak_dir_get_remote_disabled (priv->dir, remote))
|
||||
continue;
|
||||
@ -3194,11 +3195,29 @@ flatpak_transaction_add_sync_preinstalled (FlatpakTransaction *self,
|
||||
remote_collection_id = flatpak_dir_get_remote_collection_id (priv->dir,
|
||||
remote);
|
||||
|
||||
/* Choose the first match if the collection ID was not specified */
|
||||
if (config->collection_id != NULL &&
|
||||
g_strcmp0 (remote_collection_id, config->collection_id) != 0)
|
||||
continue;
|
||||
|
||||
state = flatpak_transaction_ensure_remote_state (self,
|
||||
FLATPAK_TRANSACTION_OPERATION_INSTALL,
|
||||
remote,
|
||||
priv->default_arch,
|
||||
&local_error);
|
||||
if (state == NULL)
|
||||
{
|
||||
g_warning ("Checking if preinstall ref %s is in remote %s failed: %s",
|
||||
flatpak_decomposed_get_ref (config->ref),
|
||||
remote,
|
||||
local_error->message);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!flatpak_remote_state_lookup_ref (state,
|
||||
flatpak_decomposed_get_ref (config->ref),
|
||||
NULL, NULL, NULL, NULL, NULL, NULL))
|
||||
continue;
|
||||
|
||||
g_info ("Adding preinstall of %s from remote %s",
|
||||
flatpak_decomposed_get_ref (config->ref),
|
||||
remote);
|
||||
|
||||
@ -63,6 +63,10 @@ Install=false
|
||||
Install=true
|
||||
EOF
|
||||
|
||||
cat << EOF > hello-3.preinstall
|
||||
[Flatpak Preinstall org.test.Hello3]
|
||||
EOF
|
||||
|
||||
# Set up the runtimes
|
||||
# org.test.Platform//master and org.test.Platform//devel
|
||||
# and the apps
|
||||
@ -76,8 +80,9 @@ make_updated_app test org.test.Collection.test devel HELLO2_DEVEL org.test.Hello
|
||||
|
||||
setup_repo test2
|
||||
make_updated_app test2 org.test.Collection.test2 master HELLO2_MASTER_C2 org.test.Hello2
|
||||
make_updated_app test2 org.test.Collection.test2 master HELLO2_MASTER_C3 org.test.Hello3
|
||||
|
||||
echo "1..10"
|
||||
echo "1..11"
|
||||
|
||||
# just checking that the test remote got added
|
||||
port=$(cat httpd-port)
|
||||
@ -251,4 +256,14 @@ cp bad.preinstall $FLATPAK_CONFIG_DIR/preinstall.d/
|
||||
${FLATPAK} ${U} preinstall -y > nothingtodo
|
||||
assert_file_has_content nothingtodo "Nothing to do"
|
||||
|
||||
ok "bad config"
|
||||
ok "bad config"
|
||||
|
||||
# Hello3 is in the second repo. Make sure we still manage to install it.
|
||||
cp hello-3.preinstall $FLATPAK_CONFIG_DIR/preinstall.d/
|
||||
|
||||
${FLATPAK} ${U} preinstall -y >&2
|
||||
|
||||
${FLATPAK} ${U} list --columns=ref > list-log
|
||||
assert_file_has_content list-log "^org\.test\.Hello3/.*/master$"
|
||||
|
||||
ok "app not in first repo"
|
||||
Loading…
x
Reference in New Issue
Block a user