summaryrefslogtreecommitdiff
path: root/components/chroot-hooks
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2014-08-27 23:14:12 +0200
committerDaniel Baumann <mail@daniel-baumann.ch>2014-08-28 00:59:28 +0200
commitbc50443cf043616c7087f383e11bf85cd233c54e (patch)
treed7a6c03bc3207f809f4ca4ab13f079f02df28acf /components/chroot-hooks
parent5fc57865a4124c4432333cb73468ac2494e91d75 (diff)
downloadvyos-live-build-bc50443cf043616c7087f383e11bf85cd233c54e.tar.gz
vyos-live-build-bc50443cf043616c7087f383e11bf85cd233c54e.zip
Moving partial python rewrite to separate branch, let's do it in the jessie+1 cycle rather than go with the current mixed code.
Diffstat (limited to 'components/chroot-hooks')
-rwxr-xr-xcomponents/chroot-hooks108
1 files changed, 0 insertions, 108 deletions
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()