From 52122b28451ec441e037e4003dfecf5ecc21853c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 4 Nov 2013 07:00:25 +0100 Subject: Moving python stubs to their own subdirectory within the source tree. --- Makefile | 15 ++-- components/binary_hooks | 108 ++++++++++++++++++++++++ components/bootstrap_cdebootstrap | 159 +++++++++++++++++++++++++++++++++++ components/bootstrap_debootstrap | 156 ++++++++++++++++++++++++++++++++++ components/bootstrap_hooks | 108 ++++++++++++++++++++++++ components/chroot_hooks | 108 ++++++++++++++++++++++++ components/source_hooks | 108 ++++++++++++++++++++++++ scripts/build/binary_hooks | 108 ------------------------ scripts/build/bootstrap_cdebootstrap | 159 ----------------------------------- scripts/build/bootstrap_debootstrap | 156 ---------------------------------- scripts/build/bootstrap_hooks | 108 ------------------------ scripts/build/chroot_hooks | 108 ------------------------ scripts/build/source_hooks | 108 ------------------------ 13 files changed, 752 insertions(+), 757 deletions(-) create mode 100755 components/binary_hooks create mode 100755 components/bootstrap_cdebootstrap create mode 100755 components/bootstrap_debootstrap create mode 100755 components/bootstrap_hooks create mode 100755 components/chroot_hooks create mode 100755 components/source_hooks delete mode 100755 scripts/build/binary_hooks delete mode 100755 scripts/build/bootstrap_cdebootstrap delete mode 100755 scripts/build/bootstrap_debootstrap delete mode 100755 scripts/build/bootstrap_hooks delete mode 100755 scripts/build/chroot_hooks delete mode 100755 scripts/build/source_hooks diff --git a/Makefile b/Makefile index b4a9c44dc..5374e0205 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,8 @@ test: @for SCRIPT in $(SCRIPTS); \ do \ - if ! head -n1 $${SCRIPT} | grep -qs python; \ - then \ - sh -n $${SCRIPT}; \ - echo -n "."; \ - fi; \ + sh -n $${SCRIPT}; \ + echo -n "."; \ done @echo " done." @@ -28,11 +25,8 @@ test: then \ for SCRIPT in $(SCRIPTS); \ do \ - if ! head -n1 $${SCRIPT} | grep -qs python; \ - then \ - checkbashisms -f -x $${SCRIPT}; \ - echo -n "."; \ - fi; \ + checkbashisms -f -x $${SCRIPT}; \ + echo -n "."; \ done; \ else \ echo "WARNING: skipping bashism test - you need to install devscripts."; \ @@ -55,6 +49,7 @@ 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/components/binary_hooks b/components/binary_hooks new file mode 100755 index 000000000..16a3e81f7 --- /dev/null +++ b/components/binary_hooks @@ -0,0 +1,108 @@ +#!/usr/bin/python3 + +## live-build(7) - Live System Build Components +## Copyright (C) 2006-2013 Daniel Baumann +## +## 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 hooks after the binary stage.''', + epilog = 'See \'man lb_binary_hooks\' for more information.', + version = 'live-build 4', + formatter_class = argparse.ArgumentDefaultsHelpFormatter + ) + + arguments.add_argument('--verbose', help='set verbose option', action='store_true') + + args = arguments.parse_args() + + # --verbose + verbose = args.verbose + + ## Executing 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.call('mount -o bind config binary/live-build/config', shell=True) + remount = subprocess.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 hooks: + if verbose: + print('I: Copying config/hooks/*.hook.binary to binary/live-build') + + os.link(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.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.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/bootstrap_cdebootstrap b/components/bootstrap_cdebootstrap new file mode 100755 index 000000000..24eef1d3f --- /dev/null +++ b/components/bootstrap_cdebootstrap @@ -0,0 +1,159 @@ +#!/usr/bin/python3 + +## live-build(7) - Live System Build Components +## Copyright (C) 2006-2013 Daniel Baumann +## +## 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 + + +# TODOs: +# * logfile output +# * lockfile handling +# * use gettext for i18n +# * cdebootstrap-options from config +# * take mirrors from config/archives/debian.{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.', + version = 'live-build 4', + formatter_class = argparse.ArgumentDefaultsHelpFormatter + ) + + 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 optained 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) + # packages cache + elif 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.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.call('/usr/bin/cdebootstrap ' + cdebootstrap_options, 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 new file mode 100755 index 000000000..00d86c327 --- /dev/null +++ b/components/bootstrap_debootstrap @@ -0,0 +1,156 @@ +#!/usr/bin/python3 + +## live-build(7) - Live System Build Components +## Copyright (C) 2006-2013 Daniel Baumann +## +## 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 +# * take mirrors from config/archives/debian.{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.', + version = 'live-build 4', + formatter_class = argparse.ArgumentDefaultsHelpFormatter + ) + + 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 optained 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) + # packages cache + elif 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.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') + + ## 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 new file mode 100755 index 000000000..2d6887d58 --- /dev/null +++ b/components/bootstrap_hooks @@ -0,0 +1,108 @@ +#!/usr/bin/python3 + +## live-build(7) - Live System Build Components +## Copyright (C) 2006-2013 Daniel Baumann +## +## 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 hooks after the bootstrap stage.''', + epilog = 'See \'man lb_bootstrap_hooks\' for more information.', + version = 'live-build 4', + formatter_class = argparse.ArgumentDefaultsHelpFormatter + ) + + arguments.add_argument('--verbose', help='set verbose option', action='store_true') + + args = arguments.parse_args() + + # --verbose + verbose = args.verbose + + ## Executing 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.call('mount -o bind config chroot/live-build/config', shell=True) + remount = subprocess.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 hooks: + if verbose: + print('I: Copying config/hooks/*.hook.bootstrap to chroot/live-build') + + os.link(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.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.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/chroot_hooks b/components/chroot_hooks new file mode 100755 index 000000000..ce2287a57 --- /dev/null +++ b/components/chroot_hooks @@ -0,0 +1,108 @@ +#!/usr/bin/python3 + +## live-build(7) - Live System Build Components +## Copyright (C) 2006-2013 Daniel Baumann +## +## 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 hooks after the chroot stage.''', + epilog = 'See \'man lb_chroot_hooks\' for more information.', + version = 'live-build 4', + formatter_class = argparse.ArgumentDefaultsHelpFormatter + ) + + arguments.add_argument('--verbose', help='set verbose option', action='store_true') + + args = arguments.parse_args() + + # --verbose + verbose = args.verbose + + ## Executing 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.call('mount -o bind config chroot/live-build/config', shell=True) + remount = subprocess.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 hooks: + if verbose: + print('I: Copying config/hooks/*.hook.chroot to chroot/live-build') + + os.link(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.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.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/source_hooks b/components/source_hooks new file mode 100755 index 000000000..d414c424e --- /dev/null +++ b/components/source_hooks @@ -0,0 +1,108 @@ +#!/usr/bin/python3 + +## live-build(7) - Live System Build Components +## Copyright (C) 2006-2013 Daniel Baumann +## +## 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 hooks after the source stage.''', + epilog = 'See \'man lb_source_hooks\' for more information.', + version = 'live-build 4', + formatter_class = argparse.ArgumentDefaultsHelpFormatter + ) + + arguments.add_argument('--verbose', help='set verbose option', action='store_true') + + args = arguments.parse_args() + + # --verbose + verbose = args.verbose + + ## Executing 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.call('mount -o bind config source/live-build/config', shell=True) + remount = subprocess.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 hooks: + if verbose: + print('I: Copying config/hooks/*.hook.source to source/live-build') + + os.link(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.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.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/scripts/build/binary_hooks b/scripts/build/binary_hooks deleted file mode 100755 index 16a3e81f7..000000000 --- a/scripts/build/binary_hooks +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/python3 - -## live-build(7) - Live System Build Components -## Copyright (C) 2006-2013 Daniel Baumann -## -## 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 hooks after the binary stage.''', - epilog = 'See \'man lb_binary_hooks\' for more information.', - version = 'live-build 4', - formatter_class = argparse.ArgumentDefaultsHelpFormatter - ) - - arguments.add_argument('--verbose', help='set verbose option', action='store_true') - - args = arguments.parse_args() - - # --verbose - verbose = args.verbose - - ## Executing 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.call('mount -o bind config binary/live-build/config', shell=True) - remount = subprocess.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 hooks: - if verbose: - print('I: Copying config/hooks/*.hook.binary to binary/live-build') - - os.link(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.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.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/scripts/build/bootstrap_cdebootstrap b/scripts/build/bootstrap_cdebootstrap deleted file mode 100755 index 24eef1d3f..000000000 --- a/scripts/build/bootstrap_cdebootstrap +++ /dev/null @@ -1,159 +0,0 @@ -#!/usr/bin/python3 - -## live-build(7) - Live System Build Components -## Copyright (C) 2006-2013 Daniel Baumann -## -## 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 - - -# TODOs: -# * logfile output -# * lockfile handling -# * use gettext for i18n -# * cdebootstrap-options from config -# * take mirrors from config/archives/debian.{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.', - version = 'live-build 4', - formatter_class = argparse.ArgumentDefaultsHelpFormatter - ) - - 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 optained 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) - # packages cache - elif 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.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.call('/usr/bin/cdebootstrap ' + cdebootstrap_options, shell=True) - - ## stagefile - os.makedirs('.build', exist_ok=True) - open('.build/bootstrap', 'w').close() - - -if __name__ == '__main__': - main() diff --git a/scripts/build/bootstrap_debootstrap b/scripts/build/bootstrap_debootstrap deleted file mode 100755 index 00d86c327..000000000 --- a/scripts/build/bootstrap_debootstrap +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/python3 - -## live-build(7) - Live System Build Components -## Copyright (C) 2006-2013 Daniel Baumann -## -## 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 -# * take mirrors from config/archives/debian.{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.', - version = 'live-build 4', - formatter_class = argparse.ArgumentDefaultsHelpFormatter - ) - - 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 optained 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) - # packages cache - elif 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.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') - - ## stagefile - os.makedirs('.build', exist_ok=True) - open('.build/bootstrap', 'w').close() - - -if __name__ == '__main__': - main() diff --git a/scripts/build/bootstrap_hooks b/scripts/build/bootstrap_hooks deleted file mode 100755 index 2d6887d58..000000000 --- a/scripts/build/bootstrap_hooks +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/python3 - -## live-build(7) - Live System Build Components -## Copyright (C) 2006-2013 Daniel Baumann -## -## 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 hooks after the bootstrap stage.''', - epilog = 'See \'man lb_bootstrap_hooks\' for more information.', - version = 'live-build 4', - formatter_class = argparse.ArgumentDefaultsHelpFormatter - ) - - arguments.add_argument('--verbose', help='set verbose option', action='store_true') - - args = arguments.parse_args() - - # --verbose - verbose = args.verbose - - ## Executing 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.call('mount -o bind config chroot/live-build/config', shell=True) - remount = subprocess.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 hooks: - if verbose: - print('I: Copying config/hooks/*.hook.bootstrap to chroot/live-build') - - os.link(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.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.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/scripts/build/chroot_hooks b/scripts/build/chroot_hooks deleted file mode 100755 index ce2287a57..000000000 --- a/scripts/build/chroot_hooks +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/python3 - -## live-build(7) - Live System Build Components -## Copyright (C) 2006-2013 Daniel Baumann -## -## 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 hooks after the chroot stage.''', - epilog = 'See \'man lb_chroot_hooks\' for more information.', - version = 'live-build 4', - formatter_class = argparse.ArgumentDefaultsHelpFormatter - ) - - arguments.add_argument('--verbose', help='set verbose option', action='store_true') - - args = arguments.parse_args() - - # --verbose - verbose = args.verbose - - ## Executing 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.call('mount -o bind config chroot/live-build/config', shell=True) - remount = subprocess.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 hooks: - if verbose: - print('I: Copying config/hooks/*.hook.chroot to chroot/live-build') - - os.link(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.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.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/scripts/build/source_hooks b/scripts/build/source_hooks deleted file mode 100755 index d414c424e..000000000 --- a/scripts/build/source_hooks +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/python3 - -## live-build(7) - Live System Build Components -## Copyright (C) 2006-2013 Daniel Baumann -## -## 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 hooks after the source stage.''', - epilog = 'See \'man lb_source_hooks\' for more information.', - version = 'live-build 4', - formatter_class = argparse.ArgumentDefaultsHelpFormatter - ) - - arguments.add_argument('--verbose', help='set verbose option', action='store_true') - - args = arguments.parse_args() - - # --verbose - verbose = args.verbose - - ## Executing 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.call('mount -o bind config source/live-build/config', shell=True) - remount = subprocess.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 hooks: - if verbose: - print('I: Copying config/hooks/*.hook.source to source/live-build') - - os.link(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.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.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() -- cgit v1.2.3