#10 RPM spec file
Closed 7 years ago by mjia. Opened 7 years ago by dcallagh.
dcallagh/waiverdb rpm  into  master

RPM spec file
Dan Callaghan • 7 years ago  
file modified
+1
@@ -8,3 +8,4 @@ 

  /env*/

  test_env

  .cache

+ /rpmbuild-output/

file modified
+20 -5
@@ -12,12 +12,27 @@ 

  

  node('rcm-tools-jslave-rhel-7') {

      checkout scm

-     stage('Test') {

+     stage('Build SRPM') {

+         sh './rpmbuild.sh -bs'

+         archiveArtifacts artifacts: 'rpmbuild-output/**'

+     }

+     /* We take a flock on the mock configs, to avoid multiple unrelated jobs on 

+      * the same Jenkins slave trying to use the same mock root at the same 

+      * time, which will error out. */

+     stage('Build RPM (EPEL7)') {

+         sh """

+         mkdir -p mock-result/el7

+         flock /etc/mock/epel-7-x86_64.cfg \

+         /usr/bin/mock --resultdir=mock-result/el7 -r epel-7-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm

+         """

+         archiveArtifacts artifacts: 'mock-result/el7/**'

+     }

+     stage('Build RPM (F25)') {

          sh """

-         virtualenv .

-         source bin/activate

-         pip install -r requirements.txt

-         py.test tests/

+         mkdir -p mock-result/f25

+         flock /etc/mock/fedora-25-x86_64.cfg \

+         /usr/bin/mock --resultdir=mock-result/f25 -r fedora-25-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm

          """

+         archiveArtifacts artifacts: 'mock-result/f25/**'

      }

  }

file added
+84
@@ -0,0 +1,84 @@ 

+ #!/bin/bash

+ 

+ # This program is free software; you can redistribute it and/or modify

+ # it under the terms of the GNU General Public License as published by

+ # the Free Software Foundation; either version 2 of the License, or

+ # (at your option) any later version.

+ #

+ # This program is distributed in the hope that it will be useful,

+ # but WITHOUT ANY WARRANTY; without even the implied warranty of

+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ # GNU General Public License for more details.

+ 

+ # Builds a development (S)RPM from the current git revision.

+ 

+ set -e

+ 

+ if [ $# -eq 0 ] ; then

+     echo "Usage: $1 -bs|-bb <rpmbuild-options...>" >&2

+     echo "Hint: -bs builds SRPM, -bb builds RPM, refer to rpmbuild(8)" >&2

+     exit 1

+ fi

+ 

+ name=waiverdb

+ if [ "$(git tag | wc -l)" -eq 0 ] ; then

+     # never been tagged since the project is just starting out

+     lastversion="0.0"

+     revbase=""

+ else

+     lasttag="$(git describe --abbrev=0 HEAD)"

+     lastversion="${lasttag##${name}-}"

+     revbase="^$lasttag"

+ fi

+ if [ "$(git rev-list $revbase HEAD | wc -l)" -eq 0 ] ; then

+     # building a tag

+     rpmver=""

+     rpmrel=""

+     version="$lastversion"

+ else

+     # git builds count as a pre-release of the next version

+     version="$lastversion"

+     version="${version%%[a-z]*}" # strip non-numeric suffixes like "rc1"

+     # increment the last portion of the version

+     version="${version%.*}.$((${version##*.} + 1))"

+     commitcount=$(git rev-list $revbase HEAD | wc -l)

+     commitsha=$(git rev-parse --short HEAD)

+     rpmver="${version}"

+     rpmrel="0.git.${commitcount}.${commitsha}"

+     version="${version}.dev${commitcount}+git.${commitsha}"

+ fi

+ 

+ workdir="$(mktemp -d)"

+ trap "rm -rf $workdir" EXIT

+ outdir="$(readlink -f ./rpmbuild-output)"

+ mkdir -p "$outdir"

+ 

+ git archive --format=tar --prefix="${name}-${version}/" HEAD | gzip >"$workdir/${name}-${version}.tar.gz"

+ git show HEAD:${name}.spec >"$workdir/${name}.spec"

+ 

+ if [ -n "$rpmrel" ] ; then

+     # need to hack the version in the spec

+     sed --regexp-extended --in-place \

+         -e "/%global upstream_version /c\%global upstream_version ${version}" \

+         -e "/^Version:/cVersion: ${rpmver}" \

+         -e "/^Release:/cRelease: ${rpmrel}%{?dist}" \

+         "$workdir/${name}.spec"

+     # inject %prep commands to also hack the Python module versions

+     # (beware the precarious quoting here...)

+     commands=$(cat <<EOF

+ sed -i -e "/^version = /c\\\\version = '$version'" setup.py

+ EOF

+ )

+     awk --assign "commands=$commands" \

+         '{ print } ; /^%setup/ { print commands }' \

+         "$workdir/${name}.spec" >"$workdir/${name}.spec.injected"

+     mv "$workdir/${name}.spec.injected" "$workdir/${name}.spec"

+ fi

+ 

+ rpmbuild \

+     --define "_topdir $workdir" \

+     --define "_sourcedir $workdir" \

+     --define "_specdir $workdir" \

+     --define "_rpmdir $outdir" \

+     --define "_srcrpmdir $outdir" \

+     "$@" "$workdir/${name}.spec"

file modified
+1 -1
@@ -1,6 +1,6 @@ 

  from setuptools import setup

  

- version = '1.0.0'

+ version = '0.0'

  

  setup(name='waiverdb',

        version=version,

file added
+47
@@ -0,0 +1,47 @@ 

+ 

+ %global upstream_version 0.0

+ 

+ Name:           waiverdb

+ Version:        0.0

+ Release:        1%{?dist}

+ Summary:        Service for waiving results in ResultsDB

+ License:        GPLv2+

+ URL:            https://pagure.io/waiverdb

+ Source0:        %{name}-%{upstream_version}.tar.gz

+ 

+ BuildRequires:  python2-devel

+ BuildRequires:  python-setuptools

+ BuildRequires:  python-flask

+ BuildRequires:  python-sqlalchemy

+ BuildRequires:  python-flask-restful

+ BuildRequires:  python-flask-sqlalchemy

+ BuildRequires:  pytest

+ BuildArch:      noarch

+ Requires:       python-flask

+ Requires:       python-sqlalchemy

+ Requires:       python-flask-restful

+ Requires:       python-flask-sqlalchemy

+ 

+ %description

+ .

+ 

+ %prep

+ %setup -q -n %{name}-%{upstream_version}

+ 

+ %build

+ %py2_build

+ 

+ %install

+ %py2_install

+ 

+ %check

+ export PYTHONPATH=%{buildroot}/%{python2_sitelib}

+ py.test tests/

+ 

+ %files

+ %license COPYING

+ %doc README.md

+ %{python2_sitelib}/%{name}

+ %{python2_sitelib}/%{name}*.egg-info

+ 

+ %changelog

Includes a utility script to correctly build an RPM package from git HEAD revision, and adds an RPM build step to the Jenkins pipeline.

Ahh forgot that we can't do dependencies between PRs so this can't go in just yet (it includes the commit from my other PR for adding the initial Jenkinsfile). But people can still review anyway.

Note to self: mock stuff is not working in Jenkins right now, fix it.

2 new commits added

  • RPM spec file
  • initial Jenkins pipeline to run the tests in a virtualenv
7 years ago

Just as an FYI, you won't be able to build this spec file internally since Brew doesn't allow you to install EPEL packages as dependencies for a build.

Can you make these BuildRequires and the check section of the spec file optional by setting a variable at the top of the spec file?

We do have the sed-rhel-7 tag in Brew internally, which is configured with EPEL as an external repo. It's for building internal services like this.

rebased

7 years ago

rebased

7 years ago

This is now just stuck on the fact that the tests don't actually work in EPEL7 (fixed by #4 and #11) and the Jenkins slaves are missing mock configs for Fedora 25 (they need a newer build of mock).

:+1: to the concept from me.

@mjia, can you rebase this on master and confirm that the test suite is working?

Is this stuck waiting for anything, or can it be merged?

👍 to the concept from me.
@mjia, can you rebase this on master and confirm that the test suite is working?

Sorry, I missed this comment. Is there any way to configure pagure to send a notification when someone put a comment? I have tested that the test suite works fine. I guess the only thing stucks here is we need to get mock updated in eng-rhel-7 so that we can turn on the Jenkins.

Have rebased this and moved it to #22

Pull-Request has been closed by mjia

7 years ago