🔧 Added tool to automatically update conan packages

This commit is contained in:
Edgar 2023-09-25 15:35:13 +02:00
parent b9eda16084
commit 9d35cfa92f
No known key found for this signature in database
GPG key ID: 3C2E1F2C1C353131
5 changed files with 59 additions and 3 deletions

View file

@ -1,4 +1,7 @@
sources:
"0.30":
url: "https://github.com/radarsat1/liblo/releases/download/0.30/liblo-0.30.tar.gz"
sha256: "30a7c9de49a25ed7f2425a7a7415f5b14739def62431423d3419ea26fb978d1b"
'0.30':
sha256: 30a7c9de49a25ed7f2425a7a7415f5b14739def62431423d3419ea26fb978d1b
url: https://github.com/radarsat1/liblo/releases/download/0.30/liblo-0.30.tar.gz
'0.31':
sha256: 71d1819bcd18be66bd80c95a2d3159b9ca6f13746ddbaf1e489128f3bf46d231
url: https://github.com/radarsat1/liblo/archive/refs/tags/0.31.tar.gz

View file

@ -0,0 +1,2 @@
- repo: radarsat1/liblo
folder: all

View file

@ -0,0 +1,2 @@
- repo: ValveSoftware/openvr
folder: all

View file

@ -0,0 +1,2 @@
- repo: stachenov/quazip
folder: all

View file

@ -0,0 +1,47 @@
#!/usr/bin/env python3
# Tool for automatically updating Conan packages to the latest release
# This script requires the lastversion and filehash python scripts to be installed
# pip install lastversion filehash
from filehash import FileHash
from glob import glob
from lastversion import latest
from packaging import version
from urllib.request import urlretrieve
import os
import yaml
def update_pkg(repo, folder):
path = os.path.join(folder, "conandata.yml")
with open(path, "r") as file:
conandata = yaml.load(file, Loader=yaml.FullLoader)
v = sorted(conandata["sources"].items(), reverse=True)[0][0]
latest_version = latest(repo=repo, output_format="dict")
if latest_version["version"] > version.parse(v):
print(f'{repo} has newer version: {latest_version["version"]} (from: {v})')
url = f'https://github.com/{repo}/archive/refs/tags/{latest_version["tag_name"]}.tar.gz'
tmp_path, headers = urlretrieve(url)
hs = FileHash("sha256")
hash = hs.hash_file(tmp_path)
conandata["sources"][str(latest_version["version"])] = {
"url": url,
"sha256": hash,
}
print(f'Added new data: "{url}" "{hash}"')
with open(path, "w") as ofile:
yaml.dump(conandata, ofile, default_flow_style=False)
else:
print(f"{repo} has no update available")
dirs = glob("./*/")
for p in dirs:
path = os.path.join(p, "repoinfo.yml")
if not os.path.isfile(path):
continue
with open(path) as file:
repoinfo = yaml.load(file, Loader=yaml.FullLoader)
for i in repoinfo:
update_pkg(i["repo"], os.path.join(p, i["folder"]))