runtime/generate_versions.py

39 lines
1.1 KiB
Python
Raw Normal View History

#!/usr/bin/env python
import json
import os
import subprocess
output = {
"techs": {},
"system": {
"distro": "debian",
"version": "11.6",
}
}
image = ""
with open("Dockerfile") as f:
lines = f.readlines()
for line in lines:
if line.startswith("FROM debian:"):
image = line.split(" ")[1].strip()
continue
if line.startswith("RUN build_"):
parts = line.split(" ")
name = parts[1].replace("build_", "").replace(".sh", "")
if name.startswith("php"):
name = "php"
version = line.split(" ")[2].strip()
if name not in output["techs"]:
output["techs"][name] = {
"versions": [],
}
output["techs"][name]["versions"].append(version)
# os.system(f"docker pull {image}")
2024-08-13 19:24:30 +00:00
system_version = subprocess.check_output(f"docker run --rm {image} cat /etc/debian_version", shell=True)
output["system"]["version"] = system_version.strip().decode()
print(json.dumps(output, indent=4))