Fixes template for package pinning

This commit is contained in:
Benjamin Bohard 2020-12-01 14:40:55 +01:00
parent 2e88701f8f
commit 6b009b413f

View File

@ -7,23 +7,26 @@
%return %%repository
%end def
%set %%repositories_detail = {'name': r.additional_repository_name, 'source': r.additional_repository_source, 'priority': 500, 'execptions': [] for r in %%getVar('additional_repository_name')}
%for %%priority_target in %%getVar('additional_repository_priority_target', [])
%if %%priority_target.additional_priority_target in %%repositories_detail
%silent %%repositories_detail[%%priority_target.additional_repository_priority_target]['priority'] = %%priority_target.additional_repository_global_priority
%silent %%repositories_detail[%%priority_target.additional_repository_priority_target]['exceptions'] = %%priority_target.additional_repository_exempted_packages.split()
%set %%repositories_detail = {}
%for %%additional_repository in %%getVar('additional_repository_name')
%silent %%repositories_detail[%%str(%%additional_repository)] = {'source': %%additional_repository.additional_repository_source, 'priority': 500, 'exceptions': []}
%end for
%for %%priority_settings in %%getVar('additional_repository_priority_target')
%if %%str(%%priority_settings) in %%repositories_detail
%silent %%repositories_detail[%%str(%%priority_settings)]['priority'] = %%priority_settings.additional_repository_global_priority
%if %%priority_settings.additional_repository_exempted_packages
%silent %%repositories_detail[%%str(%%priority_settings)]['exceptions'] = %%str.split(%%priority_settings.additional_repository_exempted_packages)
%end if
%end if
%end for
%for %%repository in %%repositories_detail
Package: *
Pin: release %%repository_identification(%%repository['source'])
Pin-Priority: %%repository['priority']
Pin: release %%repository_identification(%%repositories_detail[%%repository]['source'])
Pin-Priority: %%repositories_detail[%%repository]['priority']
%for %%exception in %%repositories_detail[%%repository]['exceptions']
Package: %%exception
Pin: release %%repository_identification(%%repository['source'])
Pin: release %%repository_identification(%%repositories_detail[%%repository]['source'])
Pin-Priority: 500
%end for
%end for