aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/obs/lib/debian.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/obs/lib/debian.py')
-rw-r--r--scripts/obs/lib/debian.py92
1 files changed, 89 insertions, 3 deletions
diff --git a/scripts/obs/lib/debian.py b/scripts/obs/lib/debian.py
index 3bba3ec..85fcc5f 100644
--- a/scripts/obs/lib/debian.py
+++ b/scripts/obs/lib/debian.py
@@ -7,6 +7,13 @@ import shlex
import lib
import lib.git
+# Imports that may not be available during startup, ignore it here and rely on
+# lib.check_required_programs() checking this later on (possibly after the
+# script executed itself in docker if using --docker).
+try:
+ import packaging.version
+except ImportError:
+ pass
def control_add_depend(project, pkgname, version):
""" :param pkgname: of the meta-package to depend on (e.g. osmocom-nightly)
@@ -22,8 +29,9 @@ def control_add_depend(project, pkgname, version):
lib.run_cmd(cmd, cwd=repo_path)
-def changelog_add_entry(project, feed, version):
+def changelog_add_entry(project, version):
""" :param version: for the new changelog entry """
+ feed = lib.args.feed
repo_path = lib.git.get_repo_path(project)
changelog_path = f"{repo_path}/debian/changelog"
@@ -84,16 +92,94 @@ def get_last_version_from_changelog(project):
return ret
-def changelog_add_entry_if_needed(project, feed, version):
+def transform_version(version):
+ if version is None:
+ return None
+
+ if "osmo-epdg-" in version:
+ version = f"{version.replace('osmo-epdg-', '', 1)}-osmo-epdg"
+
+ version = version.replace("-", ".")
+ return version
+
+
+def changelog_add_entry_if_needed(project, version):
""" Adjust the changelog if the version in the changelog is different from
the given version. """
version_changelog = get_last_version_from_changelog(project)
+
+ # Don't use a lower number (OS#6173)
+ try:
+ if packaging.version.parse(version_changelog.split("-")[0]) > \
+ packaging.version.parse(version.split("-")[0]):
+ print(f"{project}: WARNING: version from changelog"
+ f" ({version_changelog}) is higher than version based on git tag"
+ f" ({version}), using version from changelog (git tag not pushed"
+ " yet?)")
+ return
+ except packaging.version.InvalidVersion:
+ # packaging.version.parse can parse the version numbers used in Osmocom
+ # projects (where we need the above check), but not e.g. some versions
+ # from wireshark. Don't abort here if that is the case.
+ pass
+
+ # Debian versions must start with a digit
+ version = transform_version(version)
+
if version_changelog == version:
return
print(f"{project}: adding debian/changelog entry ({version_changelog} =>"
f" {version})")
- changelog_add_entry(project, feed, version)
+ changelog_add_entry(project, version)
+
+
+def configure_append(project, parameters):
+ """ Add one or more configure parameters like --enable-sanitize to the
+ dh_auto_configure line, also add the override_dh_auto_configure block
+ if missing. """
+ print(f"{project}: adding configure parameters: {parameters}")
+ rules = f"{lib.git.get_repo_path(project)}/debian/rules"
+ override_found = False
+ replaced = False
+ with open(rules, "r") as f:
+ lines = f.readlines()
+ for i in range(len(lines)):
+ line = lines[i]
+ if line.startswith("override_dh_auto_configure:"):
+ override_found = True
+ continue
+ if "dh_auto_configure" not in line:
+ continue
+ assert override_found
+ if " -- " in line.replace("\t", " "):
+ lines[i] = line.replace(" --", f" -- {parameters}", 1)
+ else:
+ lines[i] = line.replace("dh_auto_configure",
+ f"dh_auto_configure -- {parameters}", 1)
+ replaced = True
+ break
+ if not override_found:
+ lines += ["\n",
+ "override_dh_auto_configure:\n",
+ f"\tdh_auto_configure -- {parameters}\n"]
+ with open(rules, "w") as f:
+ f.writelines(lines)
+
+
+def disable_manuals(project):
+ """ Disabling manuals speeds up the build time significantly, we don't
+ need them for e.g. the asan repository. """
+ print(f"{project}: disabling manuals")
+ debian = f"{lib.git.get_repo_path(project)}/debian"
+ # Remove dependencies
+ lib.run_cmd(["sed", "-i", "/osmo-gsm-manuals-dev/d", f"{debian}/control"])
+ lib.run_cmd(["sed", "-i", "/doxygen/d", f"{debian}/control"])
+ # Remove debian/*-doc.install
+ lib.run_cmd(f"rm -rf {shlex.quote(debian)}/*-doc.install", shell=True)
+ # debian/rules: remove --enable-manuals/doxygen, add --disable-doxygen
+ lib.run_cmd(["sed", "-i", "s/--enable-manuals//g", f"{debian}/rules"])
+ lib.run_cmd(["sed", "-i", "s/--enable-doxygen//g", f"{debian}/rules"])
def build_source_package(project):