From c10ceaa22516d32090d26f2baa31f22ccacdb7ab Mon Sep 17 00:00:00 2001 From: r00t Date: Sat, 30 Sep 2017 05:15:52 -0400 Subject: [PATCH] support for user-specified build.ini. untested. should probably then modify te config parser to search for a config if this is set to None, not to /etc/bdisk/build.ini. --- bdisk/bdisk.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/bdisk/bdisk.py b/bdisk/bdisk.py index 40655bd..9e288bc 100755 --- a/bdisk/bdisk.py +++ b/bdisk/bdisk.py @@ -1,4 +1,6 @@ #!/bin/env python3 + +import argparse import host import prep import bchroot @@ -10,15 +12,15 @@ import bsync import bGPG import os -# we need to: -# we also need to figure out how to implement "mentos" (old bdisk) like functionality, letting us reuse an existing chroot install if possible to save time for future builds. -# if not, though, it's no big deal. -# still on the todo: iPXE -if __name__ == '__main__': + +def bdisk(args): + # we also need to figure out how to implement "mentos" (old bdisk) like functionality, letting us reuse an + # existing chroot install if possible to save time for future builds. + # if not, though, it's no big deal. if os.getuid() != 0: exit('{0}: ERROR: BDisk *must* be run as the root user or with sudo!'.format(datetime.datetime.now())) print('{0}: Starting.'.format(datetime.datetime.now())) - conf = host.parseConfig(host.getConfig())[1] + conf = host.parseConfig(host.getConfig(conf_file = args['buildini']))[1] prep.dirChk(conf) conf['gpgobj'] = bGPG.genGPG(conf) prep.buildChroot(conf, keep = False) @@ -50,3 +52,20 @@ if __name__ == '__main__': bsync.git(conf) bsync.rsync(conf) print('{0}: Finish.'.format(datetime.datetime.now())) + +def parseArgs(): + args = argparse.ArgumentParser(description = 'BDisk - a tool for building live/rescue media.', + epilog = 'brent s. || 2017 || https://bdisk.square-r00t.net') + args.add_argument('buildini', + metavar = '/path/to/build.ini', + default = '/etc/bdisk/build.ini', + nargs = '?', + help = 'The full/absolute path to the build.ini to use for this run. The default is /etc/bdisk/build.ini, but see https://bdisk.square-r00t.net/#the_code_build_ini_code_file.') + return(args) + +def main(): + args = vars(parseArgs().parse_args()) + bdisk(args) + +if __name__ == '__main__': + main()