From 6eca62e6231d45ebac9eefd908d847d6f38ab587 Mon Sep 17 00:00:00 2001
From: out <outline941@live.com>
Date: Thu, 31 Dec 2020 23:51:16 +0800
Subject: [PATCH] Fix aarch64 build by rebuilding ppsspp-ffmpeg

---
 flathub.json           | 2 +-
 org.ppsspp.PPSSPP.json | 8 ++++++++
 rebuild_ffmpeg.sh      | 8 ++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100755 rebuild_ffmpeg.sh

diff --git a/flathub.json b/flathub.json
index e92137a..5f4b9d3 100644
--- a/flathub.json
+++ b/flathub.json
@@ -1,3 +1,3 @@
 {
-  "skip-arches": ["arm", "aarch64"]
+  "skip-arches": ["arm"]
 }
diff --git a/org.ppsspp.PPSSPP.json b/org.ppsspp.PPSSPP.json
index 1c5cc61..61c5751 100644
--- a/org.ppsspp.PPSSPP.json
+++ b/org.ppsspp.PPSSPP.json
@@ -59,6 +59,14 @@
           "url": "https://github.com/hrydgard/ppsspp.git",
           "commit": "087de849bdc74205dd00d8e6e11ba17a591213ab"
         },
+        {
+          "type": "file",
+          "path": "rebuild_ffmpeg.sh"
+        },
+        {
+          "type": "shell",
+          "commands": ["./rebuild_ffmpeg.sh"]
+        },
         {
           "type": "file",
           "path": "ppsspp.desktop"
diff --git a/rebuild_ffmpeg.sh b/rebuild_ffmpeg.sh
new file mode 100755
index 0000000..15ad105
--- /dev/null
+++ b/rebuild_ffmpeg.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+if [ "$FLATPAK_ARCH" == "aarch64" ];then
+	cd ffmpeg
+	# GENERAL is used to set cross compile option, rename it to disable it.
+	sed "s/GENERAL=/GENERAL_NO=/;" linux_arm64.sh > linux_arm64_no_cross.sh
+	chmod +x linux_arm64_no_cross.sh
+	./linux_arm64_no_cross.sh
+fi