From afaba869b3f676f67dba3231b52e30bc42547a65 Mon Sep 17 00:00:00 2001 From: windowsboy111 Date: Sun, 16 Oct 2022 19:11:19 +0800 Subject: [PATCH] Improve update.yml --- .github/workflows/update.yml | 36 +++++++++++++++++++++ anda/authy/chkupdate.py | 2 +- anda/discord-canary/anda.hcl | 6 ++++ anda/discord-canary/chkupdate.py | 43 +++++++++++++++++++++++++ anda/discord-canary/discord-canary.spec | 40 +++++++++++++++++++++++ update.sh | 18 +++++++++++ 6 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update.yml create mode 100644 anda/discord-canary/anda.hcl create mode 100644 anda/discord-canary/chkupdate.py create mode 100644 anda/discord-canary/discord-canary.spec create mode 100755 update.sh diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000000..ae9a044860 --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,36 @@ +# for each folder in ultramarine/ +# if there is chkupdate.py +# run it every 2 hours +name: Automatically check for updates +on: + schedule: + - cron: '0 */2 * * *' + workflow_dispatch: + +jobs: + get-chkupdate-scripts: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - run: git fetch + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Run Update + run: ./update.sh + + - name: Save + run: | + 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 push origin master + fi diff --git a/anda/authy/chkupdate.py b/anda/authy/chkupdate.py index 642326ee13..25d6371626 100644 --- a/anda/authy/chkupdate.py +++ b/anda/authy/chkupdate.py @@ -19,7 +19,7 @@ ver = data['channel-map'][0]['version'] f = open(SPEC, 'r') content = f.read() -found = re.findall(REGEX, content) +found = re.findall(REGEX_VER, content) try: assert found curver = found[0][1] diff --git a/anda/discord-canary/anda.hcl b/anda/discord-canary/anda.hcl new file mode 100644 index 0000000000..85b0a3e780 --- /dev/null +++ b/anda/discord-canary/anda.hcl @@ -0,0 +1,6 @@ +project "pkg" { + rpm { + spec = "discord-canary.spec" + sources = "." + } +} diff --git a/anda/discord-canary/chkupdate.py b/anda/discord-canary/chkupdate.py new file mode 100644 index 0000000000..43dea66187 --- /dev/null +++ b/anda/discord-canary/chkupdate.py @@ -0,0 +1,43 @@ +import os +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' +REGEX = r'Version:(\s+)([\.\d]+)\n' +LINK = 'https://discordapp.com/api/download/canary?platform=linux&format=tar.gz' + +html = get(LINK, allow_redirects=False).text +newver = re.findall(r'https://dl-canary\.discordapp\.net/apps/linux/([\.\d]+)/', html) +if not any(newver): + exit("chkupdate: Failed to parse html!") +newver = newver[0] + +f = open(SPEC, 'r') +content = f.read() +found = re.findall(REGEX, content) +try: + assert found + curver = found[0][1] + if newver == curver: + print("chkupdate: Up to date!") + exit() + else: + print(f"chkupdate: {curver} -> {newver}") +except IndexError or AssertionError: + exit("chkupdate: 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"wget https://discordapp.com/api/download/canary?platform=linux&format=tar.gz") diff --git a/anda/discord-canary/discord-canary.spec b/anda/discord-canary/discord-canary.spec new file mode 100644 index 0000000000..abf99dcb6a --- /dev/null +++ b/anda/discord-canary/discord-canary.spec @@ -0,0 +1,40 @@ +Name: discord-canary +Version: 0.0.139 +Release: %autorelease +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 +License: https://discord.com/terms +Requires: libatomic, glibc, alsa-lib, GConf2, libnotify, nspr >= 4.13, nss >= 3.27, libstdc++, libX11 >= 1.6, libXtst >= 1.2, libappindicator, libcxx, libXScrnSaver +Group: Applications/Internet +ExclusiveArch: x86_64 +%description +Imagine a place where you can belong to a school club, a gaming group, or a worldwide art community. Where just you and a handful of friends can spend time together. A place that makes it easy to talk every day and hang out more often. + +%prep +%autosetup -n DiscordCanary + + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p %{buildroot}%{_datadir}/discord-canary +cp -rv * %{buildroot}%{_datadir}/discord-canary +mkdir -p %{buildroot}%{_datadir}/applications/ +mkdir -p %{buildroot}%{_datadir}/pixmaps +install discord-canary.desktop %{buildroot}%{_datadir}/applications/discord-canary.desktop +install discord.png %{buildroot}%{_datadir}/pixmaps/discord-canary.png + +%files +%{_datadir}/discord-canary/ +%{_datadir}/applications/discord-canary.desktop +%{_datadir}/pixmaps/discord-canary.png + +%changelog +* Sun Oct 16 2022 windowsboy111 - 0.0.139 +- Repackaged for Terra + +* Tue Feb 22 2022 Ultramarine Release Tracking Service - 0.0.133-2 +- Mass rebuild for release um36 + +* Sat Nov 20 2021 Cappy Ishihara +- Initial release diff --git a/update.sh b/update.sh new file mode 100755 index 0000000000..0a233ca4b6 --- /dev/null +++ b/update.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +search() { + for folder in $1/*; do + if [ -f "$folder/chkupdate.py" ]; then + echo :: $folder + (cd $folder && python chkupdate.py) + continue + fi + x=0 + for thing in $folder/*; do + [[ -f $thing ]] && x=1 && break + done + [[ $x -eq 1 ]] && search $folder + done +} + +search anda