diff options
author | WasabiThumb | 2023-10-26 12:21:07 -0400 |
---|---|---|
committer | WasabiThumb | 2023-10-26 12:21:07 -0400 |
commit | f435a15b0377d99c1bb94d7f27f2d5cffc8d5c80 (patch) | |
tree | 47fa4ad3a9b6d85e00ba2e3a8b83758dfeeec6d6 | |
parent | 2dd076efbea2ebeebf1b213f9c537e6d2363cb9d (diff) | |
download | aur-f435a15b0377d99c1bb94d7f27f2d5cffc8d5c80.tar.gz |
Fix makepkg stripping symbols from binary
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | PKGBUILD | 3 | ||||
-rw-r--r-- | gensrc.sh | 2 | ||||
-rw-r--r-- | maintain.py | 140 |
4 files changed, 144 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore index 485dee64bcfb..4e8e544d4b9e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea +PKGBUILD.bak @@ -1,7 +1,7 @@ # Maintainer: Wasabi <wasabithumbs@gmail.com> pkgname=open-goal-launcher-bin pkgver="2.2.2" -pkgrel=1 +pkgrel=2 pkgdesc="A launcher for the OpenGOAL Project to simplify usage and installation" arch=("x86_64") url='https://github.com/open-goal/launcher' @@ -11,6 +11,7 @@ conflicts=('open-goal-launcher') _image="open-goal-launcher_${pkgver}_amd64.AppImage" source_x86_64=("https://github.com/open-goal/launcher/releases/download/v2.2.2/${_image}") md5sums_x86_64=("eefcbcea51e66fb2c19a2a7522ae8204") +options=(!strip) prepare() { cd $srcdir diff --git a/gensrc.sh b/gensrc.sh index e69de29bb2d1..d67b20f984b5 100644 --- a/gensrc.sh +++ b/gensrc.sh @@ -0,0 +1,2 @@ +#!/bin/bash +makepkg --printsrcinfo > .SRCINFO diff --git a/maintain.py b/maintain.py index 8d1c8b69c3fc..5d7ebffc00c9 100644 --- a/maintain.py +++ b/maintain.py @@ -1 +1,139 @@ - +# Script to maintain the PKGBUILD as the launcher receives updates + +import requests +from dataclasses import dataclass +import os +import shutil +import hashlib +import re +import subprocess + +REPO = "open-goal/launcher" +SCRIPT_HOME = os.path.dirname(os.path.realpath(__file__)) +PKGBUILD = os.path.join(SCRIPT_HOME, "PKGBUILD") +API_HEADERS = { + "User-Agent": "aur-maintain; wasabithumbs@gmail.com" +} + + +@dataclass +class Release: + version: str + image: str + + +def get_latest_release() -> Release: + resp = requests.get('https://api.github.com/repos/{}/releases?per_page=1'.format(REPO), headers=API_HEADERS) + print("GitHub API: HTTP {}".format(resp.status_code)) + dat = resp.json()[0] + image = None + + for asset in dat["assets"]: + asset_name = asset["name"] + assert isinstance(asset_name, str), "Asset name is not a string!" + if asset_name.endswith("_amd64.AppImage"): + image = asset["browser_download_url"] + + version = dat["tag_name"] + assert isinstance(version, str), "Tag name is not a string!" + version = version[1:] + + assert isinstance(image, str), "No valid image found!" + + return Release(version, image) + + +def get_repo_desc() -> str: + resp = requests.get('https://api.github.com/repos/{}'.format(REPO), headers=API_HEADERS) + print("GitHub API: HTTP {}".format(resp.status_code)) + dat = resp.json() + + desc = dat["description"] + assert isinstance(desc, str), "Description is not a string!" + + return desc + + +def sum_url(url: str) -> str: + resp = requests.get(url) + assert (resp.status_code == 200), "Unexpected status code: {}".format(resp.status_code) + return hashlib.md5(resp.content).hexdigest() + + +if __name__ == '__main__': + print("Backing up PKGBUILD...") + shutil.copyfile(PKGBUILD, PKGBUILD + ".bak") + + print("Fetching latest release...") + release = get_latest_release() + dsc = get_repo_desc() + print("Found release " + release.version) + + print("Computing sum...") + image_sum = sum_url(release.image) + print(image_sum) + + image_name = release.image.split('/')[-1] + update = { + 'pkgver': release.version, + 'pkgdesc': dsc, + 'arch': ['x86_64'], + '_image': image_name.replace(release.version, '${pkgver}'), + 'source_x86_64': [release.image.replace(image_name, '${_image}')], + 'md5sums_x86_64': [image_sum] + } + + print("Updating PKGBUILD...") + + lines = [] + with open(PKGBUILD, 'r') as f: + end_of_cfg = False + for line in f.readlines(): + empty = len(line) < 1 + + if empty or re.match("^\\s+$", line): + end_of_cfg = True + lines.append(line) + continue + elif line[0] == "#" or end_of_cfg: + lines.append(line) + continue + + key = line.split('=')[0] + if not (key in update): + lines.append(line) + continue + + new_value = update[key] + + new_line = "" + if type(new_value) in [list, tuple]: + new_line = '(' + space = False + for entry in new_value: + if space: + new_line += " " + space = True + new_line += "\"{}\"".format(entry) + new_line += ")" + else: + new_line = "\"{}\"".format(new_value) + + new_line = "{}={}\n".format(key, new_line) + + lines.append(new_line) + + with open(PKGBUILD, 'w') as f: + f.write("".join(lines)) + + print("Generating .SRCINFO...") + p = subprocess.Popen(['bash', 'gensrc.sh'], cwd=SCRIPT_HOME) + p.wait() + print("Command finished with code {}".format(p.returncode)) + + print("Adding files to git...") + p = subprocess.Popen(['git', 'add', 'PKGBUILD', '.SRCINFO'], cwd=SCRIPT_HOME) + p.wait() + print("Command finished with code {}".format(p.returncode)) + + print("Done!") |