mirror of
https://github.com/clearlinux/bundle-chroot-builder.git
synced 2026-06-29 09:05:51 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4225b901a9 | |||
| dee894f28d | |||
| 9919c1523f | |||
| bda3519d4d | |||
| a1c4e4a5c5 | |||
| 58ddb254dc | |||
| 18620f4efb | |||
| efaa5b9051 | |||
| d5d8692156 | |||
| ef79a9ce59 | |||
| 2d1f4a75cd | |||
| 24d8b59fdf | |||
| 4cdc1ea888 | |||
| e14a928b37 |
@@ -2,3 +2,9 @@
|
||||
SERVER_STATE_DIR = /var/lib/update
|
||||
BUNDLE_DIR = /home/clr/mix/bundles
|
||||
YUM_CONF = /usr/share/defaults/bundle-chroot-builder/yum.conf
|
||||
|
||||
[swupd]
|
||||
BUNDLE=os-core-update
|
||||
CONTENTURL=https://download.clearlinux.org/update/
|
||||
VERSIONURL=https://download.clearlinux.org/update/
|
||||
FORMAT=3
|
||||
|
||||
@@ -56,6 +56,11 @@ def read_config(args):
|
||||
config = configparser.ConfigParser()
|
||||
config.read(buildconf)
|
||||
|
||||
for option in ['SERVER_STATE_DIR', 'BUNDLE_DIR', 'YUM_CONF']:
|
||||
if config.has_option('Builder', option) == False:
|
||||
print("ERROR:\nbuilder.conf is missing:\n[Builder]\n%s\n" % option)
|
||||
exit(1)
|
||||
|
||||
"""Read the configuration file for our script values"""
|
||||
conf = config['Builder']
|
||||
state_dir = conf['SERVER_STATE_DIR']
|
||||
@@ -67,12 +72,15 @@ def read_config(args):
|
||||
|
||||
def install_bundle(out_dir, postfix, bundle, bundles, yum_cmd):
|
||||
"""Helper function to yum install a bundle"""
|
||||
m4 = subprocess.Popen(["m4", bundles + "/" + bundle], cwd=bundles, stdout=subprocess.PIPE)
|
||||
m4.wait()
|
||||
pkgs = m4.stdout.readlines()
|
||||
lines = []
|
||||
with subprocess.Popen(["m4", bundles + "/" + bundle], cwd=bundles, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) as p:
|
||||
for line in p.stdout:
|
||||
lines.append(line)
|
||||
|
||||
pkgs = "".join(lines)
|
||||
to_install = []
|
||||
for pkg in pkgs:
|
||||
pkg = pkg.decode("utf-8").strip()
|
||||
for pkg in pkgs.splitlines():
|
||||
pkg = pkg.strip()
|
||||
# Don't add blank lines or lines with leading '#'
|
||||
if len(pkg) == 0 or pkg[0] == "#":
|
||||
continue
|
||||
@@ -155,7 +163,9 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
||||
with open(state_dir + "/server.ini", "w+") as serverini:
|
||||
serverini.write("[Server]\nemptydir=" + state_dir + "/empty/\nimagebase=" + state_dir + "/image/\noutputdir=" + state_dir + "/www/\n")
|
||||
with open(state_dir + "/groups.ini", "w+") as groupsini:
|
||||
for bundle in os.listdir(bundles):
|
||||
bundle_list = os.listdir(bundles)
|
||||
bundle_list = trim_bundles(bundle_list)
|
||||
for bundle in bundle_list:
|
||||
groupsini.write("[" + bundle + "]\ngroup=" + bundle + "\n\n")
|
||||
|
||||
"""Setup chroots for bundles"""
|
||||
@@ -253,6 +263,7 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
||||
|
||||
bundle_list = os.listdir(bundles)
|
||||
bundle_list.remove('os-core')
|
||||
bundle_list = trim_bundles(bundle_list)
|
||||
pool = multiprocessing.Pool()
|
||||
results_list = []
|
||||
|
||||
@@ -271,6 +282,40 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
||||
for r in results_list:
|
||||
r.get()
|
||||
|
||||
"""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'
|
||||
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"""
|
||||
for option in ['BUNDLE', 'CONTENTURL', 'VERSIONURL', 'FORMAT']:
|
||||
if config.has_option('swupd', option) == False:
|
||||
print("ERROR:\nbuilder.conf is missing:\n[swupd]\n%s\n" % option)
|
||||
exit(1)
|
||||
conf = config['swupd']
|
||||
bundlename = conf['BUNDLE']
|
||||
contenturl = conf['CONTENTURL']
|
||||
versionurl = conf['VERSIONURL']
|
||||
formatname = conf['FORMAT']
|
||||
|
||||
print("Adding SWUPD default values to '{}' bundle...".format(bundlename))
|
||||
"""Do not add a leading slash on anything except the first variable in os.path.join!"""
|
||||
confpath = os.path.join(out_dir, bundlename, "usr/share/defaults/swupd/")
|
||||
os.makedirs(confpath, exist_ok=True)
|
||||
with open(os.path.join(confpath, "contenturl"), "w") as file:
|
||||
file.writelines(contenturl)
|
||||
print(" contenturl: {}".format(contenturl))
|
||||
with open(os.path.join(confpath, "versionurl"), "w") as file:
|
||||
file.writelines(versionurl)
|
||||
print(" versionurl: {}".format(versionurl))
|
||||
with open(os.path.join(confpath, "format"), "w") as file:
|
||||
file.writelines(formatname)
|
||||
print(" format: {}".format(formatname))
|
||||
|
||||
print("Creating package to file mappings")
|
||||
package_mapping = {}
|
||||
map_files = [f for f in os.listdir(out_dir) if f.startswith("pkgmap-")]
|
||||
@@ -280,14 +325,14 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
||||
# real package's filename I'm using it instead of recursing through
|
||||
# temporary per bundle folders
|
||||
package_name = map_file[map_file.find(" * ") + 3:-len(".src.rpm")]
|
||||
with open(out_dir + "/" + map_file, "r") as file:
|
||||
with open(out_dir + "/" + map_file, "rb") as file:
|
||||
path_list = file.readlines()
|
||||
if package_name not in package_mapping:
|
||||
package_mapping[package_name] = set()
|
||||
for path in path_list:
|
||||
package_mapping[package_name].add(path)
|
||||
for package_name, paths in package_mapping.items():
|
||||
with open(out_dir + "/files-{}".format(package_name), "w") as file:
|
||||
with open(out_dir + "/files-{}".format(package_name), "wb") as file:
|
||||
file.writelines(sorted(paths))
|
||||
for map_file in map_files:
|
||||
os.unlink(out_dir + "/" + map_file)
|
||||
@@ -326,7 +371,9 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
||||
versions_output.append("{0: <50}{1}\n".format(name, pver))
|
||||
with open(web_dir + "versions", "w") as file:
|
||||
file.writelines(versions_output)
|
||||
for bundle in os.listdir(bundles):
|
||||
bundle_list = os.listdir(bundles)
|
||||
bundle_list = trim_bundles(bundle_list)
|
||||
for bundle in bundle_list:
|
||||
shutil.copyfile(out_dir + "/packages-{}".format(bundle), web_dir + "/noship/packages-{}".format(bundle))
|
||||
if os.path.isfile(out_dir + "/{}-includes".format(bundle)):
|
||||
shutil.copyfile(out_dir + "/{}-includes".format(bundle), web_dir + "/noship/{}-includes".format(bundle))
|
||||
@@ -334,6 +381,12 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
||||
shutil.copyfile(out_dir + "/files-{}".format(package_name),
|
||||
web_dir + "/noship/files-{}".format(package_name))
|
||||
|
||||
# Remove bundles with blacklisted characters, such as dot files
|
||||
def trim_bundles(bundles):
|
||||
for bundle in bundles:
|
||||
if bundle.startswith('.'):
|
||||
bundles.remove(bundle)
|
||||
return bundles
|
||||
|
||||
def main():
|
||||
"""Entry point for chroot creator"""
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
AC_PREREQ([2.68])
|
||||
AC_INIT([bundle-chroot-builder],[1.00],[tudor.marcu@intel.com],[bundle-chroot-builder])
|
||||
AC_INIT([bundle-chroot-builder],[1.05],[tudor.marcu@intel.com],[bundle-chroot-builder])
|
||||
AM_INIT_AUTOMAKE([foreign silent-rules color-tests no-dist-gzip dist-xz])
|
||||
AC_CONFIG_FILES(Makefile)
|
||||
AC_PREFIX_DEFAULT(/usr/local)
|
||||
|
||||
Reference in New Issue
Block a user