This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
osmith gerrit-no-reply at lists.osmocom.orgosmith has uploaded this change for review. ( https://gerrit.osmocom.org/10932
Change subject: New script to verify PKG_CHECK_MODULES
......................................................................
New script to verify PKG_CHECK_MODULES
Work in progress, see the Redmine issue.
Change-Id: I8f495dbe030775f66ac125e60ded95c5d7660b65
Relates: OS#2642
---
A scripts/dependency-check/dependency-check.py
A scripts/dependency-check/jenkins.sh
2 files changed, 199 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/32/10932/1
diff --git a/scripts/dependency-check/dependency-check.py b/scripts/dependency-check/dependency-check.py
new file mode 100755
index 0000000..6e7656d
--- /dev/null
+++ b/scripts/dependency-check/dependency-check.py
@@ -0,0 +1,196 @@
+#!/usr/bin/env python3
+from collections import OrderedDict
+import sys
+import os
+import subprocess
+
+
+def parse_error(line_num, message):
+ print("ERROR: configure.ac line " + str(line_num) + ": " + message)
+ sys.exit(1)
+
+
+def parse_repository(gitdir, program, library, line_num):
+ repos = {"libosmocore": ["libosmocodec",
+ "libosmocoding",
+ "libosmoctrl",
+ "libosmogb",
+ "libosmogsm",
+ "libosmosim",
+ "libosmovty"],
+ "libosmo-abis": ["libosmoabis",
+ "libosmotrau"],
+ "libosmo-sccp": ["libosmo-mtp",
+ "libosmo-sigtran",
+ "libosmo-xua"]}
+
+ for repo, libraries in repos.items():
+ if library in libraries:
+ print(" * " + library + " (part of " + repo + ")")
+ return repo
+
+ print(" * " + library)
+ return library
+
+
+def parse_condition(line):
+ # Only look at PKG_CHECK_MODULES lines, like these:
+ # PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.10.0)
+ # PKG_CHECK_MODULES(LIBSYSTEMD, libsystemd)
+ if "PKG_CHECK_MODULES" not in line:
+ return
+
+ # Extract the condition
+ ret = line.split(",")[1].split(")")[0].strip()
+
+ # Only look at Osmocom libraries
+ if ret.startswith("libosmo"):
+ return ret
+
+
+def parse_library_version(line_num, condition):
+ split = list(filter(None, condition.split(" ")))
+ if len(split) != 3:
+ parse_error(line_num, "invalid condition format, expected something"
+ " like 'libosmocore >= 0.10.0' but got: '" +
+ condition + "'")
+ library = split[0]
+ operator = split[1]
+ version = split[2]
+
+ # Right operator
+ if operator == ">=":
+ return (library, version)
+
+ # Wrong operator
+ parse_error(line_num, "invalid operator, expected '>=' but got: '" +
+ operator + "'")
+
+
+def parse_configure_ac(gitdir, program):
+ # Read configure.ac
+ path = gitdir + "/" + program + "/configure.ac"
+ with open(path) as handle:
+ lines = handle.readlines()
+
+ # Parse the file into ret
+ ret = {}
+ for i in range(0, len(lines)):
+ # Parse the line
+ condition = parse_condition(lines[i])
+ if not condition:
+ continue
+ (library, version) = parse_library_version(i, condition)
+
+ # Add to ret (with duplicate check)
+ if library in ret and version is not ret[library]:
+ parse_error(i, "found multiple PKG_CHECK_MODULES statements for " +
+ library + ", and they have different versions!")
+ repository = parse_repository(gitdir, program, library, i)
+ ret[repository] = version
+ return ret
+
+
+def clone(gitdir, program, version):
+ if not os.path.exists(gitdir + "/" + program):
+ url = "git://git.osmocom.org/" + program
+ print("Cloning git repo: " + url)
+ subprocess.run(["git", "-C", gitdir, "clone", "-q", url],
+ check=True)
+ subprocess.run(["git", "-C", gitdir + "/" + program, "checkout", version,
+ "-q"], check=True)
+
+
+def dependstack_generate(gitdir, initial):
+ """ Clone an Osomocom git repository, parse its configure.ac and
+ recurse.
+
+ :returns: ...
+ """
+ dependstack = OrderedDict()
+ parsestack = OrderedDict({initial: "master"})
+ while len(parsestack):
+ # Pop program from parsestack
+ program, version = next(iter(parsestack.items()))
+ del parsestack[program]
+
+ # Add to dependstack (or skip when it's there already)
+ if program in dependstack:
+ continue
+
+ # Add the program's dependencies to the parsestack
+ print("Looking at " + program + ":" + version)
+ clone(gitdir, program, version)
+ depends = parse_configure_ac(gitdir, program)
+ parsestack.update(depends)
+
+ # Add the program to the dependstack
+ dependstack[program] = {"version": version, "depends": depends}
+
+ return dependstack
+
+
+def dependstack_print(dependstack):
+ print("Dependency graph:")
+ for program, data in dependstack.items():
+ version = data["version"]
+ depends = data["depends"]
+ print(" * " + program + ":" + version + " depends: " + str(depends))
+
+
+def buildstack_next(gitdir, dependstack, done):
+ for program, data in dependstack.items():
+ if program in done:
+ continue
+ depends_done = True
+ for depend in data["depends"]:
+ if depend not in done:
+ depends_done = False
+ break
+ if depends_done:
+ return program, data["version"]
+
+ print("ERROR: can't figure out how to build the rest!")
+ print("Build order so far: " + str(done))
+ sys.exit(1)
+
+
+def buildstack_generate(gitdir, dependstack):
+ ret = OrderedDict()
+ count = len(dependstack.keys())
+ while len(ret) != count:
+ program, version = buildstack_next(gitdir, dependstack, ret)
+ ret[program] = version
+ return ret
+
+
+def buildstack_print(buildstack):
+ print("Build order:")
+ for program, version in buildstack.items():
+ print(" * " + program + ":" + version)
+
+
+def buildstack_build(gitdir, buildstack):
+ for program, version in buildstack.items():
+ print("Building " + program + ":" + version)
+ os.chdir(gitdir + "/" + program)
+ commands = [["autoreconf", "-fi"],
+ ["make"],
+ ["make", "check"], # needed?
+ ["sudo", "make", "install"],
+ ["sudo", "ldconfig"]]
+ for command in commands:
+ print(" + " + " ".join(command))
+ subprocess.run(command, check=True)
+
+
+def main():
+ gitdir = "/home/user/code/"
+ dependstack = dependstack_generate(gitdir, "osmo-bts")
+ dependstack_print(dependstack)
+ buildstack = buildstack_generate(gitdir, dependstack)
+ buildstack_print(buildstack)
+ buildstack_build(gitdir, buildstack)
+
+
+main()
diff --git a/scripts/dependency-check/jenkins.sh b/scripts/dependency-check/jenkins.sh
new file mode 100755
index 0000000..57f06f3
--- /dev/null
+++ b/scripts/dependency-check/jenkins.sh
@@ -0,0 +1,3 @@
+#!/bin/sh -ex
+
+echo "TODO"
--
To view, visit https://gerrit.osmocom.org/10932
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f495dbe030775f66ac125e60ded95c5d7660b65
Gerrit-Change-Number: 10932
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180913/3a3bba1f/attachment.htm>