Skip to content

Instantly share code, notes, and snippets.

@NickCao
Created July 2, 2023 08:49
Show Gist options
  • Save NickCao/fa592237f768c32ff26688d99b20f81f to your computer and use it in GitHub Desktop.
Save NickCao/fa592237f768c32ff26688d99b20f81f to your computer and use it in GitHub Desktop.
xorg.py
import requests
import json
import pandas as pd
from bs4 import BeautifulSoup
from packaging import version
allversions = []
for component in [
"individual/app",
"individual/data",
"individual/doc",
"individual/driver",
"individual/font",
"individual/lib",
"individual/proto",
"individual/util",
"individual/xcb",
]:
r = requests.get("https://xorg.freedesktop.org/releases/{}/".format(component))
soup = BeautifulSoup(r.text, "html.parser")
for a in soup.table.find_all("a"):
href = a["href"]
if (
not href.endswith(".tar.bz2")
and not href.endswith(".tar.gz")
and not href.endswith(".tar.xz")
):
continue
pname, rem = href.rsplit("-", 1)
ver, _, ext = rem.rsplit(".", 2)
allversions.append(
{
"pname": "{}/{}".format(component, pname),
"version": version.parse(ver),
"ext": [ext],
}
)
allversions = pd.DataFrame(allversions)
allversions = allversions.groupby(["pname", "version"]).sum().reset_index()
idx = allversions.groupby(["pname"])["version"].transform(max) == allversions["version"]
newversions = allversions[idx]
with open("./pkgs/servers/x11/xorg/tarballs.list") as f:
lines = f.readlines()
mirror = "mirror://xorg/"
for line in lines:
line = line.rstrip("\n")
if line.startswith(mirror):
line = line[len(mirror) :]
component, rem = line.rsplit("/", 1)
pname, rem = rem.rsplit("-", 1)
ver, _, ext = rem.rsplit(".", 2)
pname = "{}/{}".format(component, pname)
ver = version.parse(ver)
best = newversions[newversions["pname"] == pname]
if best.shape[0] == 0:
print("# WARNING: no version found for {}".format(pname))
best = best[best["version"] > ver]
if best.shape[0] > 0:
best = best.iloc[0]
print(
"sed -i 's|{}{}|{}{}-{}.tar.{}|' ./pkgs/servers/x11/xorg/tarballs.list".format(
mirror,
line,
mirror,
best["pname"],
best["version"],
best["ext"][-1],
)
)
else:
continue
@sdht0
Copy link

sdht0 commented Oct 27, 2023

Should also add a check for https://invisible-mirror.net/archives/luit/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment