diff --git a/britney.py b/britney.py index 7c0985c..a75be5d 100755 --- a/britney.py +++ b/britney.py @@ -691,11 +691,24 @@ class Britney(object): # register virtual packages and real packages that provide them if dpkg[PROVIDES]: - parts = [p.strip() for p in dpkg[PROVIDES].split(",")] - for p in parts: - provides[p].add(pkg) - dpkg[PROVIDES] = parts - else: dpkg[PROVIDES] = [] + parts = apt_pkg.parse_depends(dpkg[PROVIDES], False) + nprov = [] + for or_clause in parts: + if len(or_clause) != 1: + msg = "Ignoring invalid provides in %s: Alternatives [%s]" % (str(pkg_id), str(or_clause)) + self.__log(msg, type='W') + continue + for part in or_clause: + provided, version, op = part + if op != '' and op != '=': + msg = "Ignoring invalid provides in %s: %s (%s %s)" % (str(pkg_id), provided, op, version) + self.__log(msg, type='W') + continue + provides[provided].add(pkg) + nprov.append(part) + dpkg[PROVIDES] = nprov + else: + dpkg[PROVIDES] = [] # add the resulting dictionary to the package list packages[pkg] = dpkg @@ -2086,7 +2099,8 @@ class Britney(object): affected.update(inst_tester.negative_dependencies_of(rm_pkg_id)) # remove the provided virtual packages - for j in pkg_data[PROVIDES]: + for prov_rel in pkg_data[PROVIDES]: + j = prov_rel[0] key = j + "/" + parch if key not in undo['virtual']: undo['virtual'][key] = provides_t_a[j].copy() @@ -2168,7 +2182,8 @@ class Britney(object): binaries_t_a[binary] = new_pkg_data inst_tester.add_testing_binary(updated_pkg_id) # register new provided packages - for j in new_pkg_data[PROVIDES]: + for prov_rel in new_pkg_data[PROVIDES]: + j = prov_rel[0] key = j + "/" + parch if j not in provides_t_a: undo['nvirtual'].append(key) diff --git a/britney_util.py b/britney_util.py index 1cb96d6..6363c58 100644 --- a/britney_util.py +++ b/britney_util.py @@ -418,6 +418,19 @@ def write_sources(sources_s, filename): f.write(output + "\n\n") +def relation_atom_to_string(atom): + """Take a parsed dependency and turn it into a string + """ + pkg, version, rel_op = atom + if rel_op != '': + if rel_op in ('<', '>'): + # APT translate "<<" and ">>" into "<" and ">". We have + # deparse those into the original form. + rel_op += rel_op + return "%s (%s %s)" % (pkg, rel_op, version) + return pkg + + def write_controlfiles(sources, packages, suite, basedir): """Write the control files @@ -462,7 +475,7 @@ def write_controlfiles(sources, packages, suite, basedir): output += (k + ": " + source + "\n") elif key == PROVIDES: if bin_data[key]: - output += (k + ": " + ", ".join(bin_data[key]) + "\n") + output += (k + ": " + ", ".join(relation_atom_to_string(p) for p in bin_data[key]) + "\n") elif key == ESSENTIAL: if bin_data[key]: output += (k + ": " + " yes\n")