From ad23e138db93ad903c0f0e47dac634795c28ae96 Mon Sep 17 00:00:00 2001
From: Ramon Gazoni Lacerda <Ramon.GazoniLacerda@windriver.com>
Date: Tue, 23 Nov 2021 09:51:06 -0300
Subject: [PATCH] Add debian package stx-sdo-helm

Add debian packaging infrastructure for sdx-sdo-helm to build
a debian package.

Test Plan:
PASS: Built package
PASS: Built iso
PASS: Installed controller

Story: 2009101
Task: 44045

Signed-off-by: Ramon Gazoni Lacerda <Ramon.GazoniLacerda@windriver.com>
Change-Id: I0592b9619b5367a937e4d4c92874dcf220d1c8d7
---
 debian_pkg_dirs                               |  1 +
 stx-sdo-helm/debian/deb_folder/changelog      |  5 +++
 stx-sdo-helm/debian/deb_folder/control        | 18 ++++++++
 stx-sdo-helm/debian/deb_folder/copyright      | 41 +++++++++++++++++++
 stx-sdo-helm/debian/deb_folder/rules          | 40 ++++++++++++++++++
 stx-sdo-helm/debian/deb_folder/source/format  |  1 +
 .../debian/deb_folder/stx-sdo-helm.install    |  3 ++
 stx-sdo-helm/debian/meta_data.yaml            |  7 ++++
 8 files changed, 116 insertions(+)
 create mode 100644 debian_pkg_dirs
 create mode 100644 stx-sdo-helm/debian/deb_folder/changelog
 create mode 100644 stx-sdo-helm/debian/deb_folder/control
 create mode 100644 stx-sdo-helm/debian/deb_folder/copyright
 create mode 100755 stx-sdo-helm/debian/deb_folder/rules
 create mode 100644 stx-sdo-helm/debian/deb_folder/source/format
 create mode 100644 stx-sdo-helm/debian/deb_folder/stx-sdo-helm.install
 create mode 100644 stx-sdo-helm/debian/meta_data.yaml

diff --git a/debian_pkg_dirs b/debian_pkg_dirs
new file mode 100644
index 0000000..70e2240
--- /dev/null
+++ b/debian_pkg_dirs
@@ -0,0 +1 @@
+stx-sdo-helm
diff --git a/stx-sdo-helm/debian/deb_folder/changelog b/stx-sdo-helm/debian/deb_folder/changelog
new file mode 100644
index 0000000..8ffaa64
--- /dev/null
+++ b/stx-sdo-helm/debian/deb_folder/changelog
@@ -0,0 +1,5 @@
+stx-sdo-helm (1.0-1) unstable; urgency=medium
+
+  * Initial release.
+
+ -- Ramon Gazoni Lacerda <Ramon.GazoniLacerda@windriver.com>  Fri, 12 Nov 2021 10:33:54 -0300
diff --git a/stx-sdo-helm/debian/deb_folder/control b/stx-sdo-helm/debian/deb_folder/control
new file mode 100644
index 0000000..d6e608f
--- /dev/null
+++ b/stx-sdo-helm/debian/deb_folder/control
@@ -0,0 +1,18 @@
+Source: stx-sdo-helm
+Section: libs
+Priority: optional
+Maintainer: StarlingX Developers <starlingx-discuss@lists.starlingx.io>
+Build-Depends: debhelper-compat (= 13),
+ chartmuseum,
+ helm,
+ openstack-helm-infra,
+ procps
+Standards-Version: 4.1.2
+Homepage: https://www.starlingx.io
+
+Package: stx-sdo-helm
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: StarlingX SDO Application Helm charts
+ A StarlingX SDO Application Helm charts
diff --git a/stx-sdo-helm/debian/deb_folder/copyright b/stx-sdo-helm/debian/deb_folder/copyright
new file mode 100644
index 0000000..01fd96f
--- /dev/null
+++ b/stx-sdo-helm/debian/deb_folder/copyright
@@ -0,0 +1,41 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: stx-sdo-helm
+Source: https://opendev.org/starlingx/SDO-rv-service/
+
+Files: *
+Copyright: (c) 2013-2021 Wind River Systems, Inc
+License: Apache-2
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ .
+    https://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ .
+ On Debian-based systems the full text of the Apache version 2.0 license
+ can be found in `/usr/share/common-licenses/Apache-2.0'.
+
+# If you want to use GPL v2 or later for the /debian/* files use
+# the following clauses, or change it to suit. Delete these two lines
+Files: debian/*
+Copyright: 2021 Wind River Systems, Inc
+License: Apache-2
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ .
+    https://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ .
+ On Debian-based systems the full text of the Apache version 2.0 license
+ can be found in `/usr/share/common-licenses/Apache-2.0'.
diff --git a/stx-sdo-helm/debian/deb_folder/rules b/stx-sdo-helm/debian/deb_folder/rules
new file mode 100755
index 0000000..0a074af
--- /dev/null
+++ b/stx-sdo-helm/debian/deb_folder/rules
@@ -0,0 +1,40 @@
+#!/usr/bin/make -f
+#export DH_VERBOSE = 1
+
+
+export ROOT = debian/tmp
+export APP_FOLDER = $(ROOT)/usr/lib/application
+export ARMADA_FOLDER = $(ROOT)/usr/lib/armada
+export HELM_FOLDER = $(ROOT)/usr/lib/helm
+export TOOLKIT_VERSION = 0.2.19
+
+
+%:
+	dh $@
+
+override_dh_auto_build:
+
+	# Stage helm-toolkit in the local repo
+	cp /usr/lib/helm/helm-toolkit-$(TOOLKIT_VERSION).tgz helm-charts/
+
+	# Host a server for the charts
+	chartmuseum --debug --port=8879 --context-path='/charts' --storage="local" --storage-local-rootdir="./helm-charts" &
+	sleep 2
+	helm repo add local http://localhost:8879/charts
+
+	# Create the TGZ file.
+	cd helm-charts && make
+
+	# Terminate the helm chart server.
+	pkill chartmuseum
+
+override_dh_auto_install:
+
+	# helm_folder is created by openstack-helm-infra
+	install -d -m 755 $(APP_FOLDER)
+	install -p -D -m 755 files/metadata.yaml $(APP_FOLDER)
+	install -d -m 755 $(HELM_FOLDER)
+	install -p -D -m 755 helm-charts/*.tgz $(HELM_FOLDER)
+	install -d -m 755 $(ARMADA_FOLDER)
+	install -p -D -m 755 manifests/*.yaml $(ARMADA_FOLDER)
+
diff --git a/stx-sdo-helm/debian/deb_folder/source/format b/stx-sdo-helm/debian/deb_folder/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/stx-sdo-helm/debian/deb_folder/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/stx-sdo-helm/debian/deb_folder/stx-sdo-helm.install b/stx-sdo-helm/debian/deb_folder/stx-sdo-helm.install
new file mode 100644
index 0000000..937608f
--- /dev/null
+++ b/stx-sdo-helm/debian/deb_folder/stx-sdo-helm.install
@@ -0,0 +1,3 @@
+usr/lib/helm/* /usr/lib/helm
+usr/lib/armada/* /usr/lib/armada
+usr/lib/application/* /usr/lib/application
diff --git a/stx-sdo-helm/debian/meta_data.yaml b/stx-sdo-helm/debian/meta_data.yaml
new file mode 100644
index 0000000..7690f63
--- /dev/null
+++ b/stx-sdo-helm/debian/meta_data.yaml
@@ -0,0 +1,7 @@
+---
+debname: stx-sdo-helm
+debver: 1.0-1
+src_path: stx-sdo-helm
+revision:
+  dist: $STX_DIST
+  PKG_GITREVCOUNT: true