mirror of
https://github.com/clearlinux/bundle-chroot-builder.git
synced 2026-08-19 03:57:21 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f17b8187e | |||
| df44fd82f0 | |||
| 2b92b2eff2 | |||
| e6e3bab777 | |||
| ff6a30cc43 | |||
| 798b4e8906 | |||
| 6a0cafa617 |
@@ -1,3 +1,23 @@
|
|||||||
|
Building this Project
|
||||||
|
=====================
|
||||||
|
For help using automake see
|
||||||
|
http://www.gnu.org/software/automake/manual/html_node/index.html
|
||||||
|
|
||||||
|
Configure:
|
||||||
|
aclocal
|
||||||
|
autoconf
|
||||||
|
automake --add-missing
|
||||||
|
# Defaults to /usr/local or specific --prefix=/usr
|
||||||
|
# to overwrite the installed version
|
||||||
|
./configure
|
||||||
|
|
||||||
|
Build:
|
||||||
|
make
|
||||||
|
|
||||||
|
Install:
|
||||||
|
make -n install
|
||||||
|
sudo make install
|
||||||
|
|
||||||
Configuration File
|
Configuration File
|
||||||
==================
|
==================
|
||||||
Please update the configuration file paths to point to where your
|
Please update the configuration file paths to point to where your
|
||||||
|
|||||||
@@ -10,3 +10,8 @@ BUNDLE=os-core-update
|
|||||||
CONTENTURL=<URL where the content will be hosted>
|
CONTENTURL=<URL where the content will be hosted>
|
||||||
VERSIONURL=<URL where the version of the mix will be hosted>
|
VERSIONURL=<URL where the version of the mix will be hosted>
|
||||||
FORMAT=1
|
FORMAT=1
|
||||||
|
|
||||||
|
[Server]
|
||||||
|
debuginfo_banned=true
|
||||||
|
debuginfo_lib=/usr/lib/debug/
|
||||||
|
debuginfo_src=/usr/src/debug/
|
||||||
|
|||||||
+59
-16
@@ -25,6 +25,7 @@ import argparse
|
|||||||
import configparser
|
import configparser
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import io
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@@ -47,16 +48,32 @@ def handle_options():
|
|||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def read_config(args):
|
def get_config(args):
|
||||||
buildconf='/usr/share/defaults/bundle-chroot-builder/builder.conf'
|
buildconf='/usr/share/defaults/bundle-chroot-builder/builder.conf'
|
||||||
if os.path.isfile('/etc/bundle-chroot-builder/builder.conf'):
|
if os.path.isfile('/etc/bundle-chroot-builder/builder.conf'):
|
||||||
buildconf = '/etc/bundle-chroot-builder/builder.conf'
|
buildconf = '/etc/bundle-chroot-builder/builder.conf'
|
||||||
if args.config:
|
if args.config:
|
||||||
buildconf = args.config
|
buildconf = args.config
|
||||||
config = configparser.ConfigParser()
|
|
||||||
print("Reading from %s" % buildconf)
|
|
||||||
config.read(buildconf)
|
|
||||||
|
|
||||||
|
print("Reading from %s" % buildconf)
|
||||||
|
cfg_txt = ""
|
||||||
|
# Check that the environment variables in the config file are valid
|
||||||
|
pattern = re.compile("\$\{?(\w+)\}?")
|
||||||
|
for i, line in enumerate(open(buildconf, 'r')):
|
||||||
|
for match in re.finditer(pattern, line):
|
||||||
|
if not match.group(1) in os.environ:
|
||||||
|
print("ERROR:\nbuilder.conf contains an undefined environment variable: %s on line %s\n"
|
||||||
|
% (i+1, match.group(1)))
|
||||||
|
exit(1)
|
||||||
|
cfg_txt += os.path.expandvars(line)
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.readfp(io.StringIO(cfg_txt))
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
def read_config(args):
|
||||||
|
config = get_config(args)
|
||||||
for option in ['SERVER_STATE_DIR', 'BUNDLE_DIR', 'YUM_CONF']:
|
for option in ['SERVER_STATE_DIR', 'BUNDLE_DIR', 'YUM_CONF']:
|
||||||
if config.has_option('Builder', option) == False:
|
if config.has_option('Builder', option) == False:
|
||||||
print("ERROR:\nbuilder.conf is missing:\n[Builder]\n%s\n" % option)
|
print("ERROR:\nbuilder.conf is missing:\n[Builder]\n%s\n" % option)
|
||||||
@@ -151,6 +168,37 @@ def clean_bundle(out_dir, bundle, bundles, yum_cmd):
|
|||||||
os.chdir(prev_dir)
|
os.chdir(prev_dir)
|
||||||
|
|
||||||
|
|
||||||
|
def write_default_server_ini(state_dir, server_conf):
|
||||||
|
"""
|
||||||
|
Write default server.ini file in the state dir in the following format
|
||||||
|
|
||||||
|
[Server]
|
||||||
|
emptydir={state_dir}/empty/
|
||||||
|
imagebase={state_dir}/image/
|
||||||
|
outputdir={state_dir}/www/
|
||||||
|
|
||||||
|
[Debuginfo]
|
||||||
|
banned=true
|
||||||
|
lib=/usr/lib/debug/
|
||||||
|
src=/usr/src/debug/
|
||||||
|
"""
|
||||||
|
contents = ("[Server]\n"
|
||||||
|
"emptydir={0}/empty/\n"
|
||||||
|
"imagebase={0}/image/\n"
|
||||||
|
"outputdir={0}/www/\n".format(state_dir))
|
||||||
|
if server_conf:
|
||||||
|
contents += ("\n[Debuginfo]\n"
|
||||||
|
"banned={}\n"
|
||||||
|
"lib={}\n"
|
||||||
|
"src={}\n"
|
||||||
|
.format(server_conf.get('debuginfo_banned'),
|
||||||
|
server_conf.get('debuginfo_lib'),
|
||||||
|
server_conf.get('debuginfo_src')))
|
||||||
|
|
||||||
|
with open(state_dir + "/server.ini", "w+") as serverini:
|
||||||
|
serverini.write(contents)
|
||||||
|
|
||||||
|
|
||||||
def create_chroots(args, state_dir, bundles, yum_conf):
|
def create_chroots(args, state_dir, bundles, yum_conf):
|
||||||
"""The state_dir should always be created if it does not exist"""
|
"""The state_dir should always be created if it does not exist"""
|
||||||
if os.path.isdir(state_dir) == False:
|
if os.path.isdir(state_dir) == False:
|
||||||
@@ -164,14 +212,15 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
|||||||
if os.path.isdir(state_dir + "/www/0") == False:
|
if os.path.isdir(state_dir + "/www/0") == False:
|
||||||
os.makedirs(state_dir + "/www/0")
|
os.makedirs(state_dir + "/www/0")
|
||||||
|
|
||||||
"""Create server.ini and groups.ini for create_update later on"""
|
# Create server.ini and groups.ini for create_update later on
|
||||||
with open(state_dir + "/server.ini", "w+") as serverini:
|
config = get_config(args)
|
||||||
serverini.write("[Server]\nemptydir=" + state_dir + "/empty/\nimagebase=" + state_dir + "/image/\noutputdir=" + state_dir + "/www/\n")
|
config = config['Server'] if 'Server' in config else {}
|
||||||
|
write_default_server_ini(state_dir, config)
|
||||||
with open(state_dir + "/groups.ini", "w+") as groupsini:
|
with open(state_dir + "/groups.ini", "w+") as groupsini:
|
||||||
bundle_list = os.listdir(bundles)
|
bundle_list = os.listdir(bundles)
|
||||||
bundle_list = trim_bundles(bundle_list)
|
bundle_list = trim_bundles(bundle_list)
|
||||||
for bundle in bundle_list:
|
for bundle in bundle_list:
|
||||||
groupsini.write("[" + bundle + "]\ngroup=" + bundle + "\n\n")
|
groupsini.write("[{0}]\ngroup={0}\n\n".format(bundle))
|
||||||
|
|
||||||
"""Setup chroots for bundles"""
|
"""Setup chroots for bundles"""
|
||||||
bversion = ""
|
bversion = ""
|
||||||
@@ -205,7 +254,7 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
|||||||
packager = ["dnf"]
|
packager = ["dnf"]
|
||||||
else:
|
else:
|
||||||
packager = ["yum"]
|
packager = ["yum"]
|
||||||
yum_cmd = packager + ["--config={}".format(yum_conf), "-y", "--noplugins", "--releasever={}".format(build_version)]
|
yum_cmd = packager + ["--config={}".format(yum_conf), "-y", "--releasever={}".format(build_version)]
|
||||||
if 'local' in config == False:
|
if 'local' in config == False:
|
||||||
try:
|
try:
|
||||||
urllib.request.urlopen(conf_baseurl)
|
urllib.request.urlopen(conf_baseurl)
|
||||||
@@ -288,13 +337,7 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
|||||||
r.get()
|
r.get()
|
||||||
|
|
||||||
"""Read the URL values from builder.conf and insert them into os-core-update to swupd knows where to pull content from"""
|
"""Read the URL values from builder.conf and insert them into os-core-update to swupd knows where to pull content from"""
|
||||||
buildconf='/usr/share/defaults/bundle-chroot-builder/builder.conf'
|
config = get_config(args)
|
||||||
if os.path.isfile('/etc/bundle-chroot-builder/builder.conf'):
|
|
||||||
buildconf = '/etc/bundle-chroot-builder/builder.conf'
|
|
||||||
if args.config:
|
|
||||||
buildconf = args.config
|
|
||||||
config = configparser.ConfigParser()
|
|
||||||
config.read(buildconf)
|
|
||||||
|
|
||||||
"""Read the configuration file for our script values"""
|
"""Read the configuration file for our script values"""
|
||||||
for option in ['BUNDLE', 'CONTENTURL', 'VERSIONURL', 'FORMAT']:
|
for option in ['BUNDLE', 'CONTENTURL', 'VERSIONURL', 'FORMAT']:
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
AC_PREREQ([2.68])
|
AC_PREREQ([2.68])
|
||||||
AC_INIT([bundle-chroot-builder],[1.10],[tudor.marcu@intel.com],[bundle-chroot-builder])
|
AC_INIT([bundle-chroot-builder],[1.13],[tudor.marcu@intel.com],[bundle-chroot-builder])
|
||||||
AM_INIT_AUTOMAKE([foreign silent-rules color-tests no-dist-gzip dist-xz])
|
AM_INIT_AUTOMAKE([foreign silent-rules color-tests no-dist-gzip dist-xz])
|
||||||
AC_CONFIG_FILES(Makefile)
|
AC_CONFIG_FILES(Makefile)
|
||||||
AC_PREFIX_DEFAULT(/usr/local)
|
AC_PREFIX_DEFAULT(/usr/local)
|
||||||
|
|||||||
Reference in New Issue
Block a user