mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-06-24 09:28:21 -04:00
cli: check KBS version against repos.yml for relevant commands
This commit is contained in:
parent
821bde59e9
commit
c80885ddd7
7 changed files with 32 additions and 4 deletions
|
@ -9,6 +9,7 @@ from config.cli import resolve_profile_field
|
||||||
from utils import color_mark_selected, colors_supported
|
from utils import color_mark_selected, colors_supported
|
||||||
|
|
||||||
from .device import get_devices, get_device
|
from .device import get_devices, get_device
|
||||||
|
from version.cli import _check_kbs_version
|
||||||
|
|
||||||
|
|
||||||
@click.command(name='devices')
|
@click.command(name='devices')
|
||||||
|
@ -33,6 +34,7 @@ def cmd_devices(
|
||||||
output_file: Optional[str] = None,
|
output_file: Optional[str] = None,
|
||||||
):
|
):
|
||||||
'list the available devices and descriptions'
|
'list the available devices and descriptions'
|
||||||
|
_check_kbs_version(init_pkgbuilds=False)
|
||||||
devices = get_devices()
|
devices = get_devices()
|
||||||
if not devices:
|
if not devices:
|
||||||
raise Exception("No devices found!")
|
raise Exception("No devices found!")
|
||||||
|
|
|
@ -9,6 +9,7 @@ from config.state import config
|
||||||
from utils import color_mark_selected, colors_supported
|
from utils import color_mark_selected, colors_supported
|
||||||
|
|
||||||
from .flavour import get_flavours, get_flavour
|
from .flavour import get_flavours, get_flavour
|
||||||
|
from version.cli import _check_kbs_version
|
||||||
|
|
||||||
profile_option = click.option('-p', '--profile', help="name of the profile to use", required=False, default=None)
|
profile_option = click.option('-p', '--profile', help="name of the profile to use", required=False, default=None)
|
||||||
|
|
||||||
|
@ -21,13 +22,14 @@ def cmd_flavours(json: bool = False, output_file: Optional[str] = None):
|
||||||
results = []
|
results = []
|
||||||
json_results = {}
|
json_results = {}
|
||||||
profile_flavour = None
|
profile_flavour = None
|
||||||
flavours = get_flavours()
|
|
||||||
interactive_json = json and not output_file
|
interactive_json = json and not output_file
|
||||||
use_colors = colors_supported(config.runtime.colors) and not interactive_json
|
use_colors = colors_supported(config.runtime.colors) and not interactive_json
|
||||||
profile_name = config.file.profiles.current
|
profile_name = config.file.profiles.current
|
||||||
selected, inherited_from = None, None
|
selected, inherited_from = None, None
|
||||||
if output_file:
|
if output_file:
|
||||||
json = True
|
json = True
|
||||||
|
_check_kbs_version(init_pkgbuilds=False)
|
||||||
|
flavours = get_flavours()
|
||||||
if not flavours:
|
if not flavours:
|
||||||
raise Exception("No flavours found!")
|
raise Exception("No flavours found!")
|
||||||
if not interactive_json:
|
if not interactive_json:
|
||||||
|
|
|
@ -10,6 +10,7 @@ from exec.file import makedir
|
||||||
from devices.device import get_profile_device
|
from devices.device import get_profile_device
|
||||||
from flavours.flavour import get_profile_flavour
|
from flavours.flavour import get_profile_flavour
|
||||||
from flavours.cli import profile_option
|
from flavours.cli import profile_option
|
||||||
|
from version.cli import _check_kbs_version
|
||||||
from wrapper import enforce_wrap
|
from wrapper import enforce_wrap
|
||||||
|
|
||||||
from .fastboot import fastboot_boot, fastboot_erase
|
from .fastboot import fastboot_boot, fastboot_erase
|
||||||
|
@ -42,6 +43,7 @@ def cmd_boot(
|
||||||
):
|
):
|
||||||
"""Boot JumpDrive or the Kupfer aboot image. Erases Android DTBO in the process."""
|
"""Boot JumpDrive or the Kupfer aboot image. Erases Android DTBO in the process."""
|
||||||
enforce_wrap()
|
enforce_wrap()
|
||||||
|
_check_kbs_version(init_pkgbuilds=True)
|
||||||
device = get_profile_device(profile)
|
device = get_profile_device(profile)
|
||||||
flavour = get_profile_flavour(profile).name
|
flavour = get_profile_flavour(profile).name
|
||||||
deviceinfo = device.parse_deviceinfo()
|
deviceinfo = device.parse_deviceinfo()
|
||||||
|
|
|
@ -11,6 +11,7 @@ from exec.file import get_temp_dir
|
||||||
from devices.device import get_profile_device
|
from devices.device import get_profile_device
|
||||||
from flavours.flavour import get_profile_flavour
|
from flavours.flavour import get_profile_flavour
|
||||||
from flavours.cli import profile_option
|
from flavours.cli import profile_option
|
||||||
|
from version.cli import _check_kbs_version
|
||||||
from wrapper import enforce_wrap
|
from wrapper import enforce_wrap
|
||||||
|
|
||||||
from .fastboot import fastboot_flash
|
from .fastboot import fastboot_flash
|
||||||
|
@ -90,6 +91,7 @@ def cmd_flash(
|
||||||
- jumpdrive: one of "emmc", "sdcard" or a path to a block device
|
- jumpdrive: one of "emmc", "sdcard" or a path to a block device
|
||||||
"""
|
"""
|
||||||
enforce_wrap()
|
enforce_wrap()
|
||||||
|
_check_kbs_version(init_pkgbuilds=True)
|
||||||
device = get_profile_device(profile)
|
device = get_profile_device(profile)
|
||||||
flavour = get_profile_flavour(profile).name
|
flavour = get_profile_flavour(profile).name
|
||||||
device_image_path = get_image_path(device, flavour)
|
device_image_path = get_image_path(device, flavour)
|
||||||
|
|
|
@ -19,6 +19,7 @@ from exec.file import get_temp_dir, root_write_file, root_makedir, makedir
|
||||||
from flavours.flavour import Flavour, get_profile_flavour
|
from flavours.flavour import Flavour, get_profile_flavour
|
||||||
from net.ssh import copy_ssh_keys
|
from net.ssh import copy_ssh_keys
|
||||||
from packages.build import build_enable_qemu_binfmt, build_packages, filter_pkgbuilds
|
from packages.build import build_enable_qemu_binfmt, build_packages, filter_pkgbuilds
|
||||||
|
from version.cli import _check_kbs_version
|
||||||
from wrapper import enforce_wrap
|
from wrapper import enforce_wrap
|
||||||
|
|
||||||
# image files need to be slightly smaller than partitions to fit
|
# image files need to be slightly smaller than partitions to fit
|
||||||
|
@ -435,6 +436,7 @@ def cmd_build(
|
||||||
config.enforce_profile_device_set()
|
config.enforce_profile_device_set()
|
||||||
config.enforce_profile_flavour_set()
|
config.enforce_profile_flavour_set()
|
||||||
enforce_wrap()
|
enforce_wrap()
|
||||||
|
_check_kbs_version(init_pkgbuilds=True)
|
||||||
device = get_profile_device(profile_name)
|
device = get_profile_device(profile_name)
|
||||||
arch = device.arch
|
arch = device.arch
|
||||||
# check_programs_wrap(['makepkg', 'pacman', 'pacstrap'])
|
# check_programs_wrap(['makepkg', 'pacman', 'pacstrap'])
|
||||||
|
@ -515,6 +517,7 @@ def cmd_inspect(profile: Optional[str] = None, shell: bool = False, sector_size:
|
||||||
config.enforce_profile_device_set()
|
config.enforce_profile_device_set()
|
||||||
config.enforce_profile_flavour_set()
|
config.enforce_profile_flavour_set()
|
||||||
enforce_wrap()
|
enforce_wrap()
|
||||||
|
_check_kbs_version(init_pkgbuilds=True)
|
||||||
device = get_profile_device(profile)
|
device = get_profile_device(profile)
|
||||||
arch = device.arch
|
arch = device.arch
|
||||||
flavour = get_profile_flavour(profile).name
|
flavour = get_profile_flavour(profile).name
|
||||||
|
|
|
@ -15,6 +15,7 @@ from distro.distro import get_kupfer_local, get_kupfer_url, get_kupfer_repo_name
|
||||||
from distro.package import LocalPackage
|
from distro.package import LocalPackage
|
||||||
from net.ssh import run_ssh_command, scp_put_files
|
from net.ssh import run_ssh_command, scp_put_files
|
||||||
from utils import download_file, git, sha256sum
|
from utils import download_file, git, sha256sum
|
||||||
|
from version.cli import _check_kbs_version
|
||||||
from wrapper import check_programs_wrap, enforce_wrap
|
from wrapper import check_programs_wrap, enforce_wrap
|
||||||
|
|
||||||
from .build import build_packages_by_paths, init_prebuilts
|
from .build import build_packages_by_paths, init_prebuilts
|
||||||
|
@ -37,6 +38,7 @@ def build(
|
||||||
if arch not in ARCHES:
|
if arch not in ARCHES:
|
||||||
raise Exception(f'Unknown architecture "{arch}". Choices: {", ".join(ARCHES)}')
|
raise Exception(f'Unknown architecture "{arch}". Choices: {", ".join(ARCHES)}')
|
||||||
|
|
||||||
|
_check_kbs_version(init_pkgbuilds=True)
|
||||||
return build_packages_by_paths(
|
return build_packages_by_paths(
|
||||||
paths,
|
paths,
|
||||||
arch,
|
arch,
|
||||||
|
@ -160,6 +162,7 @@ def cmd_update(
|
||||||
"""Update PKGBUILDs git repo"""
|
"""Update PKGBUILDs git repo"""
|
||||||
enforce_wrap()
|
enforce_wrap()
|
||||||
init_pkgbuilds(interactive=not non_interactive, lazy=False, update=True, switch_branch=switch_branch, discard_changes=discard_changes)
|
init_pkgbuilds(interactive=not non_interactive, lazy=False, update=True, switch_branch=switch_branch, discard_changes=discard_changes)
|
||||||
|
_check_kbs_version(init_pkgbuilds=False)
|
||||||
if init_caches:
|
if init_caches:
|
||||||
init_pkgbuild_caches(clean_src_dirs=clean_src_dirs)
|
init_pkgbuild_caches(clean_src_dirs=clean_src_dirs)
|
||||||
logging.info("Refreshing outdated SRCINFO caches")
|
logging.info("Refreshing outdated SRCINFO caches")
|
||||||
|
@ -183,6 +186,7 @@ def cmd_init(
|
||||||
):
|
):
|
||||||
"Ensure PKGBUILDs git repo is checked out locally"
|
"Ensure PKGBUILDs git repo is checked out locally"
|
||||||
init_pkgbuilds(interactive=not non_interactive, lazy=False, update=update, switch_branch=switch_branch, discard_changes=discard_changes)
|
init_pkgbuilds(interactive=not non_interactive, lazy=False, update=update, switch_branch=switch_branch, discard_changes=discard_changes)
|
||||||
|
_check_kbs_version(init_pkgbuilds=False)
|
||||||
if init_caches:
|
if init_caches:
|
||||||
init_pkgbuild_caches(clean_src_dirs=clean_src_dirs)
|
init_pkgbuild_caches(clean_src_dirs=clean_src_dirs)
|
||||||
for arch in ARCHES:
|
for arch in ARCHES:
|
||||||
|
@ -308,7 +312,8 @@ def cmd_list():
|
||||||
if not os.path.exists(pkgdir):
|
if not os.path.exists(pkgdir):
|
||||||
raise Exception(f"PKGBUILDs seem not to be initialised yet: {pkgdir} doesn't exist!\n"
|
raise Exception(f"PKGBUILDs seem not to be initialised yet: {pkgdir} doesn't exist!\n"
|
||||||
f"Try running `kupferbootstrap packages init` first!")
|
f"Try running `kupferbootstrap packages init` first!")
|
||||||
check_programs_wrap(['makepkg', 'pacman'])
|
check_programs_wrap(['git', 'makepkg', 'pacman'])
|
||||||
|
_check_kbs_version(init_pkgbuilds=False)
|
||||||
packages = discover_pkgbuilds()
|
packages = discover_pkgbuilds()
|
||||||
logging.info(f'Done! {len(packages)} Pkgbuilds:')
|
logging.info(f'Done! {len(packages)} Pkgbuilds:')
|
||||||
for name in sorted(packages.keys()):
|
for name in sorted(packages.keys()):
|
||||||
|
@ -318,11 +323,13 @@ def cmd_list():
|
||||||
|
|
||||||
|
|
||||||
@cmd_packages.command(name='check')
|
@cmd_packages.command(name='check')
|
||||||
|
@click.option("--ci-mode", "--ci", is_flag=True, default=False)
|
||||||
@click.argument('paths', nargs=-1)
|
@click.argument('paths', nargs=-1)
|
||||||
def cmd_check(paths):
|
def cmd_check(paths: list[str], ci_mode: bool = False):
|
||||||
"""Check that specified PKGBUILDs are formatted correctly"""
|
"""Check that specified PKGBUILDs are formatted correctly"""
|
||||||
config.enforce_config_loaded()
|
config.enforce_config_loaded()
|
||||||
check_programs_wrap(['makepkg'])
|
check_programs_wrap(['makepkg', 'git'])
|
||||||
|
_check_kbs_version(init_pkgbuilds=False, ci_mode=ci_mode)
|
||||||
|
|
||||||
def check_quoteworthy(s: str) -> bool:
|
def check_quoteworthy(s: str) -> bool:
|
||||||
quoteworthy = ['"', "'", "$", " ", ";", "&", "<", ">", "*", "?"]
|
quoteworthy = ['"', "'", "$", " ", ";", "&", "<", ">", "*", "?"]
|
||||||
|
|
|
@ -6,6 +6,16 @@ from distro.repo_config import get_repo_config
|
||||||
from .kbs import get_kbs_version, compare_kbs_version, compare_kbs_ci_version
|
from .kbs import get_kbs_version, compare_kbs_version, compare_kbs_ci_version
|
||||||
|
|
||||||
|
|
||||||
|
def _check_kbs_version(*, init_pkgbuilds: bool = False, ci_mode: bool = False): # quiet helper for other modules
|
||||||
|
repo_config, repo_config_found = get_repo_config(initialize_pkgbuilds=init_pkgbuilds)
|
||||||
|
if not repo_config_found:
|
||||||
|
return
|
||||||
|
kbs_version = get_kbs_version()
|
||||||
|
if not kbs_version:
|
||||||
|
return
|
||||||
|
compare_kbs_version(kbs_version, repo_config)
|
||||||
|
|
||||||
|
|
||||||
@click.group("version", no_args_is_help=False, invoke_without_command=True)
|
@click.group("version", no_args_is_help=False, invoke_without_command=True)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cmd_version(ctx: click.Context):
|
def cmd_version(ctx: click.Context):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue