diff --git a/anda/discord-canary/chkupdate.py b/anda/discord-canary/chkupdate.py index 43dea66187..880a146de7 100644 --- a/anda/discord-canary/chkupdate.py +++ b/anda/discord-canary/chkupdate.py @@ -39,5 +39,3 @@ 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-ptb/anda.hcl b/anda/discord-ptb/anda.hcl new file mode 100644 index 0000000000..e568dbcd97 --- /dev/null +++ b/anda/discord-ptb/anda.hcl @@ -0,0 +1,6 @@ +project "pkg" { + rpm { + spec = "discord-ptb.spec" + sources = "." + } +} diff --git a/anda/discord-ptb/chkupdate.py b/anda/discord-ptb/chkupdate.py new file mode 100644 index 0000000000..8119e7ae59 --- /dev/null +++ b/anda/discord-ptb/chkupdate.py @@ -0,0 +1,41 @@ +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-ptb.spec' +REGEX = r'Version:(\s+)([\.\d]+)\n' +LINK = 'https://discordapp.com/api/download/ptb?platform=linux&format=tar.gz' + +html = get(LINK, allow_redirects=False).text +newver = re.findall(r'https://dl-ptb\.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() diff --git a/anda/discord-ptb/discord-ptb.spec b/anda/discord-ptb/discord-ptb.spec new file mode 100644 index 0000000000..9430bdb0fd --- /dev/null +++ b/anda/discord-ptb/discord-ptb.spec @@ -0,0 +1,34 @@ +Name: discord-ptb +Version: 0.0.33 +Release: %autorelease +Summary: Free Voice and Text Chat for Gamers. +URL: discord.com +Source0: https://dl-ptb.discordapp.net/apps/linux/%{version}/discord-ptb-%{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 DiscordPTB + + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p %{buildroot}%{_datadir}/discord-ptb +cp -rv * %{buildroot}%{_datadir}/discord-ptb +mkdir -p %{buildroot}%{_datadir}/applications/ +mkdir -p %{buildroot}%{_datadir}/pixmaps +install discord-ptb.desktop %{buildroot}%{_datadir}/applications/discord-ptb.desktop +install discord.png %{buildroot}%{_datadir}/pixmaps/discord-ptb.png + +%files +%{_datadir}/discord-ptb/ +%{_datadir}/applications/discord-ptb.desktop +%{_datadir}/pixmaps/discord-ptb.png + +%changelog +* Sun Oct 16 2022 windowsboy111 - 0.0.33 +- Initial Package.