From 55aec4bccb52c55c8cc2c4ca15cd7adffb6c6de1 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Apr 04 2017 03:58:09 +0000 Subject: RPM spec file --- diff --git a/.gitignore b/.gitignore index 2f50910..e17989c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ conf/settings.py test_env .cache docs/_build +/rpmbuild-output/ diff --git a/Jenkinsfile b/Jenkinsfile index 6fedc2a..1fac7dc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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/**' } } diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b9e4c7a --- /dev/null +++ b/MANIFEST.in @@ -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 diff --git a/rpmbuild.sh b/rpmbuild.sh new file mode 100755 index 0000000..fadeddf --- /dev/null +++ b/rpmbuild.sh @@ -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 " >&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 <"$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" diff --git a/setup.py b/setup.py index 5027489..cbc52f2 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -version = '1.0.0' +version = '0.0' setup(name='waiverdb', version=version, @@ -8,5 +8,6 @@ setup(name='waiverdb', 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'}, +) diff --git a/waiverdb.spec b/waiverdb.spec new file mode 100644 index 0000000..cb6540e --- /dev/null +++ b/waiverdb.spec @@ -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