From 72fdfeb107242903e887f8e59d5ea8f2c6184dc7 Mon Sep 17 00:00:00 2001 From: Minecrell Date: Wed, 26 Feb 2020 14:48:48 +0100 Subject: [PATCH] pmb: Fail on device ports directly in device/* (!1879) Device ports should be under the device/testing/* directory for now. In the future, devices may be moved to device/{main,community} after certain preconditions are met. --- pmb/__init__.py | 2 ++ pmb/helpers/other.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/pmb/__init__.py b/pmb/__init__.py index 88feb678..ceb13a12 100644 --- a/pmb/__init__.py +++ b/pmb/__init__.py @@ -38,6 +38,8 @@ def main(): raise RuntimeError("Work path not found, please run 'pmbootstrap" " init' to create it.") + other.check_old_devices(args) + # Migrate work folder if necessary if args.action not in ["shutdown", "zap", "log"]: other.migrate_work_folder(args) diff --git a/pmb/helpers/other.py b/pmb/helpers/other.py index b2cb0038..f759701d 100644 --- a/pmb/helpers/other.py +++ b/pmb/helpers/other.py @@ -1,5 +1,6 @@ # Copyright 2020 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later +import glob import logging import os import re @@ -173,6 +174,22 @@ def migrate_work_folder(args): " be lost.") +def check_old_devices(args): + """ + Check if there are any device ports in device/*/APKBUILD, + rather than device/*/*/APKBUILD (e.g. device/testing/...). + """ + + g = glob.glob(args.aports + "/device/*/APKBUILD") + if not g: + return + + raise RuntimeError("Found device ports outside device/testing/... " + "Please run 'pmbootstrap pull' and/or move the " + "following device ports to device/testing:\n - " + + '\n - '.join(g)) + + def validate_hostname(hostname): """ Check whether the string is a valid hostname, according to