From 8e015dc79f57394b0df69fcf72f1c056dfd14f74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Fri, 22 Feb 2019 17:08:58 +0100
Subject: [PATCH] Create sample recipes using recipe action
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

APERTIS-5675

This uses the new Recipe action to merged previous recipes in one.

ROOTDIR needs to be reseted between ostree-commit and ostree-deploy
Fixes: APERTIS-5739

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 apertis-image-sdk.yaml                |  4 ++
 apertis-image-uboot.yaml              |  4 ++
 apertis-image-uefi.yaml               |  4 ++
 apertis-ospack-basesdk.yaml           |  3 ++
 apertis-ospack-minimal.yaml           |  3 ++
 apertis-ospack-sdk.yaml               |  3 ++
 apertis-ospack-target.yaml            |  3 ++
 apertis-ostree-commit.yaml            |  3 ++
 apertis-sample-image-development.yaml | 31 +++++++++++++
 apertis-sample-image-production.yaml  | 64 +++++++++++++++++++++++++++
 apertis-sample-image-sdk.yaml         | 35 +++++++++++++++
 11 files changed, 157 insertions(+)
 create mode 100644 apertis-sample-image-development.yaml
 create mode 100644 apertis-sample-image-production.yaml
 create mode 100644 apertis-sample-image-sdk.yaml

diff --git a/apertis-image-sdk.yaml b/apertis-image-sdk.yaml
index 41182652..9c96fd4b 100644
--- a/apertis-image-sdk.yaml
+++ b/apertis-image-sdk.yaml
@@ -14,14 +14,18 @@
 {{ $sampleappscheckout := or .sampleappscheckout "disabled" }}
 {{ $devrootpack := or .devrootpack "disabled" }}
 
+{{- $unpack := or .unpack "true" }}
+
 architecture: {{ $architecture }}
 
 actions:
 
+{{- if eq $unpack "true" }}
   - action: unpack
     description: Unpack {{ $ospack }}
     compression: gz
     file: {{ $ospack }}.tar.gz
+{{- end }}
 
   # Add multimedia demo pack
   # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
diff --git a/apertis-image-uboot.yaml b/apertis-image-uboot.yaml
index 3ddfdbca..1b1a8fb2 100644
--- a/apertis-image-uboot.yaml
+++ b/apertis-image-uboot.yaml
@@ -13,13 +13,17 @@
 {{ $demopack := "disabled" }}
 {{ end }}
 
+{{- $unpack := or .unpack "true" }}
+
 architecture: {{ $architecture }}
 
 actions:
+{{- if eq $unpack "true" }}
   - action: unpack
     description: Unpack {{ $ospack }}
     compression: gz
     file: {{ $ospack }}.tar.gz
+{{- end }}
 
   # Add multimedia demo pack
   # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
diff --git a/apertis-image-uefi.yaml b/apertis-image-uefi.yaml
index 1f0c4874..d6c5189c 100644
--- a/apertis-image-uefi.yaml
+++ b/apertis-image-uefi.yaml
@@ -13,13 +13,17 @@
 {{ $demopack := "disabled" }}
 {{ end }}
 
+{{- $unpack := or .unpack "true" }}
+
 architecture: {{ $architecture }}
 
 actions:
+{{- if eq $unpack "true" }}
   - action: unpack
     description: Unpack {{ $ospack }}
     compression: gz
     file: {{ $ospack }}.tar.gz
+{{- end }}
 
   # Add multimedia demo pack
   # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
diff --git a/apertis-ospack-basesdk.yaml b/apertis-ospack-basesdk.yaml
index 12790278..5f00902a 100644
--- a/apertis-ospack-basesdk.yaml
+++ b/apertis-ospack-basesdk.yaml
@@ -4,6 +4,7 @@
 {{- $suite := or .suite "v2019dev0" -}}
 {{- $timestamp := or .timestamp "" -}}
 {{- $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) -}}
+{{- $pack := or .pack "true" -}}
 
 architecture: {{ $architecture }}
 
@@ -557,6 +558,7 @@ actions:
     description: "Drop resolv.conf so the appropriate one gets created at runtime"
     command: rm "${ROOTDIR}/etc/resolv.conf"
 
+{{- if eq $pack "true" }}
   - action: run
     description: "Save installed package status"
     chroot: false
@@ -570,3 +572,4 @@ actions:
   - action: pack
     compression: gz
     file: {{ $ospack }}.tar.gz
+{{- end }}
diff --git a/apertis-ospack-minimal.yaml b/apertis-ospack-minimal.yaml
index ba947f4e..2e503d49 100644
--- a/apertis-ospack-minimal.yaml
+++ b/apertis-ospack-minimal.yaml
@@ -5,6 +5,7 @@
 {{- $timestamp := or .timestamp "" -}}
 {{- $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) -}}
 {{- $lxc := or .lxc "enabled" -}}
+{{- $pack := or .pack "true" -}}
 
 architecture: {{ $architecture }}
 
@@ -174,6 +175,7 @@ actions:
     description: "Drop resolv.conf so the appropriate one gets created at runtime"
     command: rm "${ROOTDIR}/etc/resolv.conf"
 
+{{- if eq $pack "true" }}
   - action: run
     description: "Save installed package status"
     chroot: false
@@ -187,3 +189,4 @@ actions:
   - action: pack
     compression: gz
     file: {{ $ospack }}.tar.gz
+{{- end }}
diff --git a/apertis-ospack-sdk.yaml b/apertis-ospack-sdk.yaml
index f693cd1c..cda451dd 100644
--- a/apertis-ospack-sdk.yaml
+++ b/apertis-ospack-sdk.yaml
@@ -5,6 +5,7 @@
 {{- $timestamp := or .timestamp "" -}}
 {{- $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) -}}
 {{- $lxc := or .lxc "enabled" -}}
+{{- $pack := or .pack "true" }}
 
 architecture: {{ $architecture }}
 
@@ -759,6 +760,7 @@ actions:
     description: "Drop resolv.conf so the appropriate one gets created at runtime"
     command: rm "${ROOTDIR}/etc/resolv.conf"
 
+{{- if eq $pack "true" }}
   - action: run
     description: "Save installed package status"
     chroot: false
@@ -772,3 +774,4 @@ actions:
   - action: pack
     compression: gz
     file: {{ $ospack }}.tar.gz
+{{- end }}
diff --git a/apertis-ospack-target.yaml b/apertis-ospack-target.yaml
index 90e65854..468965e3 100644
--- a/apertis-ospack-target.yaml
+++ b/apertis-ospack-target.yaml
@@ -6,6 +6,7 @@
 {{- $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) -}}
 {{- $ivitools := or .ivitools "enabled" -}}
 {{- $lxc := or .lxc "disabled" -}}
+{{- $pack := or .pack "true" -}}
 
 architecture: {{ $architecture }}
 
@@ -283,6 +284,7 @@ actions:
     description: "Drop resolv.conf so the appropriate one gets created at runtime"
     command: rm "${ROOTDIR}/etc/resolv.conf"
 
+{{- if eq $pack "true" }}
   - action: run
     description: "Save installed package status"
     chroot: false
@@ -296,3 +298,4 @@ actions:
   - action: pack
     compression: gz
     file: {{ $ospack }}.tar.gz
+{{- end }}
diff --git a/apertis-ostree-commit.yaml b/apertis-ostree-commit.yaml
index 473f8711..341882c7 100644
--- a/apertis-ostree-commit.yaml
+++ b/apertis-ostree-commit.yaml
@@ -9,12 +9,15 @@
 {{ $image := or .image (printf "apertis-ostree-%s-%s-%s" $suite  $type $architecture) }}
 {{ $ostree := or .ostree "repo" }}
 {{ $message := or .message "Update" }}
+{{- $unpack := or .unpack "true" }}
 
 architecture: {{ $architecture }}
 
 actions:
+{{- if eq $unpack "true" }}
   - action: unpack
     file: {{ $ospack }}.tar.gz
+{{- end }}
 
   - action: overlay
     description: "Install ostree feature"
diff --git a/apertis-sample-image-development.yaml b/apertis-sample-image-development.yaml
new file mode 100644
index 00000000..f8524d20
--- /dev/null
+++ b/apertis-sample-image-development.yaml
@@ -0,0 +1,31 @@
+{{- $architecture := "armhf" }}
+{{- $type := "minimal" }}
+{{- $mirror := "https://repositories.apertis.org/apertis/" }}
+{{- $suite := "v2019dev0" }}
+{{- $timestamp := "00000000.0" }}
+{{- $image := (printf "apertis-sample-development-%s-%s-%s_%s" $suite  $type $architecture $timestamp) }}
+
+architecture: {{ $architecture }}
+
+actions:
+  - action: recipe
+    description: Create ospack for {{ $suite }} {{ $type }} {{ $architecture }}
+    recipe: apertis-ospack-{{ $type }}.yaml
+    variables:
+      type: {{ $type }}
+      mirror: {{ $mirror }}
+      suite: {{ $suite }}
+      timestamp: {{ $timestamp }}
+      pack: false
+
+  # Package up everything in a image
+  - action: recipe
+    description: Create image {{ $image }} for {{ $suite }} {{ $type }} {{ $architecture }}
+    recipe: apertis-image-uboot.yaml
+    variables:
+      type: {{ $type }}
+      mirror: {{ $mirror }}
+      suite: {{ $suite }}
+      timestamp: {{ $timestamp }}
+      image: {{ $image }}
+      unpack: false
diff --git a/apertis-sample-image-production.yaml b/apertis-sample-image-production.yaml
new file mode 100644
index 00000000..1b6dc134
--- /dev/null
+++ b/apertis-sample-image-production.yaml
@@ -0,0 +1,64 @@
+{{- $architecture := "armhf" }}
+{{- $type := "minimal" }}
+{{- $mirror := "https://repositories.apertis.org/apertis/" }}
+{{- $suite := "v2019dev0" }}
+{{- $timestamp := "00000000.0" }}
+{{- $image := (printf "apertis-sample-production-%s-%s-%s_%s" $suite  $type $architecture $timestamp) }}
+
+{{ $board := "uboot" }}
+{{ $osname := "apertis" }}
+{{ $branch := (printf "%s/%s/%s-%s/%s" $osname $suite $architecture $board $type) }}
+{{ $ostree := "repo" }}
+{{ $repourl := (printf "${ARTIFACTDIR}/%s" $ostree) }}
+
+architecture: {{ $architecture }}
+
+actions:
+  - action: run
+    description: Create local OSTree repository
+    chroot: false
+    command: ostree init --mode archive --repo=${ARTIFACTDIR}/{{ $ostree }}
+
+  # Create base rootfs
+  - action: recipe
+    description: Create ospack for {{ $suite }} {{ $type }} {{ $architecture }}
+    recipe: apertis-ospack-{{ $type }}.yaml
+    variables:
+      type: {{ $type }}
+      mirror: {{ $mirror }}
+      suite: {{ $suite }}
+      timestamp: {{ $timestamp }}
+      pack: false
+
+  # Adapt and commit OSTree based on rootfs created during previous action
+  - action: recipe
+    description: OSTree commit for {{ $suite }} {{ $type }} {{ $architecture }}
+    recipe: apertis-ostree-commit.yaml
+    variables:
+      type: {{ $type }}
+      suite: {{ $suite }}
+      timestamp: {{ $timestamp }}
+      board: {{ $board }}
+      branch: {{ $branch }}
+      image: {{ $image }}
+      ostree: {{ $ostree }}
+      unpack: false
+
+  # Reset the rootfs to allow to deploy OSTree from a clean rootfs
+  - action: run
+    description: Reset rootfs before deploying OSTree
+    chroot: false
+    command: find ${ROOTDIR} -maxdepth 1 -mindepth 1 -exec rm -rf {} \;
+
+  # Package up everything in a image
+  - action: recipe
+    description: Create image {{ $image }} for {{ $suite }} {{ $type }} {{ $architecture }}
+    recipe: apertis-ostree-image-uboot.yaml
+    variables:
+      type: {{ $type }}
+      suite: {{ $suite }}
+      image: {{ $image }}
+      board: {{ $board }}
+      repourl: {{ $repourl }}
+      branch: {{ $branch }}
+      ostree: {{ $ostree }}
diff --git a/apertis-sample-image-sdk.yaml b/apertis-sample-image-sdk.yaml
new file mode 100644
index 00000000..c65fd427
--- /dev/null
+++ b/apertis-sample-image-sdk.yaml
@@ -0,0 +1,35 @@
+{{- $architecture := "amd64" }}
+{{- $type := "basesdk" }}
+{{- $mirror := "https://repositories.apertis.org/apertis/" }}
+{{- $suite := "v2019dev0" }}
+{{- $timestamp := "00000000.0" }}
+{{- $image := (printf "apertis-sample-sdk-%s-%s-%s_%s" $suite  $type $architecture $timestamp) }}
+
+{{- $devrootpack := or .devrootpack "disabled" }}
+
+architecture: {{ $architecture }}
+
+actions:
+  # Create base rootfs for the Base SDK
+  - action: recipe
+    description: Create ospack for {{ $suite }} {{ $type }} {{ $architecture }}
+    recipe: apertis-ospack-{{ $type }}.yaml
+    variables:
+      type: {{ $type }}
+      mirror: {{ $mirror }}
+      suite: {{ $suite }}
+      timestamp: {{ $timestamp }}
+      pack: false
+
+  # Package up everything in a image for VirtualBox
+  - action: recipe
+    description: Create image {{ $image }} for {{ $suite }} {{ $type }} {{ $architecture }}
+    recipe: apertis-image-sdk.yaml
+    variables:
+      type: {{ $type }}
+      mirror: {{ $mirror }}
+      suite: {{ $suite }}
+      timestamp: {{ $timestamp }}
+      image: {{ $image }}
+      devrootpack: {{ $devrootpack }}
+      unpack: false
-- 
GitLab