From 8d108892ecdeca821ee0f2ef845a97fd138fc95b Mon Sep 17 00:00:00 2001 From: windowsboy111 Date: Sun, 20 Nov 2022 12:50:55 +0800 Subject: [PATCH] Create chkupdate.py --- .../elementary/elementary-print/chkupdate.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 anda/desktops/elementary/elementary-print/chkupdate.py diff --git a/anda/desktops/elementary/elementary-print/chkupdate.py b/anda/desktops/elementary/elementary-print/chkupdate.py new file mode 100644 index 0000000000..dd76792462 --- /dev/null +++ b/anda/desktops/elementary/elementary-print/chkupdate.py @@ -0,0 +1,19 @@ +import os +import requests +import re + +NAME = 'elementary-print' +REPO = "elementary/print" +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}')