Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions src/builder-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ commit_screenshot_ref (const char *repo_path,
static gboolean
do_install (BuilderContext *build_context,
const gchar *repodir,
const gchar *id,
GPtrArray *manifest_ids,
const gchar *branch,
GError **error)
{
Expand All @@ -369,11 +369,15 @@ do_install (BuilderContext *build_context,
g_ptr_array_add (args, g_strdup ("--noninteractive"));
g_ptr_array_add (args, g_strdup ("--reinstall"));

ref = flatpak_build_untyped_ref (id, branch,
builder_context_get_arch (build_context));

g_ptr_array_add (args, g_strdup (repodir));
g_ptr_array_add (args, g_strdup (ref));

for (size_t i = 0; i < manifest_ids->len; i++)
{
const gchar *id = g_ptr_array_index (manifest_ids, i);
ref = flatpak_build_untyped_ref (id, branch,
builder_context_get_arch (build_context));
g_ptr_array_add (args, g_strdup (ref));
}

g_ptr_array_add (args, NULL);

Expand Down Expand Up @@ -477,6 +481,7 @@ main (int argc,
gboolean is_show_manifest = FALSE;
gboolean app_dir_is_empty = FALSE;
gboolean prune_unused_stages = FALSE;
gboolean debug_exported = FALSE;
g_autoptr(FlatpakContext) arg_context = NULL;
g_autoptr(FlatpakTempDir) cleanup_manifest_dir = NULL;
g_autofree char *manifest_basename = NULL;
Expand Down Expand Up @@ -1152,6 +1157,7 @@ main (int argc,
g_printerr ("Export failed: %s\n", error->message);
return 1;
}
debug_exported = TRUE;
}

for (l = builder_manifest_get_add_extensions (manifest); l != NULL; l = l->next)
Expand Down Expand Up @@ -1275,23 +1281,35 @@ main (int argc,
g_printerr ("NOTE: No export due to --require-changes, ignoring --install\n");
else
{
g_autoptr(GPtrArray) manifest_ids = g_ptr_array_new_with_free_func (g_free);
g_ptr_array_add (manifest_ids, g_strdup (builder_manifest_get_id (manifest)));

if (debug_exported)
g_ptr_array_add (manifest_ids, builder_manifest_get_debug_id (manifest));

if (!do_install (build_context, flatpak_file_get_path_cached (export_repo),
builder_manifest_get_id (manifest),
manifest_ids,
builder_manifest_get_branch (manifest, build_context),
&error))
{
g_printerr ("Install failed: %s\n", error->message);
return 1;
}
if (builder_manifest_get_id_platform (manifest) &&
(!do_install (build_context, flatpak_file_get_path_cached (export_repo),
builder_manifest_get_id_platform (manifest),
builder_manifest_get_branch (manifest, build_context),
&error)))
{
g_printerr ("Install failed: %s\n", error->message);
return 1;
}

if (builder_manifest_get_id_platform (manifest))
{
g_autoptr(GPtrArray) platform_ids = g_ptr_array_new_with_free_func (g_free);
g_ptr_array_add (platform_ids, g_strdup (builder_manifest_get_id_platform (manifest)));

if (!do_install (build_context, flatpak_file_get_path_cached (export_repo),
platform_ids,
builder_manifest_get_branch (manifest, build_context),
&error))
{
g_printerr ("Install failed: %s\n", error->message);
return 1;
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ dist_installed_test_data = \
tests/org.flatpak_builder.gui.metainfo.xml \
tests/org.flatpak.appstream_media.json \
tests/org.test.Hello-256.png \
tests/org.flatpak.install_test.json \
$(NULL)

installed_test_keyringdir = $(installed_testdir)/test-keyring
Expand Down
1 change: 1 addition & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ if get_option('installed_tests')
'org.flatpak_builder.gui.metainfo.xml',
'org.flatpak.appstream_media.json',
'org.test.Hello-256.png',
'org.flatpak.install_test.json',

install_dir: installed_testdir,
install_mode: 'rw-r--r--',
Expand Down
27 changes: 27 additions & 0 deletions tests/org.flatpak.install_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"id": "org.flatpak.install_test",
"runtime": "org.test.Platform",
"sdk": "org.test.Sdk",
"command": "hello",
"modules": [
{
"name": "install_test",
"buildsystem": "simple",
"build-commands": [
"mkdir -p ${FLATPAK_DEST}/bin ${FLATPAK_DEST}/lib/debug ${FLATPAK_DEST}/share/locale/es",
"cp -vf hello.sh ${FLATPAK_DEST}/bin/hello",
"echo foo > ${FLATPAK_DEST}/lib/debug/hello.debug",
"echo foo > ${FLATPAK_DEST}/share/locale/es/hello.mo"
],
"sources": [
{
"type": "script",
"dest-filename": "hello.sh",
"commands": [
"echo \"Hello world, from a sandbox\""
]
}
]
}
]
}
13 changes: 12 additions & 1 deletion tests/test-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -euo pipefail

skip_without_fuse

echo "1..10"
echo "1..11"

setup_repo
install_repo
Expand Down Expand Up @@ -55,6 +55,7 @@ cp $(dirname $0)/org.flatpak_builder.gui.metainfo.xml .
cp $(dirname $0)/org.test.Hello.png .
cp $(dirname $0)/org.test.Hello-256.png .
cp $(dirname $0)/org.flatpak.appstream_media.json .
cp $(dirname $0)/org.flatpak.install_test.json .
mkdir include1
cp $(dirname $0)/module1.json include1/
cp $(dirname $0)/module1.yaml include1/
Expand Down Expand Up @@ -173,3 +174,13 @@ if appstream_has_version 0 16 3; then
else
echo "ok # Skip AppStream < 0.16.3"
fi

# test install
${FLATPAK_BUILDER} --user --install \
--force-clean builddir org.flatpak.install_test.json >&2
REFS=$(flatpak list --all --columns=ref 2>/dev/null)
echo "$REFS" | grep -q "org\.flatpak\.install_test"
echo "$REFS" | grep -q "org\.flatpak\.install_test\.Debug"
echo "$REFS" | grep -q "org\.flatpak\.install_test\.Locale"

echo "ok install"