blob: 7d81ae47e4a78ef30b82d2892fae11c3b55a97c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/usr/bin/python3
import sys
import requests
import os
import platform
ARCH = platform.machine()
NAMES = [
"$",
"$-git",
"python-$",
"python-$-git"
]
URLS = {
"core": f"https://archlinux.org/packages/core/{ARCH}/$/",
"extra": f"https://archlinux.org/packages/extra/{ARCH}/$/",
"aur": f"https://aur.archlinux.org/packages/$",
"pip": f"https://pypi.org/project/$/"
}
if len(sys.argv) == 1:
print(f"Usage: {sys.argv[0]} [-r] <package/requirements-file>")
exit(1)
pkgs = [sys.argv[1]]
# The -r option is not fully compatible with the pip Requirements File Format:
# https://pip.pypa.io/en/stable/reference/requirements-file-format/
if sys.argv[1] == "-r":
with open(sys.argv[2], 'r') as r:
pkgs = r.readlines()
for pkg in pkgs:
if pkg.replace(" ", "").startswith("#"):
continue
for repo in URLS:
for name in NAMES:
pkg = pkg \
.replace('\n', '') \
.split(" ")[0] \
.split("=")[0]
name = name.replace("$", pkg)
url = URLS[repo].replace("$", name)
req = requests.get(url)
if req.status_code == 200:
if len(pkgs) == 1:
print(f"{repo}/{name}")
else:
print(f"{pkg}: {repo}/{name}")
|