From 1eebd0c1747890a99fa992b9a354a22319de2c8b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ulrich=20M=C3=BCller?= <ulm@gentoo.org>
Date: Sat, 3 Jul 2021 19:16:15 +0200
Subject: [PATCH] app-emacs/helm: Fix path of autoloads file in emacs-helm.sh
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes: https://bugs.gentoo.org/800177
Package-Manager: Portage-3.0.20, Repoman-3.0.3
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
 .../files/helm-3.6.0-autoloads-path.patch     | 19 +++++++++++++++++++
 ...helm-3.6.0.ebuild => helm-3.6.0-r1.ebuild} |  8 +++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 app-emacs/helm/files/helm-3.6.0-autoloads-path.patch
 rename app-emacs/helm/{helm-3.6.0.ebuild => helm-3.6.0-r1.ebuild} (74%)

diff --git a/app-emacs/helm/files/helm-3.6.0-autoloads-path.patch b/app-emacs/helm/files/helm-3.6.0-autoloads-path.patch
new file mode 100644
index 000000000000..c6b3e97aba16
--- /dev/null
+++ b/app-emacs/helm/files/helm-3.6.0-autoloads-path.patch
@@ -0,0 +1,19 @@
+https://bugs.gentoo.org/800177
+
+--- helm-3.6.0/emacs-helm.sh
++++ helm-3.6.0/emacs-helm.sh
+@@ -138,13 +138,7 @@
+ cd "${0%/*}" || exit 1
+ 
+ # Check if autoload file exists.
+-# It may be in a different directory if emacs-helm.sh is a symlink.
+-TRUENAME=$(find . -samefile "$0" -printf "%l")
+-if [ ! -z "$TRUENAME" ]; then
+-    AUTO_FILE="${TRUENAME%/*}/helm-autoloads.el"
+-else
+-    AUTO_FILE="helm-autoloads.el"
+-fi
++AUTO_FILE="@SITELISP@/helm-autoloads.el"
+ if [ ! -e "$AUTO_FILE" ]; then
+     echo No autoloads found, please run make first to generate autoload file
+     exit 1
diff --git a/app-emacs/helm/helm-3.6.0.ebuild b/app-emacs/helm/helm-3.6.0-r1.ebuild
similarity index 74%
rename from app-emacs/helm/helm-3.6.0.ebuild
rename to app-emacs/helm/helm-3.6.0-r1.ebuild
index f852381e5353..bd5986716b8b 100644
--- a/app-emacs/helm/helm-3.6.0.ebuild
+++ b/app-emacs/helm/helm-3.6.0-r1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 2019 Gentoo Authors
+# Copyright 2019-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -17,8 +17,14 @@ RDEPEND="app-emacs/async
 	app-emacs/popup"
 BDEPEND="${RDEPEND}"
 
+PATCHES="${FILESDIR}/${P}-autoloads-path.patch"
 SITEFILE="50${PN}-gentoo.el"
 
+src_prepare() {
+	elisp_src_prepare
+	sed -i -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${PN}:g" emacs-helm.sh || die
+}
+
 src_compile() {
 	elisp-compile *.el
 	elisp-make-autoload-file
-- 
2.32.0