diff --git a/pmb/config/init.py b/pmb/config/init.py index 97891598..d75f6f1e 100644 --- a/pmb/config/init.py +++ b/pmb/config/init.py @@ -301,7 +301,8 @@ def ask_for_device(args): if not pmb.helpers.cli.confirm(args, default=True): continue else: - devices = sorted(pmb.helpers.devices.list_codenames(args, vendor)) + # Unmaintained devices can be selected, but are not displayed + devices = sorted(pmb.helpers.devices.list_codenames(args, vendor, unmaintained=False)) # Remove "vendor-" prefixes from device list codenames = [x.split('-', 1)[1] for x in devices] logging.info("Available codenames (" + str(len(codenames)) + "): " + @@ -314,7 +315,8 @@ def ask_for_device(args): codenames) device = vendor + '-' + codename - device_exists = pmb.helpers.devices.find_path(args, device, 'deviceinfo') is not None + device_path = pmb.helpers.devices.find_path(args, device, 'deviceinfo') + device_exists = device_path is not None if not device_exists: if device == args.device: raise RuntimeError( @@ -331,6 +333,12 @@ def ask_for_device(args): logging.info("Generating new aports for: {}...".format(device)) pmb.aportgen.generate(args, "device-" + device) pmb.aportgen.generate(args, "linux-" + device) + elif "/unmaintained/" in device_path: + apkbuild = device_path[:-len("deviceinfo")] + 'APKBUILD' + unmaintained = pmb.parse._apkbuild.unmaintained(apkbuild) + logging.info(f"WARNING: {device} is unmaintained: {unmaintained}") + if not pmb.helpers.cli.confirm(args): + continue break kernel = ask_for_device_kernel(args, device) diff --git a/pmb/helpers/devices.py b/pmb/helpers/devices.py index 372c6e11..d8c37c35 100644 --- a/pmb/helpers/devices.py +++ b/pmb/helpers/devices.py @@ -23,14 +23,17 @@ def find_path(args, codename, file=''): return g[0] -def list_codenames(args, vendor=None): +def list_codenames(args, vendor=None, unmaintained=True): """ Get all devices, for which aports are available :param vendor: vendor name to choose devices from, or None for all vendors + :param unmaintained: include unmaintained devices :returns: ["first-device", "second-device", ...] """ ret = [] for path in glob.glob(args.aports + "/device/*/device-*"): + if not unmaintained and '/unmaintained/' in path: + continue device = os.path.basename(path).split("-", 1)[1] if (vendor is None) or device.startswith(vendor + '-'): ret.append(device) diff --git a/pmb/parse/_apkbuild.py b/pmb/parse/_apkbuild.py index d1317790..2bf29c89 100644 --- a/pmb/parse/_apkbuild.py +++ b/pmb/parse/_apkbuild.py @@ -402,3 +402,17 @@ def maintainers(path): if '' in maintainers: raise RuntimeError("Empty (Co-)Maintainer: tag") return maintainers + + +def unmaintained(path): + """ + Return if (and why) an APKBUILD might be unmaintained. This should be + defined using a # Unmaintained: tag in the APKBUILD. + + :param path: full path to the APKBUILD + :returns: reason why APKBUILD is unmaintained, or None + """ + unmaintained = _parse_comment_tags(read_file(path), 'Unmaintained') + if not unmaintained: + return None + return '\n'.join(unmaintained) diff --git a/test/test_parse_apkbuild.py b/test/test_parse_apkbuild.py index 8315e3fc..4a5d8ae9 100644 --- a/test/test_parse_apkbuild.py +++ b/test/test_parse_apkbuild.py @@ -145,3 +145,9 @@ def test_parse_maintainers(args): ] assert pmb.parse._apkbuild.maintainers(path) == maintainers + + +def test_parse_unmaintained(args): + path = (f"{pmb_test.const.testdata}/apkbuild" + "/APKBUILD.missing-pkgdesc-in-subpackage") + assert pmb.parse._apkbuild.unmaintained(path) == "This is broken!" diff --git a/test/testdata/apkbuild/APKBUILD.missing-pkgdesc-in-subpackage b/test/testdata/apkbuild/APKBUILD.missing-pkgdesc-in-subpackage index 3c3e99b8..280da8ed 100644 --- a/test/testdata/apkbuild/APKBUILD.missing-pkgdesc-in-subpackage +++ b/test/testdata/apkbuild/APKBUILD.missing-pkgdesc-in-subpackage @@ -1,4 +1,5 @@ # Reference: +# Unmaintained: This is broken! pkgname="missing-pkgdesc-in-subpackage" arch="noarch" subpackages="$pkgname-subpackage invalid-function:does_not_exist"