From patchwork Tue Apr 24 03:00:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ansis Atteka X-Patchwork-Id: 903261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40VSlj3lRmz9ryr for ; Tue, 24 Apr 2018 13:01:37 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 918E7483; Tue, 24 Apr 2018 03:01:34 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id CBA5941C for ; Tue, 24 Apr 2018 03:01:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CDD6E299 for ; Tue, 24 Apr 2018 03:01:31 +0000 (UTC) X-Originating-IP: 66.170.99.1 Received: from aatteka-Precision-Tower-5810.eng.vmware.com (unknown [66.170.99.1]) (Authenticated sender: aatteka@ovn.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 30E7420005; Tue, 24 Apr 2018 05:01:31 +0200 (CEST) From: Ansis Atteka To: dev@openvswitch.org Date: Mon, 23 Apr 2018 20:00:42 -0700 Message-Id: <20180424030042.6288-1-aatteka@ovn.org> X-Mailer: git-send-email 2.14.1 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ansis Atteka Subject: [ovs-dev] [PATCH] poc: Automate building of Fedora rpm packages X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- poc/builders/Vagrantfile | 12 +++++ poc/playbook-fedora-builder.yml | 117 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 poc/playbook-fedora-builder.yml diff --git a/poc/builders/Vagrantfile b/poc/builders/Vagrantfile index af2986789..9f5fa5dce 100644 --- a/poc/builders/Vagrantfile +++ b/poc/builders/Vagrantfile @@ -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 = "generic/fedora27" + 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 diff --git a/poc/playbook-fedora-builder.yml b/poc/playbook-fedora-builder.yml new file mode 100644 index 000000000..5d7efb3a6 --- /dev/null +++ b/poc/playbook-fedora-builder.yml @@ -0,0 +1,117 @@ +--- +- hosts: all + become: true + name: builder + 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"