mirror of
https://github.com/aphrody-labs/msys2-devtools.git
synced 2026-10-14 04:19:12 +00:00
49 lines
1.1 KiB
Python
Executable File
49 lines
1.1 KiB
Python
Executable File
#!/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)
|