From 760f988efade818cbfc7068f02a165d6d407c123 Mon Sep 17 00:00:00 2001
From: bgme <i@bgme.me>
Date: Sat, 20 May 2023 14:19:33 +0800
Subject: [PATCH] fix ttf-ms-win11-auto

---
 repo/ttf-ms-win11-auto/lilac.py   | 35 +++++++++++++++++++++++++++++++
 repo/ttf-ms-win11-auto/lilac.yaml |  2 --
 2 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 repo/ttf-ms-win11-auto/lilac.py

diff --git a/repo/ttf-ms-win11-auto/lilac.py b/repo/ttf-ms-win11-auto/lilac.py
new file mode 100644
index 0000000..f6ff86d
--- /dev/null
+++ b/repo/ttf-ms-win11-auto/lilac.py
@@ -0,0 +1,35 @@
+from lilaclib import *
+
+import subprocess
+
+def apply_patch(filename, patch):
+    patch_proc = subprocess.Popen(["patch", "-p1", filename], stdin=subprocess.PIPE, text=True)
+    patch_proc.communicate(patch)
+
+def pre_build():
+    aur_pre_build()
+    apply_patch('PKGBUILD', PATCH)
+
+PATCH=r"""
+diff --git a/PKGBUILD b/PKGBUILD
+index 7c63329..457ba24 100644
+--- a/PKGBUILD
++++ b/PKGBUILD
+@@ -401,13 +401,11 @@ prepare() {
+     echo "- Fonts are missing"
+     echo -ne "- Mount filesystems as a non-privileged user: "
+     touch test.mount
+-    _unprivilegedMountAllowed=false
+-    _testLoopDev=$(udisksctl loop-setup -r -f test.mount --no-user-interaction | awk '{print $NF}') && _unprivilegedMountAllowed=true
+-    _testLoopDev=${_testLoopDev::-1}
+-    udisksctl loop-delete -b "$_testLoopDev" --no-user-interaction
++    _mount=
++    udisksctl loop-setup -r -f test.mount --no-user-interaction >/dev/null 2>&1 && _mount=true
+     rm test.mount
+ 
+-    if [ $_unprivilegedMountAllowed ]; then
++    if [ $_mount ]; then
+       echo "allowed"
+       echo "- Downloading fonts directly"
+       mkdir -p mnt/http
+"""
\ No newline at end of file
diff --git a/repo/ttf-ms-win11-auto/lilac.yaml b/repo/ttf-ms-win11-auto/lilac.yaml
index eebb791..be4cc81 100644
--- a/repo/ttf-ms-win11-auto/lilac.yaml
+++ b/repo/ttf-ms-win11-auto/lilac.yaml
@@ -7,8 +7,6 @@ repo_depends:
 
 build_prefix: extra-x86_64
 
-pre_build: aur_pre_build
-
 post_build: aur_post_build
 
 update_on: