mirror of
				https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
				synced 2025-10-31 08:34:04 +00:00 
			
		
		
		
	Refactor doop_source to simplify logic
Cleanly split doop_source into a (small) part about source packages and a (longer) part about binary packages. Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
		
							parent
							
								
									027142e12b
								
							
						
					
					
						commit
						0f45b195a6
					
				
							
								
								
									
										119
									
								
								britney.py
									
									
									
									
									
								
							
							
						
						
									
										119
									
								
								britney.py
									
									
									
									
									
								
							| @ -2170,75 +2170,66 @@ class Britney(object): | |||||||
|                                                item.is_removal, |                                                item.is_removal, | ||||||
|                                                removals=removals) |                                                removals=removals) | ||||||
| 
 | 
 | ||||||
|         # remove all binary packages (if the source already exists) |         # Handle the source package | ||||||
|         if item.architecture == 'source' or not item.is_removal: |         if item.architecture == 'source': | ||||||
|             if item.package in sources['testing']: |             if item.package in sources['testing']: | ||||||
|                 source = sources['testing'][item.package] |                 source = sources['testing'][item.package] | ||||||
| 
 |                 undo['sources'][item.package] = source | ||||||
| 
 |                 del sources['testing'][item.package] | ||||||
|                 eqv_table = {} |  | ||||||
| 
 |  | ||||||
|                 for rm_pkg_id in rms: |  | ||||||
|                     binary, _, parch = rm_pkg_id |  | ||||||
|                     key = (binary, parch) |  | ||||||
|                     eqv_table[key] = rm_pkg_id |  | ||||||
| 
 |  | ||||||
|                 for new_pkg_id in updates: |  | ||||||
|                     binary, _, parch = new_pkg_id |  | ||||||
|                     key = (binary, parch) |  | ||||||
|                     old_pkg_id = eqv_table.get(key) |  | ||||||
|                     if old_pkg_id is not None: |  | ||||||
|                         if inst_tester.are_equivalent(new_pkg_id, old_pkg_id): |  | ||||||
|                             eqv_set.add(key) |  | ||||||
| 
 |  | ||||||
|                 # remove all the binaries which aren't being smooth updated |  | ||||||
|                 for rm_pkg_id in rms: |  | ||||||
|                     binary, version, parch = rm_pkg_id |  | ||||||
|                     p = (binary, parch) |  | ||||||
|                     binaries_t_a, provides_t_a = packages_t[parch] |  | ||||||
|                     pkey = (binary, parch) |  | ||||||
| 
 |  | ||||||
|                     pkg_data = binaries_t_a[binary] |  | ||||||
|                     # save the old binary for undo |  | ||||||
|                     undo['binaries'][p] = rm_pkg_id |  | ||||||
|                     if pkey not in eqv_set: |  | ||||||
|                         # all the reverse dependencies are affected by |  | ||||||
|                         # the change |  | ||||||
|                         affected_pos.update(inst_tester.reverse_dependencies_of(rm_pkg_id)) |  | ||||||
|                         affected_remain.update(inst_tester.negative_dependencies_of(rm_pkg_id)) |  | ||||||
| 
 |  | ||||||
|                     # remove the provided virtual packages |  | ||||||
|                     for provided_pkg, prov_version, _ in pkg_data.provides: |  | ||||||
|                         key = (provided_pkg, parch) |  | ||||||
|                         if key not in undo['virtual']: |  | ||||||
|                             undo['virtual'][key] = provides_t_a[provided_pkg].copy() |  | ||||||
|                         provides_t_a[provided_pkg].remove((binary, prov_version)) |  | ||||||
|                         if not provides_t_a[provided_pkg]: |  | ||||||
|                             del provides_t_a[provided_pkg] |  | ||||||
|                     # finally, remove the binary package |  | ||||||
|                     del binaries_t_a[binary] |  | ||||||
|                     inst_tester.remove_testing_binary(rm_pkg_id) |  | ||||||
|                 # remove the source package |  | ||||||
|                 if item.architecture == 'source': |  | ||||||
|                     undo['sources'][item.package] = source |  | ||||||
|                     del sources['testing'][item.package] |  | ||||||
|             else: |             else: | ||||||
|                 # the package didn't exist, so we mark it as to-be-removed in case of undo |                 # the package didn't exist, so we mark it as to-be-removed in case of undo | ||||||
|                 undo['sources']['-' + item.package] = True |                 undo['sources']['-' + item.package] = True | ||||||
| 
 | 
 | ||||||
|         # single binary removal; used for clearing up after smooth |             # add/update the source package | ||||||
|         # updates but not supported as a manual hint |             if not item.is_removal: | ||||||
|         else: |                 sources['testing'][item.package] = sources[item.suite][item.package] | ||||||
|             assert item.package in packages_t[item.architecture][0] |  | ||||||
|             binaries_t_a = packages_t[item.architecture][0] |  | ||||||
|             pkg_id = binaries_t_a[item.package].pkg_id |  | ||||||
|             undo['binaries'][(item.package, item.architecture)] = pkg_id |  | ||||||
|             affected_pos.update(inst_tester.reverse_dependencies_of(pkg_id)) |  | ||||||
|             del binaries_t_a[item.package] |  | ||||||
|             inst_tester.remove_testing_binary(pkg_id) |  | ||||||
| 
 | 
 | ||||||
|         # add the new binary packages (if we are not removing) |         # If we are removing *and* updating packages, then check for eqv. packages | ||||||
|         if not item.is_removal: |         if rms and updates: | ||||||
|  |             eqv_table = {} | ||||||
|  |             for rm_pkg_id in rms: | ||||||
|  |                 binary, _, parch = rm_pkg_id | ||||||
|  |                 key = (binary, parch) | ||||||
|  |                 eqv_table[key] = rm_pkg_id | ||||||
|  | 
 | ||||||
|  |             for new_pkg_id in updates: | ||||||
|  |                 binary, _, parch = new_pkg_id | ||||||
|  |                 key = (binary, parch) | ||||||
|  |                 old_pkg_id = eqv_table.get(key) | ||||||
|  |                 if old_pkg_id is not None: | ||||||
|  |                     if inst_tester.are_equivalent(new_pkg_id, old_pkg_id): | ||||||
|  |                         eqv_set.add(key) | ||||||
|  | 
 | ||||||
|  |         # remove all the binaries which aren't being smooth updated | ||||||
|  |         for rm_pkg_id in rms: | ||||||
|  |             binary, version, parch = rm_pkg_id | ||||||
|  |             p = (binary, parch) | ||||||
|  |             binaries_t_a, provides_t_a = packages_t[parch] | ||||||
|  |             pkey = (binary, parch) | ||||||
|  | 
 | ||||||
|  |             pkg_data = binaries_t_a[binary] | ||||||
|  |             # save the old binary for undo | ||||||
|  |             undo['binaries'][p] = rm_pkg_id | ||||||
|  |             if pkey not in eqv_set: | ||||||
|  |                 # all the reverse dependencies are affected by | ||||||
|  |                 # the change | ||||||
|  |                 affected_pos.update(inst_tester.reverse_dependencies_of(rm_pkg_id)) | ||||||
|  |                 affected_remain.update(inst_tester.negative_dependencies_of(rm_pkg_id)) | ||||||
|  | 
 | ||||||
|  |             # remove the provided virtual packages | ||||||
|  |             for provided_pkg, prov_version, _ in pkg_data.provides: | ||||||
|  |                 key = (provided_pkg, parch) | ||||||
|  |                 if key not in undo['virtual']: | ||||||
|  |                     undo['virtual'][key] = provides_t_a[provided_pkg].copy() | ||||||
|  |                 provides_t_a[provided_pkg].remove((binary, prov_version)) | ||||||
|  |                 if not provides_t_a[provided_pkg]: | ||||||
|  |                     del provides_t_a[provided_pkg] | ||||||
|  |             # finally, remove the binary package | ||||||
|  |             del binaries_t_a[binary] | ||||||
|  |             inst_tester.remove_testing_binary(rm_pkg_id) | ||||||
|  | 
 | ||||||
|  |         # Add/Update binary packages in testing | ||||||
|  |         if updates: | ||||||
|             packages_s = self.binaries[item.suite] |             packages_s = self.binaries[item.suite] | ||||||
| 
 | 
 | ||||||
|             for updated_pkg_id in updates: |             for updated_pkg_id in updates: | ||||||
| @ -2298,10 +2289,6 @@ class Britney(object): | |||||||
|                     affected_pos.add(updated_pkg_id) |                     affected_pos.add(updated_pkg_id) | ||||||
|                     affected_remain.update(inst_tester.negative_dependencies_of(updated_pkg_id)) |                     affected_remain.update(inst_tester.negative_dependencies_of(updated_pkg_id)) | ||||||
| 
 | 
 | ||||||
|             # add/update the source package |  | ||||||
|             if item.architecture == 'source': |  | ||||||
|                 sources['testing'][item.package] = sources[item.suite][item.package] |  | ||||||
| 
 |  | ||||||
|         # Also include the transitive rdeps of the packages found so far |         # Also include the transitive rdeps of the packages found so far | ||||||
|         compute_reverse_tree(inst_tester, affected_pos) |         compute_reverse_tree(inst_tester, affected_pos) | ||||||
|         compute_reverse_tree(inst_tester, affected_remain) |         compute_reverse_tree(inst_tester, affected_remain) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user