Add arguments
This commit is contained in:
parent
18f6ddd24d
commit
a94b0378ff
24
main.py
24
main.py
|
@ -1,14 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import argparse
|
||||
import logging, sys
|
||||
import requests as r
|
||||
from datetime import date
|
||||
from utils import *
|
||||
|
||||
ARCH = "x86_64"
|
||||
|
||||
def main():
|
||||
def main(arch):
|
||||
packages = load_config()
|
||||
clean_directories()
|
||||
|
||||
|
@ -23,10 +21,10 @@ def main():
|
|||
elif 'repo' in p:
|
||||
p['tag'] = get_tags_from_git(p['repo'])
|
||||
else:
|
||||
p['tag'] = get_package_version(p['name'], ARCH)
|
||||
p['tag'] = get_package_version(p['name'], arch)
|
||||
|
||||
# Retreive current package version
|
||||
current_tag = get_package_version(p['name'], ARCH)
|
||||
current_tag = get_package_version(p['name'], arch)
|
||||
|
||||
# Check if update is required
|
||||
if p['tag'] != current_tag:
|
||||
|
@ -35,7 +33,7 @@ def main():
|
|||
commands.append(f"su -c '/tmp/build.sh /tmp/pkgbuilds/{p['name']}' user")
|
||||
diffs += 1
|
||||
else:
|
||||
tarball, url = get_package_tarball(p['name'], ARCH)
|
||||
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:
|
||||
|
@ -56,12 +54,18 @@ def main():
|
|||
docker_build()
|
||||
|
||||
# TODO:
|
||||
# - push them to the repository
|
||||
# - create a systemd timer to run this script
|
||||
# - setup a web server to publish logs in case of failure
|
||||
# - go to bed >_>
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description='Build some packages.')
|
||||
parser.add_argument('--arch', default="x86_64", help='target architecture')
|
||||
parser.add_argument('--logs', default="/tmp", help='logs destination')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(format="[%(asctime)s] %(levelname)s (%(filename)s.%(funcName)s): %(message)s",
|
||||
filename=date.today().isoformat(), level=logging.INFO)
|
||||
main()
|
||||
filename=os.path.join(args.logs, date.today().isoformat()), level=logging.INFO)
|
||||
|
||||
main(args.arch)
|
||||
|
|
Loading…
Reference in New Issue