-
Notifications
You must be signed in to change notification settings - Fork 4
/
msys2-dbremove-api
executable file
·48 lines (34 loc) · 1.07 KB
/
msys2-dbremove-api
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
#!/usr/bin/env python3
import os
import sys
import requests
import argparse
import subprocess
import shutil
DIR = os.path.dirname(os.path.realpath(__file__))
def remove_all(args):
r = requests.get("https://packages.msys2.org/api/removals")
r.raise_for_status()
to_remove = []
for entry in r.json():
repo = entry["repo"]
name = entry["name"]
to_remove.append((repo, name))
for repo, name in to_remove:
print(f"Removing '{name}' from '{repo}'")
choice = input("OK to remove? [Y/n] ")
if choice.upper() != "Y":
print("Aborting")
return
grouped = {}
for repo, name in to_remove:
grouped.setdefault(repo, []).append(name)
for repo, names in grouped.items():
subprocess.check_call([
shutil.which("bash"), os.path.join(DIR, "msys2-dbremove"), repo, *names])
def main(argv):
parser = argparse.ArgumentParser(description="Remove packages", allow_abbrev=False)
args = parser.parse_args(argv[1:])
remove_all(args)
if __name__ == "__main__":
main(sys.argv)