From 7460431faa5b53e9d1b5405bde1aa9a99c2667b9 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Sat, 14 Jul 2018 18:33:37 +0200
Subject: [PATCH] scripts/copy_output.sh: add support for "extra" images

The new extra_image command allows to copy additional images that don't
fall into the sysupgrade or factory categories to the output directory.
These images will be placed in the "other" subdirectory.

The extra_image command takes 3 arguments: in_suffix (suffix in OpenWrt
bin directory), out_suffix (suffix in Gluon output directory) and ext (file
extension). Example:

  extra_image '-tftp' '-tftp' '.bin'

The ext argument can be omitted to control the whole filename suffix
including the extension from in_suffix and out_suffix. Multiple extra_image
commands can be used for a single device; aliases work as usual.

Based-on-patch-by: David Bauer <mail@david-bauer.net>
---
 scripts/common.inc.sh  |  4 ++++
 scripts/copy_output.sh | 24 +++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/scripts/common.inc.sh b/scripts/common.inc.sh
index bcda85140..ea09c70d7 100644
--- a/scripts/common.inc.sh
+++ b/scripts/common.inc.sh
@@ -38,6 +38,10 @@ sysupgrade() {
 	:
 }
 
+extra_image() {
+	:
+}
+
 no_opkg() {
 	:
 }
diff --git a/scripts/copy_output.sh b/scripts/copy_output.sh
index 8f8643ea0..3454e6e37 100755
--- a/scripts/copy_output.sh
+++ b/scripts/copy_output.sh
@@ -9,6 +9,7 @@ default_factory_ext='.bin'
 default_factory_suffix='-squashfs-factory'
 default_sysupgrade_ext='.bin'
 default_sysupgrade_suffix='-squashfs-sysupgrade'
+default_extra_images=
 
 output=
 profile=
@@ -18,11 +19,12 @@ factory_ext=
 factory_suffix=
 sysupgrade_ext=
 sysupgrade_suffix=
+extra_images=
 
 no_opkg=
 
 
-mkdir -p "${GLUON_IMAGEDIR}/factory" "${GLUON_IMAGEDIR}/sysupgrade"
+mkdir -p "${GLUON_IMAGEDIR}/factory" "${GLUON_IMAGEDIR}/sysupgrade" "${GLUON_IMAGEDIR}/other"
 
 if [ "$(expr match "$OPENWRT_TARGET" '.*-.*')" -gt 0 ]; then
 	OPENWRT_BINDIR="${OPENWRT_TARGET//-/\/}"
@@ -76,6 +78,10 @@ copy() {
 
 	[ -z "$factory_ext" ] || do_copy 'factory' "$factory_suffix" '' "$factory_ext" "$aliases"
 	[ -z "$sysupgrade_ext" ] || do_copy 'sysupgrade' "$sysupgrade_suffix" '-sysupgrade' "$sysupgrade_ext" "$aliases"
+
+	echo -n "$extra_images" | while read in_suffix && read out_suffix && read ext; do
+		do_copy 'other' "$in_suffix" "$out_suffix" "$ext" "$aliases"
+	done
 }
 
 
@@ -92,6 +98,7 @@ device() {
 	factory_suffix="$default_factory_suffix"
 	sysupgrade_ext="$default_sysupgrade_ext"
 	sysupgrade_suffix="$default_sysupgrade_suffix"
+	extra_images="$default_extra_images"
 }
 
 factory_image() {
@@ -164,6 +171,21 @@ sysupgrade() {
 	fi
 }
 
+extra_image() {
+	local in_suffix="$1"
+	local out_suffix="$2"
+	local ext="$3"
+
+	extra_images="$in_suffix
+$out_suffix
+$ext
+$extra_images"
+
+	if [ -z "$output" ]; then
+		default_extra_images="$extra_images"
+	fi
+}
+
 no_opkg() {
 	no_opkg=1
 }
-- 
GitLab