mtes-geomatique/tmpl/99-additional_repositories

31 lines
1.5 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 = {'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()
%end if
%end for
%for %%repository in %%repositories_detail
Package: *
Pin: release %%repository_identification(%%repository['source'])
Pin-Priority: %%repository['priority']
%for %%exception in %%repositories_detail[%%repository]['exceptions']
Package: %%exception
Pin: release %%repository_identification(%%repository['source'])
Pin-Priority: 500
%end for
%end for