mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
ci/collect-repo-info: No hard dependency on git
The OBS builds run in an environment where no git is installed and release tarballs assembled manually. Drop the hard-requirement on git from ci/collect-repo-info.json.
This commit is contained in:
parent
dfdcfd9647
commit
f3253554d1
1 changed files with 18 additions and 7 deletions
|
@ -25,6 +25,16 @@ def git(*args, **kwargs):
|
||||||
return subprocess.check_output([GIT, *args], **kwargs).decode("utf-8")
|
return subprocess.check_output([GIT, *args], **kwargs).decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def git_available():
|
||||||
|
try:
|
||||||
|
git("--version", stderr=subprocess.DEVNULL)
|
||||||
|
return True
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def git_is_repo(d: pathlib.Path):
|
def git_is_repo(d: pathlib.Path):
|
||||||
try:
|
try:
|
||||||
git("-C", str(d), "rev-parse", "--is-inside-work-tree", stderr=subprocess.DEVNULL)
|
git("-C", str(d), "rev-parse", "--is-inside-work-tree", stderr=subprocess.DEVNULL)
|
||||||
|
@ -150,16 +160,14 @@ def main():
|
||||||
logger.error("%s missing zeek-config.h.in", zeek_dir)
|
logger.error("%s missing zeek-config.h.in", zeek_dir)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
try:
|
if args.only_git and not git_available():
|
||||||
git("--version")
|
logger.error("git not found and --only-git provided")
|
||||||
except OSError as e:
|
|
||||||
logger.error("No git? (%s)", str(e))
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# Attempt to collect info from git first and alternatively
|
# Attempt to collect info from git first and alternatively
|
||||||
# fall back to a repo-info.json file within what is assumed
|
# fall back to a repo-info.json file within what is assumed
|
||||||
# to be a tarball.
|
# to be a tarball.
|
||||||
if git_is_repo(zeek_dir):
|
if git_available() and git_is_repo(zeek_dir):
|
||||||
info = collect_git_info(zeek_dir)
|
info = collect_git_info(zeek_dir)
|
||||||
elif not args.only_git:
|
elif not args.only_git:
|
||||||
try:
|
try:
|
||||||
|
@ -167,10 +175,13 @@ def main():
|
||||||
info = json.load(fp)
|
info = json.load(fp)
|
||||||
info["source"] = "repo-info.json"
|
info["source"] = "repo-info.json"
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logger.error("%s is not a git repo and repo-info.json missing", zeek_dir)
|
git_info_msg = ""
|
||||||
|
if not git_available():
|
||||||
|
git_info_msg = " (git not found)"
|
||||||
|
logger.error("%s has no repo-info.json%s", zeek_dir, git_info_msg)
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
logger.error("Not a git repo and --only-git provided")
|
logger.error("%s is not a git repo and --only-git provided", zeek_dir)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
included_plugins_info = []
|
included_plugins_info = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue