mirror of
https://github.com/clearlinux/unbundle.git
synced 2026-09-08 06:42:15 +00:00
Correct handling for loops
Now that loops are possible, remove short circuit logic as it caused bundles to be skipped in certain cases. Signed-off-by: William Douglas <william.douglas@intel.com>
This commit is contained in:
+14
-10
@@ -2,17 +2,20 @@ import argparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
def resolve_includes(bundle_name, bundle_path, content, bundles=False, path=set(), seen=set()):
|
||||
|
||||
def resolve_includes(bundle_name, bundle_path,
|
||||
content, bundles=False, seen=None):
|
||||
"""
|
||||
resolve_incudes returns a full package list of include-resolved packages in
|
||||
the bundle definition file or pundle declaration under bundle_path. Sources
|
||||
for included bundles are other bundle definition files at
|
||||
bundle_path/bundles/* and bundle_path/packages.
|
||||
"""
|
||||
if not seen:
|
||||
seen = set()
|
||||
if bundle_name in seen:
|
||||
return True
|
||||
seen.add(bundle_name)
|
||||
path.add(bundle_name)
|
||||
bundle_def = os.path.join(bundle_path, "bundles", bundle_name)
|
||||
try:
|
||||
with open(bundle_def, "r", encoding="latin-1") as bundlef:
|
||||
@@ -28,24 +31,23 @@ def resolve_includes(bundle_name, bundle_path, content, bundles=False, path=set(
|
||||
line = line.split("#", 1)[0].strip()
|
||||
if not line:
|
||||
continue
|
||||
elif line.startswith("also-add("):
|
||||
if line.startswith("also-add("):
|
||||
continue
|
||||
elif line.startswith("include("):
|
||||
if line.startswith("include("):
|
||||
inc_bundle = line[line.find("(")+1:line.find(")")]
|
||||
if inc_bundle in path:
|
||||
return True
|
||||
success = resolve_includes(inc_bundle, bundle_path, content, bundles, path)
|
||||
success = resolve_includes(inc_bundle, bundle_path,
|
||||
content, bundles, seen)
|
||||
if not success:
|
||||
return False
|
||||
if bundles:
|
||||
content.add(inc_bundle)
|
||||
continue
|
||||
elif not bundles:
|
||||
if not bundles:
|
||||
content.add(line)
|
||||
|
||||
path.remove(bundle_name)
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Process bundle packages following includes')
|
||||
parser.add_argument('bundle_name', help='name of bundle to process')
|
||||
@@ -63,11 +65,13 @@ def main():
|
||||
if not success:
|
||||
sys.exit(1)
|
||||
|
||||
success = resolve_includes(args.bundle_name, args.bundle_path, content, bundles=args.bundles)
|
||||
success = resolve_includes(args.bundle_name, args.bundle_path, content,
|
||||
bundles=args.bundles)
|
||||
if not success:
|
||||
sys.exit(1)
|
||||
|
||||
print('\n'.join(sorted(os_core_set.union(content))))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user