From 4acc3a114b13f462bed44c4e9d739cf850c50ce1 Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa@fedoraproject.org>
Date: Dec 18 2023 21:16:38 +0000
Subject: [PATCH 1/5] Add Zuul CI configuration


This allows us to have pull requests tested before we review changes
to merge.

---

diff --git a/.fmf/version b/.fmf/version
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/.fmf/version
@@ -0,0 +1 @@
+1
diff --git a/.zuul.yaml b/.zuul.yaml
new file mode 100644
index 0000000..9159189
--- /dev/null
+++ b/.zuul.yaml
@@ -0,0 +1,15 @@
+---
+- job:
+    name: build-images
+    parent: tmt-test
+    vars:
+      tmt_url: "https://pagure.io/{{ zuul.project.name }}"
+      tmt_ref: "{{ zuul.ref }}"
+      distro: fedora-rawhide
+      compose: Fedora-latest
+      tf_arch: aarch64
+
+- project:
+   check:
+    jobs:
+      - build-images
diff --git a/tmt/plans/build-gnome.fmf b/tmt/plans/build-gnome.fmf
new file mode 100644
index 0000000..894d94f
--- /dev/null
+++ b/tmt/plans/build-gnome.fmf
@@ -0,0 +1,14 @@
+summary: Build GNOME image
+discover:
+    how: shell
+    tests:
+      - name: build image
+        test: |
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils
+          setenforce 0
+          $TMT_TREE/builder.py build gnome
+          $TMT_TREE/builder.py package gnome
+          setenforce 1
+
+execute:
+    how: tmt
diff --git a/tmt/plans/build-kde.fmf b/tmt/plans/build-kde.fmf
new file mode 100644
index 0000000..c4c4411
--- /dev/null
+++ b/tmt/plans/build-kde.fmf
@@ -0,0 +1,14 @@
+summary: Build KDE image
+discover:
+    how: shell
+    tests:
+      - name: build image
+        test: |
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils
+          setenforce 0
+          $TMT_TREE/builder.py build kde
+          $TMT_TREE/builder.py package kde
+          setenforce 1
+
+execute:
+    how: tmt
diff --git a/tmt/plans/build-minimal.fmf b/tmt/plans/build-minimal.fmf
new file mode 100644
index 0000000..b98fca9
--- /dev/null
+++ b/tmt/plans/build-minimal.fmf
@@ -0,0 +1,14 @@
+summary: Build Minimal image
+discover:
+    how: shell
+    tests:
+      - name: build image
+        test: |
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils
+          setenforce 0
+          $TMT_TREE/builder.py build minimal
+          $TMT_TREE/builder.py package minimal
+          setenforce 1
+
+execute:
+    how: tmt
diff --git a/tmt/plans/build-server.fmf b/tmt/plans/build-server.fmf
new file mode 100644
index 0000000..9e0344d
--- /dev/null
+++ b/tmt/plans/build-server.fmf
@@ -0,0 +1,14 @@
+summary: Build Server image
+discover:
+    how: shell
+    tests:
+      - name: build image
+        test: |
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils
+          setenforce 0
+          $TMT_TREE/builder.py build server
+          $TMT_TREE/builder.py package server
+          setenforce 1
+
+execute:
+    how: tmt

From c0a8e4bec47f92b8e49f9f26b03bd39b723114f1 Mon Sep 17 00:00:00 2001
From: Davide Cavalca <dcavalca@fedoraproject.org>
Date: Dec 19 2023 00:33:41 +0000
Subject: [PATCH 2/5] tmt: add missing dependency


---

diff --git a/tmt/plans/build-gnome.fmf b/tmt/plans/build-gnome.fmf
index 894d94f..0f39b9c 100644
--- a/tmt/plans/build-gnome.fmf
+++ b/tmt/plans/build-gnome.fmf
@@ -4,7 +4,7 @@ discover:
     tests:
       - name: build image
         test: |
-          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils rpmdistro-repoquery
           setenforce 0
           $TMT_TREE/builder.py build gnome
           $TMT_TREE/builder.py package gnome
diff --git a/tmt/plans/build-kde.fmf b/tmt/plans/build-kde.fmf
index c4c4411..fe94aba 100644
--- a/tmt/plans/build-kde.fmf
+++ b/tmt/plans/build-kde.fmf
@@ -4,7 +4,7 @@ discover:
     tests:
       - name: build image
         test: |
-          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils rpmdistro-repoquery
           setenforce 0
           $TMT_TREE/builder.py build kde
           $TMT_TREE/builder.py package kde
diff --git a/tmt/plans/build-minimal.fmf b/tmt/plans/build-minimal.fmf
index b98fca9..7130e8b 100644
--- a/tmt/plans/build-minimal.fmf
+++ b/tmt/plans/build-minimal.fmf
@@ -4,7 +4,7 @@ discover:
     tests:
       - name: build image
         test: |
-          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils rpmdistro-repoquery
           setenforce 0
           $TMT_TREE/builder.py build minimal
           $TMT_TREE/builder.py package minimal
diff --git a/tmt/plans/build-server.fmf b/tmt/plans/build-server.fmf
index 9e0344d..77c777b 100644
--- a/tmt/plans/build-server.fmf
+++ b/tmt/plans/build-server.fmf
@@ -4,7 +4,7 @@ discover:
     tests:
       - name: build image
         test: |
-          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils rpmdistro-repoquery
           setenforce 0
           $TMT_TREE/builder.py build server
           $TMT_TREE/builder.py package server

From 4b45f57c8a0068280a7c4dd4af620418fbd17597 Mon Sep 17 00:00:00 2001
From: Davide Cavalca <dcavalca@fedoraproject.org>
Date: Dec 19 2023 00:33:41 +0000
Subject: [PATCH 3/5] tmt: copy the artifacts over


---

diff --git a/builder.py b/builder.py
index dcf816c..196e042 100755
--- a/builder.py
+++ b/builder.py
@@ -188,6 +188,23 @@ def packageUpload(target):
     uploadToS3(manifest, f"os/{manifest}")
 
 
+def tmtCopy(target):
+    base = f"fedora-{RELEASE}-{target['id']}-{BUILDVER}"
+    package = f"{base}.zip"
+    logs_package = f"{base}.logs.zip"
+    image = f"{base}.raw.zst"
+    manifest = f"{base}.json"
+
+    artifacts = os.getenv("TMT_PLAN_DATA")
+    if not os.path.exists(artifacts):
+        os.mkdir(artifacts)
+
+    shutil.copyfile(package, f"{artifacts}/{package}")
+    shutil.copyfile(logs_package, f"{artifacts}/{logs_package}")
+    shutil.copyfile(image, f"{artifacts}/{image}")
+    shutil.copyfile(manifest, f"{artifacts}/{manifest}")
+
+
 def getManifest():
     if S3_BUCKET is None:
         fail("S3_BUCKET is not set")
@@ -251,6 +268,17 @@ def upload(manifest, target):
 
 
 @cli.command()
+@click.argument("target")
+def tmt(target):
+    if target not in TARGETS.keys():
+        fail(f"Unknown target: {target}")
+
+    target = TARGETS[target]
+
+    tmtCopy(target)
+
+
+@cli.command()
 @click.option("--update/--no-update", default=False)
 @click.option("--upload/--no-upload", default=False)
 def manifest(update, upload):
diff --git a/tmt/plans/build-gnome.fmf b/tmt/plans/build-gnome.fmf
index 0f39b9c..b967251 100644
--- a/tmt/plans/build-gnome.fmf
+++ b/tmt/plans/build-gnome.fmf
@@ -8,6 +8,7 @@ discover:
           setenforce 0
           $TMT_TREE/builder.py build gnome
           $TMT_TREE/builder.py package gnome
+          $TMT_TREE/builder.py tmt gnome
           setenforce 1
 
 execute:
diff --git a/tmt/plans/build-kde.fmf b/tmt/plans/build-kde.fmf
index fe94aba..bc9c1e3 100644
--- a/tmt/plans/build-kde.fmf
+++ b/tmt/plans/build-kde.fmf
@@ -8,6 +8,7 @@ discover:
           setenforce 0
           $TMT_TREE/builder.py build kde
           $TMT_TREE/builder.py package kde
+          $TMT_TREE/builder.py tmt kde
           setenforce 1
 
 execute:
diff --git a/tmt/plans/build-minimal.fmf b/tmt/plans/build-minimal.fmf
index 7130e8b..021d9bd 100644
--- a/tmt/plans/build-minimal.fmf
+++ b/tmt/plans/build-minimal.fmf
@@ -8,6 +8,7 @@ discover:
           setenforce 0
           $TMT_TREE/builder.py build minimal
           $TMT_TREE/builder.py package minimal
+          $TMT_TREE/builder.py tmt minimal
           setenforce 1
 
 execute:
diff --git a/tmt/plans/build-server.fmf b/tmt/plans/build-server.fmf
index 77c777b..7e847ef 100644
--- a/tmt/plans/build-server.fmf
+++ b/tmt/plans/build-server.fmf
@@ -8,6 +8,7 @@ discover:
           setenforce 0
           $TMT_TREE/builder.py build server
           $TMT_TREE/builder.py package server
+          $TMT_TREE/builder.py tmt server
           setenforce 1
 
 execute:

From 4b0bc5149cb4a6ff3c45124595905b17f45de4dc Mon Sep 17 00:00:00 2001
From: Davide Cavalca <dcavalca@fedoraproject.org>
Date: Dec 19 2023 00:33:41 +0000
Subject: [PATCH 4/5] Add build hotfixes repo


---

diff --git a/repositories/asahi.xml b/repositories/asahi.xml
index 3f59278..53df4b1 100644
--- a/repositories/asahi.xml
+++ b/repositories/asahi.xml
@@ -29,4 +29,9 @@
 			<signing key="file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-$releasever-primary"/>
 		</source>
 	</repository>
+	<repository type="rpm-md" alias="fedora-asahi-remix-build-hotfixes" priority="1">
+		<source path="https://fedora-asahi-remix.org/repos/build-hotfixes/$releasever/">
+			<signing key="file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-$releasever-primary"/>
+		</source>
+	</repository>
 </image>

From cbe255b36cc1b94b3eda679f670cb0da1bc4eeb1 Mon Sep 17 00:00:00 2001
From: Davide Cavalca <dcavalca@fedoraproject.org>
Date: Dec 19 2023 00:38:41 +0000
Subject: [PATCH 5/5] Merge branch 'rawhide' into f39


---

diff --git a/.fmf/version b/.fmf/version
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/.fmf/version
@@ -0,0 +1 @@
+1
diff --git a/.zuul.yaml b/.zuul.yaml
new file mode 100644
index 0000000..9159189
--- /dev/null
+++ b/.zuul.yaml
@@ -0,0 +1,15 @@
+---
+- job:
+    name: build-images
+    parent: tmt-test
+    vars:
+      tmt_url: "https://pagure.io/{{ zuul.project.name }}"
+      tmt_ref: "{{ zuul.ref }}"
+      distro: fedora-rawhide
+      compose: Fedora-latest
+      tf_arch: aarch64
+
+- project:
+   check:
+    jobs:
+      - build-images
diff --git a/builder.py b/builder.py
index dcf816c..196e042 100755
--- a/builder.py
+++ b/builder.py
@@ -188,6 +188,23 @@ def packageUpload(target):
     uploadToS3(manifest, f"os/{manifest}")
 
 
+def tmtCopy(target):
+    base = f"fedora-{RELEASE}-{target['id']}-{BUILDVER}"
+    package = f"{base}.zip"
+    logs_package = f"{base}.logs.zip"
+    image = f"{base}.raw.zst"
+    manifest = f"{base}.json"
+
+    artifacts = os.getenv("TMT_PLAN_DATA")
+    if not os.path.exists(artifacts):
+        os.mkdir(artifacts)
+
+    shutil.copyfile(package, f"{artifacts}/{package}")
+    shutil.copyfile(logs_package, f"{artifacts}/{logs_package}")
+    shutil.copyfile(image, f"{artifacts}/{image}")
+    shutil.copyfile(manifest, f"{artifacts}/{manifest}")
+
+
 def getManifest():
     if S3_BUCKET is None:
         fail("S3_BUCKET is not set")
@@ -251,6 +268,17 @@ def upload(manifest, target):
 
 
 @cli.command()
+@click.argument("target")
+def tmt(target):
+    if target not in TARGETS.keys():
+        fail(f"Unknown target: {target}")
+
+    target = TARGETS[target]
+
+    tmtCopy(target)
+
+
+@cli.command()
 @click.option("--update/--no-update", default=False)
 @click.option("--upload/--no-upload", default=False)
 def manifest(update, upload):
diff --git a/repositories/asahi.xml b/repositories/asahi.xml
index 3f59278..53df4b1 100644
--- a/repositories/asahi.xml
+++ b/repositories/asahi.xml
@@ -29,4 +29,9 @@
 			<signing key="file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-$releasever-primary"/>
 		</source>
 	</repository>
+	<repository type="rpm-md" alias="fedora-asahi-remix-build-hotfixes" priority="1">
+		<source path="https://fedora-asahi-remix.org/repos/build-hotfixes/$releasever/">
+			<signing key="file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-$releasever-primary"/>
+		</source>
+	</repository>
 </image>
diff --git a/tmt/plans/build-gnome.fmf b/tmt/plans/build-gnome.fmf
new file mode 100644
index 0000000..b967251
--- /dev/null
+++ b/tmt/plans/build-gnome.fmf
@@ -0,0 +1,15 @@
+summary: Build GNOME image
+discover:
+    how: shell
+    tests:
+      - name: build image
+        test: |
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils rpmdistro-repoquery
+          setenforce 0
+          $TMT_TREE/builder.py build gnome
+          $TMT_TREE/builder.py package gnome
+          $TMT_TREE/builder.py tmt gnome
+          setenforce 1
+
+execute:
+    how: tmt
diff --git a/tmt/plans/build-kde.fmf b/tmt/plans/build-kde.fmf
new file mode 100644
index 0000000..bc9c1e3
--- /dev/null
+++ b/tmt/plans/build-kde.fmf
@@ -0,0 +1,15 @@
+summary: Build KDE image
+discover:
+    how: shell
+    tests:
+      - name: build image
+        test: |
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils rpmdistro-repoquery
+          setenforce 0
+          $TMT_TREE/builder.py build kde
+          $TMT_TREE/builder.py package kde
+          $TMT_TREE/builder.py tmt kde
+          setenforce 1
+
+execute:
+    how: tmt
diff --git a/tmt/plans/build-minimal.fmf b/tmt/plans/build-minimal.fmf
new file mode 100644
index 0000000..021d9bd
--- /dev/null
+++ b/tmt/plans/build-minimal.fmf
@@ -0,0 +1,15 @@
+summary: Build Minimal image
+discover:
+    how: shell
+    tests:
+      - name: build image
+        test: |
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils rpmdistro-repoquery
+          setenforce 0
+          $TMT_TREE/builder.py build minimal
+          $TMT_TREE/builder.py package minimal
+          $TMT_TREE/builder.py tmt minimal
+          setenforce 1
+
+execute:
+    how: tmt
diff --git a/tmt/plans/build-server.fmf b/tmt/plans/build-server.fmf
new file mode 100644
index 0000000..7e847ef
--- /dev/null
+++ b/tmt/plans/build-server.fmf
@@ -0,0 +1,15 @@
+summary: Build Server image
+discover:
+    how: shell
+    tests:
+      - name: build image
+        test: |
+          dnf --assumeyes install fatcat git-core kiwi distribution-gpg-keys p7zip-plugins python3-boto3 zip zstd libselinux-utils rpmdistro-repoquery
+          setenforce 0
+          $TMT_TREE/builder.py build server
+          $TMT_TREE/builder.py package server
+          $TMT_TREE/builder.py tmt server
+          setenforce 1
+
+execute:
+    how: tmt

