From 092280ec843a7033cfd2c41870b5d41d23c3b2b0 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Apr 02 2020 13:55:30 +0000 Subject: Add simple-rpm-build role: simply use local rpmbuild This role will enable the creation of a local-rpm-build job designed to run on target distribution. --- diff --git a/roles/simple-rpm-build/tasks/main.yaml b/roles/simple-rpm-build/tasks/main.yaml new file mode 100644 index 0000000..24c156e --- /dev/null +++ b/roles/simple-rpm-build/tasks/main.yaml @@ -0,0 +1,53 @@ +--- +- set_fact: + zuul_output_dir: "{{ ansible_user_dir }}/zuul-output" + +- file: + path: "{{ zuul_output_dir }}/logs/repo" + state: directory + +- name: Install system dependencies + yum: + name: + - rpm-build + - "@buildsys-build" + - createrepo + - rsync + state: latest + become: true + +- name: Clean previous rpmbuild directories + file: + path: "{{ ansible_user_dir }}/rpmbuild/{{ item }}" + state: absent + loop: + - RPMS + +- name: Create rpmbuild directories + file: + path: "{{ ansible_user_dir }}/rpmbuild/{{ item }}" + state: directory + loop: + - RPMS + +- name: Copy local HEAD source to rpmbuild SOURCES directory + shell: > + cp {{ ansible_user_dir}}/{{ zuul.project.src_dir }}/*-HEAD.tgz + {{ ansible_user_dir }}/rpmbuild/SOURCES + when: "{{ build_from_source | default(false) }}" + +- name: Install build dependencies + shell: dnf builddep {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/*.spec + +- name: Build the SRPM + shell: rpmbuild -rb {{ ansible_user_dir }}/rpmbuild/SRPMS/*.src.rpm + +- name: Move built RPMs in zuul output directory + command: > + rsync -av {{ ansible_user_dir }}/rpmbuild/RPMS/x86_64/ + {{ zuul_output_dir }}/logs/repo/ + +- name: Create repository + command: createrepo . + args: + chdir: "{{ zuul_output_dir }}/logs/repo" diff --git a/roles/simple-srpm-build/tasks/main.yaml b/roles/simple-srpm-build/tasks/main.yaml index 9808ff7..214d51c 100644 --- a/roles/simple-srpm-build/tasks/main.yaml +++ b/roles/simple-srpm-build/tasks/main.yaml @@ -1,4 +1,11 @@ --- +- set_fact: + zuul_output_dir: "{{ ansible_user_dir }}/zuul-output" + +- file: + path: "{{ zuul_output_dir }}/logs/repo" + state: directory + - name: Install system dependencies yum: name: "rpm-build,spectool" @@ -42,3 +49,6 @@ - name: Set SRPM path fact set_fact: srpm: "{{ ansible_user_dir }}/rpmbuild/SRPMS/{{ result.stdout }}" + +- name: Copy SRPM in zuul output directory + command: cp {{ srpm }} {{ zuul_output_dir }}/logs/repo