Added support for Git packages.
This commit is contained in:
parent
6a6ae9370d
commit
a18bed49b1
16
ecg.py
16
ecg.py
@ -33,10 +33,12 @@ pkgmgr_cmd = {
|
|||||||
"rpm":"rpm -qa --queryformat '%{NAME},%{VERSION},rpm\\n'", \
|
"rpm":"rpm -qa --queryformat '%{NAME},%{VERSION},rpm\\n'", \
|
||||||
"pacman":"pacman -Q | awk '{print $0 \",\" $1 \",pacman\"}'", \
|
"pacman":"pacman -Q | awk '{print $0 \",\" $1 \",pacman\"}'", \
|
||||||
"pip":"pip freeze | sed 's/==/,/g' | awk '{print $0 \",pip\"}'", \
|
"pip":"pip freeze | sed 's/==/,/g' | awk '{print $0 \",pip\"}'", \
|
||||||
"conda":"/root/.conda/bin/conda list -e | sed 's/=/ /g' | awk 'NR>3 {print $1 \",\" $2 \",conda\"}'", \
|
"conda":"/root/.conda/bin/conda list -e | sed 's/=/ /g' | awk 'NR>3 {print $1 \",\" $2 \",conda\"}'"
|
||||||
"git":""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Command to obtain the latest commit hash in a git repository:
|
||||||
|
gitcmd = "git log -n 1 --pretty=format:%H"
|
||||||
|
|
||||||
# Enables logging:
|
# Enables logging:
|
||||||
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
|
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
|
||||||
|
|
||||||
@ -115,17 +117,21 @@ def check_env(config, src_dir):
|
|||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
pathlib.Path(PKGLISTS).mkdir(parents=True, exist_ok=True)
|
pathlib.Path(PKGLISTS).mkdir(parents=True, exist_ok=True)
|
||||||
path = os.path.join(src_dir, config["location"])
|
|
||||||
pkglist_file = open(PKGLISTS + "pkglist.csv", "w")
|
pkglist_file = open(PKGLISTS + "pkglist.csv", "w")
|
||||||
pkglist_file.write("Package,Version,Package manager\n")
|
pkglist_file.write("Package,Version,Package manager\n")
|
||||||
|
path = os.path.join(src_dir, config["location"])
|
||||||
for pkgmgr in config["package_managers"]:
|
for pkgmgr in config["package_managers"]:
|
||||||
logging.info(f"Checking '{pkgmgr}'")
|
logging.info(f"Checking '{pkgmgr}'")
|
||||||
check_process = subprocess.run("docker run --rm " + config["name"] + " " + pkgmgr_cmd[pkgmgr], cwd=path, capture_output=True, shell=True)
|
check_process = subprocess.run("docker run --rm " + config["name"] + " " + pkgmgr_cmd[pkgmgr], cwd=path, capture_output=True, shell=True)
|
||||||
pkglist = check_process.stdout.decode("utf-8")
|
pkglist = check_process.stdout.decode("utf-8")
|
||||||
print(pkglist)
|
|
||||||
pkglist_file.write(pkglist)
|
pkglist_file.write(pkglist)
|
||||||
if "git_packages" in config.keys():
|
if "git_packages" in config.keys():
|
||||||
print(config["git_packages"])
|
pkglist = ""
|
||||||
|
logging.info("Checking Git packages")
|
||||||
|
for repo in config["git_packages"]:
|
||||||
|
check_process = subprocess.run(["docker", "run", "--rm", "-w", repo["location"], config["name"]] + gitcmd.split(" "), cwd=path, capture_output=True)
|
||||||
|
repo_row = repo["name"] + "," + check_process.stdout.decode("utf-8") + ",git"
|
||||||
|
pkglist_file.write(repo_row)
|
||||||
pkglist_file.close()
|
pkglist_file.close()
|
||||||
|
|
||||||
def remove_image(config):
|
def remove_image(config):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user