Compare commits

...

10 Commits

Author SHA1 Message Date
Tudor Marcu bda3519d4d Release v1.04
This release introduces functionality to blacklist/ignore bundles beginning with
a '.', and will support other banned characters in the future.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-05-03 20:26:44 +00:00
Tudor Marcu a1c4e4a5c5 Do not accept bundles beginning with '.'
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-05-03 20:26:01 +00:00
Brad T. Peters 58ddb254dc Release v1.03
This release patches a bug where whitespace was not being
correctly stripped from package names

Signed-off-by: Brad T. Peters <brad.t.peters@intel.com>
2016-04-12 13:58:56 -07:00
Brad T. Peters 18620f4efb Fix whitespace issue with pkg name
Preceeding or trailing whitespaces must be stripped

Signed-off-by: Brad T. Peters <brad.t.peters@intel.com>
2016-04-12 13:54:59 -07:00
Tudor Marcu efaa5b9051 Release v1.02
This release includes fixes for validating builder.conf is correct, and fixes a
bug where the chroot builder would loop forever if m4 output was too large.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-03-29 11:54:08 -07:00
Tudor Marcu d5d8692156 Remove URL option as content & version are enough
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-03-28 14:16:54 -07:00
Tudor Marcu ef79a9ce59 Fix m4 infinite wait()
If there are a lot of packages then the m4 output will overflow the max
PIPE buffer, and the wait() will never finish. This patch reads the output
in chunks and then creates a string of the entire output to pass to yum.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-03-28 14:09:50 -07:00
Tudor Marcu 2d1f4a75cd Make sure builder.conf is filled correctly
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-03-25 17:02:51 -07:00
Tudor Marcu 24d8b59fdf Remove leading slash in os.path.join()
The os.path.join() function discard any previos paths/variables when it
encounters one starting with a leading "/" so the statedir & bundle name were
completely ignored when it ran into /usr/share/defaults/...
This fixes it so the path is correctly made, and the dirs and files should be
installed correctly.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-03-25 13:08:32 -07:00
tmarcu 4cdc1ea888 Merge pull request #2 from clearlinux/url_confs
Add url for swupd in builder.conf
2016-03-24 17:01:23 -07:00
3 changed files with 34 additions and 14 deletions
-1
View File
@@ -5,7 +5,6 @@ YUM_CONF = /usr/share/defaults/bundle-chroot-builder/yum.conf
[swupd]
BUNDLE=os-core-update
URL=https://download.clearlinux.org/update/
CONTENTURL=https://download.clearlinux.org/update/
VERSIONURL=https://download.clearlinux.org/update/
FORMAT=3
+33 -12
View File
@@ -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 = []
@@ -281,17 +292,19 @@ def create_chroots(args, state_dir, bundles, yum_conf):
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']
url = conf['URL']
contenturl = conf['CONTENTURL']
versionurl = conf['VERSIONURL']
formatname = conf['FORMAT']
confpath = os.path.join(out_dir, bundlename, "/usr/share/defaults/swupd/")
os.mkdir(confpath)
with open(os.path.join(confpath, "url"), "w") as file:
file.writelines(url)
"""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)
with open(os.path.join(confpath, "versionurl"), "w") as file:
@@ -354,7 +367,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))
@@ -362,6 +377,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
View File
@@ -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.04],[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)