diff options
-rwxr-xr-x | components/binary-includes | 105 | ||||
-rwxr-xr-x | scripts/build/binary | 2 | ||||
-rwxr-xr-x | scripts/build/binary_includes | 57 |
3 files changed, 106 insertions, 58 deletions
diff --git a/components/binary-includes b/components/binary-includes new file mode 100755 index 000000000..dfac8c760 --- /dev/null +++ b/components/binary-includes @@ -0,0 +1,105 @@ +#!/usr/bin/python3 + +## live-build(7) - Live System Build Components +## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch> +## +## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING. +## This is free software, and you are welcome to redistribute it +## under certain conditions; see COPYING for details. + + +import argparse +import configparser +import glob +import os +import shutil +import subprocess +import sys + + +# TODO: +# * logfile output +# * lockfile handling +# * use gettext for i18n +# * derefence or remove symlinks if 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/.*'): + hooks = glob.glob('config/includes/*') + glob.glob('config/includes/.*') + + if verbose: + print('I: Copying config/includes to binary') + + cpio = subprocess.call('cd config/includes && find . | cpio -dmpu --no-preserve-owner ../../binary', shell=True) + + if glob.glob('config/includes.binary/*') and not glob.glob('config/includes.binary/.*'): + hooks = glob.glob('config/includes.binary/*') + glob.glob('config/includes.binary/.*') + + if verbose: + print('I: Copying config/includes.binary to binary') + + cpio = subprocess.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/scripts/build/binary b/scripts/build/binary index 4ecf38779..62d20d68f 100755 --- a/scripts/build/binary +++ b/scripts/build/binary @@ -67,7 +67,7 @@ lb binary_syslinux ${@} lb binary_disk ${@} lb binary_loadlin ${@} lb binary_win32-loader ${@} -lb binary_includes ${@} +lb binary-includes ${@} lb binary-hooks ${@} lb binary_checksums ${@} diff --git a/scripts/build/binary_includes b/scripts/build/binary_includes deleted file mode 100755 index e9c57b141..000000000 --- a/scripts/build/binary_includes +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh - -## live-build(7) - System Build Scripts -## 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. - - -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 |