44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
|
||
|
import logging
|
||
|
import requests as r
|
||
|
from utils import *
|
||
|
|
||
|
ARCH = "x86_64"
|
||
|
|
||
|
def main():
|
||
|
packages = load_config()
|
||
|
|
||
|
clean_directories()
|
||
|
|
||
|
# Manage each package
|
||
|
for p in packages:
|
||
|
# Retreive tag to apply
|
||
|
if 'tag' in p:
|
||
|
logging.debug(f"{p['name']} forced to {p['tag']}")
|
||
|
elif 'repo' in p:
|
||
|
p['tag'] = get_tags_from_git(p['repo'])
|
||
|
else:
|
||
|
p['tag'] = get_package_version(p['name'], ARCH)
|
||
|
|
||
|
# Retreive current package version
|
||
|
current_tag = get_package_version(p['name'], ARCH)
|
||
|
|
||
|
# Check if update is required
|
||
|
if p['tag'] != current_tag:
|
||
|
logging.info(f"{p['name']} will be updated: {current_tag} → {p['tag']}")
|
||
|
render_pkgbuild(p['name'], p['tag'])
|
||
|
else:
|
||
|
tarball, url = get_package_tarball(p['name'], ARCH)
|
||
|
logging.info(f"{p['name']} will be retreived from {url}")
|
||
|
content = r.get(url).content
|
||
|
with open(f"packages/{tarball}", "wb") as file:
|
||
|
file.write(content)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
logging.basicConfig(format="[%(asctime)s] %(levelname)s (%(filename)s.%(funcName)s): %(message)s",
|
||
|
level=logging.INFO)
|
||
|
main()
|