pmbootstrap status: rework (MR 2294)

Reimplement "pmbootstrap status" to be just a simple and useful status
overview. The previous version ran a bunch of checks every time, and
would fail on these even if pmaports was used for normal development:
  * "non-official" branch checked out in pmaports
  * pmaports.git is not clean

The information about aports.git was also considered not so useful upon
revisiting this command, since it is only used for "pmbootstrap
aportgen". Most users don't need this, and if the user runs this
command, it will tell if aports.git is outdated.

All of the above made the previous version unpleasant to use and I
suspect most people stopped using the command after trying it out a few
times and seeing the irrelevant but loud NOK complaints.

New version:

  $ pmbootstrap status
  Channel: edge (pmaports: master_staging_systemd)
  Device:  qemu-amd64 (x86_64, kernel: virt)
  UI:      console
  systemd: no (default for selected UI)

Old version (without --details it only shows NOK checks):

  $ pmbootstrap status --details
  [00:55:20] *** CONFIG ***
  [00:55:20] Device: qemu-amd64 (x86_64, "QEMU amd64")
  [00:55:20] Kernel: virt
  [00:55:20] User Interface: console
  [00:55:20]
  [00:55:20] *** GIT REPOS ***
  [00:55:20] Path: /home/user/.local/var/pmbootstrap/cache_git
  [00:55:20] - aports_upstream (master)
  [00:55:20] - pmaports (master)
  [00:55:20]
  [00:55:20] *** CHECKS ***
  [00:55:20] [OK ] Chroots zapped recently (or non-existing)
  [00:55:20] [OK ] aports_upstream: on official channel branch
  [00:55:20] [OK ] aports_upstream: workdir is clean
  [00:55:20] [OK ] aports_upstream: tracking proper remote branch 'origin/master'
  [00:55:20] [OK ] aports_upstream: up to date with remote branch
  [00:55:20] [OK ] aports_upstream: remote information updated recently (via git fetch/pull)
  [00:55:20] [OK ] pmaports: on official channel branch
  [00:55:20] [OK ] pmaports: workdir is clean
  [00:55:20] [OK ] pmaports: tracking proper remote branch 'origin/master'
  [00:55:20] [OK ] pmaports: up to date with remote branch
  [00:55:20] [OK ] pmaports: remote information updated recently (via git fetch/pull)
  [00:55:20]
  [00:55:20] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
  [00:55:20] DONE!
This commit is contained in:
Oliver Smith 2024-04-12 00:09:55 +02:00
parent 56dfdd4ad3
commit 0d320d0613
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
8 changed files with 54 additions and 290 deletions

View file

@ -4,7 +4,6 @@ import os
import sys
import pytest
import shutil
import time
import pmb_test # noqa
import pmb_test.const
@ -166,29 +165,3 @@ def test_pull(args, monkeypatch, tmpdir):
run_git(["reset", "--hard", "origin/master"])
run_git(["commit", "--allow-empty", "-m", "new"], "remote")
assert func(args, name_repo) == 0
def test_is_outdated(tmpdir, monkeypatch):
func = pmb.helpers.git.is_outdated
# Override time.time(): now is "100"
def fake_time():
return 100.0
monkeypatch.setattr(time, "time", fake_time)
# Create .git/FETCH_HEAD
path = str(tmpdir)
os.mkdir(path + "/.git")
fetch_head = path + "/.git/FETCH_HEAD"
open(fetch_head, "w").close()
# Set mtime to 90
os.utime(fetch_head, times=(0, 90))
# Outdated (date_outdated: 90)
monkeypatch.setattr(pmb.config, "git_repo_outdated", 10)
assert func(path) is True
# Not outdated (date_outdated: 89)
monkeypatch.setattr(pmb.config, "git_repo_outdated", 11)
assert func(path) is False