forked from Mirror/pmbootstrap
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
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
# 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
|