aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/osmo-depcheck/dependencies.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/osmo-depcheck/dependencies.py')
-rw-r--r--scripts/osmo-depcheck/dependencies.py68
1 files changed, 43 insertions, 25 deletions
diff --git a/scripts/osmo-depcheck/dependencies.py b/scripts/osmo-depcheck/dependencies.py
index 78cf4a0..9b5187d 100644
--- a/scripts/osmo-depcheck/dependencies.py
+++ b/scripts/osmo-depcheck/dependencies.py
@@ -10,37 +10,55 @@ import sys
import parse
-def git_clone(gitdir, prefix, repository, version):
+def git_clone(workdir, prefix, cache_git_fetch, repository, version):
""" Clone a missing git repository and checkout a specific version tag.
- :param gitdir: folder to which the sources will be cloned
+ :param workdir: path to where all data (git, build, install) is stored
:param prefix: git url prefix (e.g. "git://git.osmocom.org/")
+ :param cache_git_fetch: list of repositories that have already been
+ fetched in this run of osmo-depcheck
:param repository: Osmocom git repository name (e.g. "libosmo-abis")
:param version: "master" or a version tag like "0.11.0" """
- # Clone when needed
- if not os.path.exists(gitdir + "/" + repository):
- url = prefix + repository
- print("Cloning git repo: " + url)
- try:
- subprocess.run(["git", "-C", gitdir, "clone", "-q", url],
+ repodir = workdir + "/git/" + repository
+ if repository not in cache_git_fetch:
+ if os.path.exists(repodir):
+ # Fetch tags for existing source
+ print("Fetching tags...")
+ subprocess.run(["git", "-C", repodir, "fetch", "--tags", "-q"],
check=True)
- except subprocess.CalledProcessError:
- print("NOTE: if '" + repository + "' is part of a git repository"
- " with a different name, please add it to the mapping in"
- " 'config.py' and try again.")
- sys.exit(1)
+ else:
+ # Clone the source
+ url = prefix + repository
+ print("Cloning git repo: " + url)
+ try:
+ subprocess.run(["git", "-C", workdir + "/git", "clone", "-q",
+ url], check=True)
+ except subprocess.CalledProcessError:
+ print("NOTE: if '" + repository + "' is part of a git"
+ " repository with a different name, please add it to the"
+ " mapping in 'config.py' and try again.")
+ sys.exit(1)
+
+ # Only fetch the same repository once per session
+ cache_git_fetch.append(repository)
# Checkout the version tag
- subprocess.run(["git", "-C", gitdir + "/" + repository, "checkout",
- version, "-q"], check=True)
+ try:
+ subprocess.run(["git", "-C", repodir, "checkout", version, "-q"],
+ check=True)
+ except subprocess.CalledProcessError:
+ print("ERROR: git checkout failed! Invalid version specified?")
+ sys.exit(1)
-def generate(gitdir, prefix, initial, rev):
+def generate(workdir, prefix, cache_git_fetch, initial, rev):
""" Generate the dependency graph of an Osmocom program by cloning the git
repository, parsing the "configure.ac" file, and recursing.
- :param gitdir: folder to which the sources will be cloned
+ :param workdir: path to where all data (git, build, install) is stored
:param prefix: git url prefix (e.g. "git://git.osmocom.org/")
+ :param cache_git_fetch: list of repositories that have already been
+ fetched in this run of osmo-depcheck
:param initial: the first program to look at (e.g. "osmo-bts")
:param rev: the git revision to check out ("master", "0.1.0", ...)
:returns: a dictionary like the following:
@@ -65,8 +83,8 @@ def generate(gitdir, prefix, initial, rev):
# Add the programs dependencies to the stack
print("Looking at " + program + ":" + version)
- git_clone(gitdir, prefix, program, version)
- depends = parse.configure_ac(gitdir, program)
+ git_clone(workdir, prefix, cache_git_fetch, program, version)
+ depends = parse.configure_ac(workdir, program)
stack.update(depends)
# Add the program to the ret
@@ -86,28 +104,28 @@ def print_dict(depends):
print(" * " + program + ":" + version + " depends: " + str(depends))
-def git_latest_tag(gitdir, repository):
+def git_latest_tag(workdir, repository):
""" Get the last release string by asking git for the latest tag.
- :param gitdir: folder to which the sources will be cloned
+ :param workdir: path to where all data (git, build, install) is stored
:param repository: Osmocom git repository name (e.g. "libosmo-abis")
:returns: the latest git tag (e.g. "1.0.2") """
- dir = gitdir + "/" + repository
+ dir = workdir + "/git/" + repository
complete = subprocess.run(["git", "-C", dir, "describe", "--abbrev=0",
"master"], check=True, stdout=subprocess.PIPE)
return complete.stdout.decode().rstrip()
-def print_old(gitdir, depends):
+def print_old(workdir, depends):
""" Print dependencies tied to an old release tag
- :param gitdir: folder to which the sources will be cloned
+ :param workdir: path to where all data (git, build, install) is stored
:param depends: return value from generate() above """
print("Dependencies on old releases:")
for program, data in depends.items():
for depend, version in data["depends"].items():
- latest = git_latest_tag(gitdir, depend)
+ latest = git_latest_tag(workdir, depend)
if latest == version:
continue
print(" * " + program + ":" + data["version"] + " -> " +