From c45747e61cde24180d7222b4c023781ab6285a94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Tue, 15 Sep 2020 08:50:07 +0200
Subject: [PATCH 1/7] Add build and upload gitlab-ci blocks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This will prepare split of build-runtime into build-{base,runtime,sdk}.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 .gitlab-ci.yml | 44 +++++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index febfa02..1585298 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,32 +12,16 @@ image: registry.gitlab.apertis.org/infrastructure/apertis-docker-images/${APERTI
 stages:
   - build runtime
 
-build-runtime:
+.build:
   variables:
     GIT_STRATEGY: clone
-  stage: build runtime
   tags:
     - kvm
   before_script:
     - apt update
     - apt install -y binutils debootstrap debos flatpak ostree pigz python3 python3-debian python3-gi python3-yaml systemd-container time flatpak-builder
     - chmod 0400 "$ARCHIVE_SECRET_FILE"
-  script:
     - git clone --branch apertis/${APERTIS_RELEASE} --depth 1 ${FLATDEB_PROJECT_URL}
-    - apertis-flatdeb/run.py --suite=${APERTIS_RELEASE} --arch=amd64 base
-    - apertis-flatdeb/run.py --suite=${APERTIS_RELEASE} --arch=amd64 runtimes runtimes/org.apertis.mildenhall.yaml
-    - |
-      case "$CI_COMMIT_REF_NAME" in
-        apertis/*)
-          export UPLOAD_ROOT=$upload_root_main
-          ;;
-        *)
-          export UPLOAD_ROOT=$upload_root_test
-          ;;
-      esac
-    - ssh -oStrictHostKeyChecking=no -i "$ARCHIVE_SECRET_FILE" "$upload_host" mkdir -p "$UPLOAD_ROOT"
-    - rsync -e "ssh -oStrictHostKeyChecking=no -i $ARCHIVE_SECRET_FILE" -aP ~/.cache/flatdeb/ostree-repo/. "$upload_host:$UPLOAD_ROOT"
-    - ssh -oStrictHostKeyChecking=no -i "$ARCHIVE_SECRET_FILE" "$upload_host" flatpak build-update-repo "$UPLOAD_ROOT"
   only:
     refs:
       - branches
@@ -46,3 +30,29 @@ build-runtime:
       - $ARCHIVE_SECRET_FILE
   except:
     - tags
+
+.upload:
+  after_script:
+    - |
+      if [[ -f $(pwd)/flatdeb-builddir/ostree-repo/summary ]]; then
+        case "$CI_COMMIT_REF_NAME" in
+          apertis/*)
+            export UPLOAD_ROOT=$upload_root_main
+            ;;
+          *)
+            export UPLOAD_ROOT=$upload_root_test
+            ;;
+        esac
+        ssh -oStrictHostKeyChecking=no -i "$ARCHIVE_SECRET_FILE" "$upload_host" mkdir -p "$UPLOAD_ROOT"
+        rsync -e "ssh -oStrictHostKeyChecking=no -i $ARCHIVE_SECRET_FILE" -aP ~/.cache/flatdeb/ostree-repo/. "$upload_host:$UPLOAD_ROOT"
+        ssh -oStrictHostKeyChecking=no -i "$ARCHIVE_SECRET_FILE" "$upload_host" flatpak build-update-repo "$UPLOAD_ROOT"
+      fi
+
+build-runtime:
+  extends:
+    - .build
+    - .upload
+  stage: build runtime
+  script:
+    - apertis-flatdeb/run.py --suite=${APERTIS_RELEASE} --arch=amd64 base
+    - apertis-flatdeb/run.py --suite=${APERTIS_RELEASE} --arch=amd64 runtimes runtimes/org.apertis.mildenhall.yaml
-- 
GitLab


From 832976cd6e4e1369b589648c7817e882bb23eee3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Tue, 15 Sep 2020 09:08:13 +0200
Subject: [PATCH 2/7] Split build-runtime into build-{base,runtime,sdk}
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Split the creation of base, platform and sdk runtime as process fails to
access to network on 2nd call to debos, with the following errors:
  Error: Os { code: 98, kind: AddrInUse, message: "Address already in use" }
  Core dump limits :
  	soft - NONE
  	hard - NONE
  Checking that ptrace can change system call numbers...OK
  Checking syscall emulation patch for ptrace...OK
  Checking advanced syscall emulation patch for ptrace...OK
  Checking environment variables for a tempdir.../scratch
  Checking if /scratch is on tmpfs...OK
  Checking PROT_EXEC mmap in /scratch...OK
  Adding 3395584 bytes to physical memory to account for exec-shield gap
  Event loop failed: Connection timed out
  …
  2020/09/09 07:04:39 apt-install | E: Failed to fetch https://repositories.apertis.org/apertis/pool/hmi/m/mildenhall/mildenhall_0.2020.1bv2021dev1b1_all.deb  Temporary failure resolving 'repositories.apertis.org'
  2020/09/09 07:04:39 apt-install | E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
  2020/09/09 07:04:39 apt-install | Container root failed with error code 100.
  2020/09/09 07:04:39 apt-install |
  2020/09/09 07:04:39 apt-install | ERROR:flatdeb.apt-install:Command '['systemd-nspawn', '--directory=/scratch/root', '--as-pid2', '--tmpfs=/run/lock', '--register=no', 'env', 'DEBIAN_FRONTEND=noninteractive', 'apt-get', '-y', '--no-install-recommends', 'install', 'libc6:amd64', 'libstdc++6:amd64', 'libsystemd0', 'mildenhall']' returned non-zero exit status 100.
  2020/09/09 07:04:39 Action `run` failed at stage Run, error: exit status 1

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 .gitlab-ci.yml | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1585298..c95f81b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,6 +10,7 @@ variables:
 image: registry.gitlab.apertis.org/infrastructure/apertis-docker-images/${APERTIS_RELEASE}-package-builder
 
 stages:
+  - build base
   - build runtime
 
 .build:
@@ -44,15 +45,37 @@ stages:
             ;;
         esac
         ssh -oStrictHostKeyChecking=no -i "$ARCHIVE_SECRET_FILE" "$upload_host" mkdir -p "$UPLOAD_ROOT"
-        rsync -e "ssh -oStrictHostKeyChecking=no -i $ARCHIVE_SECRET_FILE" -aP ~/.cache/flatdeb/ostree-repo/. "$upload_host:$UPLOAD_ROOT"
+        rsync -e "ssh -oStrictHostKeyChecking=no -i $ARCHIVE_SECRET_FILE" -aP $(pwd)/flatdeb-builddir/ostree-repo/. "$upload_host:$UPLOAD_ROOT"
         ssh -oStrictHostKeyChecking=no -i "$ARCHIVE_SECRET_FILE" "$upload_host" flatpak build-update-repo "$UPLOAD_ROOT"
       fi
 
-build-runtime:
+build-base:
+  extends:
+    - .build
+  stage: build base
+  script:
+    - apertis-flatdeb/run.py --build-area=$(pwd)/flatdeb-builddir --ostree-repo=$(pwd)/flatdeb-builddir/ostree-repo --suite=${APERTIS_RELEASE} --arch=amd64 base
+  artifacts:
+    expire_in: 1d
+    paths:
+      - flatdeb-builddir/base-${APERTIS_RELEASE}-amd64.tar.gz
+
+build-platform-runtime:
+  extends:
+    - .build
+    - .upload
+  stage: build runtime
+  script:
+    - apertis-flatdeb/run.py --build-area=$(pwd)/flatdeb-builddir --ostree-repo=$(pwd)/flatdeb-builddir/ostree-repo --suite=${APERTIS_RELEASE} --arch=amd64 --platform runtimes runtimes/org.apertis.mildenhall.yaml
+  dependencies:
+    - build-base
+
+build-sdk-runtime:
   extends:
     - .build
     - .upload
   stage: build runtime
   script:
-    - apertis-flatdeb/run.py --suite=${APERTIS_RELEASE} --arch=amd64 base
-    - apertis-flatdeb/run.py --suite=${APERTIS_RELEASE} --arch=amd64 runtimes runtimes/org.apertis.mildenhall.yaml
+    - apertis-flatdeb/run.py --build-area=$(pwd)/flatdeb-builddir --ostree-repo=$(pwd)/flatdeb-builddir/ostree-repo --suite=${APERTIS_RELEASE} --arch=amd64 --sdk runtimes runtimes/org.apertis.mildenhall.yaml
+  dependencies:
+    - build-base
-- 
GitLab


From 3adb2a21edd623b99f5ad72b2b81c46c2014de9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Tue, 15 Sep 2020 09:21:20 +0200
Subject: [PATCH 3/7] Use new flatdeb-builder docker image
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This new docker image already embbed the apertis-flatdeb tool.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 .gitlab-ci.yml         | 9 ++++-----
 ci-flatpak-builder.yml | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c95f81b..019e0d7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,7 +7,7 @@ variables:
   upload_root_main: /srv/images/public/flatpak/mildenhall
   upload_root_test: /srv/images/test/flatpak/mildenhall/$CI_COMMIT_REF_SLUG
 
-image: registry.gitlab.apertis.org/infrastructure/apertis-docker-images/${APERTIS_RELEASE}-package-builder
+image: registry.gitlab.apertis.org/infrastructure/apertis-docker-images/${APERTIS_RELEASE}-flatdeb-builder
 
 stages:
   - build base
@@ -22,7 +22,6 @@ stages:
     - apt update
     - apt install -y binutils debootstrap debos flatpak ostree pigz python3 python3-debian python3-gi python3-yaml systemd-container time flatpak-builder
     - chmod 0400 "$ARCHIVE_SECRET_FILE"
-    - git clone --branch apertis/${APERTIS_RELEASE} --depth 1 ${FLATDEB_PROJECT_URL}
   only:
     refs:
       - branches
@@ -54,7 +53,7 @@ build-base:
     - .build
   stage: build base
   script:
-    - apertis-flatdeb/run.py --build-area=$(pwd)/flatdeb-builddir --ostree-repo=$(pwd)/flatdeb-builddir/ostree-repo --suite=${APERTIS_RELEASE} --arch=amd64 base
+    - /opt/apertis-flatdeb/run.py --build-area=$(pwd)/flatdeb-builddir --ostree-repo=$(pwd)/flatdeb-builddir/ostree-repo --suite=${APERTIS_RELEASE} --arch=amd64 base
   artifacts:
     expire_in: 1d
     paths:
@@ -66,7 +65,7 @@ build-platform-runtime:
     - .upload
   stage: build runtime
   script:
-    - apertis-flatdeb/run.py --build-area=$(pwd)/flatdeb-builddir --ostree-repo=$(pwd)/flatdeb-builddir/ostree-repo --suite=${APERTIS_RELEASE} --arch=amd64 --platform runtimes runtimes/org.apertis.mildenhall.yaml
+    - /opt/apertis-flatdeb/run.py --build-area=$(pwd)/flatdeb-builddir --ostree-repo=$(pwd)/flatdeb-builddir/ostree-repo --suite=${APERTIS_RELEASE} --arch=amd64 --platform runtimes runtimes/org.apertis.mildenhall.yaml
   dependencies:
     - build-base
 
@@ -76,6 +75,6 @@ build-sdk-runtime:
     - .upload
   stage: build runtime
   script:
-    - apertis-flatdeb/run.py --build-area=$(pwd)/flatdeb-builddir --ostree-repo=$(pwd)/flatdeb-builddir/ostree-repo --suite=${APERTIS_RELEASE} --arch=amd64 --sdk runtimes runtimes/org.apertis.mildenhall.yaml
+    - /opt/apertis-flatdeb/run.py --build-area=$(pwd)/flatdeb-builddir --ostree-repo=$(pwd)/flatdeb-builddir/ostree-repo --suite=${APERTIS_RELEASE} --arch=amd64 --sdk runtimes runtimes/org.apertis.mildenhall.yaml
   dependencies:
     - build-base
diff --git a/ci-flatpak-builder.yml b/ci-flatpak-builder.yml
index 6171de0..359e4b3 100644
--- a/ci-flatpak-builder.yml
+++ b/ci-flatpak-builder.yml
@@ -6,7 +6,7 @@ variables:
   upload_root_main: /srv/images/public/flatpak/mildenhall
   upload_root_test: /srv/images/test/flatpak/mildenhall/$CI_COMMIT_REF_SLUG
 
-image: registry.gitlab.apertis.org/infrastructure/apertis-docker-images/${APERTIS_RELEASE}-package-builder
+image: registry.gitlab.apertis.org/infrastructure/apertis-docker-images/${APERTIS_RELEASE}-flatdeb-builder
 
 stages:
   - build app
-- 
GitLab


From dc2d81eda3c2c873d39fbe5f26d69dcc647ddbe2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Tue, 15 Sep 2020 09:23:58 +0200
Subject: [PATCH 4/7] Drop the kvm tag
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

New flatdeb-builder docker image uses latest debos version and does not
require kvm to be run.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 .gitlab-ci.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 019e0d7..a454e67 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,8 +16,6 @@ stages:
 .build:
   variables:
     GIT_STRATEGY: clone
-  tags:
-    - kvm
   before_script:
     - apt update
     - apt install -y binutils debootstrap debos flatpak ostree pigz python3 python3-debian python3-gi python3-yaml systemd-container time flatpak-builder
-- 
GitLab


From c0ca0b0833c55b3405a4fb4d47d51f54fdc35219 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Tue, 15 Sep 2020 09:26:20 +0200
Subject: [PATCH 5/7] Drop calls to apt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

New flatdeb-builder docker image already embbed packages request to build
and upload the Flatpak runtime and apps.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 .gitlab-ci.yml         | 2 --
 ci-flatpak-builder.yml | 2 --
 2 files changed, 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a454e67..4816d97 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -17,8 +17,6 @@ stages:
   variables:
     GIT_STRATEGY: clone
   before_script:
-    - apt update
-    - apt install -y binutils debootstrap debos flatpak ostree pigz python3 python3-debian python3-gi python3-yaml systemd-container time flatpak-builder
     - chmod 0400 "$ARCHIVE_SECRET_FILE"
   only:
     refs:
diff --git a/ci-flatpak-builder.yml b/ci-flatpak-builder.yml
index 359e4b3..5293c1b 100644
--- a/ci-flatpak-builder.yml
+++ b/ci-flatpak-builder.yml
@@ -16,8 +16,6 @@ build-app:
     GIT_STRATEGY: clone
   stage: build app
   before_script:
-    - apt update
-    - apt install -y binutils debootstrap debos flatpak ostree pigz python3 python3-debian python3-gi python3-yaml systemd-container time flatpak-builder
     - chmod 0400 "$ARCHIVE_SECRET_FILE"
     - flatpak --if-not-exists --user remote-add --no-gpg-verify mildenhall https://images.apertis.org/public/flatpak/mildenhall
     - flatpak install -y org.apertis.mildenhall.Platform org.apertis.mildenhall.Sdk
-- 
GitLab


From d60e51cae9aa999690a7f94e0d2e38bca34143d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Mon, 21 Sep 2020 11:00:45 +0200
Subject: [PATCH 6/7] Fix repository path and release version to use
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This fix runtime installation path in recipe used to build
applications, and get the correct version.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 ci-flatpak-builder.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ci-flatpak-builder.yml b/ci-flatpak-builder.yml
index 5293c1b..3532005 100644
--- a/ci-flatpak-builder.yml
+++ b/ci-flatpak-builder.yml
@@ -17,8 +17,8 @@ build-app:
   stage: build app
   before_script:
     - chmod 0400 "$ARCHIVE_SECRET_FILE"
-    - flatpak --if-not-exists --user remote-add --no-gpg-verify mildenhall https://images.apertis.org/public/flatpak/mildenhall
-    - flatpak install -y org.apertis.mildenhall.Platform org.apertis.mildenhall.Sdk
+    - flatpak --if-not-exists --user remote-add --no-gpg-verify mildenhall https://images.apertis.org/flatpak/mildenhall
+    - flatpak install -y org.apertis.mildenhall.Platform//${APERTIS_RELEASE} org.apertis.mildenhall.Sdk//${APERTIS_RELEASE}
   script:
     - REPODIR=$(mktemp -d repo-XXXXXX)
     - chmod 755 ${REPODIR}
-- 
GitLab


From fe3ee3a67902d4810e7e50a973aae60693f83dcb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Mon, 21 Sep 2020 11:01:21 +0200
Subject: [PATCH 7/7] Update to v2022dev0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Move runtime and SDK to v2022dev0.
The suite recipe name should be in sync with the Apertis version.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 .gitlab-ci.yml                            | 2 +-
 ci-flatpak-builder.yml                    | 2 +-
 suites/{v2021dev2.yaml => v2022dev0.yaml} | 0
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename suites/{v2021dev2.yaml => v2022dev0.yaml} (100%)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4816d97..26a39e6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@
 
 variables:
   FLATDEB_PROJECT_URL: https://gitlab.apertis.org/infrastructure/apertis-flatdeb.git
-  APERTIS_RELEASE: "v2021dev2"
+  APERTIS_RELEASE: "v2022dev0"
   upload_host: archive@images.apertis.org
   upload_root_main: /srv/images/public/flatpak/mildenhall
   upload_root_test: /srv/images/test/flatpak/mildenhall/$CI_COMMIT_REF_SLUG
diff --git a/ci-flatpak-builder.yml b/ci-flatpak-builder.yml
index 3532005..f9bc807 100644
--- a/ci-flatpak-builder.yml
+++ b/ci-flatpak-builder.yml
@@ -1,7 +1,7 @@
 # vi:et:sts=2
 
 variables:
-  APERTIS_RELEASE: "v2021dev2"
+  APERTIS_RELEASE: "v2022dev0"
   upload_host: archive@images.apertis.org
   upload_root_main: /srv/images/public/flatpak/mildenhall
   upload_root_test: /srv/images/test/flatpak/mildenhall/$CI_COMMIT_REF_SLUG
diff --git a/suites/v2021dev2.yaml b/suites/v2022dev0.yaml
similarity index 100%
rename from suites/v2021dev2.yaml
rename to suites/v2022dev0.yaml
-- 
GitLab