| |
@@ -79,8 +79,24 @@
|
| |
|
| |
# Filenames must match their contents
|
| |
expected_name = os.path.basename(filename).rsplit(".", maxsplit=1)[0]
|
| |
+ if obsoletes:
|
| |
+ if ":" not in expected_name:
|
| |
+ error(
|
| |
+ "Module obsoletes filename must be in the form of "
|
| |
+ "<name>:<old_stream>.yaml"
|
| |
+ )
|
| |
+ return False, None
|
| |
+ expected_module_name, expected_stream = expected_name.rsplit(":", maxsplit=1)
|
| |
+ if (expected_module_name != mmd.props.module_name
|
| |
+ or expected_stream != mmd.props.module_stream):
|
| |
+ error(
|
| |
+ 'Module name/stream "{}:{}" doesn\'t match filename "{}.yaml"'.format(
|
| |
+ mmd.props.module_name, mmd.props.module_stream, expected_name
|
| |
+ )
|
| |
+ )
|
| |
+ return False, None
|
| |
|
| |
- if expected_name != mmd.props.module_name:
|
| |
+ elif expected_name != mmd.props.module_name:
|
| |
error(
|
| |
'Module name "{}" doesn\'t match filename "{}.yaml"'.format(
|
| |
mmd.props.module_name, expected_name
|
| |
@@ -123,6 +139,7 @@
|
| |
script_dir = os.path.dirname(os.path.realpath(__file__))
|
| |
defaults_dir = os.path.abspath(os.path.join(script_dir, '..'))
|
| |
overrides_dir = os.path.join(defaults_dir, 'overrides')
|
| |
+ obsoletes_dir = os.path.abspath(os.path.join(script_dir, '..', 'obsoletes'))
|
| |
|
| |
# Get the repo we're running in
|
| |
repo = git.Repo(defaults_dir, search_parent_directories=True)
|
| |
@@ -153,6 +170,12 @@
|
| |
else:
|
| |
defaults_files.append(x)
|
| |
|
| |
+ print("\nValidation of modulemd documents:\n"
|
| |
+ "=================================")
|
| |
+
|
| |
+ if defaults_files:
|
| |
+ print("\nModule defaults:\n"
|
| |
+ "----------------")
|
| |
# Validate module defaults files
|
| |
for file in defaults_files:
|
| |
(valid, _) = do_validate(file)
|
| |
@@ -160,6 +183,9 @@
|
| |
error("{} failed to validate".format(file))
|
| |
result = os.EX_DATAERR
|
| |
|
| |
+ if obsoletes_test_files:
|
| |
+ print("\nModule obsoletes (testing):\n"
|
| |
+ "---------------------------")
|
| |
# Validate module obsoletes test files
|
| |
for file in obsoletes_test_files:
|
| |
(valid, _) = do_validate(file, obsoletes=True)
|
| |
@@ -170,6 +196,8 @@
|
| |
if result == os.EX_DATAERR:
|
| |
return result
|
| |
|
| |
+ print("\nDefault streams (Runtime):\n"
|
| |
+ "==========================")
|
| |
# For sanity's sake, also do a merge of all the defaults to make sure no
|
| |
# conflicts arise that weren't detected by the above tests. This should be
|
| |
# impossible.
|
| |
@@ -177,11 +205,6 @@
|
| |
idx_runtime = Modulemd.ModuleIndex()
|
| |
idx_runtime.update_from_defaults_directory(path=defaults_dir,
|
| |
strict=True)
|
| |
- # for obsoletes tests, because simple index copy is not possible
|
| |
- # due to: GObject descendants' instances are non-copyable
|
| |
- idx_tests = Modulemd.ModuleIndex()
|
| |
- idx_tests.update_from_defaults_directory(path=defaults_dir,
|
| |
- strict=True)
|
| |
except GLib.Error as e:
|
| |
error("Could not merge all defaults: {}".format(e.message))
|
| |
result = os.EX_DATAERR
|
| |
@@ -189,11 +212,11 @@
|
| |
if result == os.EX_OK:
|
| |
info("Merging all of the documents encountered no errors.")
|
| |
|
| |
- print("\nDefault streams (Runtime):\n"
|
| |
- "==========================")
|
| |
for m, s in idx_runtime.get_default_streams().items():
|
| |
print("{}:{}".format(m, s))
|
| |
|
| |
+ print("\nDefault streams (Buildroot):\n"
|
| |
+ "============================")
|
| |
try:
|
| |
idx_buildroot = Modulemd.ModuleIndex()
|
| |
idx_buildroot.update_from_defaults_directory(path=defaults_dir,
|
| |
@@ -206,44 +229,37 @@
|
| |
if result == os.EX_OK:
|
| |
info("Merging all of the documents encountered no errors.")
|
| |
|
| |
- print("\nDefault streams (Buildroot):\n"
|
| |
- "============================")
|
| |
for m, s in idx_buildroot.get_default_streams().items():
|
| |
print("{}:{}".format(m, s))
|
| |
|
| |
- # Try merging TEST module obsoletes into the module defaults index.
|
| |
- for file in obsoletes_test_files:
|
| |
- (_, mmd) = do_validate(file, obsoletes=True)
|
| |
- idx_tests.add_obsoletes(mmd)
|
| |
+ print("\nObsoletes:\n"
|
| |
+ "==========")
|
| |
|
| |
- print("\nObsoletes (tests):\n"
|
| |
- "==================")
|
| |
- for module_name in idx_tests.get_module_names():
|
| |
- module = idx_tests.get_module(module_name)
|
| |
- obsoletes = module.get_obsoletes()
|
| |
- if not obsoletes:
|
| |
- continue
|
| |
- if len(obsoletes) > 1:
|
| |
- result = os.EX_DATAERR
|
| |
- break
|
| |
- print("{}:{}".format(module_name, obsoletes[0].props.module_stream))
|
| |
+ try:
|
| |
+ idx_obsoletes = Modulemd.ModuleIndex()
|
| |
+ idx_obsoletes.update_from_defaults_directory(path=obsoletes_dir,
|
| |
+ strict=True)
|
| |
+ # Try merging module obsoletes into the module obsoletes index.
|
| |
+ for file in obsoletes_files:
|
| |
+ (_, mmd) = do_validate(file, obsoletes=True)
|
| |
+ if not mmd:
|
| |
+ result = os.EX_DATAERR
|
| |
+ break
|
| |
+ idx_obsoletes.add_obsoletes(mmd)
|
| |
+ except GLib.Error as e:
|
| |
+ error("Could not merge all obsoletes: {}".format(e.message))
|
| |
+ result = os.EX_DATAERR
|
| |
|
| |
- # Try merging module obsoletes into the module defaults index.
|
| |
- for file in obsoletes_files:
|
| |
- (_, mmd) = do_validate(file, obsoletes=True)
|
| |
- idx_runtime.add_obsoletes(mmd)
|
| |
+ if result == os.EX_OK:
|
| |
+ info("Merging all of the documents encountered no errors.")
|
| |
|
| |
- print("\nObsoletes:\n"
|
| |
- "==========")
|
| |
- for module_name in idx_runtime.get_module_names():
|
| |
- module = idx_runtime.get_module(module_name)
|
| |
+ for module_name in idx_obsoletes.get_module_names():
|
| |
+ module = idx_obsoletes.get_module(module_name)
|
| |
obsoletes = module.get_obsoletes()
|
| |
if not obsoletes:
|
| |
- continue
|
| |
- if len(obsoletes) > 1:
|
| |
+ error("Module {} has no obsoletes.".format(module_name))
|
| |
result = os.EX_DATAERR
|
| |
break
|
| |
- print("{}:{}".format(module_name, obsoletes[0].props.module_stream))
|
| |
|
| |
return result
|
| |
|
| |
Signed-off-by: Filip Valder fvalder@redhat.com