From f28deea542778bd6f2ba6948d55bffe65e20a8e0 Mon Sep 17 00:00:00 2001 From: windowsboy111 Date: Thu, 20 Oct 2022 19:29:54 +0800 Subject: [PATCH] Fix chkupdate.py for prismlauncher --- anda/prismlauncher/chkupdate.py | 19 +++++++++++++++++++ anda/prismlauncher/chkupdate.py.bak | 27 --------------------------- 2 files changed, 19 insertions(+), 27 deletions(-) create mode 100644 anda/prismlauncher/chkupdate.py delete mode 100644 anda/prismlauncher/chkupdate.py.bak diff --git a/anda/prismlauncher/chkupdate.py b/anda/prismlauncher/chkupdate.py new file mode 100644 index 0000000000..a25168a479 --- /dev/null +++ b/anda/prismlauncher/chkupdate.py @@ -0,0 +1,19 @@ +import os +import requests +import re + +NAME = 'prismlauncher' +REPO = "PrismLauncher/PrismLauncher" +REGEX_VER = r'Version:\s*([\.\d]+)\n' +SPEC = f"{NAME}.spec" +LINK = f'https://api.github.com/repos/{REPO}/releases/latest' + + +ver = requests.get(LINK).json()['tag_name'] +with open(SPEC, 'r') as f: + matches = re.findall(REGEX_VER, f.read()) +if not len(matches): exit(f"{NAME}: Failed to match regex!") +cur = matches[0] +if ver == cur: exit(f'{NAME}: Up to date!') +print(f'{NAME}: {cur} -> {ver}') +os.system(f'rpmdev-bumpspec -n {ver} {SPEC}') diff --git a/anda/prismlauncher/chkupdate.py.bak b/anda/prismlauncher/chkupdate.py.bak deleted file mode 100644 index 193dc485ae..0000000000 --- a/anda/prismlauncher/chkupdate.py.bak +++ /dev/null @@ -1,27 +0,0 @@ -# Moved chkupdate because we are now going stable - - -import requests -import re - -NAME = 'prismlauncher' -REPO = "PrismLauncher/PrismLauncher" -REGEX_COMMIT = r"^%define commit (.+)$" -SPEC = f"{NAME}.spec" - - -obj = requests.get(f'https://api.github.com/repos/{REPO}/commits/develop').json() -commit = obj['sha'] - -f = open(SPEC, 'r') -match = re.match(REGEX_COMMIT, txt:=f.read(), re.RegexFlag.M) -if not match: exit(f"{NAME}: Failed to match regex!") -cur_commit = match.group(1) -if commit == cur_commit: - exit(f'{NAME}: Up to date!') -print(f'{NAME}: {cur_commit} -> {commit}') -newspec = re.sub(REGEX_COMMIT, f'%define commit {commit}', txt, flags=re.RegexFlag.M) -f.close() -f = open(SPEC, 'w') -f.write(newspec) -f.close()