[arch] feature -> AUR: custom actions to allow/ignore rebuild-detector for a given package

This commit is contained in:
Vinicius Moreira
2021-01-14 15:32:54 -03:00
parent 0680a3118d
commit 7d539e0838
17 changed files with 319 additions and 11 deletions

View File

@@ -1,6 +1,9 @@
import os
from pathlib import Path
from typing import Set
from bauh.commons import system
from bauh.gems.arch import IGNORED_REBUILD_CHECK_FILE
def is_installed() -> bool:
@@ -22,3 +25,42 @@ def list_required_rebuild() -> Set[str]:
required.add(line_split[1])
return required
def list_ignored() -> Set[str]:
if os.path.isfile(IGNORED_REBUILD_CHECK_FILE):
with open(IGNORED_REBUILD_CHECK_FILE) as f:
ignored_str = f.read()
return {p.strip() for p in ignored_str.split('\n') if p}
else:
return set()
def add_as_ignored(pkgname: str):
ignored = list_ignored()
ignored.add(pkgname)
Path(os.path.dirname(IGNORED_REBUILD_CHECK_FILE)).mkdir(parents=True, exist_ok=True)
with open(IGNORED_REBUILD_CHECK_FILE, 'w+') as f:
for p in ignored:
f.write('{}\n'.format(p))
def remove_from_ignored(pkgname: str):
ignored = list_ignored()
if ignored is None or pkgname not in ignored:
return
ignored.remove(pkgname)
Path(os.path.dirname(IGNORED_REBUILD_CHECK_FILE)).mkdir(parents=True, exist_ok=True)
if ignored:
with open(IGNORED_REBUILD_CHECK_FILE, 'w+') as f:
for p in ignored:
f.write('{}\n'.format(p))
else:
os.remove(IGNORED_REBUILD_CHECK_FILE)