mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-23 05:35:44 -05:00
packages: add cmd_devices_list()
This commit is contained in:
parent
75c832cbfb
commit
6f9a013c2e
2 changed files with 18 additions and 2 deletions
|
@ -16,7 +16,7 @@ from wrapper import check_programs_wrap, enforce_wrap
|
|||
|
||||
from .build import build_packages_by_paths
|
||||
from .pkgbuild import discover_pkgbuilds, filter_pkgbuilds, init_pkgbuilds
|
||||
from .device import get_profile_device
|
||||
from .device import cmd_devices_list, get_profile_device
|
||||
|
||||
|
||||
def build(
|
||||
|
@ -50,6 +50,9 @@ def cmd_packages():
|
|||
"""Build and manage packages and PKGBUILDs"""
|
||||
|
||||
|
||||
cmd_packages.add_command(cmd_devices_list, 'devices')
|
||||
|
||||
|
||||
@cmd_packages.command(name='update')
|
||||
@click.option('--non-interactive', is_flag=True)
|
||||
def cmd_update(non_interactive: bool = False):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import click
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
@ -30,6 +31,10 @@ class Device(DataClass):
|
|||
package: Pkgbuild
|
||||
deviceinfo: Optional[DeviceInfo]
|
||||
|
||||
def __repr__(self):
|
||||
return (f'Device "{self.name}": "{self.package.description if self.package else ""}", '
|
||||
f'Architecture: {self.arch}, package: {self.package.name if self.package else "??? PROBABLY A BUG!"}')
|
||||
|
||||
def parse_deviceinfo(self, try_download: bool = True, lazy: bool = True):
|
||||
if not lazy or 'deviceinfo' not in self or self.deviceinfo is None:
|
||||
is_built = check_package_version_built(self.package, self.arch, try_download=try_download)
|
||||
|
@ -83,7 +88,7 @@ def parse_device_pkg(pkgbuild: Pkgbuild) -> Device:
|
|||
prefix = 'device-'
|
||||
if name.startswith(prefix):
|
||||
name = name[len(prefix):]
|
||||
return Device(name=name, arch=arch, package=pkgbuild)
|
||||
return Device(name=name, arch=arch, package=pkgbuild, deviceinfo=None)
|
||||
|
||||
|
||||
_device_cache: dict[str, Device] = {}
|
||||
|
@ -148,3 +153,11 @@ def get_device(name: str, pkgbuilds: Optional[dict[str, Pkgbuild]] = None, lazy:
|
|||
def get_profile_device(profile_name: Optional[str] = None, hint_or_set_arch: bool = False):
|
||||
profile = config.enforce_profile_device_set(profile_name=profile_name, hint_or_set_arch=hint_or_set_arch)
|
||||
return get_device(profile.device)
|
||||
|
||||
|
||||
@click.command(name='list')
|
||||
def cmd_devices_list():
|
||||
'list the available flavours and descriptions'
|
||||
devices = get_devices()
|
||||
for d in sorted(devices.keys()):
|
||||
print(devices[d])
|
||||
|
|
Loading…
Add table
Reference in a new issue