bundlewrap/nodes/attributes.py

25 lines
602 B
Python
Raw Permalink Normal View History

from bundlewrap.utils.ui import io
from bundlewrap.utils.scm import get_rev
from bundlewrap.utils.text import red, bold
@node_attribute
def needs_apply(node):
if node.dummy:
return False
if node.os not in node.OS_FAMILY_UNIX:
return True
try:
applied = node.run(
'cat /var/lib/bundlewrap/last_apply_commit_id',
may_fail=True,
).stdout.decode().strip()
if not applied or applied != get_rev():
return True
except Exception as e:
io.stderr(f'{red("!!!")} {bold(node.name)} {e!r}')
return False