summaryrefslogtreecommitdiff
path: root/scripts/build/bootstrap_debootstrap
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2013-11-04 07:00:25 +0100
committerDaniel Baumann <mail@daniel-baumann.ch>2013-11-04 07:06:08 +0100
commit52122b28451ec441e037e4003dfecf5ecc21853c (patch)
tree0e641a8a4aea0fa4d2f9bae428c51cf400fe91c5 /scripts/build/bootstrap_debootstrap
parentafafe4628cf94f586c0adae100cb2d62ca02f701 (diff)
downloadvyos-live-build-52122b28451ec441e037e4003dfecf5ecc21853c.tar.gz
vyos-live-build-52122b28451ec441e037e4003dfecf5ecc21853c.zip
Moving python stubs to their own subdirectory within the source tree.
Diffstat (limited to 'scripts/build/bootstrap_debootstrap')
-rwxr-xr-xscripts/build/bootstrap_debootstrap156
1 files changed, 0 insertions, 156 deletions
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 <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
-# * 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()