From 639a22a509f7de379fcf438fa2c441dbc4f92b19 Mon Sep 17 00:00:00 2001
From: Steve Traylen <steve.traylen@cern.ch>
Date: Thu, 3 Feb 2022 18:35:48 +0100
Subject: [PATCH 1/4] Support dynamic build requires on CentOS 9

---
 functions/rpmci_install_builddeps | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/functions/rpmci_install_builddeps b/functions/rpmci_install_builddeps
index 1f7b002..e06ee81 100755
--- a/functions/rpmci_install_builddeps
+++ b/functions/rpmci_install_builddeps
@@ -2,3 +2,20 @@
 
 # Install the build dependencies specified in the spec file
 yum-builddep -y *.spec
+
+# Package may need dynamic buildrequires
+# https://fedoraproject.org/wiki/Changes/DynamicBuildRequires
+
+if rpmci_is_OS9
+then
+  # rpmbuild -br returns
+  #   - Success if dependencies are installed.
+  # - Failure if dependencies are not installed, in which case it generates the nosrc rpm
+  # Could need multiple runs but lets cap it.
+  i=0
+  while ! rpmbuild --define "_sourcedir $(pwd)" -br *.spec && [ $i -lt 5 ]
+  do
+     dnf -y builddep /root/rpmbuild/SRPMS/*.buildreqs.nosrc.rpm
+     i=$((i + 1))
+  done
+fi
-- 
GitLab


From 5c2aac0dfef9ceb2ed6b524bf0df72d177f43e02 Mon Sep 17 00:00:00 2001
From: Alex Iribarren <Alex.Iribarren@cern.ch>
Date: Thu, 3 Feb 2022 18:44:55 +0100
Subject: [PATCH 2/4] Cosmetics

---
 functions/rpmci_install_builddeps | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/functions/rpmci_install_builddeps b/functions/rpmci_install_builddeps
index e06ee81..52a70eb 100755
--- a/functions/rpmci_install_builddeps
+++ b/functions/rpmci_install_builddeps
@@ -3,19 +3,18 @@
 # Install the build dependencies specified in the spec file
 yum-builddep -y *.spec
 
-# Package may need dynamic buildrequires
-# https://fedoraproject.org/wiki/Changes/DynamicBuildRequires
+if rpmci_is_OS9; then
+    # Package may need dynamic buildrequires
+    # https://fedoraproject.org/wiki/Changes/DynamicBuildRequires
 
-if rpmci_is_OS9
-then
-  # rpmbuild -br returns
-  #   - Success if dependencies are installed.
-  # - Failure if dependencies are not installed, in which case it generates the nosrc rpm
-  # Could need multiple runs but lets cap it.
-  i=0
-  while ! rpmbuild --define "_sourcedir $(pwd)" -br *.spec && [ $i -lt 5 ]
-  do
-     dnf -y builddep /root/rpmbuild/SRPMS/*.buildreqs.nosrc.rpm
-     i=$((i + 1))
-  done
+    # rpmbuild -br returns:
+    #  - Success if dependencies are installed
+    #  - Failure if dependencies are not installed, in which case it generates the nosrc rpm
+    # Could need multiple runs but lets cap it at 5.
+
+    i=0
+    while ! rpmbuild --define "_sourcedir $(pwd)" -br *.spec && [ $i -lt 5 ]; do
+        dnf -y builddep /root/rpmbuild/SRPMS/*.buildreqs.nosrc.rpm
+        i=$((i + 1))
+    done
 fi
-- 
GitLab


From 7c43ffb69fc1ecb3542743eb8ffb291fbfeb20b2 Mon Sep 17 00:00:00 2001
From: Alex Iribarren <Alex.Iribarren@cern.ch>
Date: Thu, 3 Feb 2022 19:32:42 +0100
Subject: [PATCH 3/4] Add some more logging

---
 functions/rpmci_install_builddeps | 1 +
 1 file changed, 1 insertion(+)

diff --git a/functions/rpmci_install_builddeps b/functions/rpmci_install_builddeps
index 52a70eb..0839f6d 100755
--- a/functions/rpmci_install_builddeps
+++ b/functions/rpmci_install_builddeps
@@ -14,6 +14,7 @@ if rpmci_is_OS9; then
 
     i=0
     while ! rpmbuild --define "_sourcedir $(pwd)" -br *.spec && [ $i -lt 5 ]; do
+        echo_info "Installing dynamic dependencies"
         dnf -y builddep /root/rpmbuild/SRPMS/*.buildreqs.nosrc.rpm
         i=$((i + 1))
     done
-- 
GitLab


From 66d595fea18940cb38de2df53af824ce4c09446b Mon Sep 17 00:00:00 2001
From: Alex Iribarren <Alex.Iribarren@cern.ch>
Date: Thu, 3 Feb 2022 20:15:55 +0100
Subject: [PATCH 4/4] Add some documentation

---
 README.md | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/README.md b/README.md
index 141cc43..9a42551 100644
--- a/README.md
+++ b/README.md
@@ -367,6 +367,13 @@ Gitlab CI's default timeout for jobs is 1 hour. If one of your jobs takes longer
 it will be terminated and the pipeline won't continue. You can change this timeout for your
 project in `Settings` -> `CI / CD` -> `General pipelines` -> `Timeout`.
 
+### Dynamic Build Requires
+
+rpmci supports [dynamic build requires](https://fedoraproject.org/wiki/Changes/DynamicBuildRequires)
+where available (currently only CS9). You can add a `%generate_buildrequires` section
+to your spec file and let your language tooling automatically generate your build dependencies.
+Check the documentation linked above for more information.
+
 ### Building Go binaries on CC7
 
 If you're building golang binaries on CC7 and you want the EPEL golang, you'll have to do the following:
-- 
GitLab