Skip to content

Commit

Permalink
build, tools, gimp-data: removing gimp_exe_config_dir from the root m…
Browse files Browse the repository at this point in the history
…eson.build.

Creating a temporary config directory for the in-build GIMP (run as a tool or
for unit-testing) is not done as a build target anymore, but in the
in-build-gimp.sh script as a unique temp directory, then cleaned out on exit.
This has a few advantages:

- It is properly cleaned out once the build ends (instead of leaving a full
  config dir as trash inside the build dir).
- It is not reused from one build to another (with risk of carrying bugs and
  issues over).
- Every use of the in-build GIMP will have its own config directory, and in
  particular when they are called in parallel.

As a side update, make sure that all `gimp_exe` runs depend on
`gimp_exe_depends`.
  • Loading branch information
Jehan authored and brunvonlope committed Apr 21, 2024
1 parent a54253d commit 2f9881c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 39 deletions.
4 changes: 3 additions & 1 deletion .gitlab-ci.yml
Expand Up @@ -278,7 +278,9 @@ gimp-debian-x64:
# and appstream-cli get confused with our exotic naming and fails
- cd ..
- git apply -v build/linux/appimage/patches/0001-desktop-po-Use-reverse-DNS-naming.patch
- git apply -v build/linux/appimage/patches/0001-images-logo-Use-reverse-DNS-naming.patch
- cd gimp-data
- git apply -v ../build/linux/appimage/patches/0001-images-logo-Use-reverse-DNS-naming.patch
- cd ..
- meson configure _build${ARTIFACTS_SUFFIX} -Drelocatable-bundle=yes -Dvector-icons=true
- cd _build${ARTIFACTS_SUFFIX}
- ninja
Expand Down
@@ -1,16 +1,16 @@
From f84e5cdc3e671491e45ec839af97f61e2272d78c Mon Sep 17 00:00:00 2001
From dfd4f599b80883a649175dd76a2f2ea71388cc18 Mon Sep 17 00:00:00 2001
From: Bruno Lopes <brunolopesdsilv@outlook.com>
Date: Sat, 30 Mar 2024 16:13:10 -0300
Date: Sun, 21 Apr 2024 20:22:35 -0300
Subject: [PATCH] images/logo: Use reverse DNS naming

---
gimp-data/images/logo/meson.build | 8 ++++----
images/logo/meson.build | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gimp-data/images/logo/meson.build b/gimp-data/images/logo/meson.build
index bf0a5ea..4ec96a1 100644
--- a/gimp-data/images/logo/meson.build
+++ b/gimp-data/images/logo/meson.build
diff --git a/images/logo/meson.build b/images/logo/meson.build
index 394a9a3..8af98eb 100644
--- a/images/logo/meson.build
+++ b/images/logo/meson.build
@@ -57,21 +57,21 @@ desktop_sizes = [
foreach size : desktop_sizes
sizedir = size + 'x' + size
Expand All @@ -29,14 +29,14 @@ index bf0a5ea..4ec96a1 100644
- 'mkdir -p "$MESON_INSTALL_DESTDIR_PREFIX/@1@/" && cp -f "@0@" "$MESON_INSTALL_DESTDIR_PREFIX/@1@/gimp.png"'.format(app_icon.full_path(), installdir))
+ 'mkdir -p "$MESON_INSTALL_DESTDIR_PREFIX/@1@/" && cp -f "@0@" "$MESON_INSTALL_DESTDIR_PREFIX/@1@/org.gimp.GIMP.png"'.format(app_icon.full_path(), installdir))
endforeach

install_data('gimp-logo.svg',
install_dir: get_option('datadir') / 'icons' / 'hicolor' / 'scalable' / 'apps',
- rename: 'gimp.svg')
+ rename: 'org.gimp.GIMP.svg')

## gimp.ico (Windows) ##

--
## gimp.ico and fileicon.ico (Windows) ##
--
2.44.0.windows.1

26 changes: 16 additions & 10 deletions build/windows/store/Assets/meson.build
Expand Up @@ -130,6 +130,7 @@ foreach scale : scales
med_tile = custom_target(icon_name,
input : [ gen_medtile_py ],
depend_files: [ wilber_path ],
depends: [ gimp_exe_depends ],
output: [ icon_name ],
command: [ gimp_exe, '-nidfs',
'--batch-interpreter', 'python-fu-eval',
Expand Down Expand Up @@ -167,6 +168,7 @@ foreach scale : scales
small_tile = custom_target(icon_name,
input : [ gen_smalltile_py ],
depend_files: [ wilber_path ],
depends: [ gimp_exe_depends ],
output: [ icon_name ],
command: [ gimp_exe, '-nidfs',
'--batch-interpreter', 'python-fu-eval',
Expand Down Expand Up @@ -202,6 +204,7 @@ foreach scale : scales
large_tile = custom_target(icon_name,
input : [ gen_largetile_py ],
depend_files: [ wilber_path ],
depends: [ gimp_exe_depends ],
output: [ icon_name ],
command: [ gimp_exe, '-nidfs',
'--batch-interpreter', 'python-fu-eval',
Expand Down Expand Up @@ -240,6 +243,7 @@ foreach scale : scales
wide_tile = custom_target(icon_name,
input : [ gen_widetile_py ],
depend_files: [ wilber_path ],
depends: [ gimp_exe_depends ],
output: [ icon_name ],
command: [ gimp_exe, '-nidfs',
'--batch-interpreter', 'python-fu-eval',
Expand Down Expand Up @@ -273,6 +277,7 @@ foreach scale : scales
custom_target(icon_name,
input : [ gen_fileicon_py ],
depend_files: [ wilber_path, fileicon_path ],
depends: [ gimp_exe_depends ],
output: [ icon_name ],
command: [ gimp_exe, '-nidfs',
'--batch-interpreter', 'python-fu-eval',
Expand All @@ -294,6 +299,7 @@ foreach size : sizes
custom_target(icon_name,
input : [ gen_fileicon_py ],
depend_files: [ wilber_path, fileicon_path ],
depends: [ gimp_exe_depends ],
output: [ icon_name ],
command: [ gimp_exe, '-nidfs',
'--batch-interpreter', 'python-fu-eval',
Expand All @@ -314,13 +320,13 @@ gen_new_xcf_py = configure_file(
)

xcf_file = custom_target('New_GIMP_Project.xcf',
input : [ gen_new_xcf_py ],
depend_files: [ wilber_path ],
output: [ 'New_GIMP_Project.xcf', ],
command: [ gimp_exe, '-nidfs',
'--batch-interpreter', 'python-fu-eval',
'-b', '-', '--quit'],
feed: true,
build_by_default: true,
env: gimp_run_env
)
input : [ gen_new_xcf_py ],
depend_files: [ wilber_path ],
depends: [ gimp_exe_depends ],
output: [ 'New_GIMP_Project.xcf', ],
command: [ gimp_exe, '-nidfs',
'--batch-interpreter', 'python-fu-eval',
'-b', '-', '--quit'],
feed: true,
build_by_default: true,
env: gimp_run_env)
2 changes: 1 addition & 1 deletion gimp-data
Submodule gimp-data updated from d77c9c to e9762d
16 changes: 1 addition & 15 deletions meson.build
Expand Up @@ -1850,6 +1850,7 @@ subdir('app-tools')
# tool.

gimp_run_env=environment()
gimp_run_env.set('GIMP_GLOBAL_BUILD_ROOT', meson.global_build_root())

if meson.can_run_host_binaries()
if enable_console_bin
Expand Down Expand Up @@ -1899,8 +1900,6 @@ if meson.can_run_host_binaries()
elif platform_osx
gimp_exe_depends += [gimp_exe_typelib]

gimp_run_env.set('GIMP_GLOBAL_BUILD_ROOT', meson.global_build_root())

gimp_run_env.set('GIMP_GI_DIR', gi.get_variable('libdir'))

gimp_run_env.set('GIMP_TEMP_UPDATE_RPATH', gimp_real_exe.full_path())
Expand Down Expand Up @@ -1932,19 +1931,6 @@ endif

gimp_exe = find_program('tools'/'in-build-gimp.sh')

# Use a temporary config directory in the top build root for 2 reasons: first
# because we don't want to pollute any existing user config folder; second
# because the default directory may not be writable (we have the case in macOS
# CI), but the build dir always is.
# XXX We might also want to delete this directory before every use, especially
# when using the binary for testing (ensuring we always start from a fresh
# config). But for now, let's keep it as-is.
gimp_exe_config_dir = custom_target('gimp_exe_config_dir',
output: [ '.tmp-config' ],
command: [ 'mkdir', '-p', '@OUTDIR@' + '/.tmp-config' ],
build_by_default: true)
gimp_run_env.set('GIMP3_DIRECTORY', gimp_exe_config_dir.full_path())

################################################################################
# Subdirs: part 2

Expand Down
27 changes: 27 additions & 0 deletions tools/in-build-gimp.sh
Expand Up @@ -2,6 +2,9 @@

set -e

export GIMP3_DIRECTORY=$(mktemp -d ${GIMP_GLOBAL_BUILD_ROOT}/.GIMP3-build-config-XXX)
echo INFO: temporary GIMP configuration directory: $GIMP3_DIRECTORY

if [ -n "$GIMP_TEMP_UPDATE_RPATH" ]; then
# Earlier code used to set DYLD_LIBRARY_PATH environment variable instead, but
# it didn't work on contributor's builds because of System Integrity
Expand Down Expand Up @@ -38,3 +41,27 @@ if [ -n "$GIMP_TEMP_UPDATE_RPATH" ]; then
done;
unset IFS
fi

# Clean-up the temporary config directory after each usage, yet making sure we
# don't get tricked by weird redirections or anything of the sort. In particular
# we check that this is a directory with user permission, not a symlink, and
# that it's inside inside the project build's root.
if [ -n "$GIMP3_DIRECTORY" ] && [ -d "$GIMP3_DIRECTORY" ] && [ -O "$GIMP3_DIRECTORY" ]; then
if [ -L "$GIMP3_DIRECTORY" ]; then
echo "ERROR: \$GIMP3_DIRECTORY ($GIMP3_DIRECTORY) should not be a symlink."
exit 1
fi
used_dir_prefix=$(realpath "$GIMP3_DIRECTORY")
used_dir_prefix=${used_dir_prefix%???}
tmpl_dir_prefix=$(realpath "$GIMP_GLOBAL_BUILD_ROOT/.GIMP3-build-config-")
if [ "$used_dir_prefix" != "$tmpl_dir_prefix" ]; then
echo "ERROR: \$GIMP3_DIRECTORY ($GIMP3_DIRECTORY) should be under the build directory with a specific prefix."
echo " \"$used_dir_prefix\" != \"$tmpl_dir_prefix\""
exit 1
fi
echo INFO: Running: rm -fr --preserve-root --one-file-system \"$GIMP3_DIRECTORY\"
rm -fr --preserve-root --one-file-system "$GIMP3_DIRECTORY"
else
echo "ERROR: \$GIMP3_DIRECTORY ($GIMP3_DIRECTORY) is not a directory or does not belong to the user"
exit 1
fi

0 comments on commit 2f9881c

Please sign in to comment.