#56 Add Makefile and testcloud.spec
Merged 6 years ago by frantisekz. Opened 6 years ago by frantisekz.

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

+ #

+ # Copyright 2018, Red Hat, Inc.

+ #

+ # 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.

+ #

+ # You should have received a copy of the GNU General Public License along

+ # with this program; if not, write to the Free Software Foundation, Inc.,

+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

+ #

+ 

+ # general variables

+ SRC:=testcloud

+ 

+ # Variables used for packaging

+ SPECFILE:=$(SRC).spec

+ BASEARCH:=$(shell uname -i)

+ DIST:=$(shell rpm --eval '%{dist}')

+ VERSION:=$(shell rpmspec -q --queryformat="%{VERSION}\n" $(SPECFILE) | uniq)

+ RELEASE:=$(subst $(DIST),,$(shell rpmspec -q --queryformat="%{RELEASE}\n" $(SPECFILE) | uniq))

+ NVR:=$(SRC)-$(VERSION)-$(RELEASE)

+ GITBRANCH:=$(shell git rev-parse --abbrev-ref HEAD)

+ TARGETVER:=$(shell lsb_release -r |grep -o '[0-9]*')

+ TARGETDIST:=fc$(TARGETVER)

+ BUILDTARGET:=fedora-$(TARGETVER)-x86_64

+ 

+ .PHONY: pylint

+ pylint:

+ 	pylint -f parseable $(SRC) | tee pylint.out

+ 

+ .PHONY: pep8

+ pep8:

+ 	pep8 $(SRC)/*.py $(SRC)/*/*.py | tee pep8.out

+ 

+ .PHONY: ci

+ ci: pylint pep8

+ 

+ .PHONY: docs

+ docs:

+ 	cd docs && $(MAKE) clean && $(MAKE) html

+ 

+ .PHONY: clean

+ clean:

+ 	rm -rf dist

+ 	rm -rf $(SRC).egg-info

+ 	rm -rf build

+ 	rm -f pep8.out

+ 	rm -f pylint.out

+ 

+ .PHONY: archive

+ archive: $(SRC)-$(VERSION).tar.gz

+ 

+ .PHONY: $(SRC)-$(VERSION).tar.gz

+ $(SRC)-$(VERSION).tar.gz:

+ 	git archive $(GITBRANCH) --prefix=$(SRC)-$(VERSION)/ | gzip -c9 > $@

+ 

+ .PHONY: mocksrpm

+ mocksrpm: archive

+ 	mock -r $(BUILDTARGET) --buildsrpm --spec $(SPECFILE) --sources .

+ 	cp /var/lib/mock/$(BUILDTARGET)/result/$(NVR).$(TARGETDIST).src.rpm .

+ 

+ .PHONY: mockbuild

+ mockbuild: mocksrpm

+ 	mock -r $(BUILDTARGET) --no-clean --rebuild $(NVR).$(TARGETDIST).src.rpm

+ 	cp /var/lib/mock/$(BUILDTARGET)/result/$(NVR).$(TARGETDIST).noarch.rpm .

+ 

+ .PHONY: nvr

+ nvr:

+ 	@echo $(NVR)

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

+ # sitelib for noarch packages, sitearch for others (remove the unneeded one)

+ %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}

+ 

+ Name:           testcloud

+ Version:        0.1.16

+ Release:        1%{?dist}

+ Summary:        Tool for running cloud images locally

+ 

+ License:        GPLv2+

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

+ Source0:        https://releases.pagure.org/testcloud/%{name}-%{version}.tar.gz

+ 

+ BuildArch:      noarch

+ 

+ # Ensure we can create the testcloud group

+ Requires(pre):  shadow-utils

+ 

+ # testcloud integrates with libvirt

+ Requires:       libvirt

+ %if 0%{?fedora} <= 26

+ Requires:       libvirt-python

+ %else

+ Requires:       python2-libvirt

+ %endif

+ 

+ # This is used to manipulate images on disk

+ Requires:       libguestfs

+ Requires:       libguestfs-tools

+ 

+ # Used to download images from valid URLs

+ Requires:       python2-requests

+ 

+ Requires:       polkit

+ Requires:       python2-jinja2

+ 

+ %if 0%{?fedora} <= 26

+ BuildRequires:  libvirt-python

+ %else

+ BuildRequires:  python2-libvirt

+ %endif

+ BuildRequires:  python2-devel

+ BuildRequires:  python2-jinja2

+ BuildRequires:  python2-mock

+ BuildRequires:  python2-pytest

+ BuildRequires:  python2-pytest-cov

+ BuildRequires:  python2-requests

+ BuildRequires:  python2-setuptools

+ 

+ # Provides:       python2-testcloud

+ 

+ %description

+ testcloud is a relatively simple system which is capable of booting images

+ designed for cloud systems on a local system with minimal configuration.

+ testcloud is designed to be (and remain) somewhat simple, trading fancy cloud

+ system features for ease of use and sanity in development.

+ 

+ # Create the testcloud group

+ %pre

+ getent group testcloud >/dev/null || groupadd testcloud

+ 

+ %prep

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

+ 

+ %check

+ %{__python2} setup.py test

+ # Remove compiled .py files from /etc after running unittests

+ rm -f %{buildroot}%{_sysconfdir}/testcloud/*.py{c,o}

+ 

+ %build

+ %{__python2} setup.py build

+ 

+ %install

+ %{__python2} setup.py install -O1 --skip-build --root %{buildroot}

+ 

+ # configuration files

+ mkdir -p %{buildroot}%{_sysconfdir}/testcloud/

+ install conf/settings-example.py %{buildroot}%{_sysconfdir}/testcloud/settings.py

+ 

+ # Create running directory for testcloud

+ install -d %{buildroot}%{_sharedstatedir}/testcloud/

+ 

+ # Install domain jinja template for libvirt to import

+ install conf/domain-template.jinja %{buildroot}/%{_sharedstatedir}/testcloud/domain-template.jinja

+ 

+ # backingstores dir

+ install -d %{buildroot}/%{_sharedstatedir}/testcloud/backingstores

+ 

+ # instance dir

+ install -d %{buildroot}/%{_sharedstatedir}/testcloud/instances

+ 

+ # create polkit rules dir and install polkit rule

+ mkdir -p %{buildroot}%{_sysconfdir}/polkit-1/rules.d

+ install conf/99-testcloud-nonroot-libvirt-access.rules %{buildroot}%{_sysconfdir}/polkit-1/rules.d/99-testcloud-nonroot-libvirt-access.rules

+ 

+ %files

+ %doc README.rst

+ %license LICENSE

+ %{python2_sitelib}/testcloud

+ %{python2_sitelib}/*.egg-info

+ 

+ %dir %{_sysconfdir}/testcloud

+ %dir %attr(0775, qemu, testcloud) %{_sharedstatedir}/testcloud

+ %dir %attr(0775, qemu, testcloud) %{_sharedstatedir}/testcloud/backingstores

+ %dir %attr(0775, qemu, testcloud) %{_sharedstatedir}/testcloud/instances

+ %attr(0764, qemu, testcloud) %{_sharedstatedir}/testcloud/domain-template.jinja

+ 

+ %attr(0644, root, root) %{_sysconfdir}/polkit-1/rules.d/99-testcloud-nonroot-libvirt-access.rules

+ 

+ %config(noreplace) %{_sysconfdir}/testcloud/settings.py

+ %{_bindir}/testcloud

+ 

+ %changelog

+ * Tue Feb 20 2018 Frantisek Zatloukal <fzatlouk@redhat.com> - 0.1.16-1

+ - Retry to stop instance when host is busy

+ 

+ * Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.15-3

+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

+ 

+ * Fri Feb 02 2018 Frantisek Zatloukal <fzatlouk@redhat.com> - 0.1.15-2

+ - Update Python 2 dependency declarations to new packaging standards

+   (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)

+ 

+ * Thu Oct 26 2017 Kamil Páral <kparal@redhat.com> - 0.1.15-1

+ - keep backwards compatible API

+ 

+ * Thu Oct 26 2017 Kamil Páral <kparal@redhat.com> - 0.1.14-1

+ - replace arp with libvirt method (lose dep on net-tools)

+ - fix test suite in spec file

+ 

+ * Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.11-4

+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

+ 

+ * Wed Feb 22 2017 Kamil Páral <kparal@redhat.com> - 0.1.11-3

+ - don't install py[co] files into /etc

+ 

+ * Mon Feb 20 2017 Kamil Páral <kparal@redhat.com> - 0.1.11-2

+ - add python-pytest-cov builddep to run test suite during building

+ 

+ * Mon Feb 20 2017 Kamil Páral <kparal@redhat.com> - 0.1.11-1

+ - make libvirt url configurable

+ - avoid race condition during listing domains

+ 

+ * Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.10-2

+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

+ 

+ * Wed Aug 17 2016 Martin Krizek <mkrizek@redhat.com> - 0.1.10-1

+ - use symlinks for file:// urls

+ - look for the jinja template in the conf/ dir first

+ 

+ * Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.1.9-2

+ - https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

+ 

+ * Tue Jul 19 2016 Kamil Páral <kparal@redhat.com> - 0.1.9-1

+ - upstream 0.1.9 release

+ - "destroy" commands renamed to "remove"

+ - "instance remove" now supports "--force"

+ - new "instance reboot" command

+ - no more crashes when stopping an already stopped instance

+ - option to automatically stop an instance during remove (API)

+ 

+ * Mon Jul 18 2016 Martin Krizek <mkrizek@redhat.com> - 0.1.8-3

+ - libguestfs on arm should be fixed now, removing exclude arm

+ 

+ * Wed Jun 22 2016 Martin Krizek <mkrizek@redhat.com> - 0.1.8-2

+ - exclude arm until libguestfs dep is resolved there

+ 

+ * Fri Feb 05 2016 Tim Flink <tflink@fedoraproject.org> - 0.1.8-1

+ - Explicitly fail when IP address is not found

+ 

+ * Fri Feb 05 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.7-2

+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

+ 

+ * Tue Dec 8 2015 Tim Flink <tflink@fedoraproject.org> - 0.1.7-1

+ - Enabling configurable instance memory and disk size (T420, T659)

+ - Improved handling of images with larger disks (T657)

+ - Changed "cache" to "backingstores" to reduce confusion (T521)

+ 

+ * Tue Dec 1 2015 Tim Flink <tflink@fedoraproject.org> - 0.1.6-1

+ - fixing python2 macros

+ - other small fixes as per review

+ 

+ * Wed Nov 18 2015 Tim Flink <tflink@fedoraproject.org> - 0.1.5-4

+ - adding net-tools as a dependency

+ 

+ * Wed Nov 11 2015 Martin Krizek <mkrizek@redhat.com> - 0.1.5-3

+ - adding python-jinja2 as a dependency

+ 

+ * Thu Nov 05 2015 Tim Flink <tflink@fedoraproject.org> - 0.1.5-2

+ - rework setup to work with github sources, proper file declarations

+ 

+ * Wed Nov 04 2015 Mike Ruckman <roshi@fedoraproject.org> - 0.1.5-1

+ - Multiple bugfixes (mainly use libvirt, not virt-install)

+ 

+ * Tue Sep 29 2015 Mike Ruckman <roshi@fedoraproject.org> - 0.1.4-2

+ - Fix permissions issues and no long overwrite stored configs.

+ 

+ * Tue Sep 29 2015 Mike Ruckman <roshi@fedoraproject.org> - 0.1.4-1

+ - Multiple bug fixes.

+ 

+ * Tue Sep 01 2015 Mike Ruckman <roshi@fedoraproject.org> - 0.1.3-2

+ - Unkludge the last release.

+ 

+ * Sun Aug 30 2015 Mike Ruckman <roshi@fedoraproject.org> - 0.1.3-1

+ - Multiple bugfixes and general clean up.

+ 

+ * Tue Jul 14 2015 Mike Ruckman <roshi@fedoraproject.org> - 0.1.1-2

+ - Added polkit rule for headless machine (or passwordless) execution.

+ 

+ * Thu Jul 09 2015 Mike Ruckman <roshi@fedoraproject.org> - 0.1.1-1

+ - Fixed packaging issues. Removed uneeded code.

+ 

+ * Thu Jul 09 2015 Mike Ruckman <roshi@fedoraproject.org> - 0.1.0-2

+ - Fixed packaging issues. Removed uneeded code.

+ 

+ * Tue Jun 23 2015 Mike Ruckman <roshi@fedoraproject.org> - 0.1.0-1

+ - Initial packaging of testcloud

Take a look at Makefile:

# TARGETDIST:=fc27
# BUILDTARGET=fedora-27-x86_64
TARGETVER:=$(shell lsb_release -r |grep -o '[0-9]*')
TARGETDIST:=fc$(TARGETVER)
BUILDTARGET:=fedora-$(TARGETVER)-x86_64

Compared to our other Makefiles, I've implemented setting buildroot to the release that is currently running.

No point in having this commented out. Either put it in or remove it.

Are you sure about that? :)

Is there a reason for having all those venv targets? Nothing seems to use them.

There is already a docs/Makefile file. Shouldn't you call it instead?

Let's remove the comments then.

Have you tested that all the targets work?

rebased onto 3269d82eb8035d08f924ebd2af8d9a0cb8cc5a59

6 years ago

rebased onto 9c25206c81e402b9070b0a5a6164513fc68926e4

6 years ago

I've updated it, almost ( :P ) everything you've pointed at should be sorted out now.

I've made one more change:

SRC:=$(shell rpmspec -q --queryformat="%{NAME}\n" *.spec | uniq)

With that, this Makefile can become generic, shared across all our projects. The only drawback is breakage when there are more spec files in the same directory. Anyway, I've never seen more than one spec in any of our projects.

Have you tested that all the targets work?

Yep, everything looks just fantastic.

rebased onto 403343bb99e2862ab8ddc5ec0031789c49dea309

6 years ago

rebased onto c848a3c

6 years ago

Pull-Request has been merged by frantisekz

6 years ago
Metadata