build: add subcommands to kexttool
This commit is contained in:
@@ -3,30 +3,25 @@
|
||||
# -*- mode: python -*-
|
||||
|
||||
import glob
|
||||
import inquirer
|
||||
import os
|
||||
from kexttool import kext
|
||||
import sys
|
||||
from kexttool import kext, scan, select
|
||||
|
||||
cwd = os.getcwd()
|
||||
scan_arg = os.path.join(cwd, 'extensions', '**/extension.yaml')
|
||||
|
||||
nr_extensions = 0
|
||||
if len(sys.argv) < 2:
|
||||
print('usage: {} <command>'.format(sys.argv[0]))
|
||||
exit(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
|
||||
cmd = sys.argv[1]
|
||||
|
||||
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:')
|
||||
commands = {
|
||||
'select': select.select_kexts,
|
||||
'list': scan.list_all
|
||||
}
|
||||
|
||||
for src in kext_src.sources():
|
||||
print(' {}'.format(src))
|
||||
if cmd not in commands:
|
||||
print('E: unknown command \'{}\''.format(cmd))
|
||||
exit(-1)
|
||||
|
||||
nr_extensions = nr_extensions + 1
|
||||
commands[cmd]()
|
||||
|
||||
Reference in New Issue
Block a user