From 48bcd519aee4e80fccff91e2c7f44fc43a01c28f Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Fri, 11 Nov 2016 14:41:22 -0800
Subject: [PATCH] scripts/mkimg.base.sh: search for apkovl script

search for apkovl script in current dir, in ~/.mkimg and in the dir
where the mkimage script was started from.
---
 scripts/mkimage.sh    |  5 ++++-
 scripts/mkimg.base.sh | 12 ++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)
 mode change 100644 => 100755 scripts/mkimage.sh
 mode change 100644 => 100755 scripts/mkimg.base.sh

diff --git a/scripts/mkimage.sh b/scripts/mkimage.sh
old mode 100644
new mode 100755
index b8203fb2052e..baf3380edb91
--- a/scripts/mkimage.sh
+++ b/scripts/mkimage.sh
@@ -28,7 +28,10 @@ _hostkeys=""
 _simulate=""
 _checksum=""
 
+scriptdir="$(dirname $0)"
 OUTDIR="$PWD"
+RELEASE="${build_date}"
+
 
 msg() {
 	if [ -n "$quiet" ]; then return 0; fi
@@ -182,7 +185,7 @@ build_profile() {
 }
 
 # load plugins
-load_plugins "$(dirname $0)"
+load_plugins "$scriptdir"
 [ -z "$HOME" ] || load_plugins "$HOME/.mkimage"
 
 mkimage_yaml="$(dirname $0)"/mkimage-yaml.sh
diff --git a/scripts/mkimg.base.sh b/scripts/mkimg.base.sh
old mode 100644
new mode 100755
index 354d174010bb..408faf3e0b0a
--- a/scripts/mkimg.base.sh
+++ b/scripts/mkimg.base.sh
@@ -52,9 +52,17 @@ section_apks() {
 }
 
 build_apkovl() {
-	local _host="$1"
+	local _host="$1" _script=
 	msg "Generating $_host.apkovl.tar.gz"
-	(local _pwd=$PWD; cd "$DESTDIR"; fakeroot "$_pwd"/"$apkovl" "$_host")
+	for _script in "$PWD"/"$apkovl" $HOME/.mkimage/$apkovl \
+		$(readlink -f "$scriptdir/$apkovl"); do
+
+		if [ -f "$_script" ]; then
+			break
+		fi
+	done
+	[ -n "$_script" ] || die "could not find $apkovl"
+	(cd "$DESTDIR"; fakeroot "$_script" "$_host")
 }
 
 section_apkovl() {
-- 
GitLab