From f0ef3dcf86be05c092fbd8f46fd65758cd668b96 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Apr 03 2020 13:11:35 +0000 Subject: [PATCH 1/3] 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 From 4b707edb12d567a4b47296ffc7a1e100b1eaa6fc Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Apr 03 2020 13:11:35 +0000 Subject: [PATCH 2/3] Add job rpm-local-build This jobs is designed to run (build rpm) on a build node that is the same target as the build system. In theory this job could be used into a container. --- diff --git a/playbooks/rpm/local-build.yaml b/playbooks/rpm/local-build.yaml new file mode 100644 index 0000000..e18fbbe --- /dev/null +++ b/playbooks/rpm/local-build.yaml @@ -0,0 +1,11 @@ +- hosts: all + tasks: + - include_role: + name: source-to-tarball + when: "{{ build_from_source | default(false) }}" + + - include_role: + name: simple-srpm-build + + - include_role: + name: simple-rpm-build diff --git a/playbooks/rpm/repo-artifact-export.yaml b/playbooks/rpm/repo-artifact-export.yaml new file mode 100644 index 0000000..85ae543 --- /dev/null +++ b/playbooks/rpm/repo-artifact-export.yaml @@ -0,0 +1,9 @@ +- hosts: all + tasks: + - name: Return repo url + zuul_return: + data: + zuul: + artifacts: + - name: repo + url: logs/repo diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index fb5798a..13f1f33 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -1,8 +1,15 @@ --- - job: + name: base-rpm-build + abstract: true + provides: repo + requires: repo + +- job: name: rpm-mock-build + parent: base-rpm-build description: | - Base job to build rpm(s) in a mock from a distgit repository. + Base job to build rpm(s) from a distgit repository. Responds to these variables: @@ -55,12 +62,49 @@ node and mock build root. eg. {name: 'nightly', url: 'scheme://...', gpgcheck: 1} - provides: repo - requires: repo run: playbooks/rpm/mock-build.yaml post-run: playbooks/rpm/repo-fetch.yaml - job: + name: rpm-local-build + parent: base-rpm-build + description: | + Base job to build rpm(s) from a distgit repository. + + Responds to these variables: + + .. zuul:jobvar:: build_from_source + : default: False + + Set it to true if specfile is stored in + the same repository than the source. The + source will be used to create the source tarball. + + .. zuul:jobvar:: version_from_specfile + : default: False + + Using or not the version detected from + the specfile. + + .. zuul:jobvar:: src_name + : default: specfile base name + + If the specfile base name differs than the source + name. Specify src_name. This is useful when + build_from_source is set and discovered source + name is failing leading to a %prep phase failure. + + .. zuul:jobvar:: repos + : default: [] + + A list of rpm repositories to be exposed on build + node and mock build root. eg. + {name: 'nightly', url: 'scheme://...', gpgcheck: 1} + + run: playbooks/rpm/local-build.yaml + post-run: playbooks/rpm/repo-artifact-export.yaml + +- job: name: rpm-lint description: | Base job to run rpm-lint on rpms From b3c92215e33df690f734ed989a98645f6fd50207 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Apr 03 2020 13:11:35 +0000 Subject: [PATCH 3/3] simple-rpm-build: ensure become:true when install builddeps and plugin install --- diff --git a/roles/simple-rpm-build/tasks/main.yaml b/roles/simple-rpm-build/tasks/main.yaml index 24c156e..93f089e 100644 --- a/roles/simple-rpm-build/tasks/main.yaml +++ b/roles/simple-rpm-build/tasks/main.yaml @@ -10,6 +10,7 @@ yum: name: - rpm-build + - "dnf-command(builddep)" - "@buildsys-build" - createrepo - rsync @@ -37,9 +38,10 @@ when: "{{ build_from_source | default(false) }}" - name: Install build dependencies - shell: dnf builddep {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/*.spec + shell: dnf builddep -y {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/*.spec + become: true -- name: Build the SRPM +- name: Build the package shell: rpmbuild -rb {{ ansible_user_dir }}/rpmbuild/SRPMS/*.src.rpm - name: Move built RPMs in zuul output directory