summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2013-11-04 18:46:56 +0100
committerDaniel Baumann <mail@daniel-baumann.ch>2013-11-04 18:46:56 +0100
commit8e0188c72ccbe1d9db95c40ac9b10a955b74b09b (patch)
tree2697a975ceb2caf47be29a8c2bb080bea34453e4
parent3ad37ba9f8397be6e4eb0efa750fb5c7260e51b3 (diff)
downloadvyos-live-build-8e0188c72ccbe1d9db95c40ac9b10a955b74b09b.tar.gz
vyos-live-build-8e0188c72ccbe1d9db95c40ac9b10a955b74b09b.zip
Adding sources-includes.
-rwxr-xr-xcomponents/source-includes105
-rwxr-xr-xscripts/build/source1
2 files changed, 106 insertions, 0 deletions
diff --git a/components/source-includes b/components/source-includes
new file mode 100755
index 000000000..39d0e82c9
--- /dev/null
+++ b/components/source-includes
@@ -0,0 +1,105 @@
+#!/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
+# * derefence or remove symlinks if source filesystem does not support them
+
+def main():
+ ## Parsing Arguments
+ arguments = argparse.ArgumentParser(
+ prog = 'lb source-includes',
+ usage = '%(prog)s [arguments]',
+ description = '''live-build contains the components to build a live system from a configuration directory.
+ The source-includes command copies include files into the source stage.''',
+ epilog = 'See \'man lb-source-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 source includes
+
+ # stagefile
+ if os.path.isfile('.build/source-includes'):
+ if verbose:
+ print('I: source-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.source/*') and not glob.glob('config/includes.source/.*'):
+ if verbose:
+ print ('I: no source includes found at config/includes.source - 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 source')
+
+ cpio = subprocess.call('cd config/includes && find . | cpio -dmpu --no-preserve-owner ../../source', shell=True)
+
+ if glob.glob('config/includes.source/*') and not glob.glob('config/includes.source/.*'):
+ hooks = glob.glob('config/includes.source/*') + glob.glob('config/includes.source/.*')
+
+ if verbose:
+ print('I: Copying config/includes.source to source')
+
+ cpio = subprocess.call('cd config/includes.source && find . | cpio -dmpu --no-preserve-owner ../../source', shell=True)
+
+ # stagefile
+ os.makedirs('.build', exist_ok=True)
+ open('.build/source-includes', 'w').close()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/scripts/build/source b/scripts/build/source
index d32cd44e0..3cdb0e00f 100755
--- a/scripts/build/source
+++ b/scripts/build/source
@@ -51,6 +51,7 @@ lb chroot_archives source install ${@}
lb source_live ${@}
lb source_debian ${@}
lb source_disk ${@}
+lb source-includes ${@}
lb source-hooks ${@}
lb source_checksums ${@}