File 1085-Adjust-the-installation-scripts-for-Android.patch of Package erlang

From 668c9098c6238795d66be95ed9fa77fc29892fc2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20de=20Bretagne?=
 <jerome.debretagne@gmail.com>
Date: Thu, 27 Aug 2020 12:15:37 +0200
Subject: [PATCH] Adjust the installation scripts for Android

Replace /bin/sh into /system/bin/sh in the various Erlang/OTP release
scripts and update the documentation accordingly.
---
 HOWTO/INSTALL-ANDROID.md    | 16 ++--------------
 erts/Makefile               |  9 +++++++++
 erts/etc/common/Makefile.in | 16 ++++++++++++++++
 3 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/HOWTO/INSTALL-ANDROID.md b/HOWTO/INSTALL-ANDROID.md
index ad6aed95e7..24e8b0d658 100644
--- a/HOWTO/INSTALL-ANDROID.md
+++ b/HOWTO/INSTALL-ANDROID.md
@@ -45,7 +45,8 @@ Use the following instead when compiling a 32-bit version.
 
 ### Compile Erlang/OTP ###
 
-    $ # make noboot [-j4] # noboot doesn't work, is it a recent regression?
+    $ make noboot [-j4]
+      or
     $ make [-j4]
 
 
@@ -78,19 +79,6 @@ To properly integrate into an Android application, the installation would have
 to target /data/data/[your/app/package/name]/files/[erlang/dir/once/unpacked]
 as shown in https://github.com/JeromeDeBretagne/erlanglauncher as an example.
 
-TODO: Propose a permanent fix for the following issue.
-Adapt the installation specifically for Android, by replacing manually /bin/sh
-into /system/bin/sh in the various Erlang/OTP release scripts, such as:
-   - bin/erl
-   - bin/start
-   - bin/start_erl
-   - erts-X.Y.Z/bin/erl
-   - erts-X.Y.Z/bin/erl.src
-   - erts-X.Y.Z/bin/start
-   - erts-X.Y.Z/bin/start_erl.src
-   - erts-X.Y.Z/bin/start.src
-   - etc.
-
 WARNING: adb has issues with symlinks (and java.util.zip too). There is only
 one symlink for epmd in recent Erlang/OTP releases (20 to master-based 23) so
 it has to be removed before using adb push, and then recreated manually on the
diff --git a/erts/Makefile b/erts/Makefile
index 7808dccecc..4827789c96 100644
--- a/erts/Makefile
+++ b/erts/Makefile
@@ -111,6 +111,15 @@ local_setup:
 		$(ERL_TOP)/bin/start_sasl.script \
 		$(ERL_TOP)/bin/start_clean.script \
 		$(ERL_TOP)/bin/no_dot_erlang.script
+# On Android, the shell is found in /system/bin/sh instead of /bin/sh
+	@case "$(TARGET)" in \
+		*-android*) \
+		sed -i'' -e "s;/bin/sh;/system/bin/sh;" \
+			$(ERL_TOP)/bin/erl; \
+		sed -i'' -e "s;/bin/sh;/system/bin/sh;" \
+			$(ERL_TOP)/bin/cerl; \
+		;; \
+	esac
 
 # Run the configure script
 .PHONY: configure
diff --git a/erts/etc/common/Makefile.in b/erts/etc/common/Makefile.in
index 650ab1f6fe..7a2b821c46 100644
--- a/erts/etc/common/Makefile.in
+++ b/erts/etc/common/Makefile.in
@@ -513,6 +513,13 @@ endif
 ifneq ($(TARGET), win32)
 ifneq ($(findstring vxworks,$(TARGET)), vxworks)
 	$(INSTALL_SCRIPT) erl.src "$(RELEASE_PATH)/erts-$(VSN)/bin"
+# On Android, the shell is found in /system/bin/sh instead of /bin/sh
+	case "$(TARGET)" in \
+		*-android*) \
+		sed -i'' -e "s;/bin/sh;/system/bin/sh;" \
+			"$(RELEASE_PATH)/erts-$(VSN)/bin/erl.src" \
+		;; \
+	esac
 endif
 endif
 ifneq ($(INSTALL_PROGS),)
@@ -534,6 +541,15 @@ ifneq ($(INSTALL_SRC),)
 endif
 ifneq ($(INSTALL_EMBEDDED_DATA),)
 	$(INSTALL_SCRIPT) $(INSTALL_EMBEDDED_DATA) "$(RELEASE_PATH)/erts-$(VSN)/bin"
+# On Android, the shell is found in /system/bin/sh instead of /bin/sh
+	case "$(TARGET)" in \
+		*-android*) \
+		sed -i'' -e "s;/bin/sh;/system/bin/sh;" \
+			"$(RELEASE_PATH)/erts-$(VSN)/bin/start_erl.src"; \
+		sed -i'' -e "s;/bin/sh;/system/bin/sh;" \
+			"$(RELEASE_PATH)/erts-$(VSN)/bin/start.src"; \
+		;; \
+	esac
 endif
 ifneq ($(INSTALL_LIBS),)
 	$(INSTALL_DATA) $(INSTALL_LIBS) "$(RELEASE_PATH)/erts-$(VSN)/bin"
-- 
2.26.2

openSUSE Build Service is sponsored by