forked from Mirror/pmbootstrap
pmbootstrap status: show if chroots are outdated (!1878)
Add new "pmbootstrap status" command, which does a quick health check for the work dir. As first health check, verify that the chroots are not too old. Replace the reminder text at the end of "pmbootstrap init" to tell users to run "pmbootstrap status" instead of "pmbootstrap zap" once a day before working with pmbootstrap. Related: #1829
This commit is contained in:
parent
17673c5bf1
commit
1724ed4665
5 changed files with 110 additions and 6 deletions
48
pmb/helpers/status.py
Normal file
48
pmb/helpers/status.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Copyright 2020 Oliver Smith
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import logging
|
||||
|
||||
import pmb.config.workdir
|
||||
|
||||
|
||||
def print_checks_chroots_outdated(args, details):
|
||||
""" Check if chroots were zapped recently.
|
||||
:param details: if True, print each passing check instead of a summary
|
||||
:returns: list of unresolved checklist items """
|
||||
if pmb.config.workdir.chroots_outdated(args):
|
||||
logging.info("[NOK] Chroots not zapped recently")
|
||||
return ["Run 'pmbootststrap zap' to delete possibly outdated chroots"]
|
||||
elif details:
|
||||
logging.info("[OK ] Chroots zapped recently (or non-existing)")
|
||||
return []
|
||||
|
||||
|
||||
def print_checks(args, details):
|
||||
""" :param details: if True, print each passing check instead of a summary
|
||||
:returns: True if all checks passed, False otherwise """
|
||||
logging.info("*** CHECKS ***")
|
||||
checklist = []
|
||||
checklist += print_checks_chroots_outdated(args, details)
|
||||
|
||||
# All OK
|
||||
if not checklist:
|
||||
if not details:
|
||||
logging.info("All checks passed! \\o/")
|
||||
logging.info("")
|
||||
return True
|
||||
|
||||
# Some NOK: print checklist
|
||||
logging.info("")
|
||||
logging.info("*** CHECKLIST ***")
|
||||
for item in checklist:
|
||||
logging.info("- " + item)
|
||||
logging.info("- Run 'pmbootstrap status' to verify that all is resolved")
|
||||
return False
|
||||
|
||||
|
||||
def print_status(args, details=False):
|
||||
""" :param details: if True, print each passing check instead of a summary
|
||||
:returns: True if all checks passed, False otherwise """
|
||||
ret = print_checks(args, details)
|
||||
|
||||
return ret
|
Loading…
Add table
Add a link
Reference in a new issue