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:
parent
1fe3b72c63
commit
a3e93f9c57
|
@ -42,22 +42,22 @@ def main():
|
|||
args = arguments.parse_args()
|
||||
|
||||
## Parsing Configuration
|
||||
if not os.path.isfile('config/build'):
|
||||
print('E: config/build - no such file', file=sys.stderr)
|
||||
if not os.path.isfile('config/build.conf'):
|
||||
print('E: config/build.conf - no such file', file=sys.stderr)
|
||||
|
||||
sys.exit(1)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
config.read('config/build')
|
||||
config.read('config/build.conf')
|
||||
|
||||
try:
|
||||
architecture = config.get('Image', 'Architecture')
|
||||
distribution = config.get('Image', 'Parent-Distribution')
|
||||
mirror_bootstrap = config.get('Image', 'Parent-Mirror-Bootstrap')
|
||||
architecture = config.get('build', 'Architecture')
|
||||
distribution = config.get('build', 'Parent-Distribution')
|
||||
mirror_bootstrap = config.get('build', 'Parent-Mirror-Bootstrap')
|
||||
except:
|
||||
distribution = config.get('Image', 'Distribution')
|
||||
mirror_bootstrap = config.get('Image', 'Mirror-Bootstrap')
|
||||
distribution = config.get('build', 'Distribution')
|
||||
mirror_bootstrap = config.get('build', 'Mirror-Bootstrap')
|
||||
|
||||
# --verbose
|
||||
verbose = args.verbose
|
||||
|
|
|
@ -42,24 +42,24 @@ def main():
|
|||
args = arguments.parse_args()
|
||||
|
||||
## Parsing Configuration
|
||||
if not os.path.isfile('config/build'):
|
||||
print('E: config/build - no such file', file=sys.stderr)
|
||||
if not os.path.isfile('config/build.conf'):
|
||||
print('E: config/build.conf - no such file', file=sys.stderr)
|
||||
|
||||
sys.exit(1)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
config.read('config/build')
|
||||
config.read('config/build.conf')
|
||||
|
||||
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')
|
||||
architecture = config.get('build', 'Architecture')
|
||||
archive_areas = config.get('build', 'Parent-Archive-Areas')
|
||||
distribution = config.get('build', 'Parent-Distribution')
|
||||
mirror_bootstrap = config.get('build', 'Parent-Mirror-Bootstrap')
|
||||
except:
|
||||
archive_areas = config.get('Image', 'Archive-Areas')
|
||||
distribution = config.get('Image', 'Distribution')
|
||||
mirror_bootstrap = config.get('Image', 'Mirror-Bootstrap')
|
||||
archive_areas = config.get('build', 'Archive-Areas')
|
||||
distribution = config.get('build', 'Distribution')
|
||||
mirror_bootstrap = config.get('build', 'Mirror-Bootstrap')
|
||||
|
||||
# --verbose
|
||||
verbose = args.verbose
|
||||
|
|
108
components/init
108
components/init
|
@ -12,6 +12,7 @@ import argparse
|
|||
import configparser
|
||||
import glob
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -24,6 +25,12 @@ import urllib.request
|
|||
# * use gettext for i18n
|
||||
|
||||
def main():
|
||||
## early defaults detection
|
||||
architecture = platform.machine()
|
||||
|
||||
if (architecture == 'x86_64'):
|
||||
architecture = 'amd64'
|
||||
|
||||
## Parsing Arguments
|
||||
arguments = argparse.ArgumentParser(
|
||||
prog = 'lb init',
|
||||
|
@ -34,27 +41,54 @@ def main():
|
|||
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')
|
||||
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('--distribution', help='set default distribution', default='jessie')
|
||||
arguments.add_argument('--project', help='set project defaults', default='debian')
|
||||
arguments.add_argument('--system', help='set system type', default='live')
|
||||
arguments.add_argument('--project', help='set project defaults', default='debian')
|
||||
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()
|
||||
|
||||
# --verbose
|
||||
verbose = args.verbose
|
||||
|
||||
# --distribution
|
||||
distribution = args.distribution
|
||||
|
||||
# --project
|
||||
project = args.project
|
||||
|
||||
# --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
|
||||
|
||||
if not system:
|
||||
|
@ -72,6 +106,31 @@ def main():
|
|||
|
||||
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
|
||||
|
||||
# stagefile
|
||||
|
@ -94,6 +153,39 @@ def main():
|
|||
|
||||
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
|
||||
if (project == 'progress-linux'):
|
||||
# dependencies
|
||||
|
|
|
@ -26,7 +26,6 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\
|
|||
\t [--apt-recommends true|false]\n\
|
||||
\t [--apt-secure 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 [--binary-filesystem fat16|fat32|ext2|ext3|ext4|ntfs]\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-tarball true|false]\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 [--source true|false]\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:,
|
||||
cache-stages:,debconf-frontend:,debconf-priority:,dump,
|
||||
initramfs:,initramfs-compression:,initsystem:,fdisk:,losetup:,mode:,system:,tasksel:,
|
||||
templates:,architectures:,clean,
|
||||
distribution:,parent-distribution:,parent-debian-installer-distribution:,parent-mirror-bootstrap:,parent-mirror-chroot:,parent-mirror-chroot-security:,parent-mirror-binary:,
|
||||
templates:,clean,
|
||||
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:,
|
||||
mirror-bootstrap:,mirror-chroot:,mirror-chroot-security:,mirror-binary:,
|
||||
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:,
|
||||
security:,updates:,backports:,binary-filesystem:,binary-images:,
|
||||
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
|
||||
-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)
|
||||
LB_PARENT_MIRROR_BOOTSTRAP="${2}"
|
||||
shift 2
|
||||
|
@ -421,16 +403,6 @@ Local_arguments ()
|
|||
shift 2
|
||||
;;
|
||||
|
||||
--archive-areas)
|
||||
LIVE_IMAGE_ARCHIVE_AREAS="${2}"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--parent-archive-areas)
|
||||
LIVE_IMAGE_PARENT_ARCHIVE_AREAS="${2}"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
# config/chroot
|
||||
--chroot-filesystem)
|
||||
LB_CHROOT_FILESYSTEM="${2}"
|
||||
|
@ -1338,33 +1310,5 @@ then
|
|||
rmdir --ignore-fail-on-non-empty local > /dev/null 2>&1 || true
|
||||
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
|
||||
Create_stagefile .build/config
|
||||
|
|
Loading…
Reference in New Issue