diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2013-11-04 18:59:23 +0100 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2013-11-04 18:59:23 +0100 |
commit | 4fa62f53fa66984487d753c0f599a5be013fa1b1 (patch) | |
tree | 74a5cf2cdfdf39a10ad540d8bfe852760200124c | |
parent | 3dbe0430d968a3b3f019a759bfe7448e3f497daf (diff) | |
download | vyos-live-build-4fa62f53fa66984487d753c0f599a5be013fa1b1.tar.gz vyos-live-build-4fa62f53fa66984487d753c0f599a5be013fa1b1.zip |
Adding bootstrap-includes.
-rwxr-xr-x | components/bootstrap-includes | 104 | ||||
-rwxr-xr-x | scripts/build/bootstrap | 1 |
2 files changed, 105 insertions, 0 deletions
diff --git a/components/bootstrap-includes b/components/bootstrap-includes new file mode 100755 index 000000000..f02235ada --- /dev/null +++ b/components/bootstrap-includes @@ -0,0 +1,104 @@ +#!/usr/bin/python3 + +## live-build(7) - Live System Build Components +## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch> +## +## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING. +## This is free software, and you are welcome to redistribute it +## under certain conditions; see COPYING for details. + + +import argparse +import configparser +import glob +import os +import shutil +import subprocess +import sys + + +# TODO: +# * logfile output +# * lockfile handling +# * use gettext for i18n + +def main(): + ## Parsing Arguments + arguments = argparse.ArgumentParser( + prog = 'lb bootstrap-includes', + usage = '%(prog)s [arguments]', + description = '''live-build contains the components to build a live system from a configuration directory. + The bootstrap-includes command copies include files into the bootstrap stage.''', + epilog = 'See \'man lb-bootstrap-includes\' for more information.', + formatter_class = argparse.ArgumentDefaultsHelpFormatter + ) + + arguments.add_argument('--version', help='show program\'s version number and exit', action='version', version='live-build 4') + arguments.add_argument('--verbose', help='set verbose option', action='store_true') + + args = arguments.parse_args() + + # --verbose + verbose = args.verbose + + ## Copying bootstrap includes + + # stagefile + if os.path.isfile('.build/bootstrap-includes'): + if verbose: + print('I: bootstrap-includes already done - nothing to do') + + sys.exit(0) + + # dependencies + if not os.path.isfile('.build/bootstrap'): + print('E: bootstrap stage missing - aborting', file=sys.stderr) + + if verbose: + print('I: use \'lb bootstrap\' to bootstrap system') + + sys.exit(1) + + if not os.path.isfile('/bin/cpio'): + print('E: /bin/cpio - no such file', file=sys.stderr) + + if verbose: + print('I: cpio can be obtained from:\n' + 'I: http://www.gnu.org/software/cpio/\n' + 'I: http://ftp.gnu.org/gnu/cpio/\n' + 'I: On Debian based systems, cpio can be installed with:\n' + 'I: # sudo apt-get install cpio') + + sys.exit(1) + + # includes + if not glob.glob('config/includes/*') and not glob.glob('config/includes/.*') and not glob.glob('config/includes.bootstrap/*') and not glob.glob('config/includes.bootstrap/.*'): + if verbose: + print ('I: no bootstrap includes found at config/includes.bootstrap - nothing to do') + + sys.exit(0) + + # process includes + if glob.glob('config/includes/*') or glob.glob('config/includes/.*'): + hooks = glob.glob('config/includes/*') + glob.glob('config/includes/.*') + + if verbose: + print('I: Copying config/includes to chroot') + + cpio = subprocess.call('cd config/includes && find . | cpio -dmpu --no-preserve-owner ../../chroot', shell=True) + + if glob.glob('config/includes.bootstrap/*') and not glob.glob('config/includes.bootstrap/.*'): + hooks = glob.glob('config/includes.bootstrap/*') + glob.glob('config/includes.bootstrap/.*') + + if verbose: + print('I: Copying config/includes.bootstrap to chroot') + + cpio = subprocess.call('cd config/includes.bootstrap && find . | cpio -dmpu --no-preserve-owner ../../chroot', shell=True) + + # stagefile + os.makedirs('.build', exist_ok=True) + open('.build/bootstrap-includes', 'w').close() + + +if __name__ == '__main__': + main() diff --git a/scripts/build/bootstrap b/scripts/build/bootstrap index 006d9d628..2249d69c6 100755 --- a/scripts/build/bootstrap +++ b/scripts/build/bootstrap @@ -53,6 +53,7 @@ lb chroot_hostname install ${@} lb chroot_apt install ${@} lb bootstrap_archives binary ${@} +lb bootstrap-includes ${@} lb bootstrap-hooks ${@} # Deconfiguring chroot |