summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--README.Python21
-rwxr-xr-xcomponents/binary-hooks108
-rwxr-xr-xcomponents/binary-includes101
-rwxr-xr-xcomponents/bootstrap-cdebootstrap183
-rwxr-xr-xcomponents/bootstrap-debootstrap180
-rwxr-xr-xcomponents/bootstrap-hooks108
-rwxr-xr-xcomponents/bootstrap-includes100
-rwxr-xr-xcomponents/chroot-hooks108
-rwxr-xr-xcomponents/chroot-includes100
-rwxr-xr-xcomponents/init165
-rwxr-xr-xcomponents/source-hooks108
-rwxr-xr-xcomponents/source-includes101
-rw-r--r--debian/control1
-rwxr-xr-xfrontend/cli/lb4
-rwxr-xr-xscripts/build/binary4
-rwxr-xr-xscripts/build/binary_hooks78
-rwxr-xr-xscripts/build/binary_includes57
-rwxr-xr-xscripts/build/bootstrap8
-rwxr-xr-xscripts/build/bootstrap_archive-keys77
-rwxr-xr-xscripts/build/bootstrap_cache86
-rwxr-xr-xscripts/build/bootstrap_cdebootstrap143
-rwxr-xr-xscripts/build/bootstrap_debootstrap139
-rwxr-xr-xscripts/build/build1
-rwxr-xr-xscripts/build/chroot4
-rwxr-xr-xscripts/build/chroot_hooks115
-rwxr-xr-xscripts/build/chroot_includes50
-rwxr-xr-xscripts/build/chroot_live-packages87
-rwxr-xr-xscripts/build/config17
-rwxr-xr-xscripts/build/source4
-rwxr-xr-xscripts/build/source_debian-live62
-rwxr-xr-xscripts/build/source_hooks78
32 files changed, 998 insertions, 1401 deletions
diff --git a/Makefile b/Makefile
index 5374e0205..d79c79aac 100644
--- a/Makefile
+++ b/Makefile
@@ -49,7 +49,6 @@ install:
mkdir -p $(DESTDIR)/usr/lib/live
cp -a scripts/* $(DESTDIR)/usr/lib/live
- cp -a components/* $(DESTDIR)/usr/lib/live/build
# Installing documentation
mkdir -p $(DESTDIR)/usr/share/doc/live-build
diff --git a/README.Python b/README.Python
deleted file mode 100644
index 153cd8ea1..000000000
--- a/README.Python
+++ /dev/null
@@ -1,21 +0,0 @@
-live-build 4.x is transitioning from shell scripts to Python scripts.
-
-In order to ensure a smooth transition without breaks until completion,
-one component at the time is being rewritten and re-documented without
-interconnection between them.
-
-Once done, the newly Python sources will be shaped into modules and
-subcommands properly.
-
----
-
-Some notes on coding style:
-
- * live-build commands should be *prefixed* with the stage:
- chroot-includes, not includes-chroot; -> tab-completion
-
- * directories/files in the config directory should be *suffixed* with the stage:
- includes.chroot, not chroot.includes; -> sort-order
-
- * cli arguments should be *suffixed* with the stage:
- --mirror-bootstrap, not --bootstrap-mirror; -> tab-completion
diff --git a/components/binary-hooks b/components/binary-hooks
deleted file mode 100755
index 20c5c0190..000000000
--- a/components/binary-hooks
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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 binary-hooks',
- usage = '%(prog)s [arguments]',
- description = '''live-build contains the components to build a live system from a configuration directory.
- The binary-hooks command executes hook files after the binary stage.''',
- epilog = 'See \'man lb-binary-hooks\' 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
-
- ## Calling binary hooks
-
- # stagefile
- if os.path.isfile('.build/binary-hooks'):
- if verbose:
- print('I: binary-hooks 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)
-
- # hooks
- if not glob.glob('config/hooks/*.hook') and not glob.glob('config/hooks/*.hook.binary'):
- if verbose:
- print ('I: no binary hooks found at config/hooks/*.hook{,.binary} - nothing to do')
-
- sys.exit(0)
-
- # bind mount configuration directory
- if verbose:
- print('I: Mounting config to binary/live-build/config')
-
- os.makedirs('binary/live-build/config', exist_ok=True)
-
- mount = subprocess.check_call('mount -o bind config binary/live-build/config', shell=True)
- remount = subprocess.check_call('mount -o remount,ro,bind binary/live-build/config', shell=True)
-
- # process hooks
- os.makedirs('binary/live-build', exist_ok=True)
-
- hooks = glob.glob('config/hooks/*.hook') + glob.glob('config/hooks/*.hook.binary')
-
- for hook in sorted(hooks):
- if verbose:
- print('I: Copying config/hooks/*.hook.binary to binary/live-build')
-
- shutil.copy(hook, os.path.join('binary/live-build/' + os.path.basename(hook)), follow_symlinks=True)
-
- if verbose:
- print('I: Executing \' ' + hook + '\'')
-
- os.chmod(hook, 0o755)
- exec_hook = subprocess.check_call('cd binary && live-build/' + os.path.basename(hook), shell=True)
- os.remove('binary/live-build/' + os.path.basename(hook))
-
- # unmount coniguration directory
- umount = subprocess.check_call('umount binary/live-build/config', shell=True)
-
- os.rmdir('binary/live-build/config')
- os.rmdir('binary/live-build')
-
- ## stagefile
- os.makedirs('.build', exist_ok=True)
- open('.build/binary-hooks', 'w').close()
-
-
-if __name__ == '__main__':
- main()
diff --git a/components/binary-includes b/components/binary-includes
deleted file mode 100755
index 5b829aeba..000000000
--- a/components/binary-includes
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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 binary filesystem does not support them
-
-def main():
- ## Parsing Arguments
- arguments = argparse.ArgumentParser(
- prog = 'lb binary-includes',
- usage = '%(prog)s [arguments]',
- description = '''live-build contains the components to build a live system from a configuration directory.
- The binary-includes command copies include files into the binary stage.''',
- epilog = 'See \'man lb-binary-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 binary includes
-
- # stagefile
- if os.path.isfile('.build/binary-includes'):
- if verbose:
- print('I: binary-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.binary/*') and not glob.glob('config/includes.binary/.*'):
- if verbose:
- print ('I: no binary includes found at config/includes{,.binary} - nothing to do')
-
- sys.exit(0)
-
- # process includes
- if glob.glob('config/includes/*') or glob.glob('config/includes/.*'):
- if verbose:
- print('I: Copying config/includes to binary')
-
- cpio = subprocess.check_call('cd config/includes && find . | cpio -dmpu --no-preserve-owner ../../binary', shell=True)
-
- if glob.glob('config/includes.binary/*') or glob.glob('config/includes.binary/.*'):
- if verbose:
- print('I: Copying config/includes.binary to binary')
-
- cpio = subprocess.check_call('cd config/includes.binary && find . | cpio -dmpu --no-preserve-owner ../../binary', shell=True)
-
- # stagefile
- os.makedirs('.build', exist_ok=True)
- open('.build/binary-includes', 'w').close()
-
-
-if __name__ == '__main__':
- main()
diff --git a/components/bootstrap-cdebootstrap b/components/bootstrap-cdebootstrap
deleted file mode 100755
index 59c83c8df..000000000
--- a/components/bootstrap-cdebootstrap
+++ /dev/null
@@ -1,183 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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
-# * cdebootstrap-options from config/options/cdebootstrap
-# * take mirrors from config/archives/mirror.{bootstrap,chroot}
-
-def main():
- ## Parsing Arguments
- arguments = argparse.ArgumentParser(
- prog = 'lb bootstrap-cdebootstrap',
- usage = '%(prog)s [arguments]',
- description = '''live-build contains the components to build a live system from a configuration directory.
- The bootstrap-cdebootstrap command bootstraps the chroot system with cdebootstrap.''',
- epilog = 'See \'man lb-bootstrap-cdebootstrap\' 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('--cdebootstrap-options', help='set cdebootstrap(1) options' )
-
- args = arguments.parse_args()
-
- ## Parsing Configuration
- if not os.path.isfile('config/build'):
- print('E: config/build - no such file', file=sys.stderr)
-
- sys.exit(1)
-
- config = configparser.ConfigParser()
-
- config.read('config/build')
-
- try:
- architecture = config.get('Image', 'Architecture')
- distribution = config.get('Image', 'Parent-Distribution')
- mirror_bootstrap = config.get('Image', 'Parent-Mirror-Bootstrap')
- except:
- distribution = config.get('Image', 'Distribution')
- mirror_bootstrap = config.get('Image', 'Mirror-Bootstrap')
-
- # --verbose
- verbose = args.verbose
-
- # --cdebootstrap-options
- cdebootstrap_options_late = distribution + ' chroot ' + mirror_bootstrap
-
- cdebootstrap_options_early = ''
-
- if (architecture) and (not architecture == 'auto'):
- cdebootstrap_options_early = cdebootstrap_options_early + ' --arch=' + architecture
-
- if args.cdebootstrap_options:
- cdebootstrap_options = cdebootstrap_options_early + ' ' + args.cdebootstrap_options + ' ' + cdebootstrap_options_late
- else:
- cdebootstrap_options = cdebootstrap_options_early + ' ' + cdebootstrap_options_late
-
- ## Calling cdebootstrap
-
- # stagefile
- if os.path.isfile('.build/bootstrap'):
- if verbose:
- print('I: bootstrap already done - nothing to do')
-
- sys.exit(0)
-
- # dependencies
- if not os.path.isfile('/usr/bin/cdebootstrap'):
- print('E: /usr/bin/cdebootstrap - no such file', file=sys.stderr)
-
- if verbose:
- print('I: cdebootstrap can be obtained from:\n'
- 'I: http://anonscm.debian.org/gitweb/?p=users/waldi/cdebootstrap.git\n'
- 'I: http://ftp.debian.org/debian/pool/main/c/cdebootstrap/\n'
- 'I: On Debian based systems, cdebootstrap can be installed with:\n'
- 'I: # sudo apt-get install cdebootstrap')
-
- sys.exit(1)
-
- # clean
- if os.path.exists('chroot'):
- print('E: chroot already exists - unclean build', file=sys.stderr)
-
- if verbose:
- print('I: use \'lb clean\' to clean up a previously incomplete build')
-
- sys.exit(1)
-
- # stage cache
- if os.path.exists('cache/bootstrap'):
- if verbose:
- print('I: Copying cache/bootstrap to chroot')
-
- # Notes:
- # * there's no Python equivalent to 'cp -a' that handels both symlinks and device nodes properly.
- cache = subprocess.check_call('cp -a cache/bootstrap chroot', shell=True)
-
- os.makedirs('.build', exist_ok=True)
- open('.build/bootstrap', 'w').close()
-
- sys.exit(0)
-
- # packages cache
- if glob.glob('cache/packages.bootstrap/*.deb'):
- if verbose:
- print('I: Copying cache/packages.bootstrap/*.deb to chroot/var/cache/bootstrap/*.deb')
-
- # Notes:
- # * copy instead of move to make cache survive incomplete build
- os.makedirs('chroot/var/cache/bootstrap', exist_ok=True)
-
- for package in glob.glob('cache/packages.bootstrap/*.deb'):
- os.link(package, os.path.join('chroot/var/cache/bootstrap/' + os.path.basename(package)))
- else:
- # cdebootstrap
- if verbose:
- print('I: Calling \'/usr/bin/debootstrap --download-only ' + cdebootstrap_options + '\'')
-
- # Notes:
- # * calling cdebootstrap twice:
- # - to use already downloaded /var/cache/bootstrap/*.deb on incomplete builds
- # - to use /var/cache/boottrap/*.deb for debian-installer
- cdebootstrap = subprocess.check_call('/usr/bin/cdebootstrap --download-only ' + cdebootstrap_options, shell=True)
-
- # package cache
- if glob.glob('chroot/var/cache/bootstrap/*.deb'):
- if verbose:
- print('I: Copying chroot/var/cache/bootstrap/*.deb to cache/packages.bootstrap')
-
- # Notes:
- # * remove first to keep cache minimal
- # * remove files instead of directory to work with symlinked directory
- for package in glob.glob('cache/packages.bootstrap/*.deb'):
- os.remove(package)
-
- os.makedirs('cache/packages.bootstrap', exist_ok=True)
-
- for package in glob.glob('chroot/var/cache/bootstrap/*.deb'):
- shutil.copy2(package, 'cache/packages.bootstrap')
-
- # cdebootstrap
- if not os.path.exists('chroot/bin'):
- if verbose:
- print('I: Calling \'/usr/bin/debootstrap ' + cdebootstrap_options + '\'')
-
- cdebootstrap = subprocess.check_call('/usr/bin/cdebootstrap ' + cdebootstrap_options, shell=True)
-
- # stage cache
- if not os.path.exists('cache/bootstrap'):
- if verbose:
- print('I: Copying chroot to cache/bootstrap')
-
- # Notes:
- # * there's no Python equivalent to 'cp -a' that handels both symlinks and device nodes properly.
- cache = subprocess.check_call('cp -a chroot cache/bootstrap', shell=True)
-
- # stagefile
- os.makedirs('.build', exist_ok=True)
- open('.build/bootstrap', 'w').close()
-
-
-if __name__ == '__main__':
- main()
diff --git a/components/bootstrap-debootstrap b/components/bootstrap-debootstrap
deleted file mode 100755
index 70974be6e..000000000
--- a/components/bootstrap-debootstrap
+++ /dev/null
@@ -1,180 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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
-# * debootstrap-options from config/options/debootstrap
-# * take mirrors from config/archives/mirror.{bootstrap,chroot}
-
-def main():
- ## Parsing Arguments
- arguments = argparse.ArgumentParser(
- prog = 'lb bootstrap-debootstrap',
- usage = '%(prog)s [arguments]',
- description = '''live-build contains the components to build a live system from a configuration directory.
- The bootstrap-debootstrap command bootstraps the chroot system with debootstrap.''',
- epilog = 'See \'man lb-bootstrap-debootstrap\' 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('--debootstrap-options', help='set debootstrap(8) options' )
-
- args = arguments.parse_args()
-
- ## Parsing Configuration
- if not os.path.isfile('config/build'):
- print('E: config/build - no such file', file=sys.stderr)
-
- sys.exit(1)
-
- config = configparser.ConfigParser()
-
- config.read('config/build')
-
- try:
- architecture = config.get('Image', 'Architecture')
- archive_areas = config.get('Image', 'Parent-Archive-Areas')
- distribution = config.get('Image', 'Parent-Distribution')
- mirror_bootstrap = config.get('Image', 'Parent-Mirror-Bootstrap')
- except:
- archive_areas = config.get('Image', 'Archive-Areas')
- distribution = config.get('Image', 'Distribution')
- mirror_bootstrap = config.get('Image', 'Mirror-Bootstrap')
-
- # --verbose
- verbose = args.verbose
-
- # --debootstrap-options
- debootstrap_options_late = distribution + ' chroot ' + mirror_bootstrap
-
- debootstrap_options_early = ''
-
- if (architecture) and (not architecture == 'auto'):
- debootstrap_options_early = debootstrap_options_early + ' --arch=' + architecture
-
- if (archive_areas) and (not archive_areas == 'main'):
- debootstrap_options_early = debootstrap_options_early + ' --components=' + archive_areas.replace(' ',',')
-
- if args.debootstrap_options:
- debootstrap_options = debootstrap_options_early + ' ' + args.debootstrap_options + ' ' + debootstrap_options_late
- else:
- debootstrap_options = debootstrap_options_early + ' ' + debootstrap_options_late
-
- ## Calling debootstrap
-
- # stagefile
- if os.path.isfile('.build/bootstrap'):
- if verbose:
- print('I: bootstrap already done - nothing to do')
-
- sys.exit(0)
-
- # dependencies
- if not os.path.isfile('/usr/sbin/debootstrap'):
- print('E: /usr/sbin/debootstrap - no such file', file=sys.stderr)
-
- if verbose:
- print('I: debootstrap can be obtained from:\n'
- 'I: http://anonscm.debian.org/gitweb/?p=d-i/debootstrap.git\n'
- 'I: http://ftp.debian.org/debian/pool/main/d/debootstrap/\n'
- 'I: On Debian based systems, debootstrap can be installed with:\n'
- 'I: # sudo apt-get install debootstrap')
-
- sys.exit(1)
-
- # clean
- if os.path.exists('chroot'):
- print('E: chroot already exists - unclean build', file=sys.stderr)
-
- if verbose:
- print('I: use \'lb clean\' to clean up a previously incomplete build')
-
- sys.exit(1)
-
- # stage cache
- if os.path.exists('cache/bootstrap'):
- if verbose:
- print('I: Copying cache/bootstrap to chroot')
-
- # Notes:
- # * there's no Python equivalent to 'cp -a' that handels both symlinks and device nodes properly.
- cache = subprocess.check_call('cp -a cache/bootstrap chroot', shell=True)
-
- os.makedirs('.build', exist_ok=True)
- open('.build/bootstrap', 'w').close()
-
- sys.exit(0)
-
- # packages cache
- if glob.glob('cache/packages.bootstrap/*.deb'):
- if verbose:
- print('I: Copying cache/packages.bootstrap/*.deb to chroot/var/cache/apt/archives/*.deb')
-
- # Notes:
- # * copy instead of move to make cache survive incomplete build
- os.makedirs('chroot/var/cache/apt/archives', exist_ok=True)
-
- for package in glob.glob('cache/packages.bootstrap/*.deb'):
- os.link(package, os.path.join('chroot/var/cache/apt/archives/' + os.path.basename(package)))
-
- # debootstrap
- if not os.path.exists('chroot/bin'):
- if verbose:
- print('I: Calling \'/usr/sbin/debootstrap ' + debootstrap_options + '\'')
-
- debootstrap = subprocess.check_call('/usr/sbin/debootstrap ' + debootstrap_options, shell=True)
-
- # package cache
- if glob.glob('chroot/var/cache/apt/archives/*.deb'):
- if verbose:
- print('I: Copying chroot/var/cache/apt/archives/*.deb to cache/packages.bootstrap')
-
- # Notes:
- # * remove first to keep cache minimal,
- # * remove files instead of directory to work with symlinked directory
- for package in glob.glob('cache/packages.bootstrap/*.deb'):
- os.remove(package)
-
- os.makedirs('cache/packages.bootstrap', exist_ok=True)
-
- # Notes:
- # * move instead of copy to keep stage minimal
- for package in glob.glob('chroot/var/cache/apt/archives/*.deb'):
- shutil.move(package, 'cache/packages.bootstrap')
-
- # stage cache
- if not os.path.exists('cache/bootstrap'):
- if verbose:
- print('I: Copying chroot to cache/bootstrap')
-
- # Notes:
- # * there's no Python equivalent to 'cp -a' that handels both symlinks and device nodes properly.
- cache = subprocess.check_call('cp -a chroot cache/bootstrap', shell=True)
-
- # stagefile
- os.makedirs('.build', exist_ok=True)
- open('.build/bootstrap', 'w').close()
-
-
-if __name__ == '__main__':
- main()
diff --git a/components/bootstrap-hooks b/components/bootstrap-hooks
deleted file mode 100755
index 694d66b95..000000000
--- a/components/bootstrap-hooks
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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-hooks',
- usage = '%(prog)s [arguments]',
- description = '''live-build contains the components to build a live system from a configuration directory.
- The bootstrap-hooks command executes hook files after the bootstrap stage.''',
- epilog = 'See \'man lb-bootstrap-hooks\' 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
-
- ## Calling bootstrap hooks
-
- # stagefile
- if os.path.isfile('.build/bootstrap-hooks'):
- if verbose:
- print('I: bootstrap-hooks 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)
-
- # hooks
- if not glob.glob('config/hooks/*.hook') and not glob.glob('config/hooks/*.hook.bootstrap'):
- if verbose:
- print ('I: no bootstrap hooks found at config/hooks/*.hook{,.bootstrap} - nothing to do')
-
- sys.exit(0)
-
- # bind mount configuration directory
- if verbose:
- print('I: Mounting config to chroot/live-build/config')
-
- os.makedirs('chroot/live-build/config', exist_ok=True)
-
- mount = subprocess.check_call('mount -o bind config chroot/live-build/config', shell=True)
- remount = subprocess.check_call('mount -o remount,ro,bind chroot/live-build/config', shell=True)
-
- # process hooks
- os.makedirs('chroot/live-build', exist_ok=True)
-
- hooks = glob.glob('config/hooks/*.hook') + glob.glob('config/hooks/*.hook.bootstrap')
-
- for hook in sorted(hooks):
- if verbose:
- print('I: Copying config/hooks/*.hook.bootstrap to chroot/live-build')
-
- shutil.copy(hook, os.path.join('chroot/live-build/' + os.path.basename(hook)), follow_symlinks=True)
-
- if verbose:
- print('I: Executing \' ' + hook + '\'')
-
- os.chmod(hook, 0o755)
- exec_hook = subprocess.check_call('chroot chroot /live-build/' + os.path.basename(hook), shell=True)
- os.remove('chroot/live-build/' + os.path.basename(hook))
-
- # unmount coniguration directory
- umount = subprocess.check_call('umount chroot/live-build/config', shell=True)
-
- os.rmdir('chroot/live-build/config')
- os.rmdir('chroot/live-build')
-
- # stagefile
- os.makedirs('.build', exist_ok=True)
- open('.build/bootstrap-hooks', 'w').close()
-
-
-if __name__ == '__main__':
- main()
diff --git a/components/bootstrap-includes b/components/bootstrap-includes
deleted file mode 100755
index 2ce677282..000000000
--- a/components/bootstrap-includes
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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/.*'):
- if verbose:
- print('I: Copying config/includes to chroot')
-
- cpio = subprocess.check_call('cd config/includes && find . | cpio -dmpu --no-preserve-owner ../../chroot', shell=True)
-
- if glob.glob('config/includes.bootstrap/*') or glob.glob('config/includes.bootstrap/.*'):
- if verbose:
- print('I: Copying config/includes.bootstrap to chroot')
-
- cpio = subprocess.check_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/components/chroot-hooks b/components/chroot-hooks
deleted file mode 100755
index 6d973afea..000000000
--- a/components/chroot-hooks
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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 chroot-hooks',
- usage = '%(prog)s [arguments]',
- description = '''live-build contains the components to build a live system from a configuration directory.
- The chroot-hooks command executes hook files after the chroot stage.''',
- epilog = 'See \'man lb-chroot-hooks\' 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
-
- ## Calling chroot hooks
-
- # stagefile
- if os.path.isfile('.build/chroot-hooks'):
- if verbose:
- print('I: chroot-hooks 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)
-
- # hooks
- if not glob.glob('config/hooks/*.hook') and not glob.glob('config/hooks/*.hook.chroot'):
- if verbose:
- print ('I: no chroot hooks found at config/hooks/*.hook{,.chroot} - nothing to do')
-
- sys.exit(0)
-
- # bind mount configuration directory
- if verbose:
- print('I: Mounting config to chroot/live-build/config')
-
- os.makedirs('chroot/live-build/config', exist_ok=True)
-
- mount = subprocess.check_call('mount -o bind config chroot/live-build/config', shell=True)
- remount = subprocess.check_call('mount -o remount,ro,bind chroot/live-build/config', shell=True)
-
- # process hooks
- os.makedirs('chroot/live-build', exist_ok=True)
-
- hooks = glob.glob('config/hooks/*.hook') + glob.glob('config/hooks/*.hook.chroot')
-
- for hook in sorted(hooks):
- if verbose:
- print('I: Copying config/hooks/*.hook.chroot to chroot/live-build')
-
- shutil.copy(hook, os.path.join('chroot/live-build/' + os.path.basename(hook)), follow_symlinks=True)
-
- if verbose:
- print('I: Executing \' ' + hook + '\'')
-
- os.chmod(hook, 0o755)
- exec_hook = subprocess.check_call('chroot chroot /live-build/' + os.path.basename(hook), shell=True)
- os.remove('chroot/live-build/' + os.path.basename(hook))
-
- # unmount coniguration directory
- umount = subprocess.check_call('umount chroot/live-build/config', shell=True)
-
- os.rmdir('chroot/live-build/config')
- os.rmdir('chroot/live-build')
-
- # stagefile
- os.makedirs('.build', exist_ok=True)
- open('.build/chroot-hooks', 'w').close()
-
-
-if __name__ == '__main__':
- main()
diff --git a/components/chroot-includes b/components/chroot-includes
deleted file mode 100755
index a961db6cf..000000000
--- a/components/chroot-includes
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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 chroot-includes',
- usage = '%(prog)s [arguments]',
- description = '''live-build contains the components to build a live system from a configuration directory.
- The chroot-includes command copies include files into the chroot stage.''',
- epilog = 'See \'man lb-chroot-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 chroot includes
-
- # stagefile
- if os.path.isfile('.build/chroot-includes'):
- if verbose:
- print('I: chroot-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.chroot/*') and not glob.glob('config/includes.chroot/.*'):
- if verbose:
- print ('I: no chroot includes found at config/includes{,.chroot} - nothing to do')
-
- sys.exit(0)
-
- # process includes
- if glob.glob('config/includes/*') or glob.glob('config/includes/.*'):
- if verbose:
- print('I: Copying config/includes to chroot')
-
- cpio = subprocess.check_call('cd config/includes && find . | cpio -dmpu --no-preserve-owner ../../chroot', shell=True)
-
- if glob.glob('config/includes.chroot/*') or glob.glob('config/includes.chroot/.*'):
- if verbose:
- print('I: Copying config/includes.chroot to chroot')
-
- cpio = subprocess.check_call('cd config/includes.chroot && find . | cpio -dmpu --no-preserve-owner ../../chroot', shell=True)
-
- # stagefile
- os.makedirs('.build', exist_ok=True)
- open('.build/chroot-includes', 'w').close()
-
-
-if __name__ == '__main__':
- main()
diff --git a/components/init b/components/init
deleted file mode 100755
index c6eb21992..000000000
--- a/components/init
+++ /dev/null
@@ -1,165 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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
-import urllib.request
-
-
-# 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 directory 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('--distribution', help='set default distribution')
- arguments.add_argument('--project', help='set project defaults')
-
- args = arguments.parse_args()
-
- # --verbose
- verbose = args.verbose
-
- # --distribution
- distribution = args.distribution
-
- # --project
- project = args.project
-
- ## Setting defaults
-
- if not project:
- # FIXME: hardcoded project information
- project = 'debian'
-
- if not distribution:
- # FIXME hardcoded release information
- default_distribution = { 'debian' : 'jessie',
- 'progress-linux' : 'cairon',
- }
-
- distribution = default_distribution[project]
-
- ## Creating configuration directory
-
- # stagefile
- if os.path.isdir('.build'):
- if verbose:
- print('I: configuration directory already initialized - nothing to do')
-
- # Notes:
- # * until further tests, we do not allow to re-run lb init on an already initialized directory.
- sys.exit(0)
-
- # Print warning about live-build development version
- print('WARNING: THIS VERSION OF LIVE-BUILD IS EXPERIMENTAL\n')
-
- print('IT IS UNFINISHED AND CHANGES HEAVILY WITHOUT PRIOR NOTICE.')
- print('USER DISCRETION IS ADVISED.\n')
-
- print('Please also note that you are running a live-build development version')
- print('and that we are only supporting the newest development version.\n')
-
- print('Make sure you are using the newest version at all times.')
-
- # Configuring default archive-keys
- if (project == 'progress-linux'):
- # dependencies
- if not os.path.isfile('/usr/bin/gpgv'):
- print('E: /usr/bin/gpgv - no such file', file=sys.stderr)
-
- if verbose:
- print('I: gnupg can be obtained from:\n'
- 'I: http://www.gnupg.org/\n'
- 'I: On Debian based systems, gnupg can be installed with:\n'
- 'I: # sudo apt-get install gnupg')
-
- sys.exit(1)
-
- os.makedirs('config/archives', exist_ok=True)
-
- # FIXME hardcoded release information
- archive_keys_url = 'http://cdn.archive.progress-linux.org/packages/project/keys/'
-
- archive_keys = { 'artax' : [ 'archive-key-1-artax.asc' , 'archive-key-1+-artax-backports.asc' ],
- 'artax-backports' : [ 'archive-key-1-artax.asc' , 'archive-key-1+-artax-backports.asc' ],
- 'baureo' : [ 'archive-key-2-baureo.asc' , 'archive-key-2+-baureo-backports.asc' ],
- 'baureo-backports' : [ 'archive-key-2-baureo.asc' , 'archive-key-2+-baureo-backports.asc' ],
- 'cairon' : [ 'archive-key-3-cairon.asc' , 'archive-key-3+-cairon-backports.asc' ],
- 'cairon-backports' : [ 'archive-key-3-cairon.asc' , 'archive-key-3+-cairon-backports.asc' ],
- }
-
- keys = archive_keys[distribution]
-
- for key in keys:
- url = archive_keys_url + key
- target = os.path.splitext(os.path.basename(key))
-
- if verbose:
- print('I: Downloading ' + url)
-
- r = urllib.request.urlopen(url)
- f = open('config/archives/' + target[0] + '.key', 'w')
-
- f.write(r.read())
-
- # FIXME: download signatures and verify them against debian-keyring
-
- # 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)
-
- # Ensure correct include directory permissions avoiding tainting of target system
- os.chmod('config/includes', 0o755)
- os.chmod('config/includes.bootstrap', 0o755)
- os.chmod('config/includes.chroot', 0o755)
- os.chmod('config/includes.binary', 0o755)
- os.chmod('config/includes.source', 0o755)
-
- # Configuring default package lists
- os.makedirs('config/package-lists', exist_ok=True)
-
- f = open('config/package-lists/live.list.chroot', 'w')
- 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/components/source-hooks b/components/source-hooks
deleted file mode 100755
index 552e228da..000000000
--- a/components/source-hooks
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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 source-hooks',
- usage = '%(prog)s [arguments]',
- description = '''live-build contains the components to build a live system from a configuration directory.
- The source-hooks command executes hook files after the source stage.''',
- epilog = 'See \'man lb-source-hooks\' 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
-
- ## Calling source hooks
-
- # stagefile
- if os.path.isfile('.build/source-hooks'):
- if verbose:
- print('I: source-hooks already done - nothing to do')
-
- sys.exit(0)
-
- # dependencies
- if not os.path.isfile('.build/source'):
- print('E: source stage missing - aborting', file=sys.stderr)
-
- if verbose:
- print('I: use \'lb source\' to source system')
-
- sys.exit(1)
-
- # hooks
- if not glob.glob('config/hooks/*.hook') and not glob.glob('config/hooks/*.hook.source'):
- if verbose:
- print ('I: no source hooks found at config/hooks/*.hook{,.source} - nothing to do')
-
- sys.exit(0)
-
- # bind mount configuration directory
- if verbose:
- print('I: Mounting config to source/live-build/config')
-
- os.makedirs('source/live-build/config', exist_ok=True)
-
- mount = subprocess.check_call('mount -o bind config source/live-build/config', shell=True)
- remount = subprocess.check_call('mount -o remount,ro,bind source/live-build/config', shell=True)
-
- # process hooks
- os.makedirs('source/live-build', exist_ok=True)
-
- hooks = glob.glob('config/hooks/*.hook') + glob.glob('config/hooks/*.hook.source')
-
- for hook in sorted(hooks):
- if verbose:
- print('I: Copying config/hooks/*.hook.source to source/live-build')
-
- shutil.copy(hook, os.path.join('source/live-build/' + os.path.basename(hook)), follow_symlinks=True)
-
- if verbose:
- print('I: Executing \' ' + hook + '\'')
-
- os.chmod(hook, 0o755)
- exec_hook = subprocess.check_call('cd source && live-build/' + os.path.basename(hook), shell=True)
- os.remove('source/live-build/' + os.path.basename(hook))
-
- # unmount coniguration directory
- umount = subprocess.check_call('umount source/live-build/config', shell=True)
-
- os.rmdir('source/live-build/config')
- os.rmdir('source/live-build')
-
- # stagefile
- os.makedirs('.build', exist_ok=True)
- open('.build/source-hooks', 'w').close()
-
-
-if __name__ == '__main__':
- main()
diff --git a/components/source-includes b/components/source-includes
deleted file mode 100755
index 85eca1482..000000000
--- a/components/source-includes
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/python3
-
-## live-build(7) - Live System Build Components
-## Copyright (C) 2006-2014 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/.*'):
- if verbose:
- print('I: Copying config/includes to source')
-
- cpio = subprocess.check_call('cd config/includes && find . | cpio -dmpu --no-preserve-owner ../../source', shell=True)
-
- if glob.glob('config/includes.source/*') or glob.glob('config/includes.source/.*'):
- if verbose:
- print('I: Copying config/includes.source to source')
-
- cpio = subprocess.check_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/debian/control b/debian/control
index fcb40aeee..e8f639b69 100644
--- a/debian/control
+++ b/debian/control
@@ -14,7 +14,6 @@ Architecture: all
Depends:
${misc:Depends},
debootstrap | cdebootstrap | cdebootstrap-static,
- python3,
Recommends:
cpio,
live-boot-doc,
diff --git a/frontend/cli/lb b/frontend/cli/lb
index e2862cdcc..63e46a9e0 100755
--- a/frontend/cli/lb
+++ b/frontend/cli/lb
@@ -67,10 +67,6 @@ case "${1}" in
then
# User has live-build copied locally in the system
SCRIPT="${LIVE_BUILD}/scripts/build/${COMMAND}"
- elif [ -x "${LIVE_BUILD}/components/${COMMAND}" ]
- then
- # User has live-build copied locally in the system
- SCRIPT="${LIVE_BUILD}/components/${COMMAND}"
elif [ -x "local/live-build/scripts/build/${COMMAND}" ]
then
# User has live-build copied locally in the config
diff --git a/scripts/build/binary b/scripts/build/binary
index 60e053203..c1f9ec662 100755
--- a/scripts/build/binary
+++ b/scripts/build/binary
@@ -67,8 +67,8 @@ lb binary_syslinux ${@}
lb binary_disk ${@}
lb binary_loadlin ${@}
lb binary_win32-loader ${@}
-lb binary-includes ${@}
-lb binary-hooks ${@}
+lb binary_includes ${@}
+lb binary_hooks ${@}
lb binary_checksums ${@}
if [ "${LB_BUILD_WITH_CHROOT}" != "true" ]
diff --git a/scripts/build/binary_hooks b/scripts/build/binary_hooks
new file mode 100755
index 000000000..91340adcc
--- /dev/null
+++ b/scripts/build/binary_hooks
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'execute hooks in binary')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+Echo_message "Begin executing hooks..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/binary_hooks
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+## Processing distribution hooks
+
+# Running hooks
+for _HOOK in ${LB_BINARY_HOOKS}
+do
+ for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks
+ do
+ for FILE in "${LOCATION}"/????-"${_HOOK}".binary
+ do
+ if [ -e "${FILE}" ]
+ then
+ cd binary
+ "${FILE}" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+ cd "${OLDPWD}"
+ fi
+ done
+ done
+done
+
+## Processing local hooks
+
+if Find_files config/hooks/*.binary
+then
+ for HOOK in config/hooks/*.binary
+ do
+ # Making hook executable
+ if [ ! -x "${HOOK}" ]
+ then
+ chmod +x "${HOOK}"
+ fi
+
+ # Executing hook
+ ./"${HOOK}" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+ done
+
+ # Creating stage file
+ Create_stagefile .build/binary_hooks
+fi
diff --git a/scripts/build/binary_includes b/scripts/build/binary_includes
new file mode 100755
index 000000000..68edfd6fa
--- /dev/null
+++ b/scripts/build/binary_includes
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'copy files into binary')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+Echo_message "Begin copying binary includes..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/includes.binary
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+if Find_files config/includes.binary/
+then
+ # Copying includes
+ cd config/includes.binary
+ find . | cpio -dmpu --no-preserve-owner "${OLDPWD}"/binary
+ cd "${OLDPWD}"
+
+ # Removing symlinks
+ case "${LIVE_IMAGE_TYPE}" in
+ hdd*)
+ find binary -type l | xargs rm -f
+ ;;
+ esac
+
+ # Creating stage file
+ Create_stagefile .build/binary_includes
+fi
diff --git a/scripts/build/bootstrap b/scripts/build/bootstrap
index dcee793c2..8a8293a5c 100755
--- a/scripts/build/bootstrap
+++ b/scripts/build/bootstrap
@@ -35,7 +35,11 @@ Set_defaults
Setup_cleanup
# Bootstrapping system
-lb bootstrap-${LB_BOOTSTRAP}
+lb bootstrap_cache restore ${@}
+lb bootstrap_cdebootstrap ${@}
+lb bootstrap_debootstrap ${@}
+lb bootstrap_archive-keys ${@}
+lb bootstrap_cache save ${@}
# Configuring chroot
lb chroot_devpts install ${@}
@@ -53,8 +57,6 @@ lb chroot_hostname install ${@}
lb chroot_apt install ${@}
lb bootstrap_archives binary ${@}
-lb bootstrap-includes ${@}
-lb bootstrap-hooks ${@}
# Deconfiguring chroot
lb chroot_apt remove ${@}
diff --git a/scripts/build/bootstrap_archive-keys b/scripts/build/bootstrap_archive-keys
new file mode 100755
index 000000000..4b9324f51
--- /dev/null
+++ b/scripts/build/bootstrap_archive-keys
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'bootstrap non-Debian archive-signing-keys')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+# TODO: allow verification against user-specified keyring
+# For now, we'll only validate against debian-keyring
+
+# TODO2: use chrooted validation rather than host system based one
+
+case "${LB_MODE}" in
+ progress-linux)
+ case "${LB_DISTRIBUTION}" in
+ artax*)
+ _KEYS="1.0-artax 1.0-artax-packages"
+ ;;
+
+ baureo*)
+ _KEYS="2.0-baureo 2.0-baureo-packages"
+ ;;
+
+ chairon*)
+ _KEYS="3.0-chairon 3.0-chairon-packages"
+ ;;
+ esac
+
+ _URL="${LB_MIRROR_CHROOT}/project/keys"
+ ;;
+esac
+
+for _KEY in ${_KEYS}
+do
+ Echo_message "Fetching archive-key ${_KEY}..."
+
+ wget -q "${_URL}/archive-key-${_KEY}.asc" -O chroot/key.asc
+ wget -q "${_URL}/archive-key-${_KEY}.asc.sig" -O chroot/key.asc.sig
+
+ if [ -e /usr/bin/gpgv ] && [ -e /usr/share/keyrings/debian-keyring.gpg ]
+ then
+ Echo_message "Verifying archive-key ${_KEY} against debian-keyring..."
+
+ /usr/bin/gpgv --quiet --keyring /usr/share/keyrings/debian-keyring.gpg chroot/key.asc.sig chroot/key.asc > /dev/null 2>&1 || { Echo_error "archive-key ${_KEY} has invalid signature."; return 1;}
+ else
+ Echo_warning "Skipping archive-key ${_KEY} verification, either gpgv or debian-keyring not available on host system..."
+ fi
+
+ Echo_message "Importing archive-key ${_KEY}..."
+
+ Chroot chroot "apt-key add key.asc"
+ rm -f chroot/key.asc chroot/key.asc.sig
+done
+
+Chroot chroot "apt-get update"
+
+# Creating stage file
+Create_stagefile .build/bootstrap_archive-keys
diff --git a/scripts/build/bootstrap_cache b/scripts/build/bootstrap_cache
new file mode 100755
index 000000000..c9b28d78d
--- /dev/null
+++ b/scripts/build/bootstrap_cache
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'cache bootstrap stage')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+# Check architecture
+Check_crossarchitectures
+
+for STAGE in ${LB_CACHE_STAGES}
+do
+ if [ "${STAGE}" = "bootstrap" ]
+ then
+ case "${1}" in
+ restore)
+ Echo_message "Restoring bootstrap stage from cache..."
+
+ # Checking stage file
+ Check_stagefile .build/bootstrap_cache.restore
+
+ if [ -d cache/bootstrap ]
+ then
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Removing old chroot
+ rm -rf chroot
+
+ # Restoring old cache
+ cp -a cache/bootstrap chroot
+
+ # Creating stage file
+ Create_stagefile .build/bootstrap_cache.restore
+ Create_stagefile .build/bootstrap
+
+ exit 0
+ fi
+ ;;
+
+ save)
+ Echo_message "Saving bootstrap stage to cache..."
+
+ # Checking stage file
+ Check_stagefile .build/bootstrap_cache.save
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ rm -rf cache/bootstrap
+
+ mkdir -p cache
+
+ cp -a chroot cache/bootstrap
+
+ # Creating stage file
+ Create_stagefile .build/bootstrap_cache.save
+ ;;
+ esac
+ fi
+done
diff --git a/scripts/build/bootstrap_cdebootstrap b/scripts/build/bootstrap_cdebootstrap
new file mode 100755
index 000000000..5704ee538
--- /dev/null
+++ b/scripts/build/bootstrap_cdebootstrap
@@ -0,0 +1,143 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'bootstrap a Debian system with cdebootstrap(1)')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+if [ "${LB_BOOTSTRAP}" != "cdebootstrap" ] && [ "${LB_BOOTSTRAP}" != "cdebootstrap-static" ]
+then
+ exit 0
+fi
+
+if [ ! -x "$(which cdebootstrap 2>/dev/null)" ]
+then
+ echo "E: cdebootstrap - command not found"
+ echo "I: cdebootstrap can be obtained from http://ftp.debian.org/debian/pool/main/d/cdebootstrap/"
+ echo "I: On Debian based systems, cdebootstrap can be installed with 'apt-get install cdebootstrap'."
+ exit 1
+fi
+
+# Check architecture
+Check_crossarchitectures
+
+Echo_message "Begin bootstrapping system..."
+
+Check_package /usr/bin/${LB_BOOTSTRAP} cdebootstrap
+
+# Ensure that a system is built as root
+lb testroot
+
+# Checking stage file
+Check_stagefile .build/bootstrap
+Check_stagefile .build/bootstrap_cache.restore
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Creating chroot directory
+mkdir -p chroot
+
+# Setting cdebootstrap options
+if [ -n "${LIVE_IMAGE_ARCHITECTURE}" ]
+then
+ CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --arch=${LIVE_IMAGE_ARCHITECTURE}"
+fi
+
+if [ "${_DEBUG}" = "true" ]
+then
+ CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --debug"
+fi
+
+if [ "${_QUIET}" = "true" ]
+then
+ CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --quiet"
+fi
+
+if [ "${_VERBOSE}" = "true" ]
+then
+ CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --verbose"
+fi
+
+if [ "${LB_APT_SECURE}" = "false" ]
+then
+ CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --allow-unauthenticated"
+fi
+
+if [ -x "/usr/bin/cdebootstrap" ] || [ -x "/usr/bin/cdebootstrap-static" ]
+then
+ if [ "${LB_CACHE_PACKAGES}" = "true" ]
+ then
+ if ls cache/packages.bootstrap/*.deb > /dev/null 2>&1
+ then
+ mkdir -p chroot/var/cache/bootstrap
+ cp cache/packages.bootstrap/*.deb chroot/var/cache/bootstrap
+ fi
+
+ Echo_breakage "Running ${LB_BOOTSTRAP} (download-only)... "
+ ${LB_BOOTSTRAP} ${CDEBOOTSTRAP_OPTIONS} --download-only "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
+
+ # Removing old cache
+ rm -f cache/packages.bootstrap/*.deb
+
+ # Saving new cache
+ mkdir -p cache/packages.bootstrap
+ cp chroot/var/cache/bootstrap/*.deb cache/packages.bootstrap
+ fi
+
+ Echo_breakage "Running ${LB_BOOTSTRAP}... "
+
+ # Run appropriate bootstrap, i.e. foreign or regular bootstrap
+ if [ "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" = "${LIVE_IMAGE_ARCHITECTURE}" ]; then
+
+ if [ -n "${LB_BOOTSTRAP_QEMU_EXCLUDE}" ]
+ then
+ CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --exclude=$(echo ${LB_BOOTSTRAP_QEMU_EXCLUDE} | sed 's| *|,|g')"
+ fi
+
+ Echo_message "Bootstrap will be foreign"
+ ${LB_BOOTSTRAP} ${CDEBOOTSTRAP_OPTIONS} --foreign "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
+
+ Echo_message "Running debootstrap second stage under QEMU"
+ cp ${LB_BOOTSTRAP_QEMU_STATIC} chroot/usr/bin
+ Chroot chroot /bin/sh /sbin/cdebootstrap-foreign
+ else
+ ${LB_BOOTSTRAP} ${CDEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
+ fi
+
+ # Deconfiguring cdebootstrap configurations
+ rm -f chroot/etc/apt/sources.list
+ rm -f chroot/etc/hosts
+ rm -f chroot/etc/resolv.conf
+
+ # Removing bootstrap cache
+ rm -rf chroot/var/cache/bootstrap
+
+ # Creating stage file
+ Create_stagefile .build/bootstrap
+else
+ Echo_error "Can't process file /usr/bin/${LB_BOOTSTRAP} (FIXME)"
+ exit 1
+fi
diff --git a/scripts/build/bootstrap_debootstrap b/scripts/build/bootstrap_debootstrap
new file mode 100755
index 000000000..9ecceb80f
--- /dev/null
+++ b/scripts/build/bootstrap_debootstrap
@@ -0,0 +1,139 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'bootstrap a Debian system with debootstrap(8)')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+if [ "${LB_BOOTSTRAP}" != "debootstrap" ]
+then
+ exit 0
+fi
+
+if [ ! -x "$(which debootstrap 2>/dev/null)" ]
+then
+ echo "E: debootstrap - command not found"
+ echo "I: debootstrap can be obtained from http://ftp.debian.org/debian/pool/main/d/debootstrap/"
+ echo "I: On Debian based systems, debootstrap can be installed with 'apt-get install debootstrap'."
+ exit 1
+fi
+
+# Check architecture
+Check_crossarchitectures
+
+Echo_message "Begin bootstrapping system..."
+
+Check_package /usr/sbin/debootstrap debootstrap
+
+# Ensure that a system is built as root
+lb testroot
+
+# Checking stage file
+Check_stagefile .build/bootstrap
+Check_stagefile .build/bootstrap_cache.restore
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Creating chroot directory
+mkdir -p chroot
+
+# Setting debootstrap options
+if [ -n "${LIVE_IMAGE_ARCHITECTURE}" ]
+then
+ DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --arch=${LIVE_IMAGE_ARCHITECTURE}"
+fi
+
+if [ "${LIVE_IMAGE_ARCHIVE_AREAS}" != "main" ]
+then
+ # Modify archive areas to remove leading/trailing whitespaces and replace other whitepspace with commas
+ DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --components=$(echo ${LIVE_IMAGE_ARCHIVE_AREAS} | sed -e 's| |,|g')"
+fi
+
+if [ "${_VERBOSE}" = "true" ]
+then
+ DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --verbose"
+fi
+
+# If LB_APT_SECURE is false, do not check signatures of the Release file
+# (requires debootstrap >= 1.0.30)
+if [ "${LB_APT_SECURE}" = "false" ] && /usr/sbin/debootstrap --help | grep -qs '\-\-no-check-gpg'
+then
+ DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --no-check-gpg"
+fi
+
+if [ -x "/usr/sbin/debootstrap" ]
+then
+ if [ "${LB_CACHE_PACKAGES}" = "true" ]
+ then
+ if ls cache/packages.bootstrap/*.deb > /dev/null 2>&1
+ then
+ mkdir -p chroot/var/cache/apt/archives
+ cp cache/packages.bootstrap/*.deb chroot/var/cache/apt/archives
+ fi
+
+ Echo_breakage "Running debootstrap (download-only)... "
+ debootstrap ${DEBOOTSTRAP_OPTIONS} --download-only "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
+
+ # Removing old cache
+ rm -f cache/packages.bootstrap/*.deb
+
+ # Saving new cache
+ mkdir -p cache/packages.bootstrap
+ cp chroot/var/cache/apt/archives/*.deb cache/packages.bootstrap
+ fi
+
+ Echo_breakage "Running debootstrap... "
+
+ # Run appropriate bootstrap, i.e. foreign or regular bootstrap
+ if [ "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" = "${LIVE_IMAGE_ARCHITECTURE}" ]; then
+
+ if [ -n "${LB_BOOTSTRAP_QEMU_EXCLUDE}" ]
+ then
+ DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --exclude=$(echo ${LB_BOOTSTRAP_QEMU_EXCLUDE} | sed 's| *|,|g')"
+ fi
+
+ Echo_message "Bootstrap will be foreign"
+ debootstrap ${DEBOOTSTRAP_OPTIONS} --foreign "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
+
+ Echo_message "Running debootstrap second stage under QEMU"
+ cp ${LB_BOOTSTRAP_QEMU_STATIC} chroot/usr/bin
+ Chroot chroot /bin/sh /debootstrap/debootstrap --second-stage
+ else
+ debootstrap ${DEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
+ fi
+
+ # Deconfiguring debootstrap configurations
+ rm -f chroot/etc/hosts
+
+ # Removing bootstrap cache
+ rm -f chroot/var/cache/apt/archives/*.deb
+
+ # Creating stage file
+ Create_stagefile .build/bootstrap
+else
+ Echo_error "Can't process file /usr/bin/debootstrap (FIXME)"
+ exit 1
+fi
diff --git a/scripts/build/build b/scripts/build/build
index 1e73ce564..9c3cf4f9c 100755
--- a/scripts/build/build
+++ b/scripts/build/build
@@ -17,7 +17,6 @@ set -e
if [ -x auto/config ] && [ ! -e .build/config ]
then
Echo_message "Automatically populating config tree."
- lb init
lb config
fi
diff --git a/scripts/build/chroot b/scripts/build/chroot
index d1be31c5d..beeca1158 100755
--- a/scripts/build/chroot
+++ b/scripts/build/chroot
@@ -67,8 +67,8 @@ do
fi
done
-lb chroot-includes ${@}
-lb chroot-hooks ${@}
+lb chroot_includes ${@}
+lb chroot_hooks ${@}
lb chroot_hacks ${@}
lb chroot_interactive ${@}
diff --git a/scripts/build/chroot_hooks b/scripts/build/chroot_hooks
new file mode 100755
index 000000000..59cf286bf
--- /dev/null
+++ b/scripts/build/chroot_hooks
@@ -0,0 +1,115 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'execute hooks in chroot')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+Echo_message "Begin executing hooks..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_hooks
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+## Processing distribution hooks
+
+# Make build config available to chroot hooks. First, make the bind
+# mount and then make it read-only. This can't happen in one mount
+# command, then the resulting mount will be rw (see mount(8)). Making it
+# ro prevents modifications and prevents accidentally removing the
+# contents of the config directory when removing the chroot.
+mkdir -p chroot/live-build/config
+mount -o bind config chroot/live-build/config
+mount -o remount,ro,bind config chroot/live-build/config
+
+# Copying hooks
+for _HOOK in ${LB_CHROOT_HOOKS}
+do
+ for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks
+ do
+ for FILE in "${LOCATION}"/????-"${_HOOK}".chroot
+ do
+ if [ -e "${FILE}" ]
+ then
+ mkdir -p chroot/root/lb_chroot_hooks
+ cp "${FILE}" chroot/root/lb_chroot_hooks
+ fi
+ done
+ done
+done
+
+# Running hooks
+if ls chroot/root/lb_chroot_hooks/* > /dev/null 2>&1
+then
+ for _HOOK in chroot/root/lb_chroot_hooks/*
+ do
+ Chroot chroot "/root/lb_chroot_hooks/$(basename ${_HOOK})" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+ rm -f chroot/root/lb_chroot_hooks/"$(basename ${_HOOK})"
+ done
+
+ rmdir chroot/root/lb_chroot_hooks
+fi
+
+## Processing local hooks
+
+if Find_files config/hooks/*.chroot
+then
+ # Restoring cache
+ Restore_cache cache/packages.chroot
+
+ for _HOOK in config/hooks/*.chroot
+ do
+ # Copying hook
+ cp "${_HOOK}" chroot/root
+
+ # Making hook executable
+ if [ ! -x chroot/root/"$(basename ${_HOOK})" ]
+ then
+ chmod +x chroot/root/"$(basename ${_HOOK})"
+ fi
+
+ # Executing hook
+ Chroot chroot "/root/$(basename ${_HOOK})" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+
+ # Removing hook
+ rm -f chroot/root/"$(basename ${_HOOK})"
+ done
+
+ # Saving cache
+ Save_cache cache/packages.chroot
+
+ # Creating stage file
+ Create_stagefile .build/chroot_hooks
+fi
+
+# Remove bind mount of build config inside chroot.
+umount chroot/live-build/config
+rmdir chroot/live-build/config
+
diff --git a/scripts/build/chroot_includes b/scripts/build/chroot_includes
new file mode 100755
index 000000000..78a416620
--- /dev/null
+++ b/scripts/build/chroot_includes
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'copy files into chroot')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+Echo_message "Begin copying chroot includes..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/includes.chroot
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+if Find_files config/includes.chroot/
+then
+ # Copying includes
+ cd config/includes.chroot
+ find . | cpio -dmpu --no-preserve-owner "${OLDPWD}"/chroot
+ cd "${OLDPWD}"
+
+ # Creating stage file
+ Create_stagefile .build/chroot_includes
+fi
diff --git a/scripts/build/chroot_live-packages b/scripts/build/chroot_live-packages
new file mode 100755
index 000000000..603dc0ef0
--- /dev/null
+++ b/scripts/build/chroot_live-packages
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'schedule live packages for installation')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_live-packages
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Queue installation of live-boot
+if [ -n "${LB_INITRAMFS}" ] && [ "${LB_INITRAMFS}" != "none" ]
+then
+ _PACKAGES="${LB_INITRAMFS}"
+fi
+
+# Queue installation of live-config
+if [ -n "${LB_INITSYSTEM}" ] && [ "${LB_INITSYSTEM}" != "none" ]
+then
+ _PACKAGES="${_PACKAGES} live-config live-config-${LB_INITSYSTEM}"
+fi
+
+# Do initsystem specific hacks
+case "${LB_INITSYSTEM}" in
+ systemd)
+ _PACKAGES="${_PACKAGES} systemd-sysv"
+
+ if [ -e chroot/var/lib/dpkg/info/sysvinit.list ]
+ then
+ Chroot chroot "dpkg --force-remove-essential --purge sysvinit"
+ fi
+ ;;
+
+ sysvinit)
+ _PACKAGES="${_PACKAGES} sysvinit"
+
+ if [ -e chroot/var/lib/dpkg/info/systemd-sysv.list ]
+ then
+ Chroot chroot "dpkg --force-remove-essential --purge systemd systemd-sysv"
+ fi
+ ;;
+esac
+
+# Install live packages
+if [ -n "${_PACKAGES}" ]
+then
+ case "${LB_APT}" in
+ apt|apt-get)
+ Chroot chroot "apt-get ${APT_OPTIONS} install ${_PACKAGES}"
+ ;;
+
+ aptitude)
+ Chroot chroot "aptitude ${APTITUDE_OPTIONS} install ${_PACKAGES}"
+ ;;
+ esac
+
+ # Creating stage file
+ Create_stagefile .build/chroot_live-packages
+fi
diff --git a/scripts/build/config b/scripts/build/config
index e3ae1410d..6e390e74d 100755
--- a/scripts/build/config
+++ b/scripts/build/config
@@ -883,8 +883,8 @@ Check_defaults
if [ ! -e config ]
then
- Echo_error "fatal: Not a live-build directory: use 'lb init' to initialize it"
- exit 1
+ Echo_message "Creating config tree for a ${LB_MODE}/${LB_DISTRIBUTION}/${LIVE_IMAGE_ARCHITECTURE} system"
+ mkdir config
else
Echo_message "Updating config tree for a ${LB_MODE}/${LB_DISTRIBUTION}/${LIVE_IMAGE_ARCHITECTURE} system"
fi
@@ -1338,6 +1338,19 @@ then
rmdir --ignore-fail-on-non-empty local > /dev/null 2>&1 || true
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}
diff --git a/scripts/build/source b/scripts/build/source
index 3f68aae86..a4fd58a17 100755
--- a/scripts/build/source
+++ b/scripts/build/source
@@ -51,8 +51,8 @@ lb chroot_archives source install ${@}
lb source_live ${@}
lb source_debian ${@}
lb source_disk ${@}
-lb source-includes ${@}
-lb source-hooks ${@}
+lb source_includes ${@}
+lb source_hooks ${@}
lb source_checksums ${@}
# Building images
diff --git a/scripts/build/source_debian-live b/scripts/build/source_debian-live
new file mode 100755
index 000000000..6c825e72b
--- /dev/null
+++ b/scripts/build/source_debian-live
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'copy debian-live config into source')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
+Set_defaults
+
+if [ "${LB_SOURCE}" != "true" ]
+then
+ exit 0
+fi
+
+Echo_message "Begin copying live-build configuration..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/source_debian-live
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Remove old sources
+if [ -d source/debian-live ]
+then
+ rm -rf source/debian-live
+fi
+
+# Copy system configuration
+mkdir -p source/debian-live
+cp -a config source/debian-live
+
+if Find_files auto/*
+then
+ cp -a auto source/debian-live
+fi
+
+# Creating stage file
+Create_stagefile .build/source_debian-live
diff --git a/scripts/build/source_hooks b/scripts/build/source_hooks
new file mode 100755
index 000000000..3c22edfd1
--- /dev/null
+++ b/scripts/build/source_hooks
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'execute hooks in source')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot config/source config/source
+Set_defaults
+
+Echo_message "Begin executing hooks..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/source_hooks
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+## Processing distribution hooks
+
+# Running hooks
+for _HOOK in ${LB_BINARY_HOOKS}
+do
+ for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks
+ do
+ for FILE in "${LOCATION}"/????-"${_HOOK}".source
+ do
+ if [ -e "${FILE}" ]
+ then
+ cd source
+ "${FILE}" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+ cd "${OLDPWD}"
+ fi
+ done
+ done
+done
+
+## Processing local hooks
+
+if Find_files config/hooks/*.source
+then
+ for HOOK in config/hooks/*.source
+ do
+ # Making hook executable
+ if [ ! -x "${HOOK}" ]
+ then
+ chmod +x "${HOOK}"
+ fi
+
+ # Executing hook
+ ./"${HOOK}" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+ done
+
+ # Creating stage file
+ Create_stagefile .build/source_hooks
+fi