Created
April 22, 2024 19:45
-
-
Save jeremyd2019/27f079c5134390353123543f58655f7c to your computer and use it in GitHub Desktop.
Script to convert msys2's mingw-w64-rust PKGBUILD to build latest beta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import fileinput | |
import pprint | |
import re | |
import tomli | |
from urllib.request import urlopen | |
with urlopen("https://static.rust-lang.org/dist/channel-rust-beta.toml") as f: | |
x = tomli.load(f) | |
a = [y for y in x['artifacts']['source-code']['target']['*'] if y['url'].endswith('.gz')] | |
assert(len(a) == 1) | |
obj = a[0] | |
obj['version'] = x['pkg']['rustc']['version'] | |
pprint.pprint(obj) | |
newpkgver = re.sub(r'^(\d+\.\d+\.\d+)-(beta\.\d+) \([^)]*\)$', r'\1\2', obj['version']) | |
pkgverre = re.compile(r'^(pkgver=)\S*(\s*)$') | |
pkgrelre = re.compile(r'^(pkgrel=)\S*(\s*)$') | |
shasumre = re.compile(r"^(sha256sums=\(')[0-9a-fA-F]{64}('\s*)$") | |
realnamecsrcre = re.compile(r'(\$\{_realname\}c-)\$\{pkgver\}(-src)') | |
with fileinput.input("mingw-w64-rust/PKGBUILD", encoding="utf-8", inplace=True) as f: | |
for line in f: | |
print(realnamecsrcre.sub(r'\g<1>beta\g<2>', shasumre.sub(r'\g<1>' + obj['hash-sha256'] + r'\g<2>', pkgrelre.sub(r'\g<1>1\g<2>', pkgverre.sub(r'\g<1>' + newpkgver + r'\g<2>', line)))), end="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment