forked from Mirrors/flatpak-builder
builder: Use build-args during cleanup
Any build-args specified in the manifest should be used during the cleanup and platform-cleanup stages. This is because if you are using QEMU to build for another architecture, for example, you need to pass --bind-mount in the build-args, and the bind mount also needs to be present while running cleanup commands.tingping/wmclass
parent
3b6f018809
commit
86bc5f39be
|
@ -1815,6 +1815,30 @@ appstream_compose (GFile *app_dir,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static char **
|
||||
strcatv (char **strv1,
|
||||
char **strv2)
|
||||
{
|
||||
if (strv1 == NULL && strv2 == NULL)
|
||||
return NULL;
|
||||
if (strv1 == NULL)
|
||||
return g_strdupv (strv2);
|
||||
if (strv2 == NULL)
|
||||
return g_strdupv (strv1);
|
||||
|
||||
unsigned len1 = g_strv_length (strv1);
|
||||
unsigned len2 = g_strv_length (strv2);
|
||||
char **retval = g_new (char *, len1 + len2 + 1);
|
||||
unsigned ix;
|
||||
|
||||
for (ix = 0; ix < len1; ix++)
|
||||
retval[ix] = g_strdup (strv1[ix]);
|
||||
for (ix = 0; ix < len2; ix++)
|
||||
retval[len1 + ix] = g_strdup (strv2[ix]);
|
||||
retval[len1 + len2] = NULL;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
gboolean
|
||||
builder_manifest_cleanup (BuilderManifest *self,
|
||||
|
@ -1849,10 +1873,13 @@ builder_manifest_cleanup (BuilderManifest *self,
|
|||
|
||||
if (self->cleanup_commands)
|
||||
{
|
||||
g_auto(GStrv) build_args = builder_options_get_build_args (self->build_options, context, error);
|
||||
if (!build_args)
|
||||
return FALSE;
|
||||
env = builder_options_get_env (self->build_options, context);
|
||||
for (i = 0; self->cleanup_commands[i] != NULL; i++)
|
||||
{
|
||||
if (!command (app_dir, env, NULL, self->cleanup_commands[i], error))
|
||||
if (!command (app_dir, env, build_args, self->cleanup_commands[i], error))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -2662,7 +2689,11 @@ builder_manifest_create_platform (BuilderManifest *self,
|
|||
if (self->cleanup_platform_commands)
|
||||
{
|
||||
g_auto(GStrv) env = builder_options_get_env (self->build_options, context);
|
||||
char *extra_args[] = { "--sdk-dir=platform", "--metadata=metadata.platform", NULL};
|
||||
g_auto(GStrv) build_args = builder_options_get_build_args (self->build_options, context, error);
|
||||
if (!build_args)
|
||||
return FALSE;
|
||||
char *platform_args[] = { "--sdk-dir=platform", "--metadata=metadata.platform", NULL };
|
||||
g_auto(GStrv) extra_args = strcatv (build_args, platform_args);
|
||||
|
||||
for (i = 0; self->cleanup_platform_commands[i] != NULL; i++)
|
||||
{
|
||||
|
|
|
@ -89,6 +89,7 @@ dist_installed_test_data = \
|
|||
tests/org.test.Hello.png \
|
||||
tests/package_version.txt \
|
||||
tests/test.json \
|
||||
tests/test-runtime.json \
|
||||
tests/module1.json \
|
||||
tests/data1 \
|
||||
tests/data1.patch \
|
||||
|
|
|
@ -24,7 +24,7 @@ set -euo pipefail
|
|||
skip_without_bwrap
|
||||
skip_without_user_xattrs
|
||||
|
||||
echo "1..3"
|
||||
echo "1..4"
|
||||
|
||||
setup_repo
|
||||
install_repo
|
||||
|
@ -38,6 +38,7 @@ cd $TEST_DATA_DIR/
|
|||
cp -a $(dirname $0)/test-configure .
|
||||
echo "version1" > app-data
|
||||
cp $(dirname $0)/test.json .
|
||||
cp $(dirname $0)/test-runtime.json .
|
||||
cp $(dirname $0)/0001-Add-test-logo.patch .
|
||||
mkdir include1
|
||||
cp $(dirname $0)/module1.json include1/
|
||||
|
@ -88,3 +89,10 @@ run --command=cat org.test.Hello2 /app/share/app-data > app_data_2
|
|||
assert_file_has_content app_data_2 version2
|
||||
|
||||
echo "ok update"
|
||||
|
||||
# The build-args of --help should prevent the faulty cleanup and
|
||||
# platform-cleanup commands from executing
|
||||
${FLATPAK_BUILDER} $FL_GPGARGS --repo=$REPO --force-clean runtimedir \
|
||||
test-runtime.json
|
||||
|
||||
echo "ok runtime build cleanup with build-args"
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"build-runtime": true,
|
||||
"id": "org.test.Hello.Sdk",
|
||||
"id-platform": "org.test.Hello.Platform",
|
||||
"runtime": "org.test.Platform",
|
||||
"sdk": "org.test.Sdk",
|
||||
"tags": ["test"],
|
||||
"cleanup-commands": [ "fdghksdfjhsdfkg" ],
|
||||
"cleanup-platform-commands": [ "sdjfgkafyewgdbvhsail" ],
|
||||
"build-options": {
|
||||
"build-args": ["--help"]
|
||||
},
|
||||
|
||||
"modules": [
|
||||
{
|
||||
"name": "empty"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue