From 4da29e815bd698f3ab70fbe2e89baa009dca8cb0 Mon Sep 17 00:00:00 2001
From: psykose <alice@ayaya.dev>
Date: Tue, 4 Jul 2023 18:21:00 +0000
Subject: [PATCH] community/plan9port: fix O_LARGEFILE for aarch64

---
 community/plan9port/APKBUILD          |  4 +++-
 community/plan9port/o_largefile.patch | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 community/plan9port/o_largefile.patch

diff --git a/community/plan9port/APKBUILD b/community/plan9port/APKBUILD
index 8e6e3882fae8..a669025300d3 100644
--- a/community/plan9port/APKBUILD
+++ b/community/plan9port/APKBUILD
@@ -3,7 +3,7 @@
 pkgname=plan9port
 _commit=ffbdd1aa20c8a20a8e9dcd3cec644b6dfa3c6acb
 pkgver=0_git20220912
-pkgrel=0
+pkgrel=1
 pkgdesc="Port of many Plan 9 libraries and programs to Unix"
 url="https://9fans.github.io/plan9port/"
 arch="all"
@@ -15,6 +15,7 @@ subpackages="$pkgname-doc"
 source="$pkgname-$pkgver-$_commit.tar.gz::https://github.com/9fans/plan9port/archive/$_commit.tar.gz
 	no-html-man-pages.patch
 	libucontext.patch
+	o_largefile.patch
 	plan9.sh"
 builddir="$srcdir/$pkgname-$_commit"
 
@@ -58,5 +59,6 @@ sha512sums="
 12889ca91d04cb623d44efb39196dca7591b4fb81f06e6b47bb07aae7aeff054191353ff44c8fd75c56505a42102c1ad7eb058e428b59c0d098c76df0ce6b7d4  plan9port-0_git20220912-ffbdd1aa20c8a20a8e9dcd3cec644b6dfa3c6acb.tar.gz
 117c450854ebebfb9fc826c11fac5ef3f06185f4c28aee40eb12beeeaf300bd7b6be414d10a1d4a461f3983c721f7de7ca66a45b40aff6a95788fa859daf7da8  no-html-man-pages.patch
 15c3427d36cf9dfaa58c301756d3a8c94ea3acc7edbe3d1b484032acad5c401691e159949844ce277d4bf90b3fc8a38ff8e7c92567b2084c697895f609f11008  libucontext.patch
+456da6462d8ee0efd4052cefffa18a642c49fea390a99bcc2da74bcf22895844dade3bdc991bb85d4ed558cd0894a44b51bdb1447a352189e9ca9028da2887e7  o_largefile.patch
 1862807e8c45280fbd3e7827c253de093deb773d846713e3c46256e77c409b2d69cce44a2fe086d2776ebf5204707f84a3577324800173daa2f3d4fb3eae09f0  plan9.sh
 "
diff --git a/community/plan9port/o_largefile.patch b/community/plan9port/o_largefile.patch
new file mode 100644
index 000000000000..19db45495431
--- /dev/null
+++ b/community/plan9port/o_largefile.patch
@@ -0,0 +1,18 @@
+redefining O_LARGEFILE like this breaks it on aarch64,
+because it is 0400000(!).
+musl defines this correctly, so don't redefine it
+https://github.com/9fans/plan9port/issues/619
+--
+diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c
+index 4fa330a..2b66875 100644
+--- a/src/cmd/9pfuse/main.c
++++ b/src/cmd/9pfuse/main.c
+@@ -38,7 +38,7 @@
+  * On ARM however, the O_LARGEFILE is set correctly.
+  */
+ 
+-#if defined(__linux__) && !defined(__arm__)
++#if defined(__GLIBC__)
+ #  undef O_LARGEFILE
+ #  define O_LARGEFILE 0100000
+ #endif
-- 
GitLab