diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index ab4f617b56..46dc31a77f 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -23,6 +23,9 @@ jobs: with: python-version: '3.10' + - name: Install rpmdev + run: dnf install rpmdevtools + - name: Run Update run: ./update.sh @@ -31,6 +34,6 @@ jobs: if [[ `git status --porcelain` ]]; then git config user.name "Package Update Checker" git config user.email "<>" - git commit -a -m "Automatic Update by chkupdate.py" + git commit -a -m "Automatic Update" git push -u origin main fi diff --git a/anda/authy/chkupdate.py b/anda/authy/chkupdate.py index 25d6371626..31a2061fce 100644 --- a/anda/authy/chkupdate.py +++ b/anda/authy/chkupdate.py @@ -3,15 +3,16 @@ import re from requests import get import json -SPEC = "authy.spec" +NAME = "authy" +SPEC = f"{NAME}.spec" REGEX_VER = r'Version:(\s*)([\.\d]+)\n' REGEX_SRC = r'Source0:(\s*)([^\n]+)\n' def run_cmds(*cmds: str): for cmd in cmds: - print(f"chkupdate: $ {cmd}") + print(f"{NAME}: $ {cmd}") if rc := os.system(cmd): - exit(f"chkupdate: Stopping because {rc=}") + exit(f"{NAME}: Stopping because {rc=}") raw = get('https://api.snapcraft.io/v2/snaps/info/authy', headers={'Snap-Device-Series': '16'}).text data = json.loads(raw) @@ -24,10 +25,10 @@ try: assert found curver = found[0][1] if ver == curver: - exit("chkupdate: Up to date!") - print(f"chkupdate: {curver} -> {ver}") + exit(f"{NAME}: Up to date!") + print(f"{NAME}: {curver} -> {ver}") except IndexError or AssertionError: - exit("chkupdate: Failed to read spec!") + exit(f"{NAME}: Failed to read spec!") link = data['channel-map'][0]['download']['url'] newspec = re.sub(REGEX_VER, f'Version:{found[0][0]}{ver}\n', ver) diff --git a/anda/discord-canary/chkupdate.py b/anda/discord-canary/chkupdate.py index 880a146de7..888eedea39 100644 --- a/anda/discord-canary/chkupdate.py +++ b/anda/discord-canary/chkupdate.py @@ -3,21 +3,23 @@ import re from requests import get -def run_cmds(*cmds: str): - for cmd in cmds: - print(f"chkupdate: $ {cmd}") - if rc := os.system(cmd): - exit(f"chkupdate: Stopping because {rc=}") - - -SPEC = 'discord-canary.spec' +NAME = 'discord-canary' +SPEC = f'{NAME}.spec' REGEX = r'Version:(\s+)([\.\d]+)\n' +REGEX_LINK = r'https://dl-canary\.discordapp\.net/apps/linux/([\.\d]+)/' LINK = 'https://discordapp.com/api/download/canary?platform=linux&format=tar.gz' + +def run_cmds(*cmds: str): + for cmd in cmds: + print(f"{NAME}: $ {cmd}") + if rc := os.system(cmd): + exit(f"{NAME}: Stopping because {rc=}") + html = get(LINK, allow_redirects=False).text -newver = re.findall(r'https://dl-canary\.discordapp\.net/apps/linux/([\.\d]+)/', html) +newver = re.findall(REGEX_LINK, html) if not any(newver): - exit("chkupdate: Failed to parse html!") + exit(f"{NAME}: Failed to parse html!") newver = newver[0] f = open(SPEC, 'r') @@ -27,15 +29,10 @@ try: assert found curver = found[0][1] if newver == curver: - print("chkupdate: Up to date!") - exit() + exit(f"{NAME}: Up to date!") else: - print(f"chkupdate: {curver} -> {newver}") + print(f"{NAME}: {curver} -> {newver}") except IndexError or AssertionError: - exit("chkupdate: Failed to read spec!") + exit(f"{NAME}: Failed to read spec!") -newspec = re.sub(REGEX, f'Version:{found[0][0]}{newver}\n', content, 1) -f.close() -f = open(SPEC, 'w') -f.write(newspec) -f.close() +run_cmds(f'rpmdev-bumpspec -n {newver} {SPEC}') diff --git a/anda/discord-canary/discord-canary.spec b/anda/discord-canary/discord-canary.spec index e41b6158b2..aa9f56c32a 100644 --- a/anda/discord-canary/discord-canary.spec +++ b/anda/discord-canary/discord-canary.spec @@ -1,6 +1,6 @@ Name: discord-canary Version: 0.0.140 -Release: %autorelease +Release: 1%{?dist} Summary: Free Voice and Text Chat for Gamers. URL: discord.com Source0: https://dl-canary.discordapp.net/apps/linux/%{version}/discord-canary-%{version}.tar.gz @@ -30,6 +30,9 @@ install discord.png %{buildroot}%{_datadir}/pixmaps/discord-canary.png %{_datadir}/pixmaps/discord-canary.png %changelog +* Wed Oct 19 2022 windowsboy111 - 0.0.140-1 +- new version + * Sun Oct 16 2022 windowsboy111 - 0.0.139 - Repackaged for Terra diff --git a/anda/discord-ptb/chkupdate.py b/anda/discord-ptb/chkupdate.py index 8119e7ae59..034d8e65e3 100644 --- a/anda/discord-ptb/chkupdate.py +++ b/anda/discord-ptb/chkupdate.py @@ -3,21 +3,23 @@ import re from requests import get -def run_cmds(*cmds: str): - for cmd in cmds: - print(f"chkupdate: $ {cmd}") - if rc := os.system(cmd): - exit(f"chkupdate: Stopping because {rc=}") - - -SPEC = 'discord-ptb.spec' +NAME = 'discord-ptb' +SPEC = f'{NAME}.spec' REGEX = r'Version:(\s+)([\.\d]+)\n' +REGEX_LINK = r'https://dl-ptb\.discordapp\.net/apps/linux/([\.\d]+)/' LINK = 'https://discordapp.com/api/download/ptb?platform=linux&format=tar.gz' + +def run_cmds(*cmds: str): + for cmd in cmds: + print(f"{NAME}: $ {cmd}") + if rc := os.system(cmd): + exit(f"{NAME}: Stopping because {rc=}") + html = get(LINK, allow_redirects=False).text -newver = re.findall(r'https://dl-ptb\.discordapp\.net/apps/linux/([\.\d]+)/', html) +newver = re.findall(REGEX_LINK, html) if not any(newver): - exit("chkupdate: Failed to parse html!") + exit(f"{NAME}: Failed to parse html!") newver = newver[0] f = open(SPEC, 'r') @@ -27,15 +29,10 @@ try: assert found curver = found[0][1] if newver == curver: - print("chkupdate: Up to date!") - exit() + exit(f"{NAME}: Up to date!") else: - print(f"chkupdate: {curver} -> {newver}") + print(f"{NAME}: {curver} -> {newver}") except IndexError or AssertionError: - exit("chkupdate: Failed to read spec!") + exit(f"{NAME}: Failed to read spec!") -newspec = re.sub(REGEX, f'Version:{found[0][0]}{newver}\n', content, 1) -f.close() -f = open(SPEC, 'w') -f.write(newspec) -f.close() +run_cmds(f'rpmdev-bumpspec -n {newver} {SPEC}') diff --git a/anda/prismlauncher/chkupdate.py b/anda/prismlauncher/chkupdate.py index dd10f67697..2ec2e95b60 100644 --- a/anda/prismlauncher/chkupdate.py +++ b/anda/prismlauncher/chkupdate.py @@ -1,9 +1,24 @@ 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() diff --git a/anda/prismlauncher/prismlauncher.spec b/anda/prismlauncher/prismlauncher.spec index 34ad2f143e..27b2cdb9e8 100644 --- a/anda/prismlauncher/prismlauncher.spec +++ b/anda/prismlauncher/prismlauncher.spec @@ -1,4 +1,4 @@ -%define commit f3db9c392066ae632191658ade4e1946db9d29ee +%define commit c6515c1dad7e2d3698e78398f838ac60bd5d376f %global shortcommit %(c=%{commit}; echo ${c:0:7}) %define libnbtplusplus_commit 2203af7eeb48c45398139b583615134efd8d407f %define libnbtplusplus_shortcommit %(c=%{libnbtplusplus_commit}; echo ${c:0:7}) diff --git a/update.sh b/update.sh index 12580a4cea..56b91227ab 100755 --- a/update.sh +++ b/update.sh @@ -1,14 +1,11 @@ #!/bin/bash -x -echo :: ensurepip python -m ensurepip -echo :: python modules python -m pip install -r requirements.txt search() { for folder in $1/*; do if [ -f "$folder/chkupdate.py" ]; then - echo :: $folder (cd $folder && python chkupdate.py) continue fi @@ -16,7 +13,7 @@ search() { for thing in $folder/*; do [[ -f $thing ]] && x=1 && break done - [[ $x -eq 1 ]] && search $folder + [[ $x -eq 0 ]] && search $folder done }