build: add subcommands to kexttool
This commit is contained in:
32
tools/kexttool/scan.py
Normal file
32
tools/kexttool/scan.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import glob
|
||||
import os
|
||||
from kexttool import kext
|
||||
|
||||
def list_all(pretty=False):
|
||||
cwd = os.getcwd()
|
||||
scan_arg = os.path.join(cwd, 'extensions', '**/extension.yaml')
|
||||
|
||||
nr_extensions = 0
|
||||
|
||||
# root_dir needs a trailing slash (i.e. /root/dir/)
|
||||
for filename in glob.iglob(scan_arg, recursive=True):
|
||||
try:
|
||||
kext_src = kext.KextSource(filename)
|
||||
except Exception as e:
|
||||
print('E: cannot read kernel extension source manifest (reason: {})'.format(e))
|
||||
continue
|
||||
|
||||
if pretty:
|
||||
print('* {}'.format(kext_src.name()))
|
||||
print(' Bundle ID: {}'.format(kext_src.id()))
|
||||
print(' License: {}'.format(kext_src.license()))
|
||||
print(' Copyright: {}'.format(kext_src.copyright()))
|
||||
print(' Location: {}'.format(kext_src.src_dirpath()))
|
||||
print(' Sources:')
|
||||
|
||||
for src in kext_src.sources():
|
||||
print(' {}'.format(src))
|
||||
else:
|
||||
print('\033[1;96m* \033[0;1m{}\033[0m ({})'.format(kext_src.id(), kext_src.src_dirpath()))
|
||||
|
||||
nr_extensions = nr_extensions + 1
|
||||
Reference in New Issue
Block a user