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
96 changes: 65 additions & 31 deletions src/builder-manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -3539,26 +3539,42 @@ builder_manifest_finish (BuilderManifest *self,

if (sub_ids->len > 0)
{
g_autoptr(GFile) metadata_file = NULL;
g_autoptr(GFileOutputStream) output = NULL;
g_autoptr(GString) extension_contents = g_string_new ("\n"
"[Build]\n");
g_autoptr(GFile) metadata_file = g_file_get_child (app_dir, "metadata");
g_autoptr(GKeyFile) keyfile = g_key_file_new ();
g_auto(GStrv) old_subs = NULL;
g_autoptr(GPtrArray) all_subs = g_ptr_array_new ();
gsize j;

if (!g_key_file_load_from_file (keyfile,
flatpak_file_get_path_cached (metadata_file),
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
error))
return FALSE;

old_subs = g_key_file_get_string_list (keyfile,
FLATPAK_METADATA_GROUP_BUILD,
FLATPAK_METADATA_KEY_BUILD_EXTENSIONS,
NULL, NULL);

for (j = 0; old_subs != NULL && old_subs[j] != NULL; j++)
g_ptr_array_add (all_subs, old_subs[j]);

g_string_append (extension_contents, FLATPAK_METADATA_KEY_BUILD_EXTENSIONS"=");
for (i = 0; i < sub_ids->len; i++)
for (j = 0; j < sub_ids->len; j++)
{
g_string_append (extension_contents, (const char *)sub_ids->pdata[i]);
g_string_append (extension_contents, ";");
if (old_subs == NULL ||
!g_strv_contains ((const char * const *) old_subs, sub_ids->pdata[j]))
g_ptr_array_add (all_subs, sub_ids->pdata[j]);
}

metadata_file = g_file_get_child (app_dir, "metadata");
output = g_file_append_to (metadata_file, G_FILE_CREATE_NONE, NULL, error);
if (output == NULL)
return FALSE;
g_key_file_set_string_list (keyfile,
FLATPAK_METADATA_GROUP_BUILD,
FLATPAK_METADATA_KEY_BUILD_EXTENSIONS,
(const char * const *) all_subs->pdata,
all_subs->len);

if (!g_output_stream_write_all (G_OUTPUT_STREAM (output),
extension_contents->str, extension_contents->len,
NULL, NULL, error))
if (!g_key_file_save_to_file (keyfile,
flatpak_file_get_path_cached (metadata_file),
error))
return FALSE;
}

Expand Down Expand Up @@ -3981,27 +3997,45 @@ builder_manifest_finish_platform (BuilderManifest *self,

if (sub_ids->len > 0)
{
g_autoptr(GFile) metadata_file = NULL;
g_autoptr(GFileOutputStream) output = NULL;
g_autoptr(GString) extension_contents = g_string_new ("\n"
"[Build]\n");
g_autoptr(GFile) metadata_file = g_file_get_child (app_dir, "metadata.platform");
g_autoptr(GKeyFile) keyfile = g_key_file_new ();
g_auto(GStrv) old_subs = NULL;
g_autoptr(GPtrArray) all_subs = g_ptr_array_new ();
gsize j;

g_string_append (extension_contents, FLATPAK_METADATA_KEY_BUILD_EXTENSIONS"=");
for (i = 0; i < sub_ids->len; i++)
{
g_string_append (extension_contents, (const char *)sub_ids->pdata[i]);
g_string_append (extension_contents, ";");
}
metadata_file = g_file_get_child (app_dir, "metadata.platform");
if (!flatpak_break_hardlink (metadata_file, error))
return FALSE;
output = g_file_append_to (metadata_file, G_FILE_CREATE_NONE, NULL, error);
if (output == NULL)

if (!g_key_file_load_from_file (keyfile,
flatpak_file_get_path_cached (metadata_file),
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
error))
return FALSE;

if (!g_output_stream_write_all (G_OUTPUT_STREAM (output),
extension_contents->str, extension_contents->len,
NULL, NULL, error))
old_subs = g_key_file_get_string_list (keyfile,
FLATPAK_METADATA_GROUP_BUILD,
FLATPAK_METADATA_KEY_BUILD_EXTENSIONS,
NULL, NULL);

for (j = 0; old_subs != NULL && old_subs[j] != NULL; j++)
g_ptr_array_add (all_subs, old_subs[j]);

for (j = 0; j < sub_ids->len; j++)
{
if (old_subs == NULL ||
!g_strv_contains ((const char * const *) old_subs, sub_ids->pdata[j]))
g_ptr_array_add (all_subs, sub_ids->pdata[j]);
}

g_key_file_set_string_list (keyfile,
FLATPAK_METADATA_GROUP_BUILD,
FLATPAK_METADATA_KEY_BUILD_EXTENSIONS,
(const char * const *) all_subs->pdata,
all_subs->len);

if (!g_key_file_save_to_file (keyfile,
flatpak_file_get_path_cached (metadata_file),
error))
return FALSE;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/make-test-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ PATH="$PATH:/usr/sbin:/sbin"
# Add bash and dependencies
mkdir -p ${DIR}/usr/bin
mkdir -p ${DIR}/usr/lib
mkdir -p ${DIR}/usr/share/runtime/locale/en
echo "test" > ${DIR}/usr/share/runtime/locale/en/test
ln -s ../lib ${DIR}/usr/lib64
ln -s ../lib ${DIR}/usr/lib32
if test -f /sbin/ldconfig.real; then
Expand Down
1 change: 1 addition & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ if get_option('installed_tests')
'org.test.Hello-256.png',
'org.flatpak.install_test.json',
'test-locale-cleanup.json',
'test-runtime-platform.json',

install_dir: installed_testdir,
install_mode: 'rw-r--r--',
Expand Down
20 changes: 19 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..12"
echo "1..13"

setup_repo
install_repo
Expand All @@ -41,6 +41,7 @@ cp $(dirname $0)/test-rename-appdata.json .
cp $(dirname $0)/test.json .
cp $(dirname $0)/test.yaml .
cp $(dirname $0)/test-runtime.json .
cp $(dirname $0)/test-runtime-platform.json .
cp $(dirname $0)/0001-Add-test-logo.patch .
cp $(dirname $0)/Hello.desktop .
cp $(dirname $0)/Hello.xml .
Expand Down Expand Up @@ -139,6 +140,23 @@ ${FLATPAK_BUILDER} $FL_GPGARGS --repo=$REPO --force-clean runtimedir \

echo "ok runtime build cleanup with build-args"

${FLATPAK_BUILDER} $FL_GPGARGS --repo=$REPO --force-clean runtimedir \
test-runtime-platform.json >&2

BUILD_GROUP_COUNT=$(grep -c '^\[Build\]' runtimedir/metadata.platform)
if [ "$BUILD_GROUP_COUNT" -gt 1 ]; then
echo "not ok no duplicate [Build] groups in platform metadata"
exit 1
fi

BUILT_EXTENSIONS_COUNT=$(grep -c '^built-extensions=' runtimedir/metadata.platform)
if [ "$BUILT_EXTENSIONS_COUNT" -gt 1 ]; then
echo "not ok duplicate built-extensions keys in platform metadata"
exit 1
fi

echo "ok no duplicate [Build] groups in platform metadata"

# test screenshot ref commit
${FLATPAK_BUILDER} --repo=$REPO/repo_sc --force-clean builddir_sc \
--mirror-screenshots-url=https://example.org/media \
Expand Down
9 changes: 9 additions & 0 deletions tests/test-runtime-platform.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"build-runtime": true,
"id": "org.test.Hello.Sdk",
"id-platform": "org.test.Hello.Platform",
"runtime": "org.test.Platform",
"sdk": "org.test.Sdk",
"separate-locales": true,
"modules": []
}
Loading