pikaur_builder/piker/template/drone.yml.j2

269 lines
5.3 KiB
Plaintext
Raw Permalink Normal View History

2021-02-23 00:01:03 +01:00
---
kind: pipeline
type: docker
name: pre_clean
platform:
os: linux
arch: amd64
workspace:
path: /drone
steps:
- name: remove-locks
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
user: root
commands:
- rm -f /output/lock
volumes:
- name: output
path: /output
volumes:
- name: output
host:
path: {{ base_path }}/output
{% for pkg in pkgs %}
---
kind: pipeline
type: docker
2021-02-23 16:04:26 +01:00
name: {{ pkg.name }}
2021-02-23 00:01:03 +01:00
platform:
os: linux
arch: amd64
workspace:
path: /drone
steps:
2021-02-23 16:04:26 +01:00
- name: cache-init_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
user: root
commands:
- |
if ! [ "$(ls -A /cache_stage/etc)" ]; then
cp -r /etc/. /cache_stage/etc/
getfacl -p -R /etc > /cache_stage/etc/permissions.acl
fi
- |
if ! [ "$(ls -A /cache_stage/opt)" ]; then
cp -r /opt/. /cache_stage/opt/
getfacl -p -R /opt > /cache_stage/opt/permissions.acl
fi
- |
if ! [ "$(ls -A /cache_stage/var)" ]; then
cp -r /var/. /cache_stage/var/
getfacl -p -R /var > /cache_stage/var/permissions.acl
fi
- |
if ! [ "$(ls -A /cache_stage/usr)" ]; then
cp -r /usr/. /cache_stage/usr/
getfacl -p -R /usr > /cache_stage/usr/permissions.acl
fi
- |
if ! [ "$(ls -A /build2)" ]; then
cp -r /build/. /build2/
getfacl -p -R /usr > /build2/permissions.acl
fi
- chmod a+rw /output
volumes:
2021-02-23 16:04:26 +01:00
- name: build_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /build2
2021-02-23 16:04:26 +01:00
- name: etc_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /cache_stage/etc
2021-02-23 16:04:26 +01:00
- name: opt_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /cache_stage/opt
2021-02-23 16:04:26 +01:00
- name: var_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /cache_stage/var
2021-02-23 16:04:26 +01:00
- name: usr_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /cache_stage/usr
- name: output
path: /output
2021-02-23 16:04:26 +01:00
- name: cache-acl_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
user: root
commands:
- setfacl --restore=/etc/permissions.acl
- setfacl --restore=/opt/permissions.acl
- setfacl --restore=/var/permissions.acl
- setfacl --restore=/usr/permissions.acl
- setfacl --restore=/build/permissions.acl
- chown -R {{ user_uid }}:{{ user_gid }} /build
volumes:
2021-02-23 16:04:26 +01:00
- name: build_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /build
2021-02-23 16:04:26 +01:00
- name: etc_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /etc
2021-02-23 16:04:26 +01:00
- name: opt_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /opt
2021-02-23 16:04:26 +01:00
- name: var_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /var
2021-02-23 16:04:26 +01:00
- name: usr_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /usr
2021-02-23 16:04:26 +01:00
- name: build_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
commands:
2021-02-23 16:04:26 +01:00
{%- for cmd in pkg.pre_cmd|default([]) %}
- {{ cmd }}
{%- endfor %}
2021-02-23 00:01:03 +01:00
- |
if [ -f /output/lock ]; then
while [ -f /output/lock ]; do
sleep 10
echo "Waiting $(cat /output/lock)"
done
else
2021-02-23 16:04:26 +01:00
echo "{{ pkg.name }}" >> /output/lock
2021-02-23 00:01:03 +01:00
fi
- |
set -euo pipefail
2021-02-23 00:15:40 +01:00
cd /build
rm -rf {{ pkg.name }}
2021-02-23 16:04:26 +01:00
/usr/bin/pikaur -G --noconfirm {{ pkg.name }} 2>&1|tee /output/{{ pkg.name }}.log
2021-03-26 09:15:57 +01:00
/usr/bin/pikaur -Py --keepbuilddeps --noconfirm --rebuild {{ pkg.name }}/PKGBUILD 2>&1|tee /output/{{ pkg.name }}.log
2021-02-23 16:04:26 +01:00
{%- for cmd in pkg.post_cmd|default([]) %}
- {{ cmd }}
{%- endfor %}
2021-02-23 00:01:03 +01:00
- rm -f /output/lock
volumes:
2021-02-23 16:04:26 +01:00
- name: build_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /build
2021-02-23 16:04:26 +01:00
- name: etc_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /etc
2021-02-23 16:04:26 +01:00
- name: opt_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /opt
2021-02-23 16:04:26 +01:00
- name: var_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /var
2021-02-23 16:04:26 +01:00
- name: usr_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
path: /usr
- name: output
path: /output
volumes:
2021-02-23 16:04:26 +01:00
- name: build_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
host:
2021-02-23 16:04:26 +01:00
path: {{ base_path }}/{{ pkg.name }}
- name: etc_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
host:
2021-02-23 16:04:26 +01:00
path: {{ base_path }}/etc/{{ pkg.name }}
- name: opt_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
host:
2021-02-23 16:04:26 +01:00
path: {{ base_path }}/opt/{{ pkg.name }}
- name: var_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
host:
2021-02-23 16:04:26 +01:00
path: {{ base_path }}/var/{{ pkg.name }}
- name: usr_{{ pkg.name }}
2021-02-23 00:01:03 +01:00
host:
2021-02-23 16:04:26 +01:00
path: {{ base_path }}/usr/{{ pkg.name }}
2021-02-23 00:01:03 +01:00
- name: output
host:
path: {{ base_path }}/output
trigger:
branch:
- master
event:
- push
- cron
depends_on:
- pre_clean
---
kind: pipeline
type: docker
2021-02-23 16:04:26 +01:00
name: notify_failure-{{ pkg.name }}
2021-02-23 00:01:03 +01:00
clone:
disable: true
steps:
- name: notify_failure
pull: if-not-exists
image: leophys/mailer:{{ mailer_version }}
environment:
M_SERVER_ADDRESS:
from_secret: m_server_address
M_USER:
from_secret: m_user
M_PASSWORD:
from_secret: m_password
M_FROM:
from_secret: m_from
M_TO:
from_secret: m_to
2021-02-23 16:04:26 +01:00
M_SUB: "[{{ pkg.name }}] FAILURE"
2021-02-23 00:01:03 +01:00
commands:
2021-02-23 16:04:26 +01:00
- /sendmail.sh /output/{{ pkg.name }}.log
2021-02-23 00:01:03 +01:00
volumes:
- name: output
path: /output
- name: clean_lock
pull: if-not-exists
image: leophys/pikaur:{{ pikaur_version }}
user: root
commands:
- rm -f /output/lock
volumes:
- name: output
path: /output
volumes:
- name: output
host:
path: {{ base_path }}/output
trigger:
status:
- failure
depends_on:
2021-02-23 16:04:26 +01:00
- {{ pkg.name }}
2021-02-23 00:01:03 +01:00
{% endfor %}
---
kind: pipeline
type: docker
name: notify_success
clone:
disable: true
steps:
- name: notify_success
pull: if-not-exists
image: leophys/mailer:{{ mailer_version }}
environment:
M_SERVER_ADDRESS:
from_secret: m_server_address
M_USER:
from_secret: m_user
M_PASSWORD:
from_secret: m_password
M_FROM:
from_secret: m_from
M_TO:
from_secret: m_to
M_SUB: "[archlinux] SUCCESS"
M_TEXT: "Success building archlinux packages"
trigger:
status:
- success
depends_on:
{%- for pkg in pkgs %}
2021-02-23 16:04:26 +01:00
- {{ pkg.name }}
2021-02-23 00:01:03 +01:00
{%- endfor %}