Skip to content

Commit

Permalink
Initial RPM packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
ghjm committed Jan 9, 2020
1 parent ea82507 commit 57ee2b9
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 9 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ __pycache__/
# Distribution / packaging
.Python
build/
rpm-build/
develop-eggs/
dist/
downloads/
Expand All @@ -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
Expand Down
43 changes: 40 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

44 changes: 44 additions & 0 deletions packaging/rpm/receptor.spec.j2
Original file line number Diff line number Diff line change
@@ -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 <UNKNOWN>
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)

0 comments on commit 57ee2b9

Please sign in to comment.