obs: srcpkg.py: Run generate_build_dep.sh for all projects

Adjust srcpkg.py to run a generate_build_dep.sh not only for
osmo_dia2gsup, but for any Osmocom project that has such a script. This
is in preparation for osmo-epdg, which will also have one.

Change-Id: Icd9dc734ec938398668640f77ec83aae4a1ee0f4
diff --git a/scripts/obs/lib/srcpkg.py b/scripts/obs/lib/srcpkg.py
index cffb961..324bc66 100644
--- a/scripts/obs/lib/srcpkg.py
+++ b/scripts/obs/lib/srcpkg.py
@@ -103,13 +103,6 @@
     return ""
 
 
-def prepare_project_osmo_dia2gsup():
-    """ Run erlang/osmo_dia2gsup's generate_build_dep.sh script to download
-        sources for dependencies. """
-    lib.run_cmd("contrib/generate_build_dep.sh",
-                cwd=lib.git.get_repo_path("erlang/osmo_dia2gsup"))
-
-
 def prepare_project_open5gs():
     """ Download the subproject sources here, so the package can be built in
         OBS without Internet access. """
@@ -124,6 +117,17 @@
                  "-i", "debian/control"], cwd=lib.git.get_repo_path("limesuite"))
 
 
+def run_generate_build_dep(project):
+    """ Run contrib/generate_build_dep.sh if it exists in the given project, to
+        to download sources for dependencies (see e.g. osmo_dia2gsup.git). """
+    repo_path = lib.git.get_repo_path(project)
+    script_path = "contrib/generate_build_dep.sh"
+
+    if os.path.exists(f"{repo_path}/{script_path}"):
+        print(f"{project}: running {script_path}")
+        lib.run_cmd(script_path, cwd=repo_path)
+
+
 def write_tarball_version(project, version):
     repo_path = lib.git.get_repo_path(project)
 
@@ -182,6 +186,9 @@
         print(f"{project}: running {project_specific_func}")
         globals()[project_specific_func]()
 
+    if project in lib.config.projects_osmocom:
+        run_generate_build_dep(project)
+
     lib.debian.build_source_package(project)
     lib.debian.move_files_to_output(project)