Debian Codegraph @

test/integration/targets/setup_deb_repo/tasks/main.yml

raw
1 - block:
2 - name: Install needed packages
3 apt:
4 name: "{{ item }}"
5 with_items:
6 - dpkg-dev
7 - equivs
8 - libfile-fcntllock-perl # to silence warning by equivs-build
9 - python3-debian
10
11 - set_fact:
12 repodir: /tmp/repo/
13
14 - name: Create repo dirs
15 file:
16 path: "{{ repodir }}/dists/{{ item }}/main/binary-all"
17 state: directory
18 mode: 0755
19 loop:
20 - stable
21 - testing
22
23 - name: Copy package specs to remote
24 copy:
25 src: package_specs
26 dest: "{{ remote_tmp_dir }}"
27
28 - name: Create deb files
29 shell: "find {{ remote_tmp_dir }}/package_specs/{{ item }} -type f -exec equivs-build {} \\;"
30 args:
31 chdir: "{{ repodir }}/dists/{{ item }}/main/binary-all"
32 loop:
33 - stable
34 - testing
35
36 - name: Create repo Packages
37 shell: dpkg-scanpackages --multiversion . /dev/null dists/{{ item }}/main/binary-all/ | gzip -9c > Packages.gz
38 args:
39 chdir: "{{ repodir }}/dists/{{ item }}/main/binary-all"
40 loop:
41 - stable
42 - testing
43
44 - name: Create repo Release
45 copy:
46 content: |
47 Codename: {{ item.0 }}
48 {% for k,v in item.1.items() %}
49 {{ k }}: {{ v }}
50 {% endfor %}
51 dest: "{{ repodir }}/dists/{{ item.0 }}/Release"
52 loop:
53 - [stable, {}]
54 - [testing, {NotAutomatic: "yes", ButAutomaticUpgrades: "yes"}]
55
56 - name: Add local filesystem repository using deb822 format
57 deb822_repository:
58 name: "local_repo_{{ item }}"
59 uris: "file://{{ repodir }}"
60 suites: "{{ item }}"
61 components: "main"
62 state: present
63 architectures: all
64 trusted: true
65 loop:
66 - stable
67 - testing
68 when: install_repo|default(True)|bool is true
69
70 when: ansible_facts.distribution in ['Ubuntu', 'Debian']
71
72 - block:
73 # Need to uncomment the deb-src for the universe component for build-dep state
74 - name: Ensure deb-src for the universe component
75 lineinfile:
76 path: /etc/apt/sources.list
77 backrefs: True
78 regexp: ^#\s*deb-src (http://.*\.ubuntu\.com/ubuntu.*/) (\w*){{ item }} universe$
79 line: deb-src \1 \2{{ item }} universe
80 state: present
81 with_items:
82 - ''
83 - -updates
84 when: ansible_facts.distribution_version is version('24.04', '<')
85
86 - name: Enable deb-src in ubuntu.sources
87 # see: https://askubuntu.com/questions/1512042/ubuntu-24-04-getting-error-you-must-put-some-deb-src-uris-in-your-sources-list
88 command: |
89 sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
90 when: ansible_facts.distribution_version is version('24.04', '>=')
91
92 when: ansible_facts.distribution == 'Ubuntu'