diff --git a/anda/authy/anda.hcl b/anda/authy/anda.hcl new file mode 100644 index 0000000000..1c865b0473 --- /dev/null +++ b/anda/authy/anda.hcl @@ -0,0 +1,6 @@ +project "pkg" { + rpm { + spec = "authy.spec" + sources = "." + } +} diff --git a/anda/authy/authy.spec b/anda/authy/authy.spec new file mode 100644 index 0000000000..b3b1649310 --- /dev/null +++ b/anda/authy/authy.spec @@ -0,0 +1,38 @@ +Name: authy +Version: 2.2.1 +Release: 2%{?dist} +Summary: Two factor authentication desktop application +License: Unknown +URL: https://authy.com/ +Source0: https://api.snapcraft.io/api/v1/snaps/download/H8ZpNgIoPyvmkgxOWw5MSzsXK1wRZiHn_11.snap +Requires: gtk3 +Requires: nss +BuildRequires: squashfs-tools + +%description + +%prep +unsquashfs -q -f -d snap %{SOURCE0} + +%install +install -d "%{buildroot}/opt/authy" +cp -r "snap/." "%{buildroot}/opt/authy" + +sed -i 's|${SNAP}/meta/gui/icon.png|authy|g' "%{buildroot}/opt/authy/meta/gui/authy.desktop" +install -Dm644 "%{buildroot}/opt/authy/meta/gui/authy.desktop" -t "%{buildroot}/usr/share/applications" +install -Dm644 "%{buildroot}/opt/authy/meta/gui/icon.png" "%{buildroot}/usr/share/pixmaps/authy.png" + +rm -rf "%{buildroot}/opt/authy"/{data-dir,gnome-platform,lib,meta,scripts,usr,*.sh} + +install -d "%{buildroot}/usr/bin" +ln -s "/opt/authy/authy" "%{buildroot}/usr/bin" + +%files +/opt/authy/ +/usr/bin/authy +/usr/share/applications/authy.desktop +/usr/share/pixmaps/authy.png + +%changelog +* Sat Oct 15 2022 windowsboy111 +- Initial release diff --git a/anda/authy/chkupdate.py b/anda/authy/chkupdate.py new file mode 100644 index 0000000000..642326ee13 --- /dev/null +++ b/anda/authy/chkupdate.py @@ -0,0 +1,38 @@ +import os +import re +from requests import get +import json + +SPEC = "authy.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}") + if rc := os.system(cmd): + exit(f"chkupdate: Stopping because {rc=}") + +raw = get('https://api.snapcraft.io/v2/snaps/info/authy', headers={'Snap-Device-Series': '16'}).text +data = json.loads(raw) +ver = data['channel-map'][0]['version'] + +f = open(SPEC, 'r') +content = f.read() +found = re.findall(REGEX, content) +try: + assert found + curver = found[0][1] + if ver == curver: + exit("chkupdate: Up to date!") + print(f"chkupdate: {curver} -> {ver}") +except IndexError or AssertionError: + exit("chkupdate: Failed to read spec!") + +link = data['channel-map'][0]['download']['url'] +newspec = re.sub(REGEX_VER, f'Version:{found[0][0]}{ver}\n', ver) +newspec = re.sub(REGEX_SRC, f'Source0:{found[0][0]}{link}\n', link) +f.close() +f = open(SPEC, 'w') +f.write(newspec) +f.close()