#22 RPM spec file
Merged 7 years ago by mjia. Opened 7 years ago by mjia.
mjia/waiverdb rpm  into  master

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

  test_env

  .cache

  docs/_build

+ /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
+10
@@ -0,0 +1,10 @@ 

+ global-exclude *.pyc *.pyo

+ include README.md

+ include COPYING

+ include requirements.txt

+ include tests/*.py

+ include pytest.ini

+ include tox.ini

+ include runapp.py

+ recursive-include conf *

+ recursive-include docs *.py *.rst Makefile

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
+4 -3
@@ -1,6 +1,6 @@ 

  from setuptools import setup

  

- version = '1.0.0'

+ version = '0.0'

  

  setup(name='waiverdb',

        version=version,
@@ -8,5 +8,6 @@ 

        author='Red Hat, Inc.',

        author_email='qa-devel@lists.fedoraproject.org',

        license='GPLv2+',

-       packages=['waiverdb'],

-       package_dir={'waiverdb': 'waiverdb'})

+       packages=['waiverdb', 'waiverdb.models'],

+       package_dir={'waiverdb': 'waiverdb'},

+ )

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

+ 

+ %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:  python-kerberos

+ BuildRequires:  pytest

+ BuildRequires:  python-mock

+ BuildRequires:  pytest

+ BuildRequires:  fedmsg

+ BuildArch:      noarch

+ Requires:       python-flask

+ Requires:       python-sqlalchemy

+ Requires:       python-flask-restful

+ Requires:       python-flask-sqlalchemy

+ Requires:       python-kerberos

+ Requires:       python-mock

+ Requires:       fedmsg

+ 

+ %description

+ WaiverDB is a companion service to ResultsDB, for recording waivers against test results.

+ 

+ %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 conf docs

+ %{python2_sitelib}/%{name}

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

+ 

+ %changelog

no initial comment

Would be nice to add a short description :-)

Any specific reason for this? I could sort of understand 0.0.1 - 0.0 seems weird :-)

I tried running $ fedora-review -n waiverdb after building the .src.rpm here and it failed to run the tests in the %check section.

It looks like you may need to include the tests/ directory in the tarball with a MANIFEST.in file or some change to setup.py.

Try iterating on this with the fedora-review tool until it returns few or no errors.

I tried running $ fedora-review -n waiverdb after building the .src.rpm here and it failed to run the tests in the %check section.
It looks like you may need to include the tests/ directory in the tarball with a MANIFEST.in file or some change to setup.py.
Try iterating on this with the fedora-review tool until it returns few or no errors.

Thanks, fedora-review is new to me, :-)

rebased

7 years ago

I have updated the patch to make fedora-review happy.

:+1: for me. This looks like a good baseline to iterate on.

fedora-review is new to me, :-)

Yeah! @sochotni wrote it like 1000 years ago. :fireworks:

I don't want to take credit for something I didn't do so - originally fedora-review was created by Tim Lauridsen :-)

See: https://pagure.io/FedoraReview/blob/master/f/AUTHORS

Also: :+1:

rebased

7 years ago

Also :+1: from me but I guess we need to sort out the issue with mock on the Jenkins slaves before we can hit the button here.

rebased

7 years ago

Also 👍 from me but I guess we need to sort out the issue with mock on the Jenkins slaves before we can hit the button here.

The issue with mock has been sorted out, :v:

Pull-Request has been merged by mjia

7 years ago