From a1ebaae9e8b13acf24f3859efbb4397ebb168ac8 Mon Sep 17 00:00:00 2001
From: Emanuele Aina <emanuele.aina@collabora.com>
Date: Wed, 29 Aug 2018 01:39:36 +0200
Subject: [PATCH] ospack,images: Make demopack available on OSTree images

The default demopack installs media files in `/home/shared`: by
including them only in the ospack they are unavailble on the ostree
images as the whole `/home` gets filtered out during `ostree commit`.

Moving the extraction of the demopack when the full filesystem gets
deployed to the images makes the media files available on ostree images
as well.

See https://phabricator.apertis.org/T5313

Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
---
 Jenkinsfile                             |  3 ++-
 apertis-image-mx6qsabrelite.yaml        | 17 +++++++++++++++++
 apertis-image-sdk.yaml                  | 14 ++++++++++++++
 apertis-image-uboot.yaml                | 17 +++++++++++++++++
 apertis-image-uefi.yaml                 | 17 +++++++++++++++++
 apertis-ospack.yaml                     | 15 ---------------
 apertis-ostree-image-mx6qsabrelite.yaml | 14 ++++++++++++++
 apertis-ostree-image-uboot.yaml         | 14 ++++++++++++++
 apertis-ostree-image-uefi.yaml          | 14 ++++++++++++++
 9 files changed, 109 insertions(+), 16 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 592415de..ead14fcc 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -170,7 +170,6 @@ def buildOSpack(architecture, type, debosarguments = "") {
             -t architecture:${architecture} \
             -t suite:${release} \
             -t timestamp:${PIPELINE_VERSION} \
-            -t demopack:${demopack} \
             -t ospack:ospack_${release}-${architecture}-${type}_${PIPELINE_VERSION} \
             ${WORKSPACE}/${osname}-ospack.yaml""")
     }
@@ -189,6 +188,7 @@ def buildImage(architecture, type, board, debosarguments = "") {
             -t type:${type} \
             -t ospack:ospack_${release}-${architecture}-${type}_${PIPELINE_VERSION} \
             -t image:${image_name} \
+            -t demopack:${demopack} \
             ${WORKSPACE}/${osname}-image-${board}.yaml""")
     }
 }
@@ -210,6 +210,7 @@ def buildOStreeImage(architecture, type, board, debosarguments = "") {
             -t suite:$release \
             -t ospack:ospack_${release}-${architecture}-${type}_${PIPELINE_VERSION} \
             -t image:${image_name} \
+            -t demopack:${demopack} \
             -t message:${release}-${type}-${architecture}-${board}_${PIPELINE_VERSION} \
             -t ostree:${repo} \
             ${WORKSPACE}/apertis-ostree-image-${board}.yaml;""")
diff --git a/apertis-image-mx6qsabrelite.yaml b/apertis-image-mx6qsabrelite.yaml
index cd9865d5..7e83975a 100644
--- a/apertis-image-mx6qsabrelite.yaml
+++ b/apertis-image-mx6qsabrelite.yaml
@@ -8,6 +8,11 @@
 
 {{ $cmdline := or .cmdline " console=tty0 console=ttymxc1,115200n8 plymouth.ignore-serial-consoles" }}
 
+{{ $demopack := or .demopack "disabled" }}
+{{ if eq $type "minimal" }}
+{{ $demopack := "disabled" }}
+{{ end }}
+
 architecture: {{ $architecture }}
 
 actions:
@@ -16,6 +21,18 @@ actions:
     compression: gz
     file: {{ $ospack }}.tar.gz
 
+  # Add multimedia demo pack
+  # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
+  # to add multimedia demo files
+  {{ if ne $demopack "disabled" }}
+  - action: download
+    url: {{ $demopack }}
+    name: mediademo
+
+  - action: unpack
+    origin: mediademo
+  {{ end }}
+
   - action: image-partition
     imagename: {{ $image }}.img
 {{ if eq $type "minimal" }}
diff --git a/apertis-image-sdk.yaml b/apertis-image-sdk.yaml
index 970fcc99..04f63122 100644
--- a/apertis-image-sdk.yaml
+++ b/apertis-image-sdk.yaml
@@ -8,6 +8,8 @@
 
 {{ $cmdline := or .cmdline "console=tty0 console=ttyS0,115200n8 rootwait ro quiet splash plymouth.ignore-serial-consoles" }}
 
+{{ $demopack := or .demopack "disabled" }}
+
 {{ $size := or .size "20G" }}
 {{ $ivitools := or .ivitools "enabled" }}
 
@@ -20,6 +22,18 @@ actions:
     compression: gz
     file: {{ $ospack }}.tar.gz
 
+  # Add multimedia demo pack
+  # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
+  # to add multimedia demo files
+  {{ if ne $demopack "disabled" }}
+  - action: download
+    url: {{ $demopack }}
+    name: mediademo
+
+  - action: unpack
+    origin: mediademo
+  {{ end }}
+
   - action: image-partition
     imagename: {{ $image }}.img
     imagesize: {{ $size }}
diff --git a/apertis-image-uboot.yaml b/apertis-image-uboot.yaml
index 5da8862e..f0ffde6d 100644
--- a/apertis-image-uboot.yaml
+++ b/apertis-image-uboot.yaml
@@ -8,6 +8,11 @@
 
 {{ $cmdline := or .cmdline " rootwait ro" }}
 
+{{ $demopack := or .demopack "disabled" }}
+{{ if eq $type "minimal" }}
+{{ $demopack := "disabled" }}
+{{ end }}
+
 architecture: {{ $architecture }}
 
 actions:
@@ -16,6 +21,18 @@ actions:
     compression: gz
     file: {{ $ospack }}.tar.gz
 
+  # Add multimedia demo pack
+  # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
+  # to add multimedia demo files
+  {{ if ne $demopack "disabled" }}
+  - action: download
+    url: {{ $demopack }}
+    name: mediademo
+
+  - action: unpack
+    origin: mediademo
+  {{ end }}
+
   - action: image-partition
     imagename: {{ $image }}.img
 {{ if eq $type "minimal" }}
diff --git a/apertis-image-uefi.yaml b/apertis-image-uefi.yaml
index 0a593f36..c932915a 100644
--- a/apertis-image-uefi.yaml
+++ b/apertis-image-uefi.yaml
@@ -8,6 +8,11 @@
 
 {{ $cmdline := or .cmdline "console=tty0 console=ttyS0,115200n8 rootwait ro quiet splash plymouth.ignore-serial-consoles" }}
 
+{{ $demopack := or .demopack "disabled" }}
+{{ if eq $type "minimal" }}
+{{ $demopack := "disabled" }}
+{{ end }}
+
 architecture: {{ $architecture }}
 
 actions:
@@ -16,6 +21,18 @@ actions:
     compression: gz
     file: {{ $ospack }}.tar.gz
 
+  # Add multimedia demo pack
+  # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
+  # to add multimedia demo files
+  {{ if ne $demopack "disabled" }}
+  - action: download
+    url: {{ $demopack }}
+    name: mediademo
+
+  - action: unpack
+    origin: mediademo
+  {{ end }}
+
   - action: image-partition
     imagename: {{ $image }}.img
 {{ if eq $type "minimal" }}
diff --git a/apertis-ospack.yaml b/apertis-ospack.yaml
index f0c62db9..1825e230 100644
--- a/apertis-ospack.yaml
+++ b/apertis-ospack.yaml
@@ -4,7 +4,6 @@
 {{- $suite := or .suite "18.06" -}}
 {{- $timestamp := or .timestamp "00000000.0" -}}
 {{- $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) -}}
-{{- $demopack := or .demopack "disabled" -}}
 {{- $ivitools := or .ivitools "enabled" -}}
 {{- $lxc := or .lxc "enabled" -}}
 
@@ -766,20 +765,6 @@ actions:
     chroot: true
     script: scripts/generate_locales.chroot
 
-  # Add multimedia demo pack for target and development images
-  # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
-  # to add multimedia demo files
-  {{ if eq $type "target" "development" "sdk"}}
-  {{ if ne $demopack "disabled" }}
-  - action: download
-    url: {{ $demopack }}
-    name: mediademo
-
-  - action: unpack
-    origin: mediademo
-  {{ end }}
-  {{ end }}
-
   - action: run
     description: "Save installed package status"
     chroot: false
diff --git a/apertis-ostree-image-mx6qsabrelite.yaml b/apertis-ostree-image-mx6qsabrelite.yaml
index 2a84a3e9..ff7210ed 100644
--- a/apertis-ostree-image-mx6qsabrelite.yaml
+++ b/apertis-ostree-image-mx6qsabrelite.yaml
@@ -11,6 +11,8 @@
 
 {{ $cmdline := or .cmdline "rootwait rw quiet splash plymouth.ignore-serial-consoles" }}
 
+{{ $demopack := or .demopack "disabled" }}
+
 architecture: {{ $architecture }}
 
 actions:
@@ -61,6 +63,18 @@ actions:
     os: {{ $osname }}
     append-kernel-cmdline: {{ $cmdline }}
 
+  # Add multimedia demo pack
+  # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
+  # to add multimedia demo files
+  {{ if ne $demopack "disabled" }}
+  - action: download
+    url: {{ $demopack }}
+    name: mediademo
+
+  - action: unpack
+    origin: mediademo
+  {{ end }}
+
   - action: run
     description: Locating u-boot
     chroot: false
diff --git a/apertis-ostree-image-uboot.yaml b/apertis-ostree-image-uboot.yaml
index 5c86778f..f8ef8316 100644
--- a/apertis-ostree-image-uboot.yaml
+++ b/apertis-ostree-image-uboot.yaml
@@ -11,6 +11,8 @@
 
 {{ $cmdline := or .cmdline "rootwait rw quiet splash plymouth.ignore-serial-consoles" }}
 
+{{ $demopack := or .demopack "disabled" }}
+
 architecture: {{ $architecture }}
 
 actions:
@@ -61,6 +63,18 @@ actions:
     os: {{ $osname }}
     append-kernel-cmdline: {{ $cmdline }}
 
+  # Add multimedia demo pack
+  # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
+  # to add multimedia demo files
+  {{ if ne $demopack "disabled" }}
+  - action: download
+    url: {{ $demopack }}
+    name: mediademo
+
+  - action: unpack
+    origin: mediademo
+  {{ end }}
+
   - action: run
     description: List files on {{ $image }}
     chroot: false
diff --git a/apertis-ostree-image-uefi.yaml b/apertis-ostree-image-uefi.yaml
index 94cdc6c1..449ed126 100644
--- a/apertis-ostree-image-uefi.yaml
+++ b/apertis-ostree-image-uefi.yaml
@@ -11,6 +11,8 @@
 
 {{ $cmdline := or .cmdline "console=tty0 console=ttyS0,115200n8 rootwait rw quiet splash plymouth.ignore-serial-consoles" }}
 
+{{ $demopack := or .demopack "disabled" }}
+
 architecture: {{ $architecture }}
 
 actions:
@@ -62,6 +64,18 @@ actions:
     os: {{ $osname }}
     append-kernel-cmdline: {{ $cmdline }}
 
+  # Add multimedia demo pack
+  # Provide URL via '-t demopack:"https://images.apertis.org/media/multimedia-demo.tar.gz"'
+  # to add multimedia demo files
+  {{ if ne $demopack "disabled" }}
+  - action: download
+    url: {{ $demopack }}
+    name: mediademo
+
+  - action: unpack
+    origin: mediademo
+  {{ end }}
+
   - action: run
     description: Install UEFI bootloader
     chroot: false
-- 
GitLab