mirror of
https://github.com/clearlinux/bundle-chroot-builder.git
synced 2026-08-19 12:06:37 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9fc98a03b1 | |||
| c96046001e | |||
| 0d0e64e2a9 | |||
| be05f6b513 | |||
| d07ac01932 | |||
| 82bd4409f8 | |||
| 78e419ee2c | |||
| 9d987f5e3b | |||
| 629f940676 | |||
| 68084ca1b6 | |||
| 4225b901a9 | |||
| dee894f28d | |||
| 9919c1523f | |||
| bda3519d4d | |||
| a1c4e4a5c5 |
+9
-6
@@ -1,10 +1,13 @@
|
|||||||
[Builder]
|
[Builder]
|
||||||
SERVER_STATE_DIR = /var/lib/update
|
SERVER_STATE_DIR=/home/clr/mix/update
|
||||||
BUNDLE_DIR = /home/clr/mix/bundles
|
BUNDLE_DIR=/home/clr/mix/mix-bundles
|
||||||
YUM_CONF = /usr/share/defaults/bundle-chroot-builder/yum.conf
|
YUM_CONF=/home/clr/mix/.yum-mix.conf
|
||||||
|
CERT=/home/clr/mix/ClearLinuxRoot.pem
|
||||||
|
CLEAR_VERSION=VER
|
||||||
|
MIX_VERSION=VER
|
||||||
|
|
||||||
[swupd]
|
[swupd]
|
||||||
BUNDLE=os-core-update
|
BUNDLE=os-core-update
|
||||||
CONTENTURL=https://download.clearlinux.org/update/
|
CONTENTURL=<URL where the content will be hosted>
|
||||||
VERSIONURL=https://download.clearlinux.org/update/
|
VERSIONURL=<URL where the version of the mix will be hosted>
|
||||||
FORMAT=3
|
FORMAT=1
|
||||||
|
|||||||
+31
-14
@@ -54,6 +54,7 @@ def read_config(args):
|
|||||||
if args.config:
|
if args.config:
|
||||||
buildconf = args.config
|
buildconf = args.config
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
print("Reading from %s" % buildconf)
|
||||||
config.read(buildconf)
|
config.read(buildconf)
|
||||||
|
|
||||||
for option in ['SERVER_STATE_DIR', 'BUNDLE_DIR', 'YUM_CONF']:
|
for option in ['SERVER_STATE_DIR', 'BUNDLE_DIR', 'YUM_CONF']:
|
||||||
@@ -163,7 +164,9 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
|||||||
with open(state_dir + "/server.ini", "w+") as serverini:
|
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")
|
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:
|
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")
|
groupsini.write("[" + bundle + "]\ngroup=" + bundle + "\n\n")
|
||||||
|
|
||||||
"""Setup chroots for bundles"""
|
"""Setup chroots for bundles"""
|
||||||
@@ -175,8 +178,8 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
|||||||
out_version = args.version
|
out_version = args.version
|
||||||
build_version = args.version
|
build_version = args.version
|
||||||
|
|
||||||
if os.path.exists(state_dir + "/image/latest.version") == False:
|
if os.path.exists(state_dir + "/image/LAST_VER") == False:
|
||||||
with open(state_dir + "/image/latest.version", "w") as latestver:
|
with open(state_dir + "/image/LAST_VER", "w") as latestver:
|
||||||
latestver.write("0\n")
|
latestver.write("0\n")
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
@@ -261,6 +264,7 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
|||||||
|
|
||||||
bundle_list = os.listdir(bundles)
|
bundle_list = os.listdir(bundles)
|
||||||
bundle_list.remove('os-core')
|
bundle_list.remove('os-core')
|
||||||
|
bundle_list = trim_bundles(bundle_list)
|
||||||
pool = multiprocessing.Pool()
|
pool = multiprocessing.Pool()
|
||||||
results_list = []
|
results_list = []
|
||||||
|
|
||||||
@@ -299,15 +303,19 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
|||||||
versionurl = conf['VERSIONURL']
|
versionurl = conf['VERSIONURL']
|
||||||
formatname = conf['FORMAT']
|
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!"""
|
"""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/")
|
confpath = os.path.join(out_dir, bundlename, "usr/share/defaults/swupd/")
|
||||||
os.makedirs(confpath, exist_ok=True)
|
os.makedirs(confpath, exist_ok=True)
|
||||||
with open(os.path.join(confpath, "contenturl"), "w") as file:
|
with open(os.path.join(confpath, "contenturl"), "w") as file:
|
||||||
file.writelines(contenturl)
|
file.writelines(contenturl)
|
||||||
|
print(" contenturl: {}".format(contenturl))
|
||||||
with open(os.path.join(confpath, "versionurl"), "w") as file:
|
with open(os.path.join(confpath, "versionurl"), "w") as file:
|
||||||
file.writelines(versionurl)
|
file.writelines(versionurl)
|
||||||
|
print(" versionurl: {}".format(versionurl))
|
||||||
with open(os.path.join(confpath, "format"), "w") as file:
|
with open(os.path.join(confpath, "format"), "w") as file:
|
||||||
file.writelines(formatname)
|
file.writelines(formatname)
|
||||||
|
print(" format: {}".format(formatname))
|
||||||
|
|
||||||
print("Creating package to file mappings")
|
print("Creating package to file mappings")
|
||||||
package_mapping = {}
|
package_mapping = {}
|
||||||
@@ -318,14 +326,14 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
|||||||
# real package's filename I'm using it instead of recursing through
|
# real package's filename I'm using it instead of recursing through
|
||||||
# temporary per bundle folders
|
# temporary per bundle folders
|
||||||
package_name = map_file[map_file.find(" * ") + 3:-len(".src.rpm")]
|
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()
|
path_list = file.readlines()
|
||||||
if package_name not in package_mapping:
|
if package_name not in package_mapping:
|
||||||
package_mapping[package_name] = set()
|
package_mapping[package_name] = set()
|
||||||
for path in path_list:
|
for path in path_list:
|
||||||
package_mapping[package_name].add(path)
|
package_mapping[package_name].add(path)
|
||||||
for package_name, paths in package_mapping.items():
|
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))
|
file.writelines(sorted(paths))
|
||||||
for map_file in map_files:
|
for map_file in map_files:
|
||||||
os.unlink(out_dir + "/" + map_file)
|
os.unlink(out_dir + "/" + map_file)
|
||||||
@@ -335,16 +343,17 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
|||||||
|
|
||||||
print("Cleaning package list")
|
print("Cleaning package list")
|
||||||
web_dir = state_dir + "/www/" + out_version + "/"
|
web_dir = state_dir + "/www/" + out_version + "/"
|
||||||
|
image_dir = state_dir + "/image/" + out_version + "/"
|
||||||
if os.path.isdir(web_dir):
|
if os.path.isdir(web_dir):
|
||||||
print(" removing pre-existing {} before setting version file" .format(web_dir))
|
print(" removing pre-existing {} before setting version file" .format(web_dir))
|
||||||
os.system('rm -rf '+web_dir)
|
os.system('rm -rf '+web_dir)
|
||||||
# FIXME: Figure out problems with the below to replace the above.
|
# FIXME: Figure out problems with the below to replace the above.
|
||||||
# Consider all uses of os.system("rm -fr") as FIXMEs of the same variety.
|
# Consider all uses of os.system("rm -fr") as FIXMEs of the same variety.
|
||||||
# if os.path.isdir(web_dir):
|
# if os.path.isdir(image_dir):
|
||||||
# print(" removing pre-existing {} before setting version file"
|
# print(" removing pre-existing {} before setting version file"
|
||||||
# .format(web_dir))
|
# .format(imagedir())
|
||||||
# shutil.rmtree(web_dir)
|
# shutil.rmtree(image_dir)
|
||||||
os.makedirs(web_dir + '/noship')
|
os.makedirs(image_dir + '/noship')
|
||||||
versions_output = []
|
versions_output = []
|
||||||
with open(out_dir + "/versions", "r") as file:
|
with open(out_dir + "/versions", "r") as file:
|
||||||
versions = set()
|
versions = set()
|
||||||
@@ -362,16 +371,24 @@ def create_chroots(args, state_dir, bundles, yum_conf):
|
|||||||
versions_output.append("{0: <50}{1}\n".format("Available", "Packages"))
|
versions_output.append("{0: <50}{1}\n".format("Available", "Packages"))
|
||||||
for name, pver in [line.split(":") for line in versions]:
|
for name, pver in [line.split(":") for line in versions]:
|
||||||
versions_output.append("{0: <50}{1}\n".format(name, pver))
|
versions_output.append("{0: <50}{1}\n".format(name, pver))
|
||||||
with open(web_dir + "versions", "w") as file:
|
with open(image_dir + "versions", "w") as file:
|
||||||
file.writelines(versions_output)
|
file.writelines(versions_output)
|
||||||
for bundle in os.listdir(bundles):
|
bundle_list = os.listdir(bundles)
|
||||||
shutil.copyfile(out_dir + "/packages-{}".format(bundle), web_dir + "/noship/packages-{}".format(bundle))
|
bundle_list = trim_bundles(bundle_list)
|
||||||
|
for bundle in bundle_list:
|
||||||
|
shutil.copyfile(out_dir + "/packages-{}".format(bundle), image_dir + "/noship/packages-{}".format(bundle))
|
||||||
if os.path.isfile(out_dir + "/{}-includes".format(bundle)):
|
if os.path.isfile(out_dir + "/{}-includes".format(bundle)):
|
||||||
shutil.copyfile(out_dir + "/{}-includes".format(bundle), web_dir + "/noship/{}-includes".format(bundle))
|
shutil.copyfile(out_dir + "/{}-includes".format(bundle), image_dir + "/noship/{}-includes".format(bundle))
|
||||||
for package_name in package_mapping.keys():
|
for package_name in package_mapping.keys():
|
||||||
shutil.copyfile(out_dir + "/files-{}".format(package_name),
|
shutil.copyfile(out_dir + "/files-{}".format(package_name),
|
||||||
web_dir + "/noship/files-{}".format(package_name))
|
image_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():
|
def main():
|
||||||
"""Entry point for chroot creator"""
|
"""Entry point for chroot creator"""
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
AC_PREREQ([2.68])
|
AC_PREREQ([2.68])
|
||||||
AC_INIT([bundle-chroot-builder],[1.03],[tudor.marcu@intel.com],[bundle-chroot-builder])
|
AC_INIT([bundle-chroot-builder],[1.08],[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