mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 09:58:01 +00:00
poc: Automate building of Fedora rpm packages
This patch automates building of Fedora rpm packages (Just like we are already doing this for for CentOS and Ubuntu). Signed-off-by: Ansis Atteka <aatteka@ovn.org> Acked-by: Aaron Conole <aconole@redhat.com>
This commit is contained in:
parent
9aef43f085
commit
3a2ceb01c8
12
poc/builders/Vagrantfile
vendored
12
poc/builders/Vagrantfile
vendored
@ -30,4 +30,16 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
end
|
||||
end
|
||||
|
||||
# Fedora builder host
|
||||
config.vm.define "fedorabuilder" do |builder|
|
||||
builder.vm.hostname = "fedoraubuilder.dev"
|
||||
builder.vm.box = "fedora/27-cloud-base"
|
||||
builder.vm.synced_folder "../../", "/git/ovs", type: "rsync",
|
||||
rsync__args: ["--archive", "--delete", "-z"]
|
||||
builder.vm.provision "builder", type: "ansible" do |ansible|
|
||||
ansible.playbook = "../playbook-fedora-builder.yml"
|
||||
ansible.sudo = true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
128
poc/playbook-fedora-builder.yml
Normal file
128
poc/playbook-fedora-builder.yml
Normal file
@ -0,0 +1,128 @@
|
||||
---
|
||||
- hosts: all
|
||||
become: true
|
||||
name: builder
|
||||
|
||||
gather_facts: false
|
||||
pre_tasks:
|
||||
|
||||
- name: Install python2 for Ansible
|
||||
raw: bash -c "test -e /usr/bin/python || (dnf -y install python2)"
|
||||
register: output
|
||||
changed_when: output.stdout != ""
|
||||
|
||||
- name: Gathering Facts
|
||||
setup:
|
||||
|
||||
tasks:
|
||||
- name: Create Ansible Local Facts Directory
|
||||
file: path=/etc/ansible/facts.d state=directory
|
||||
|
||||
- name: Install "yum-utils", "rpmdevtools", "createrepo", "httpd", "git"
|
||||
dnf: name={{item}} state=present
|
||||
with_items:
|
||||
- yum-utils
|
||||
- rpmdevtools
|
||||
- createrepo
|
||||
- httpd
|
||||
- git
|
||||
- libselinux-python
|
||||
|
||||
- name: Initiate Build Numbering
|
||||
copy:
|
||||
content: '{ "release":"1" }'
|
||||
dest: "/etc/ansible/facts.d/builder.fact"
|
||||
force: no
|
||||
|
||||
- name: Set source directory for building
|
||||
set_fact:
|
||||
SOURCE: "/root/rpmbuild/SOURCES"
|
||||
|
||||
- name: Reload Ansible Local Facts
|
||||
setup: filter=ansible_local
|
||||
|
||||
- name: Remove untracked files from Open vSwitch GIT repository
|
||||
command: chdir=/git/ovs/ git clean -xdf
|
||||
|
||||
- name: Reset Open vSwitch GIT repository to last comitted state
|
||||
command: chdir=/git/ovs/ git reset --hard
|
||||
|
||||
- name: Generate spec files for easy build dependency retrieval
|
||||
shell: sed -e 's/@VERSION@/0.0.1/' {{item}}.in > /tmp/{{item}}
|
||||
args:
|
||||
chdir: /git/ovs/rhel
|
||||
with_items:
|
||||
- openvswitch-fedora.spec
|
||||
- openvswitch-kmod-fedora.spec
|
||||
- openvswitch-dkms.spec
|
||||
|
||||
- name: Install build dependencies specified from spec files
|
||||
shell: echo "y" | yum-builddep /tmp/{{item}}
|
||||
with_items:
|
||||
- openvswitch-fedora.spec
|
||||
- openvswitch-kmod-fedora.spec
|
||||
- openvswitch-dkms.spec
|
||||
|
||||
- name: Create rpm dev tree
|
||||
command: rpmdev-setuptree
|
||||
|
||||
- name: Run "./boot.sh"
|
||||
command: chdir=/git/ovs/ ./boot.sh
|
||||
|
||||
- name: Run "./configure"
|
||||
command: chdir=/git/ovs/ ./configure
|
||||
|
||||
- name: Run "make dist"
|
||||
command: chdir=/git/ovs/ make dist
|
||||
|
||||
- name: Parse out Open vSwitch version from "configure.ac"
|
||||
command: chdir=/git/ovs autoconf -t AC_INIT:'$2'
|
||||
register: version
|
||||
|
||||
- name: Copy source tarball to rpm dev tree
|
||||
command: cp /git/ovs/openvswitch-{{version.stdout}}.tar.gz {{SOURCE}}
|
||||
|
||||
- name: Unarchive openvswitch source tarball
|
||||
unarchive:
|
||||
src: "{{SOURCE}}/openvswitch-{{version.stdout}}.tar.gz"
|
||||
dest: "{{SOURCE}}"
|
||||
remote_src: yes
|
||||
|
||||
- name: Update release number in spec files
|
||||
lineinfile:
|
||||
path: "{{SOURCE}}/openvswitch-{{version.stdout}}/rhel/{{item}}"
|
||||
regexp: '^Release:'
|
||||
line: "Release: {{ ansible_local.builder.release }}"
|
||||
with_items:
|
||||
- openvswitch-fedora.spec
|
||||
- openvswitch-kmod-fedora.spec
|
||||
- openvswitch-dkms.spec
|
||||
|
||||
- name: Build Open vSwitch user space rpms
|
||||
command: rpmbuild -bb --without check rhel/openvswitch-fedora.spec
|
||||
args:
|
||||
chdir: "{{SOURCE}}/openvswitch-{{version.stdout}}"
|
||||
|
||||
- name: Build Open vSwitch kmod rpm
|
||||
command: rpmbuild -bb --without check rhel/openvswitch-fedora.spec
|
||||
args:
|
||||
chdir: "{{SOURCE}}/openvswitch-{{version.stdout}}"
|
||||
|
||||
- name: Build Open vSwitch dkms rpm
|
||||
command: rpmbuild -bb --without check rhel/openvswitch-dkms.spec
|
||||
args:
|
||||
chdir: "{{SOURCE}}/openvswitch-{{version.stdout}}"
|
||||
|
||||
- name: Copy RPM packages to /var/www/html
|
||||
command: cp -r /root/rpmbuild/RPMS/ /var/www/html
|
||||
|
||||
- name: Create RPM Package index file for repository
|
||||
command: chdir=/var/www/html createrepo /var/www/html
|
||||
|
||||
- name: Make sure Apache is running
|
||||
systemd: state=started name=httpd
|
||||
|
||||
- name: Bump up Build Number
|
||||
copy:
|
||||
content: '{ "release":"{{ansible_local.builder.release|int+1}}" }'
|
||||
dest: "/etc/ansible/facts.d/builder.fact"
|
Loading…
x
Reference in New Issue
Block a user