|
1 |
| -# Downloading dependencies |
2 |
| -- name: GPG dependencies |
3 |
| - apt: |
4 |
| - name: gnupg |
5 |
| - |
6 |
| -- name: Add Postgres GPG key |
7 |
| - apt_key: |
8 |
| - keyserver: keyserver.ubuntu.com |
9 |
| - id: B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 |
10 |
| - |
11 |
| -- name: Add Postgres PPA |
12 |
| - apt_repository: |
13 |
| - repo: "deb https://apt-archive.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg-archive main" |
14 |
| - state: present |
| 1 | +- name: Postgres - copy package |
| 2 | + copy: |
| 3 | + src: files/postgres/ |
| 4 | + dest: /tmp/build/ |
15 | 5 |
|
16 |
| -# let's build binaries from their published source packages |
17 |
| -- name: Add Postgres PPA - source |
| 6 | +- name: Postgres - add PPA |
18 | 7 | apt_repository:
|
19 |
| - repo: "deb-src https://apt-archive.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg-archive main" |
| 8 | + repo: "deb [ trusted=yes ] file:///tmp/build ./" |
20 | 9 | state: present
|
21 | 10 |
|
22 |
| -- name: Create temporary build directory |
23 |
| - tempfile: |
24 |
| - state: directory |
25 |
| - register: pg_build_dir |
26 |
| - |
27 |
| -- name: Setting mcpu (arm) |
28 |
| - set_fact: |
29 |
| - mcpu: "neoverse-n1" |
30 |
| - when: platform == "arm64" |
31 |
| - |
32 |
| -- name: Postgres - build |
33 |
| - shell: | |
34 |
| - set -e |
35 |
| - export PYTHONDONTWRITEBYTECODE=1 |
36 |
| - savedAptMark="$(apt-mark showmanual)" |
37 |
| - cd "{{ pg_build_dir.path }}" |
38 |
| -
|
39 |
| - # create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be) |
40 |
| - apt-get update |
41 |
| - apt-get install -y --no-install-recommends dpkg-dev |
42 |
| - echo "deb [ trusted=yes ] file://{{ pg_build_dir.path }} ./" > /etc/apt/sources.list.d/temp.list |
43 |
| - _update_repo() { |
44 |
| - dpkg-scanpackages . > Packages |
45 |
| - apt-get -o Acquire::GzipIndexes=false update |
46 |
| - } |
47 |
| - _update_repo |
48 |
| -
|
49 |
| - # build .deb files from upstream's source packages (which are verified by apt-get) |
50 |
| - export DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" |
51 |
| - export DEB_CPPFLAGS_APPEND="-mcpu={{ mcpu }} -fsigned-char" |
52 |
| -
|
53 |
| - # we have to build postgresql-common first because postgresql-15 shares "debian/rules" logic with it: https://salsa.debian.org/postgresql/postgresql/-/commit/99f44476e258cae6bf9e919219fa2c5414fa2876 |
54 |
| - # (and it "Depends: pgdg-keyring") |
55 |
| - apt-get build-dep -y postgresql-common pgdg-keyring |
56 |
| - apt-get source --compile postgresql-common pgdg-keyring |
57 |
| - _update_repo |
58 |
| - apt-get build-dep -y "postgresql-{{ postgresql_major }}={{ postgresql_release }}-1.pgdg20.04+1" |
59 |
| - apt-get source --compile "postgresql-{{ postgresql_major }}={{ postgresql_release }}-1.pgdg20.04+1" |
60 |
| -
|
61 |
| - # we don't remove APT lists here because they get re-downloaded and removed later |
62 |
| - # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies |
63 |
| - # (which is done after we install the built packages so we don't have to redownload any overlapping dependencies) |
64 |
| - apt-mark showmanual | xargs apt-mark auto > /dev/null |
65 |
| - apt-mark manual $savedAptMark |
66 |
| - _update_repo |
67 |
| -
|
68 | 11 | - name: Postgres - install commons
|
69 | 12 | apt:
|
70 | 13 | name: postgresql-common
|
|
79 | 22 | name: postgresql-{{ postgresql_major }}={{ postgresql_release }}-1.pgdg20.04+1
|
80 | 23 | install_recommends: no
|
81 | 24 |
|
82 |
| -# if we have leftovers from building, let's purge them (including extra, unnecessary build deps) |
83 |
| -- name: Remove build dependencies |
84 |
| - shell: | |
85 |
| - set -e |
86 |
| - rm -rf /var/lib/apt/lists/* |
87 |
| - apt-get purge -y --auto-remove |
88 |
| - rm -rf "{{ pg_build_dir.path }}" /etc/apt/sources.list.d/temp.list |
89 |
| - find /usr -name '*.pyc' -type f -exec bash -c 'for pyc; do dpkg -S "$pyc" &> /dev/null || rm -vf "$pyc"; done' -- '{}' + |
90 |
| -
|
91 |
| -- name: Hold postgres {{ postgresql_release }} from apt upgrade |
92 |
| - shell: apt-mark hold postgresql-{{ postgresql_major }} |
| 25 | +- name: Postgres - remove PPA |
| 26 | + apt_repository: |
| 27 | + repo: "deb [ trusted=yes ] file:///tmp/build ./" |
| 28 | + state: absent |
| 29 | + |
| 30 | +- name: Postgres - cleanup package |
| 31 | + file: |
| 32 | + path: /tmp/build |
| 33 | + state: absent |
93 | 34 |
|
94 | 35 | - name: Create symlink to /usr/lib/postgresql/bin
|
95 | 36 | shell:
|
|
0 commit comments