From bd41acf9c5b2a7c880e5ddea63a146d43b276f2d Mon Sep 17 00:00:00 2001 From: Hernan Martinez Date: Wed, 25 Jan 2023 00:53:10 -0700 Subject: [PATCH] Fix exe, py and scm script support --- ...mingw-add-ModuleFileName-dir-to-PATH.patch | 37 +++++++++++++++++++ mingw-w64-gimp3/PKGBUILD | 17 ++++++--- .../gimp-script-fu-interpreter.interp | 4 ++ 3 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 mingw-w64-gimp3/0003-mingw-add-ModuleFileName-dir-to-PATH.patch create mode 100644 mingw-w64-gimp3/gimp-script-fu-interpreter.interp diff --git a/mingw-w64-gimp3/0003-mingw-add-ModuleFileName-dir-to-PATH.patch b/mingw-w64-gimp3/0003-mingw-add-ModuleFileName-dir-to-PATH.patch new file mode 100644 index 0000000000..3d4b2cd766 --- /dev/null +++ b/mingw-w64-gimp3/0003-mingw-add-ModuleFileName-dir-to-PATH.patch @@ -0,0 +1,37 @@ +diff -bur gimp-2.99.14-c/app/main.c gimp-2.99.14/app/main.c +--- gimp-2.99.14-c/app/main.c 2023-01-24 18:49:00.342793400 -0700 ++++ gimp-2.99.14/app/main.c 2023-01-24 18:49:33.030776800 -0700 +@@ -637,6 +637,33 @@ + + SetDllDirectoryW (w_bin_dir); + ++ /* Add ourself to system path */ ++ { ++ int result = 0; ++ static char progpath[PATH_MAX] = {'\0'}; ++ char *path = getenv("PATH"); ++ result = GetModuleFileNameA(NULL, progpath, PATH_MAX); ++ if (path) { ++ /* Add path of executable to system path. */ ++ char *module_path = progpath; ++ char *new_path = alloca(strlen("PATH=")+strlen(module_path)+1+strlen(path)+1); ++ if (new_path) { ++ strcpy( new_path, "PATH=" ); ++ strcat( new_path, module_path ); ++ char *slashes = strchr( new_path, '/' ); ++ while (slashes) { ++ *slashes = '\\'; ++ slashes = strchr( slashes+1, '/' ); ++ } ++ char *end = strrchr(new_path, '\\') ? strrchr(new_path, '\\') : new_path + strlen(new_path); ++ end[0] = ';'; ++ end[1] = '\0'; ++ strcat( new_path, path ); ++ putenv( new_path ); ++ } ++ } ++ } ++ + out: + if (w_bin_dir) + g_free (w_bin_dir); diff --git a/mingw-w64-gimp3/PKGBUILD b/mingw-w64-gimp3/PKGBUILD index 34d3cb658d..4e9775872f 100644 --- a/mingw-w64-gimp3/PKGBUILD +++ b/mingw-w64-gimp3/PKGBUILD @@ -58,14 +58,15 @@ options=('strip' 'makeflags') source=("https://download.gimp.org/pub/gimp/v2.99/gimp-${pkgver}.tar.xz" 0001-clang-rc-files-fix.patch 0002-skip-test-env.patch + 0003-mingw-add-ModuleFileName-dir-to-PATH.patch 0004-clang-windres.patch https://gitlab.gnome.org/GNOME/gimp/-/commit/9b517fbf7d629fb940344719eddf9421f013569b.patch ) sha256sums=('313a205475d1ff03c5c4d9602f09f5c975ba6c1c79d8843e2396f9fe2abdf7a8' '54b3abc136b78fd2ae9b7d2acd202fb91bf3b6c248b131f1629ca50ef2493fbe' '511a2a969d1ff3254b4f2453cdfbc3a86a60e2379adf9f6ed5735454a45ef6ee' - 'ca612aeec8ae33e1fdcc70262aa65feefc4c0e391a9fda600b44aebfdd5f8cf5' - 'af745ee612a83f5f9744ea9c0efe83326996c2a817ca1dc1bf6d73018e2cf78a') + 'b24786f6f0e38457f7d7582dc632aa127fad74eed4927888edc03c14afef17a9' + 'ca612aeec8ae33e1fdcc70262aa65feefc4c0e391a9fda600b44aebfdd5f8cf5') apply_patch_with_msg() { for _patch in "$@" @@ -79,7 +80,8 @@ prepare() { cd "${srcdir}/gimp-${pkgver}" apply_patch_with_msg \ 0001-clang-rc-files-fix.patch \ - 0002-skip-test-env.patch + 0002-skip-test-env.patch \ + 0003-mingw-add-ModuleFileName-dir-to-PATH.patch # Workaround for https://github.com/llvm/llvm-project/issues/57334 apply_patch_with_msg \ @@ -123,9 +125,14 @@ package() { cd "${srcdir}"/build-${MSYSTEM} ${MINGW_PREFIX}/bin/meson.exe install --destdir="${pkgdir}" - sed -e "s|${MINGW_PREFIX}/bin/python3|python3w.exe|g" -i "${pkgdir}${MINGW_PREFIX}"/lib/gimp/2.99/interpreters/pygimp.interp + # Adjust the python interpreter path + sed -e "s|\=.*|\=python3w.exe|g" -i "${pkgdir}${MINGW_PREFIX}"/lib/gimp/2.99/interpreters/pygimp.interp + sed -e "s|::python3|::python3w.exe|g" -i "${pkgdir}${MINGW_PREFIX}"/lib/gimp/2.99/interpreters/pygimp.interp - rm -f "${pkgdir}${MINGW_PREFIX}/lib/gimp/2.0/modules/*.dll.a" + # Create the scm scripts interpreter path (Only created by the installer in Windows) + cp "${srcdir}"/../gimp-script-fu-interpreter.interp "${pkgdir}${MINGW_PREFIX}"/lib/gimp/2.99/interpreters + + rm -f "${pkgdir}${MINGW_PREFIX}/lib/gimp/2.99/modules/*.dll.a" install -Dm644 "${srcdir}/gimp-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE" install -Dm644 "${srcdir}/gimp-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING" diff --git a/mingw-w64-gimp3/gimp-script-fu-interpreter.interp b/mingw-w64-gimp3/gimp-script-fu-interpreter.interp new file mode 100644 index 0000000000..ad07a986ea --- /dev/null +++ b/mingw-w64-gimp3/gimp-script-fu-interpreter.interp @@ -0,0 +1,4 @@ +gimp-script-fu-interpreter=gimp-script-fu-interpreter-3.0.exe +gimp-script-fu-interpreter-3.0=gimp-script-fu-interpreter-3.0.exe +/usr/bin/gimp-script-fu-interpreter=gimp-script-fu-interpreter-3.0.exe +:ScriptFu:E::scm::gimp-script-fu-interpreter-3.0.exe: