X-Git-Url: https://git.distorted.org.uk/~mdw/termux-packages/blobdiff_plain/74b5c53c18520fb467cf6411491a67370fe6fe7a..601e514efbb153ea30a8415c975fd2dc392ea431:/scripts/buildorder.py diff --git a/scripts/buildorder.py b/scripts/buildorder.py index 19cb01c8..10cdb316 100755 --- a/scripts/buildorder.py +++ b/scripts/buildorder.py @@ -31,6 +31,10 @@ def unique_everseen(iterable, key=None): def die(msg): sys.exit('ERROR: ' + msg) +def rchop(thestring, ending): + if thestring.endswith(ending): + return thestring[:-len(ending)] + return thestring class TermuxBuildFile(object): def __init__(self, path): @@ -38,27 +42,34 @@ class TermuxBuildFile(object): def _get_dependencies(self): pkg_dep_prefix = 'TERMUX_PKG_DEPENDS=' + pkg_build_dep_prefix = 'TERMUX_PKG_BUILD_DEPENDS=' subpkg_dep_prefix = 'TERMUX_SUBPKG_DEPENDS=' + comma_deps = '' - with open(self.path) as f: + with open(self.path, encoding="utf-8") as f: prefix = None for line in f: if line.startswith(pkg_dep_prefix): prefix = pkg_dep_prefix + elif line.startswith(pkg_build_dep_prefix): + prefix = pkg_build_dep_prefix elif line.startswith(subpkg_dep_prefix): prefix = subpkg_dep_prefix else: continue - comma_deps = line[len(prefix):].replace('"', '').replace("'", '') + comma_deps += line[len(prefix):].replace('"', '').replace("'", '').replace("\n", ",") - return set([ - # Replace parenthesis to handle version qualifiers, as in "gcc (>= 5.0)": - re.sub(r'\(.*?\)', '', dep).replace('-dev', '').strip() for dep in comma_deps.split(',') - ]) + # Remove trailing ',' that is otherwise replacing the final newline + comma_deps = comma_deps[:-1] + if not comma_deps: + # no deps found + return set() - # no deps found - return set() + return set([ + # Replace parenthesis to handle version qualifiers, as in "gcc (>= 5.0)": + rchop(re.sub(r'\(.*?\)', '', dep).strip(), '-dev') for dep in comma_deps.split(',') + ]) class TermuxPackage(object): @@ -218,6 +229,8 @@ def generate_targets_buildorder(targetnames): buildorder = [] for pkgname in targetnames: + if not pkgname in pkgs_map: + die('Dependencies for ' + pkgname + ' could not be calculated (skip dependency check with -s)') buildorder += deps_then_me(pkgs_map[pkgname]) return unique_everseen(buildorder)