mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 21:44:16 +02:00
[arch] feature -> AUR: custom actions to allow/ignore rebuild-detector for a given package
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user