32 lines
1.6 KiB
Plaintext
32 lines
1.6 KiB
Plaintext
%import re
|
|
%def repository_identification(%%repository)
|
|
%set %%repository_re = re.compile(r'^((deb)|(deb-src)) (\[ .* \] )?(((http)|(https)|(ftp)|(ftps))://(?P<url>\S+)) (?P<suite>(\S+))(?P<components>(( \S+)+)?)')
|
|
%set %%elements = %%repository_re.match(%%repository).groupdict()
|
|
%return 'o={},a={},c={}'.format(%%elements['url'].split('/')[0], %%elements['suite'], %%elements['components'].strip())
|
|
%return %%repository
|
|
%end def
|
|
%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'] = %%unicode.split(%%priority_settings.additional_repository_exempted_packages)
|
|
%end if
|
|
%end if
|
|
%end for
|
|
%for %%repository in %%repositories_detail
|
|
Package: *
|
|
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(%%repositories_detail[%%repository]['source'])
|
|
Pin-Priority: 500
|
|
%end for
|
|
|
|
%end for
|