add authy

This commit is contained in:
windowsboy111
2022-10-15 17:23:17 +08:00
parent 9768acb7fb
commit f3bf4055a2
3 changed files with 82 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
project "pkg" {
rpm {
spec = "authy.spec"
sources = "."
}
}
+38
View File
@@ -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 <windowsboy111@fyralabs.com>
- Initial release
+38
View File
@@ -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()