diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2013-11-05 11:39:10 +0100 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2013-11-05 12:20:11 +0100 |
commit | 960de852b7b482b809e012cb34a1797999e1aa2f (patch) | |
tree | 7d1c554860190908bfb33b9f487a33ea632cd336 | |
parent | 42fb1e197607ac8920b3f8f3a583d1d540c5ae05 (diff) | |
download | vyos-live-build-960de852b7b482b809e012cb34a1797999e1aa2f.tar.gz vyos-live-build-960de852b7b482b809e012cb34a1797999e1aa2f.zip |
Adding initial stub for lb init.
In the past, we had lb config for both creating a configuration directory
and updating settings in there. With the rewrite in Python, we're now
changing this finally to the more sane 'init' (create initial 'sample'
configuration directory tree, taking most arguments that lb config did)
and 'config' which will only be a get/set program to work on top of
an already initialized configuration tree.
-rwxr-xr-x | components/init | 84 | ||||
-rwxr-xr-x | scripts/build/config | 25 |
2 files changed, 84 insertions, 25 deletions
diff --git a/components/init b/components/init new file mode 100755 index 000000000..c1dba21dc --- /dev/null +++ b/components/init @@ -0,0 +1,84 @@ +#!/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 init', + usage = '%(prog)s [arguments]', + description = '''live-build contains the components to build a live system from a configuration directory. + The init command creates an empty configuration tree or reinitialize an existing one.''', + epilog = 'See \'man lb-init\' 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') + + arguments.add_argument('--project', help='set project defaults') + + args = arguments.parse_args() + + # --verbose + verbose = args.verbose + + # --project + project = args.project + + ## Creating configuration directory + + # stagefile + if os.path.isdir('.build'): + if verbose: + print('I: configuration directory already initialized - nothing to do') + + # Note: until further tests, we do not allow to re-run lb init on an already initialized directory. + sys.exit(0) + + # Configuring default hooks + os.makedirs('config/hooks', exist_ok=True) + + for hook in glob.glob('/usr/share/live/build/hooks/*.hook*'): + os.symlink(hook, os.path.join('config/hooks/' + os.path.basename(hook))) + + # Configuring default includes + os.makedirs('config/includes', exist_ok=True) + os.makedirs('config/includes.bootstrap', exist_ok=True) + os.makedirs('config/includes.chroot', exist_ok=True) + os.makedirs('config/includes.binary', exist_ok=True) + os.makedirs('config/includes.source', exist_ok=True) + + # Configuring default package lists + os.makedirs('config/package-lists', exist_ok=True) + + f = open('config/package-lists/live.list.chroot', 'a') + f.write('live-boot\nlive-config\nlive-config-sysvinit\n') + f.close() + + ## stagefile + os.makedirs('.build', exist_ok=True) + + +if __name__ == '__main__': + main() diff --git a/scripts/build/config b/scripts/build/config index 670479def..7610d5e83 100755 --- a/scripts/build/config +++ b/scripts/build/config @@ -1350,19 +1350,6 @@ then Echo_warning "Make sure you are using the newest version at all times." fi -mkdir -p config/hooks -mkdir -p config/includes config/includes.bootstrap config/includes.chroot config/includes.binary config/includes.source - -Echo_message "Symlinking hooks..." - -for _HOOK in "${LIVE_BUILD}"/share/hooks/*.hook* /usr/share/live/build/hooks/*.hook* -do - if [ -e "${_HOOK}" ] && [ ! -e "config/hooks/$(basename ${_HOOK})" ] - then - ln -s "${_HOOK}" "config/hooks/$(basename ${_HOOK})" - fi -done - cat > config/build << EOF [Image] Architecture: ${LIVE_IMAGE_ARCHITECTURE} @@ -1475,17 +1462,5 @@ do fi done -case "${LB_SYSTEM}" in - live) - for _PACKAGE in live-boot live-config live-config-sysvinit - do - if ! grep -qs "${_PACKAGE}" config/package-lists/* - then - echo "${_PACKAGE}" >> config/package-lists/live.list.chroot - fi - done - ;; -esac - # Creating stage file Create_stagefile .build/config |