From 57ee2b93349e875eb9a5354b32f2abfc525fb9b8 Mon Sep 17 00:00:00 2001 From: Graham Mainwaring Date: Thu, 9 Jan 2020 14:37:21 -0500 Subject: [PATCH] Initial RPM packaging --- .gitignore | 7 +----- Makefile | 43 ++++++++++++++++++++++++++++++--- packaging/rpm/receptor.spec.j2 | 44 ++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 packaging/rpm/receptor.spec.j2 diff --git a/.gitignore b/.gitignore index 20770e26..28741b09 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ __pycache__/ # Distribution / packaging .Python build/ +rpm-build/ develop-eggs/ dist/ downloads/ @@ -34,12 +35,6 @@ wheels/ *.egg MANIFEST -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - # Installer logs pip-log.txt pip-delete-this-directory.txt diff --git a/Makefile b/Makefile index 22c46695..ec2ff278 100644 --- a/Makefile +++ b/Makefile @@ -13,22 +13,37 @@ ifeq ($(OFFICIAL),yes) RELEASE ?= 1 else ifeq ($(origin RELEASE), undefined) - RELEASE := 0.git$(shell date -u +%Y%m%d%H%M).$(shell git rev-parse --short HEAD) + RELEASE := 0.git_$(shell git rev-parse --short HEAD) endif endif +DIST ?= el7 +ARCH ?= x86_64 -.PHONY: dist sdist test +NVR_RELEASE = $(RELEASE).$(DIST) +EPEL_DIST = $(subst el,epel-,$(DIST)) +NVR = $(NAME)-$(VERSION)-$(NVR_RELEASE) +RESULTDIR = rpm-build/results-$(DIST)-$(ARCH) + +.PHONY: clean version release dist sdist image dev shell test \ + mock-rpm mock-srpm image clean: rm -rf dist rm -rf receptor.egg-info + rm -rf rpm-build + +version: + @echo $(VERSION) + +release: + @echo $(RELEASE) dist: $(DIST_PYTHON) setup.py bdist_wheel --universal sdist: dist/$(NAME)-$(VERSION).tar.gz -dist/$(NAME)-$(VERSION).tar.gz: +dist/$(NAME)-$(VERSION).tar.gz: $(shell find receptor -type f -name '*.py') $(DIST_PYTHON) setup.py sdist image: dist @@ -42,3 +57,25 @@ shell: test: tox + +dist/$(VERSION).tar.gz: dist/$(NAME)-$(VERSION).tar.gz + cp dist/$(NAME)-$(VERSION).tar.gz dist/$(VERSION).tar.gz + +rpm-build/$(NVR).spec: packaging/rpm/$(NAME).spec.j2 + mkdir -p rpm-build + ansible -i localhost, -c local all -m template \ + -a "src=packaging/rpm/$(NAME).spec.j2 dest=rpm-build/$(NVR).spec" \ + -e version=$(VERSION) \ + -e release=$(NVR_RELEASE) + +$(RESULTDIR)/$(NVR).src.rpm: dist/$(VERSION).tar.gz rpm-build/$(NVR).spec + mock --buildsrpm --no-clean -r $(EPEL_DIST)-$(ARCH) --spec rpm-build/$(NVR).spec --sources dist/$(VERSION).tar.gz --resultdir $(RESULTDIR) + +$(RESULTDIR)/$(NVR).rpm: $(RESULTDIR)/$(NVR).src.rpm + mock --rebuild --no-clean -r $(EPEL_DIST)-$(ARCH) $(RESULTDIR)/$(NVR).src.rpm --resultdir $(RESULTDIR) + @touch $@ + +mock-srpm: $(RESULTDIR)/$(NVR).src.rpm + +mock-rpm: $(RESULTDIR)/$(NVR).rpm + diff --git a/packaging/rpm/receptor.spec.j2 b/packaging/rpm/receptor.spec.j2 new file mode 100644 index 00000000..001b3086 --- /dev/null +++ b/packaging/rpm/receptor.spec.j2 @@ -0,0 +1,44 @@ +%define name receptor +%define version {{ version }} +%define release {{ release }} + +Summary: UNKNOWN +Name: %{name} +Version: %{version} +Release: %{release} +Source0: https://github.com/project-receptor/%{name}/archive/%{version}.tar.gz + +License: Apache +Group: Development/Libraries +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot +Prefix: %{_prefix} +BuildArch: noarch +Vendor: Red Hat +Url: https://github.com/project-receptor/receptor + +BuildRequires: python3 +BuildRequires: python3-setuptools +Requires: python3 +Requires: python3-setuptools +Requires: python3-aiohttp +Requires: python3-prometheus_client + +%description +Receptor +============== +Project Receptor is a flexible multi-service relayer with remote execution and orchestration capabilities linking controllers with executors across a mesh of nodes. For the latest documentation see: [https://receptor.readthedocs.io](https://receptor.readthedocs.io/en/latest/) + +%prep +%setup -n %{name}-%{version} -n %{name}-%{version} + +%build +python3 setup.py build + +%install +python3 setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES + +%clean +rm -rf $RPM_BUILD_ROOT + +%files -f INSTALLED_FILES +%defattr(-,root,root)