From 70ad2ee3a19d56dd3b0f677b61dd54aba66ca3ce Mon Sep 17 00:00:00 2001
From: Emanuele Aina <emanuele.aina@collabora.com>
Date: Fri, 8 Mar 2019 17:30:48 +0100
Subject: [PATCH] Drop the "00000000.0" timestamp defaults

Jenkins is actually defining the full names for every artifact anyway and the
default is not particularly useful when building stuff locally without passing
any parameter so let's ensure the default names are sane and drop the
00000000.0 default.

Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
---
 apertis-image-sdk.yaml         | 6 +++---
 apertis-image-uboot.yaml       | 6 +++---
 apertis-image-uefi.yaml        | 6 +++---
 apertis-ospack-basesdk.yaml    | 6 +++---
 apertis-ospack-devroot.yaml    | 6 +++---
 apertis-ospack-minimal.yaml    | 6 +++---
 apertis-ospack-sdk.yaml        | 6 +++---
 apertis-ospack-sysroot.yaml    | 6 +++---
 apertis-ospack-target.yaml     | 6 +++---
 apertis-ostree-commit.yaml     | 4 ++--
 scripts/setup_image_version.sh | 4 +++-
 11 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/apertis-image-sdk.yaml b/apertis-image-sdk.yaml
index e265a41b..2728b4e2 100644
--- a/apertis-image-sdk.yaml
+++ b/apertis-image-sdk.yaml
@@ -2,9 +2,9 @@
 {{ $type := or .type "sdk" }}
 {{ $mirror := or .mirror "https://repositories.apertis.org/apertis/" }}
 {{ $suite := or .suite "v2019dev0" }}
-{{ $timestamp := or .timestamp "00000000.0" }}
-{{ $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) }}
-{{ $image := or .image (printf "apertis-%s-%s-%s_%s" $suite  $type $architecture $timestamp) }}
+{{ $timestamp := or .timestamp "" }}
+{{ $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) }}
+{{ $image := or .image (printf "apertis-%s-%s-%s" $suite  $type $architecture) }}
 
 {{ $cmdline := or .cmdline "console=tty0 console=ttyS0,115200n8 rootwait ro quiet splash plymouth.ignore-serial-consoles fsck.mode=auto fsck.repair=yes" }}
 
diff --git a/apertis-image-uboot.yaml b/apertis-image-uboot.yaml
index 08deeda8..7bc9e0f6 100644
--- a/apertis-image-uboot.yaml
+++ b/apertis-image-uboot.yaml
@@ -2,9 +2,9 @@
 {{ $type := or .type "minimal" }}
 {{ $mirror := or .mirror "https://repositories.apertis.org/apertis/" }}
 {{ $suite := or .suite "v2019dev0" }}
-{{ $timestamp := or .timestamp "00000000.0" }}
-{{ $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) }}
-{{ $image := or .image (printf "apertis-%s-%s-%s_%s" $suite  $type $architecture $timestamp) }}
+{{ $timestamp := or .timestamp "" }}
+{{ $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) }}
+{{ $image := or .image (printf "apertis-%s-%s-%s" $suite  $type $architecture) }}
 
 {{ $cmdline := or .cmdline " rootwait ro fsck.mode=auto fsck.repair=yes" }}
 
diff --git a/apertis-image-uefi.yaml b/apertis-image-uefi.yaml
index 7d4ad2d2..52cea976 100644
--- a/apertis-image-uefi.yaml
+++ b/apertis-image-uefi.yaml
@@ -2,9 +2,9 @@
 {{ $type := or .type "minimal" }}
 {{ $mirror := or .mirror "https://repositories.apertis.org/apertis/" }}
 {{ $suite := or .suite "v2019dev0" }}
-{{ $timestamp := or .timestamp "00000000.0" }}
-{{ $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) }}
-{{ $image := or .image (printf "apertis-%s-%s-%s_%s" $suite  $type $architecture $timestamp) }}
+{{ $timestamp := or .timestamp "" }}
+{{ $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) }}
+{{ $image := or .image (printf "apertis-%s-%s-%s" $suite  $type $architecture) }}
 
 {{ $cmdline := or .cmdline "console=tty0 console=ttyS0,115200n8 rootwait ro quiet splash plymouth.ignore-serial-consoles fsck.mode=auto fsck.repair=yes" }}
 
diff --git a/apertis-ospack-basesdk.yaml b/apertis-ospack-basesdk.yaml
index 354f0c70..c1d6d1f2 100644
--- a/apertis-ospack-basesdk.yaml
+++ b/apertis-ospack-basesdk.yaml
@@ -2,8 +2,8 @@
 {{- $type := or .type "basesdk" -}}
 {{- $mirror := or .mirror "https://repositories.apertis.org/apertis/" -}}
 {{- $suite := or .suite "v2019dev0" -}}
-{{- $timestamp := or .timestamp "00000000.0" -}}
-{{- $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) -}}
+{{- $timestamp := or .timestamp "" -}}
+{{- $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) -}}
 
 architecture: {{ $architecture }}
 
@@ -22,7 +22,7 @@ actions:
   - action: run
     description: "Setting up image version metadata"
     chroot: true
-    script: scripts/setup_image_version.sh apertis {{ $suite }} {{ $timestamp }} collabora {{ $type }}
+    script: scripts/setup_image_version.sh apertis {{ $suite }} '{{ $timestamp }}' collabora {{ $type }}
 
   # Extend apt sources list
   - action: run
diff --git a/apertis-ospack-devroot.yaml b/apertis-ospack-devroot.yaml
index cf2a37ae..ba91f873 100644
--- a/apertis-ospack-devroot.yaml
+++ b/apertis-ospack-devroot.yaml
@@ -2,8 +2,8 @@
 {{- $type := or .type "devroot" -}}
 {{- $mirror := or .mirror "https://repositories.apertis.org/apertis/" -}}
 {{- $suite := or .suite "v2019dev0" -}}
-{{- $timestamp := or .timestamp "00000000.0" -}}
-{{- $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) -}}
+{{- $timestamp := or .timestamp "" -}}
+{{- $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) -}}
 {{- $ivitools := or .ivitools "enabled" -}}
 {{- $lxc := or .lxc "enabled" -}}
 
@@ -24,7 +24,7 @@ actions:
   - action: run
     description: "Setting up image version metadata"
     chroot: true
-    script: scripts/setup_image_version.sh apertis {{ $suite }} {{ $timestamp }} collabora {{ $type }}
+    script: scripts/setup_image_version.sh apertis {{ $suite }} '{{ $timestamp }}' collabora {{ $type }}
 
   # Extend apt sources list
   - action: run
diff --git a/apertis-ospack-minimal.yaml b/apertis-ospack-minimal.yaml
index a5c458da..c167a325 100644
--- a/apertis-ospack-minimal.yaml
+++ b/apertis-ospack-minimal.yaml
@@ -2,8 +2,8 @@
 {{- $type := or .type "minimal" -}}
 {{- $mirror := or .mirror "https://repositories.apertis.org/apertis/" -}}
 {{- $suite := or .suite "v2019dev0" -}}
-{{- $timestamp := or .timestamp "00000000.0" -}}
-{{- $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) -}}
+{{- $timestamp := or .timestamp "" -}}
+{{- $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) -}}
 {{- $lxc := or .lxc "enabled" -}}
 
 architecture: {{ $architecture }}
@@ -23,7 +23,7 @@ actions:
   - action: run
     description: "Setting up image version metadata"
     chroot: true
-    script: scripts/setup_image_version.sh apertis {{ $suite }} {{ $timestamp }} collabora {{ $type }}
+    script: scripts/setup_image_version.sh apertis {{ $suite }} '{{ $timestamp }}' collabora {{ $type }}
 
   # Extend apt sources list
   - action: run
diff --git a/apertis-ospack-sdk.yaml b/apertis-ospack-sdk.yaml
index 4d146fd4..931e12a9 100644
--- a/apertis-ospack-sdk.yaml
+++ b/apertis-ospack-sdk.yaml
@@ -2,8 +2,8 @@
 {{- $type := or .type "sdk" -}}
 {{- $mirror := or .mirror "https://repositories.apertis.org/apertis/" -}}
 {{- $suite := or .suite "v2019dev0" -}}
-{{- $timestamp := or .timestamp "00000000.0" -}}
-{{- $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) -}}
+{{- $timestamp := or .timestamp "" -}}
+{{- $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) -}}
 {{- $lxc := or .lxc "enabled" -}}
 
 architecture: {{ $architecture }}
@@ -23,7 +23,7 @@ actions:
   - action: run
     description: "Setting up image version metadata"
     chroot: true
-    script: scripts/setup_image_version.sh apertis {{ $suite }} {{ $timestamp }} collabora {{ $type }}
+    script: scripts/setup_image_version.sh apertis {{ $suite }} '{{ $timestamp }}' collabora {{ $type }}
 
   # Extend apt sources list
   - action: run
diff --git a/apertis-ospack-sysroot.yaml b/apertis-ospack-sysroot.yaml
index 4996a354..409ada7d 100644
--- a/apertis-ospack-sysroot.yaml
+++ b/apertis-ospack-sysroot.yaml
@@ -2,8 +2,8 @@
 {{- $type := or .type "sysroot" -}}
 {{- $mirror := or .mirror "https://repositories.apertis.org/apertis/" -}}
 {{- $suite := or .suite "v2019dev0" -}}
-{{- $timestamp := or .timestamp "00000000.0" -}}
-{{- $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) -}}
+{{- $timestamp := or .timestamp "" -}}
+{{- $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) -}}
 {{- $ivitools := or .ivitools "enabled" -}}
 {{- $lxc := or .lxc "enabled" -}}
 
@@ -24,7 +24,7 @@ actions:
   - action: run
     description: "Setting up image version metadata"
     chroot: true
-    script: scripts/setup_image_version.sh apertis {{ $suite }} {{ $timestamp }} collabora {{ $type }}
+    script: scripts/setup_image_version.sh apertis {{ $suite }} '{{ $timestamp }}' collabora {{ $type }}
 
   # Extend apt sources list
   - action: run
diff --git a/apertis-ospack-target.yaml b/apertis-ospack-target.yaml
index b7513960..ffc7a8b1 100644
--- a/apertis-ospack-target.yaml
+++ b/apertis-ospack-target.yaml
@@ -2,8 +2,8 @@
 {{- $type := or .type "target" -}}
 {{- $mirror := or .mirror "https://repositories.apertis.org/apertis/" -}}
 {{- $suite := or .suite "v2019dev0" -}}
-{{- $timestamp := or .timestamp "00000000.0" -}}
-{{- $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) -}}
+{{- $timestamp := or .timestamp "" -}}
+{{- $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) -}}
 {{- $ivitools := or .ivitools "disabled" -}}
 {{- $lxc := or .lxc "disabled" -}}
 
@@ -24,7 +24,7 @@ actions:
   - action: run
     description: "Setting up image version metadata"
     chroot: true
-    script: scripts/setup_image_version.sh apertis {{ $suite }} {{ $timestamp }} collabora {{ $type }}
+    script: scripts/setup_image_version.sh apertis {{ $suite }} '{{ $timestamp }}' collabora {{ $type }}
 
   # Extend apt sources list
   - action: run
diff --git a/apertis-ostree-commit.yaml b/apertis-ostree-commit.yaml
index d154ef5b..af58f02d 100644
--- a/apertis-ostree-commit.yaml
+++ b/apertis-ostree-commit.yaml
@@ -1,8 +1,8 @@
 {{ $architecture := or .architecture "amd64" }}
 {{ $type := or .type "minimal" }}
 {{ $suite := or .suite "v2019dev0" }}
-{{ $timestamp := or .timestamp "00000000.0" }}
-{{ $ospack := or .ospack (printf "ospack_%s-%s-%s_%s" $suite $architecture $type $timestamp) }}
+{{ $timestamp := or .timestamp "" }}
+{{ $ospack := or .ospack (printf "ospack_%s-%s-%s" $suite $architecture $type) }}
 
 {{ $board := or .board "uefi" }}
 {{ $branch := or .branch (printf "apertis/%s/%s-%s/%s" $suite $architecture $board $type) }}
diff --git a/scripts/setup_image_version.sh b/scripts/setup_image_version.sh
index 3bb6e031..c4cf46e8 100755
--- a/scripts/setup_image_version.sh
+++ b/scripts/setup_image_version.sh
@@ -13,4 +13,6 @@ echo "${distro} ${rel} ${timestamp} ${vendor}" > /etc/image_version
 if [ -n "$variant" ]; then
     echo "VARIANT_ID=$variant" >> /etc/os-release
 fi
-echo "BUILD_ID=$timestamp" >> /etc/os-release
+if [ -n "$timestamp" ]; then
+    echo "BUILD_ID=$timestamp" >> /etc/os-release
+fi
-- 
GitLab