From 782423fd53b43ce9ef819243de4d7641ad850446 Mon Sep 17 00:00:00 2001 From: Denis Zheleztsov Date: Mon, 14 Nov 2016 17:28:35 +0300 Subject: [PATCH] rpm for CentOS build. Initial --- .travis.yml | 1 + build/build.sh | 3 +- build/functions.sh | 44 ++++++++++++++++++++++++++++ surok.spec | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 surok.spec diff --git a/.travis.yml b/.travis.yml index fd28d66..3a3e305 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ before_install: - cd build && ./build.sh surok_image - ./build.sh alpine - ./build.sh centos + - ./build.sh centos_rpm script: - ./runtests.sh diff --git a/build/build.sh b/build/build.sh index 088fed7..3be9f11 100755 --- a/build/build.sh +++ b/build/build.sh @@ -5,7 +5,7 @@ set -e . functions.sh function usage() { - echo "$0 " + echo "$0 " } case $1 in @@ -19,5 +19,6 @@ case $1 in surok_image_no_rebuild) build_surok_base ;; alpine) build_alpine ;; centos) build_centos ;; + centos_rpm) build_centos_rpm ;; *) usage ;; esac diff --git a/build/functions.sh b/build/functions.sh index 3006117..bfa5ed8 100644 --- a/build/functions.sh +++ b/build/functions.sh @@ -125,3 +125,47 @@ ENTRYPOINT cd /opt/surok && python3 surok.py -c /etc/surok/conf/surok.json EOF docker build -t surok_centos -f Dockerfile.centos . } + +function centos_builder() { + copy_surok + VERSION=$(grep 'Version: ' surok/surok.spec | awk -F': ' '{print $2}') + cat > Dockerfile.centos_builder < + +RUN yum -y install rpm-build +COPY surok /tmp/surok-${VERSION} +RUN find /tmp/surok-${VERSION} -name '*pyc' -delete +RUN find /tmp/surok-${VERSION} -name '*pyo' -delete +RUN rm -rf /tmp/surok-${VERSION}/surok/__pycache__ +RUN mkdir -p /root/rpmbuild/SPECS +RUN mkdir -p /root/rpmbuild/SOURCES +RUN cd /tmp && tar -czvf /root/rpmbuild/SOURCES/surok.tar.gz surok-${VERSION} +ADD surok/surok.spec /root/rpmbuild/SPECS/ + +RUN yum clean all + +ENTRYPOINT cd /root/rpmbuild/SPECS && rpmbuild -bb surok.spec +EOF + docker build -t surok_builder_centos -f Dockerfile.centos_builder . +} + +function fedora_builder() { + cat > Dockerfile.fedora_builder < + +RUN dnf -y install rpm-build +COPY surok /root/rpmbuild/SOURCES/surok + +RUN dnf clean all +EOF + docker build -t surok_builder_fedora -f Dockerfile.fedora_builder . +} + +function build_centos_rpm() { + centos_builder + docker run -v $(pwd)/out:/root/rpmbuild/RPMS -ti surok_builder_centos +} diff --git a/surok.spec b/surok.spec new file mode 100644 index 0000000..84da33a --- /dev/null +++ b/surok.spec @@ -0,0 +1,72 @@ +Summary: Simple service discovery for Apache Mesos clusters +Name: surok +Version: 0.7.4.1 +Release: 1 +License: BSD +Group: admin +URL: https://github.com/Difrex/surok +Source0: surok.tar.gz +BuildArch: noarch +Requires: python34 +# BuildRoot: %{_tmppath}/%{name}-%{release}-root + +%description +Simple service discovery for Apache Mesos clusters + +%prep +%setup -q + +%build + +%install +mkdir -p %{buildroot}/opt/surok/surok +install -p -m 644 /root/rpmbuild/BUILD/surok-%{version}/surok/__init__.py %{buildroot}/opt/surok/surok +install -p -m 644 /root/rpmbuild/BUILD/surok-%{version}/surok/logger.py %{buildroot}/opt/surok/surok +install -p -m 644 /root/rpmbuild/BUILD/surok-%{version}/surok/system.py %{buildroot}/opt/surok/surok +install -p -m 644 /root/rpmbuild/BUILD/surok-%{version}/surok/discovery.py %{buildroot}/opt/surok/surok +install -p -m 644 /root/rpmbuild/BUILD/surok-%{version}/surok/templates.py %{buildroot}/opt/surok/surok +install -p -m 644 /root/rpmbuild/BUILD/surok-%{version}/surok.py %{buildroot}/opt/surok +mkdir -p %{buildroot}/etc/surok/{conf,conf.d,templates} +install -p -m 644 /root/rpmbuild/BUILD/surok-%{version}/conf/surok.json %{buildroot}/etc/surok/conf +install -p -m 644 /root/rpmbuild/BUILD/surok-%{version}/conf.d/selfcheck.json %{buildroot}/etc/surok/conf.d +install -p -m 644 /root/rpmbuild/BUILD/surok-%{version}/templates/selfcheck.jj2 %{buildroot}/etc/surok/templates +install -p -m 644 /root/rpmbuild/BUILD/surok-%{version}/requriments.txt %{buildroot}/opt/surok + + +%clean +rm -rf $RPM_BUILD_ROOT + +%post +cd /opt/surok && pip3 install -r requriments.txt + +%files +/opt/surok/surok/__init__.py +/opt/surok/surok/__init__.pyc +/opt/surok/surok/__init__.pyo +/opt/surok/surok/logger.py +/opt/surok/surok/logger.pyc +/opt/surok/surok/logger.pyo +/etc/surok/conf/surok.json +/opt/surok/surok.py +/opt/surok/surok.pyc +/opt/surok/surok.pyo +/opt/surok/surok/discovery.py +/opt/surok/surok/discovery.pyc +/opt/surok/surok/discovery.pyo +/opt/surok/surok/system.py +/opt/surok/surok/system.pyc +/opt/surok/surok/system.pyo +/opt/surok/surok/templates.py +/opt/surok/surok/templates.pyc +/opt/surok/surok/templates.pyo +/etc/surok/conf.d/selfcheck.json +/etc/surok/templates/selfcheck.jj2 +/opt/surok/requriments.txt +%defattr(-,root,root,-) +%doc + + +%changelog +* Mon Nov 14 2016 Denis Zheleztsov - +- Initial build. +