36 lines
925 B
Python
36 lines
925 B
Python
from invoke import task
|
|
import yaml
|
|
|
|
@task
|
|
def aur(c, name):
|
|
url = f"https://aur.archlinux.org/{name}.git"
|
|
add(c, url, name)
|
|
|
|
@task
|
|
def add(c, url, name=None):
|
|
if name is None:
|
|
ending = url.rfind('/') + 1
|
|
ending = ending.split(".")
|
|
name = ending[0]
|
|
c.run(f"git submodule add {url} {name}")
|
|
c.run(f"git commit -am 'added: {name}'")
|
|
addyaml(c, name)
|
|
|
|
@task
|
|
def update(c):
|
|
c.run("git pull && git submodule update --init")
|
|
|
|
@task
|
|
def addyaml(c, directory):
|
|
f = "./build-pacman-repo.yaml"
|
|
with open(f, "r") as stream:
|
|
data = yaml.safe_load(stream)
|
|
exists = [x["directory"] == directory for x in data["members"]]
|
|
exists = any(exists)
|
|
print(exists)
|
|
print(data)
|
|
if not exists:
|
|
data["members"].append({"directory":directory})
|
|
with open(f, "w") as stream2:
|
|
yaml.safe_dump(data, stream2)
|