Writing configuration out to config/build.conf in init component and getting rid of intermediate configuration file by using only new build.conf file.

This commit is contained in:
Daniel Baumann 2014-08-25 05:10:17 +02:00
parent 1fe3b72c63
commit a3e93f9c57
4 changed files with 121 additions and 85 deletions

View File

@ -42,22 +42,22 @@ def main():
args = arguments.parse_args() args = arguments.parse_args()
## Parsing Configuration ## Parsing Configuration
if not os.path.isfile('config/build'): if not os.path.isfile('config/build.conf'):
print('E: config/build - no such file', file=sys.stderr) print('E: config/build.conf - no such file', file=sys.stderr)
sys.exit(1) sys.exit(1)
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('config/build') config.read('config/build.conf')
try: try:
architecture = config.get('Image', 'Architecture') architecture = config.get('build', 'Architecture')
distribution = config.get('Image', 'Parent-Distribution') distribution = config.get('build', 'Parent-Distribution')
mirror_bootstrap = config.get('Image', 'Parent-Mirror-Bootstrap') mirror_bootstrap = config.get('build', 'Parent-Mirror-Bootstrap')
except: except:
distribution = config.get('Image', 'Distribution') distribution = config.get('build', 'Distribution')
mirror_bootstrap = config.get('Image', 'Mirror-Bootstrap') mirror_bootstrap = config.get('build', 'Mirror-Bootstrap')
# --verbose # --verbose
verbose = args.verbose verbose = args.verbose

View File

@ -42,24 +42,24 @@ def main():
args = arguments.parse_args() args = arguments.parse_args()
## Parsing Configuration ## Parsing Configuration
if not os.path.isfile('config/build'): if not os.path.isfile('config/build.conf'):
print('E: config/build - no such file', file=sys.stderr) print('E: config/build.conf - no such file', file=sys.stderr)
sys.exit(1) sys.exit(1)
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('config/build') config.read('config/build.conf')
try: try:
architecture = config.get('Image', 'Architecture') architecture = config.get('build', 'Architecture')
archive_areas = config.get('Image', 'Parent-Archive-Areas') archive_areas = config.get('build', 'Parent-Archive-Areas')
distribution = config.get('Image', 'Parent-Distribution') distribution = config.get('build', 'Parent-Distribution')
mirror_bootstrap = config.get('Image', 'Parent-Mirror-Bootstrap') mirror_bootstrap = config.get('build', 'Parent-Mirror-Bootstrap')
except: except:
archive_areas = config.get('Image', 'Archive-Areas') archive_areas = config.get('build', 'Archive-Areas')
distribution = config.get('Image', 'Distribution') distribution = config.get('build', 'Distribution')
mirror_bootstrap = config.get('Image', 'Mirror-Bootstrap') mirror_bootstrap = config.get('build', 'Mirror-Bootstrap')
# --verbose # --verbose
verbose = args.verbose verbose = args.verbose

View File

@ -12,6 +12,7 @@ import argparse
import configparser import configparser
import glob import glob
import os import os
import platform
import shutil import shutil
import subprocess import subprocess
import sys import sys
@ -24,6 +25,12 @@ import urllib.request
# * use gettext for i18n # * use gettext for i18n
def main(): def main():
## early defaults detection
architecture = platform.machine()
if (architecture == 'x86_64'):
architecture = 'amd64'
## Parsing Arguments ## Parsing Arguments
arguments = argparse.ArgumentParser( arguments = argparse.ArgumentParser(
prog = 'lb init', prog = 'lb init',
@ -34,27 +41,54 @@ def main():
formatter_class = argparse.ArgumentDefaultsHelpFormatter 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('--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('--verbose', help='set verbose option', action='store_true')
arguments.add_argument('--distribution', help='set default distribution', default='jessie') arguments.add_argument('--project', help='set project defaults', default='debian')
arguments.add_argument('--project', help='set project defaults', default='debian') arguments.add_argument('--system', help='set system type', default='live')
arguments.add_argument('--system', help='set system type', default='live') arguments.add_argument('--architecture', help='set system architecture', default=architecture)
arguments.add_argument('--archive-areas', help='set default archive areas', default='main')
arguments.add_argument('--parent-archive-areas', help='set default parent archive areas', default='main')
arguments.add_argument('--distribution', help='set default distribution', default='jessie')
arguments.add_argument('--parent-distribution', help='set default parent distribution', default='jessie')
arguments.add_argument('--mirror-bootstrap', help='set default bootstrap mirror', default='http://ftp.debian.org/debian')
arguments.add_argument('--parent-mirror-bootstrap', help='set default parent bootstrap mirror', default='http://ftp.debian.org/debian')
args = arguments.parse_args() args = arguments.parse_args()
# --verbose # --verbose
verbose = args.verbose verbose = args.verbose
# --distribution
distribution = args.distribution
# --project # --project
project = args.project project = args.project
# --system # --system
system = args.system system = args.system
# --architecture
architecture = args.architecture
# --archive-areas
archive_areas = args.archive_areas
# --parent-archive-areas
parent_archive_areas = args.parent_archive_areas
# --distribution
distribution = args.distribution
# --parent-distribution
parent_distribution = args.parent_distribution
# --mirror-bootstrap
mirror_bootstrap = args.mirror_bootstrap
# --parent-mirror-bootstrap
parent_mirror_bootstrap = args.parent_mirror_bootstrap
## Setting defaults ## Setting defaults
if not system: if not system:
@ -72,6 +106,31 @@ def main():
distribution = default_distribution[project] distribution = default_distribution[project]
## Setting derivative defaults
if (project == 'progress-linux'):
# parent-distribution
if(distribution == 'artax'):
parent_distribution = 'squeeze'
if(distribution == 'artax-backports'):
parent_distribution = 'squeeze'
if(distribution == 'baureo'):
parent_distribution = 'wheezy'
if(distribution == 'baureo-backports'):
parent_distribution = 'wheezy'
if(distribution == 'cairon'):
parent_distribution = 'jessie'
if(distribution == 'cairon-backports'):
parent_distribution = 'jessie'
else:
# parent-architecture
parent_architecture = architecture
# parent-distribution
parent_distribution = distribution
# parent-mirror-bootstrap
parent_mirror_bootstrap = mirror_bootstrap
## Creating configuration directory ## Creating configuration directory
# stagefile # stagefile
@ -94,6 +153,39 @@ def main():
print('Make sure you are using the newest version at all times.') print('Make sure you are using the newest version at all times.')
## Writing main configuration file
os.makedirs('config', exist_ok=True)
config = configparser.ConfigParser()
configfile = open("config/build.conf", 'w')
config.add_section('build')
config.set('build','Architecture', architecture)
config.set('build','Archive-Areas', archive_areas)
config.set('build','Parent-Archive-Areas', parent_archive_areas)
config.set('build','Distribution', distribution)
config.set('build','Parent-Distribution', parent_distribution)
config.set('build','Mirror-Bootstrap', mirror_bootstrap)
config.set('build','Parent-Mirror-Bootstrap', parent_mirror_bootstrap)
config.set('build','Project', project)
config.set('build','System', system)
config.add_section('meta')
config.set('meta','Version', '4.0')
config.write(configfile)
configfile.close()
## Populating configuration directory
# Configuring default archive-keys # Configuring default archive-keys
if (project == 'progress-linux'): if (project == 'progress-linux'):
# dependencies # dependencies

View File

@ -26,7 +26,6 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\
\t [--apt-recommends true|false]\n\ \t [--apt-recommends true|false]\n\
\t [--apt-secure true|false]\n\ \t [--apt-secure true|false]\n\
\t [--apt-source-archives true|false]\n\ \t [--apt-source-archives true|false]\n\
\t [-a|--architectures ARCHITECTURE]\n\
\t [-b|--binary-images iso|iso-hybrid|netboot|tar|hdd]\n\ \t [-b|--binary-images iso|iso-hybrid|netboot|tar|hdd]\n\
\t [--binary-filesystem fat16|fat32|ext2|ext3|ext4|ntfs]\n\ \t [--binary-filesystem fat16|fat32|ext2|ext3|ext4|ntfs]\n\
\t [--bootappend-install PARAMETER|\"PARAMETERS\"]\n\ \t [--bootappend-install PARAMETER|\"PARAMETERS\"]\n\
@ -104,8 +103,6 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\
\t [--net-cow-server IP|HOSTNAME]\n\ \t [--net-cow-server IP|HOSTNAME]\n\
\t [--net-tarball true|false]\n\ \t [--net-tarball true|false]\n\
\t [--quiet]\n\ \t [--quiet]\n\
\t [--archive-areas ARCHIVE_AREA|\"ARCHIVE_AREAS\"]\n\
\t [--parent-archive-areas ARCHIVE_AREA|\"ARCHIVE_AREAS\"]\n\
\t [--security true|false]\n\ \t [--security true|false]\n\
\t [--source true|false]\n\ \t [--source true|false]\n\
\t [-s|--source-images iso|netboot|tar|hdd]\n\ \t [-s|--source-images iso|netboot|tar|hdd]\n\
@ -131,12 +128,12 @@ Local_arguments ()
apt-pipeline:,apt-recommends:,apt-secure:,apt-source-archives:,bootstrap:,cache:,cache-indices:,cache-packages:, apt-pipeline:,apt-recommends:,apt-secure:,apt-source-archives:,bootstrap:,cache:,cache-indices:,cache-packages:,
cache-stages:,debconf-frontend:,debconf-priority:,dump, cache-stages:,debconf-frontend:,debconf-priority:,dump,
initramfs:,initramfs-compression:,initsystem:,fdisk:,losetup:,mode:,system:,tasksel:, initramfs:,initramfs-compression:,initsystem:,fdisk:,losetup:,mode:,system:,tasksel:,
templates:,architectures:,clean, templates:,clean,
distribution:,parent-distribution:,parent-debian-installer-distribution:,parent-mirror-bootstrap:,parent-mirror-chroot:,parent-mirror-chroot-security:,parent-mirror-binary:, parent-debian-installer-distribution:,parent-mirror-bootstrap:,parent-mirror-chroot:,parent-mirror-chroot-security:,parent-mirror-binary:,
parent-mirror-binary-security:,parent-mirror-debian-installer:, parent-mirror-binary-security:,parent-mirror-debian-installer:,
mirror-bootstrap:,mirror-chroot:,mirror-chroot-security:,mirror-binary:, mirror-bootstrap:,mirror-chroot:,mirror-chroot-security:,mirror-binary:,
mirror-binary-security:,mirror-debian-installer:, mirror-binary-security:,mirror-debian-installer:,
archive-areas:,parent-archive-areas:,chroot-filesystem:, chroot-filesystem:,
gzip-options:,image-name:,interactive:,keyring-packages:,linux-flavours:,linux-packages:, gzip-options:,image-name:,interactive:,keyring-packages:,linux-flavours:,linux-packages:,
security:,updates:,backports:,binary-filesystem:,binary-images:, security:,updates:,backports:,binary-filesystem:,binary-images:,
apt-indices:,bootappend-install:,bootappend-live:,bootappend-live-failsafe:,bootloader:,checksums:,compression:,config:,zsync:,build-with-chroot:, apt-indices:,bootappend-install:,bootappend-live:,bootappend-live-failsafe:,bootloader:,checksums:,compression:,config:,zsync:,build-with-chroot:,
@ -346,21 +343,6 @@ Local_arguments ()
;; ;;
# config/bootstrap # config/bootstrap
-a|--architectures)
LIVE_IMAGE_ARCHITECTURE="${2}"
shift 2
;;
-d|--distribution)
LB_DISTRIBUTION="${2}"
shift 2
;;
--parent-distribution)
LB_PARENT_DISTRIBUTION="${2}"
shift 2
;;
-m|--parent-mirror-bootstrap) -m|--parent-mirror-bootstrap)
LB_PARENT_MIRROR_BOOTSTRAP="${2}" LB_PARENT_MIRROR_BOOTSTRAP="${2}"
shift 2 shift 2
@ -421,16 +403,6 @@ Local_arguments ()
shift 2 shift 2
;; ;;
--archive-areas)
LIVE_IMAGE_ARCHIVE_AREAS="${2}"
shift 2
;;
--parent-archive-areas)
LIVE_IMAGE_PARENT_ARCHIVE_AREAS="${2}"
shift 2
;;
# config/chroot # config/chroot
--chroot-filesystem) --chroot-filesystem)
LB_CHROOT_FILESYSTEM="${2}" LB_CHROOT_FILESYSTEM="${2}"
@ -1338,33 +1310,5 @@ then
rmdir --ignore-fail-on-non-empty local > /dev/null 2>&1 || true rmdir --ignore-fail-on-non-empty local > /dev/null 2>&1 || true
fi fi
cat > config/build << EOF
[Image]
Architecture: ${LIVE_IMAGE_ARCHITECTURE}
Archive-Areas: ${LIVE_IMAGE_ARCHIVE_AREAS}
Distribution: ${LB_DISTRIBUTION}
Mirror-Bootstrap: ${LB_MIRROR_BOOTSTRAP}
EOF
if [ "${LB_DERIVATIVE}" = "true" ]
then
cat >> config/build << EOF
Parent-Archive-Areas: ${LIVE_IMAGE_ARCHIVE_AREAS}
Parent-Distribution: ${LB_PARENT_DISTRIBUTION}
Parent-Mirror-Bootstrap: ${LB_PARENT_MIRROR_BOOTSTRAP}
EOF
fi
cat >> config/build << EOF
[FIXME]
Configuration-Version: ${LIVE_CONFIGURATION_VERSION}
Name: ${LIVE_IMAGE_NAME}
Type: ${LIVE_IMAGE_TYPE}
EOF
# Creating stage file # Creating stage file
Create_stagefile .build/config Create_stagefile .build/config