pmbootstrap deviceinfo_parse: new action (MR 1986)

Co-Authored-By: Oliver Smith <ollieparanoid@postmarketos.org>
This commit is contained in:
timbz 2020-10-28 18:31:40 +01:00 committed by Alexey Min
parent 4d3c14f6c1
commit d0b32b3b05
No known key found for this signature in database
GPG Key ID: EBF5ECFFFEE34DED
3 changed files with 29 additions and 0 deletions

View File

@ -171,6 +171,11 @@ Use `-v` on any action to get verbose logging:
$ pmbootstrap -v build hello-world
```
Parse a single deviceinfo and return it as JSON:
```
$ pmbootstrap deviceinfo_parse pine64-pinephone
```
Parse a single APKBUILD and return it as JSON:
```
$ pmbootstrap apkbuild_parse hello-world

View File

@ -15,6 +15,7 @@ import pmb.chroot.other
import pmb.config
import pmb.export
import pmb.flasher
import pmb.helpers.devices
import pmb.helpers.git
import pmb.helpers.lint
import pmb.helpers.logging
@ -367,6 +368,20 @@ def kconfig(args):
pmb.build.menuconfig(args, args.package)
def deviceinfo_parse(args):
# Default to all devices
devices = args.devices
if not devices:
devices = pmb.helpers.devices.list_codenames(args)
# Iterate over all devices
kernel = args.deviceinfo_parse_kernel
for device in devices:
print(f"{device}, with kernel={kernel}:")
print(json.dumps(pmb.parse.deviceinfo(args, device, kernel), indent=4,
sort_keys=True))
def apkbuild_parse(args):
# Default to all packages
packages = args.packages

View File

@ -623,6 +623,15 @@ def arguments():
" a kernel compiled with envkernel.sh.")
add_packages_arg(build, nargs="+")
# Action: deviceinfo_parse
deviceinfo_parse = sub.add_parser("deviceinfo_parse")
deviceinfo_parse.add_argument("devices", nargs="*")
deviceinfo_parse.add_argument("--kernel", help="the kernel to select (for"
" device packages with multiple kernels),"
" e.g. 'downstream', 'mainline'",
dest="deviceinfo_parse_kernel",
metavar="KERNEL")
# Action: apkbuild_parse
apkbuild_parse = sub.add_parser("apkbuild_parse")
add_packages_arg(apkbuild_parse, nargs="*")