fontconfig: port to meson

* python-lxml doesn't seem to be used
* bzip2 also
* iconv support is disabled by upstream by default in meson, we could patch it back in if needed
* gettext support isn't included in the upstream meson config, we could patch it back if needed

Removed patches: all patching tests or autotools files which are no longer used by default
in the meson port

Added patches:
0010-fix-relocation.patch: set DLL_EXPORT, so the config relocation logic is active, also set dllexport
0011-conf-copy-instead-of-symlink.patch: copy default config files since we can't package symlinks
This commit is contained in:
Christoph Reiter
2024-02-18 12:47:30 +01:00
parent 13997c5277
commit 2ec8cee73c
7 changed files with 92 additions and 330 deletions

View File

@@ -1,12 +0,0 @@
--- fontconfig-2.13.93/test/test-migration.c.orig 2020-12-05 10:40:30.302459200 +0100
+++ fontconfig-2.13.93/test/test-migration.c 2020-12-05 10:42:21.727935600 +0100
@@ -30,6 +30,9 @@
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
+#ifdef _WIN32
+#define mkdir(path,mode) _mkdir(path)
+#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

View File

@@ -1,216 +0,0 @@
--- fontconfig-2.11.0/test/test-migration.c.orig 2014-02-06 12:24:45.529605800 +0000
+++ fontconfig-2.11.0/test/test-migration.c 2014-02-06 14:43:19.691870300 +0000
@@ -9,6 +9,213 @@
#endif
#include <fontconfig/fontconfig.h>
+#if defined(_WIN32)
+#include <time.h>
+#include <math.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <windows.h>
+#include <accctrl.h>
+#include <aclapi.h>
+
+static PSECURITY_DESCRIPTOR
+create_sd (int permissions)
+{
+ PSECURITY_DESCRIPTOR pSD = NULL;
+ int i;
+ int j;
+ EXPLICIT_ACCESS ea[3];
+ PSID sids[3] = { NULL, NULL, NULL };
+ WELL_KNOWN_SID_TYPE sidtypes[3] = { WinCreatorOwnerSid, WinCreatorGroupSid, WinWorldSid };
+ int ea_len = 0;
+ DWORD dwRes, dwDisposition;
+ PACL pACL = NULL;
+
+ /* Initialize a security descriptor. */
+ pSD = (PSECURITY_DESCRIPTOR) LocalAlloc (LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
+ if (NULL == pSD)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ if (!InitializeSecurityDescriptor (pSD, SECURITY_DESCRIPTOR_REVISION))
+ {
+ LocalFree (pSD);
+ errno = EIO;
+ return NULL;
+ }
+
+ for (i = 0; i < 3; i++)
+ {
+ BOOL b;
+ DWORD bytes;
+ int imasked = permissions & (07 << (2 - i));
+ if (!imasked)
+ continue;
+
+ bytes = SECURITY_MAX_SID_SIZE;
+ sids[ea_len] = (PSID) LocalAlloc (LMEM_FIXED, bytes);
+ if (NULL == sids[ea_len])
+ {
+ errno = ENOMEM;
+ LocalFree (pSD);
+ for (j = 0; j < ea_len; j++)
+ {
+ if (sids[j] != NULL)
+ {
+ LocalFree (sids[j]);
+ sids[j] = NULL;
+ }
+ }
+ return NULL;
+ }
+
+ b = CreateWellKnownSid (sidtypes[i], NULL, sids[ea_len], &bytes);
+ if (!b)
+ {
+ errno = EINVAL;
+ LocalFree (pSD);
+ for (j = 0; j < ea_len; j++)
+ {
+ if (sids[j] != NULL)
+ {
+ LocalFree (sids[j]);
+ sids[j] = NULL;
+ }
+ }
+ return NULL;
+ }
+
+ /* Initialize an EXPLICIT_ACCESS structure for an ACE. */
+ ZeroMemory (&ea[ea_len], sizeof(EXPLICIT_ACCESS));
+ bytes = 0;
+ if (01 & imasked)
+ bytes = bytes | GENERIC_READ;
+ if (02 & imasked)
+ bytes = bytes | GENERIC_WRITE;
+ if (04 & imasked)
+ bytes = bytes | GENERIC_EXECUTE;
+ ea[ea_len].grfAccessPermissions = bytes;
+ ea[ea_len].grfAccessMode = SET_ACCESS;
+ ea[ea_len].grfInheritance= NO_INHERITANCE;
+ ea[ea_len].Trustee.TrusteeForm = TRUSTEE_IS_SID;
+ ea[ea_len].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
+ ea[ea_len].Trustee.ptstrName = (LPTSTR) sids[ea_len];
+ ea_len = ea_len + 1;
+ }
+
+ /* Create a new ACL that contains the new ACEs. */
+ dwRes = SetEntriesInAcl (ea_len, ea, NULL, &pACL);
+ if (ERROR_SUCCESS != dwRes)
+ {
+ errno = EIO;
+ LocalFree (pSD);
+ for (j = 0; j < ea_len; j++)
+ {
+ if (sids[j] != NULL)
+ {
+ LocalFree (sids[j]);
+ sids[j] = NULL;
+ }
+ }
+ return NULL;
+ }
+
+ for (j = 0; j < ea_len; j++)
+ {
+ if (sids[j] != NULL)
+ {
+ LocalFree (sids[j]);
+ sids[j] = NULL;
+ }
+ }
+
+ /* Add the ACL to the security descriptor. */
+ if (!SetSecurityDescriptorDacl (pSD,
+ TRUE, // bDaclPresent flag
+ pACL,
+ FALSE)) // not a default DACL
+ {
+ errno = EIO;
+ LocalFree (pSD);
+ LocalFree (pACL);
+ return NULL;
+ }
+
+ return pSD;
+}
+
+static void
+free_sd (PSECURITY_DESCRIPTOR sd)
+{
+ BOOL b, present, defaulted;
+ PACL pACL = NULL;
+ present = FALSE;
+ b = GetSecurityDescriptorDacl (sd, &present, &pACL, &defaulted);
+ if (b && present && !defaulted && pACL)
+ LocalFree (pACL);
+ LocalFree (sd);
+}
+
+static void
+randtemplate (char *template, size_t l)
+{
+ int i;
+ for (i = l - 6; i < l; i++)
+ {
+ int r = rand ();
+ if ((r / (RAND_MAX + 1)) > ((RAND_MAX + 1) / 2))
+ template[i] = 'A' + (double) rand () / (RAND_MAX + 1) * ('Z' - 'A');
+ else
+ template[i] = 'a' + (double) rand () / (RAND_MAX + 1) * ('z' - 'a');
+ }
+}
+
+static char *
+mkdtemp (char *template)
+{
+ int i;
+ size_t l;
+ BOOL b;
+ SECURITY_ATTRIBUTES sa;
+
+ if (template == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ l = strlen (template);
+ if (l < 6 || strcmp (&template[l - 6], "XXXXXX") != 0)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ srand(time (NULL));
+ sa.nLength = sizeof (sa);
+ sa.lpSecurityDescriptor = create_sd (0700);
+ sa.bInheritHandle = FALSE;
+ do
+ {
+ randtemplate (template, l);
+ SetLastError (0);
+ b = CreateDirectoryA (template, &sa);
+ } while (!b && GetLastError () == ERROR_ALREADY_EXISTS);
+ free_sd (sa.lpSecurityDescriptor);
+ if (!b)
+ {
+ errno = EIO;
+ return NULL;
+ }
+ else
+ {
+ errno = 0;
+ return template;
+ }
+}
+#endif
+
FcBool
mkdir_p(const char *dir)
{

View File

@@ -1,27 +0,0 @@
--- fontconfig-2.11.0/test/test-migration.c.orig 2014-02-06 14:43:19.691870300 +0000
+++ fontconfig-2.11.0/test/test-migration.c 2014-02-06 14:48:25.336182200 +0000
@@ -214,6 +214,24 @@
return template;
}
}
+
+static int
+setenv (const char *var, const char *val, int ovr)
+{
+ BOOL b;
+ char c[2];
+ if (!ovr)
+ {
+ DWORD d;
+ d = GetEnvironmentVariableA (var, c, 2);
+ if (0 != d && GetLastError () != ERROR_ENVVAR_NOT_FOUND)
+ return;
+ }
+ b = SetEnvironmentVariableA (var, val);
+ if (b)
+ return 0;
+ return 1;
+}
#endif
FcBool

View File

@@ -1,22 +0,0 @@
--- fontconfig-2.11.93/m4/pkg.m4.orig 2015-03-09 02:54:03.000000000 +0000
+++ fontconfig-2.11.93/m4/pkg.m4 2015-04-06 11:04:21.862416100 +0000
@@ -111,8 +111,8 @@
pkg_failed=no
AC_MSG_CHECKING([for $1])
-_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
-_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+_PKG_CONFIG([$1][_CFLAGS], [cflags --dont-define-prefix], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs --dont-define-prefix], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
@@ -207,7 +207,7 @@
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
-_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+_PKG_CONFIG([$1], [variable="][$3][" --dont-define-prefix], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl

View File

@@ -0,0 +1,13 @@
--- fontconfig-2.15.0/src/meson.build.orig 2024-02-18 11:57:16.082497200 +0100
+++ fontconfig-2.15.0/src/meson.build 2024-02-18 11:56:40.872987500 +0100
@@ -57,8 +57,9 @@
# Define FcPublic appropriately for exports on windows
fc_extra_c_args = []
-if cc.get_argument_syntax() == 'msvc'
+if host_machine.system() == 'windows' and get_option('default_library') == 'shared'
fc_extra_c_args += '-DFcPublic=__declspec(dllexport)'
+ fc_extra_c_args += '-DDLL_EXPORT'
endif
libfontconfig = library('fontconfig',

View File

@@ -0,0 +1,24 @@
--- fontconfig-2.15.0/conf.d/link_confs.py.orig 2024-02-18 12:02:06.238444000 +0100
+++ fontconfig-2.15.0/conf.d/link_confs.py 2024-02-18 11:20:14.335114100 +0100
@@ -26,6 +26,8 @@
if not os.path.exists(confpath):
os.makedirs(confpath)
+ args.availpath = str(PurePath(os.environ.get('DESTDIR'), *PurePath(args.availpath).parts[1:]))
+
for link in args.links:
src = os.path.join(args.availpath, link)
dst = os.path.join(confpath, link)
@@ -33,6 +35,12 @@
os.remove(dst)
except FileNotFoundError:
pass
+
+ if os.name == "nt":
+ import shutil
+ shutil.copyfile(src, dst)
+ continue
+
try:
os.symlink(os.path.relpath(src, start=args.confpath), dst)
except NotImplementedError:

View File

@@ -5,7 +5,7 @@ _realname=fontconfig
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.15.0
pkgrel=1
pkgrel=2
pkgdesc="A library for configuring and customizing font access (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
@@ -13,82 +13,84 @@ url="https://wiki.freedesktop.org/www/Software/fontconfig/"
msys2_repository_url="https://gitlab.freedesktop.org/fontconfig/fontconfig"
license=("custom")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-autotools"
"${MINGW_PACKAGE_PREFIX}-python-lxml"
"${MINGW_PACKAGE_PREFIX}-gperf"
"python")
"${MINGW_PACKAGE_PREFIX}-meson"
"${MINGW_PACKAGE_PREFIX}-gperf")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
"${MINGW_PACKAGE_PREFIX}-expat>=2.1.0"
"${MINGW_PACKAGE_PREFIX}-freetype>=2.3.11"
"${MINGW_PACKAGE_PREFIX}-bzip2>=1.0.6"
"${MINGW_PACKAGE_PREFIX}-libiconv")
options=('staticlibs' 'strip')
"${MINGW_PACKAGE_PREFIX}-expat"
"${MINGW_PACKAGE_PREFIX}-freetype")
install=${_realname}-${MSYSTEM}.install
source=("https://www.freedesktop.org/software/fontconfig/release/fontconfig-${pkgver}.tar.xz"
0002-fix-mkdir.mingw.patch
0004-fix-mkdtemp.mingw.patch
0005-fix-setenv.mingw.patch
0007-pkgconfig.mingw.patch
0010-fix-relocation.patch
0011-conf-copy-instead-of-symlink.patch
fontconfig.hook.in
https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/a76b95105ca26c600279b2daf4bd43b37a918823.patch)
sha256sums=('63a0658d0e06e0fa886106452b58ef04f21f58202ea02a94c39de0d3335d7c0e'
'9e5700b9c555e60cd8116fdc2e24cf0a01de01e83373dbbe78cef1e32b91da3b'
'57ff8420dbf62873b6fcb38b52fb7b37e0e278425a9125e15dccba54668c8ab9'
'552b54010f9fe4097f332cf2397bbd3e78489542d3bbf07792ed1cfe9381796e'
'af373531873da46d0356305da5444c1ec74f443cd2635ea2db6b7dadd1561f5b'
'1506f01dcc7c8b80a9e7fbe56720742bd9134c8e4c3321579fd44dbe1aac028d'
'73ed74a1f4624466084d219e2fbc0d5780da9f63763f1307629251e58cccf2cd'
'ad4ce48983045d7f39b40ca9e04d4be2eaa9177b89dcc516388d779c131a88bc'
'c225c156c4732a492c9588c8d33705ca29af6f3195f201f4012b09ff012f1831')
prepare() {
cd "${srcdir}"/${_realname}-${pkgver}
patch -p1 -i ${srcdir}/0002-fix-mkdir.mingw.patch
patch -p1 -i ${srcdir}/0004-fix-mkdtemp.mingw.patch
patch -p1 -i ${srcdir}/0005-fix-setenv.mingw.patch
patch -p1 -i ${srcdir}/0007-pkgconfig.mingw.patch
cd "${_realname}-${pkgver}"
# backport because it seems relevant for us
patch -p1 -i ${srcdir}/a76b95105ca26c600279b2daf4bd43b37a918823.patch
autoreconf -fiv
patch -p1 -i ${srcdir}/0010-fix-relocation.patch
patch -p1 -i ${srcdir}/0011-conf-copy-instead-of-symlink.patch
}
build() {
[[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
mkdir -p "${srcdir}/build-${MINGW_CHOST}"
cd "${srcdir}/build-${MINGW_CHOST}"
mkdir -p "build-${MSYSTEM}-static" && cd "build-${MSYSTEM}-static"
# Use msys python for link_confs.py, so we don't have to fixup the path conversion
# and patch out symlinking
PYTHON=/usr/bin/python \
../${_realname}-${pkgver}/configure \
--prefix=${MINGW_PREFIX} \
--build=${MINGW_CHOST} \
--host=${MINGW_CHOST} \
--enable-shared \
--enable-static \
--enable-iconv \
--with-libiconv=${MINGW_PREFIX} \
--disable-docs \
--with-arch=${CARCH} \
--with-cache-dir=/var/cache/${_realname} \
as_ln_s="cp -pR"
MSYS2_ARG_CONV_EXCL="--prefix=" \
meson setup \
--default-library=static \
--prefix="${MINGW_PREFIX}" \
--wrap-mode=nodownload \
--auto-features=enabled \
--buildtype=plain \
-Ddoc-man=disabled \
-Ddoc-txt=disabled \
-Ddoc-pdf=disabled \
-Ddoc-html=disabled \
-Dcache-build=disabled \
../"${_realname}-${pkgver}"
sed -i 's,all-am: Makefile $(PROGRAMS),all-am:,' test/Makefile
make
meson compile
cd ..
mkdir -p "build-${MSYSTEM}-shared" && cd "build-${MSYSTEM}-shared"
MSYS2_ARG_CONV_EXCL="--prefix=" \
meson setup \
--default-library=shared \
--prefix="${MINGW_PREFIX}" \
--wrap-mode=nodownload \
--auto-features=enabled \
--buildtype=plain \
-Ddoc-man=disabled \
-Ddoc-txt=disabled \
-Ddoc-pdf=disabled \
-Ddoc-html=disabled \
-Dcache-build=disabled \
../"${_realname}-${pkgver}"
meson compile
}
package() {
cd "${srcdir}/build-${MINGW_CHOST}"
make -j1 DESTDIR="${pkgdir}" install
cd "${srcdir}/build-${MSYSTEM}-static"
DESTDIR="${pkgdir}" meson install
cd "${srcdir}/build-${MSYSTEM}-shared"
DESTDIR="${pkgdir}" meson install
install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
mv ${pkgdir}{,${MINGW_PREFIX}}/var
find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
# Convert MSYS2-specific paths to pkg-config variables (see issue #872)
sed -i "s#${MINGW_PREFIX}/lib#\${libdir}#g" "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/fontconfig.pc
sed -i "s#${MINGW_PREFIX}/include#\${includedir}#g" "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/fontconfig.pc
sed -i "s|${MINGW_PREFIX}/etc$|\${prefix}/etc|g" "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/fontconfig.pc
sed -i "s|${MINGW_PREFIX}/etc/|\${sysconfdir}/|g" "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/fontconfig.pc
sed -i "s|${MINGW_PREFIX}/var|\${prefix}/var|g" "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/fontconfig.pc
for hook in fontconfig; do
local hook_path="${srcdir}/${MINGW_PACKAGE_PREFIX}-${hook}.hook";