mirror of
				https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
				synced 2025-11-04 02:24:24 +00:00 
			
		
		
		
	Partially support versioned provides
With this patch, Britney will correctly parse (and deparse) a versioned Provides. Furthermore, she will allow it to satisfy any unversioned dependency on the provided package. This is the easy half of #786803. Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
		
							parent
							
								
									8d94bbc212
								
							
						
					
					
						commit
						7fcb6e3354
					
				
							
								
								
									
										29
									
								
								britney.py
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								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)
 | 
			
		||||
 | 
			
		||||
@ -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")
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user