rpm for CentOS build. Initial

This commit is contained in:
Denis Zheleztsov 2016-11-14 17:28:35 +03:00
parent 3f161d14ed
commit 782423fd53
4 changed files with 119 additions and 1 deletions

View File

@ -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

View File

@ -5,7 +5,7 @@ set -e
. functions.sh
function usage() {
echo "$0 <clean|build_package|surok_image|alpine|centos>"
echo "$0 <clean|build_package|surok_image|alpine|centos|centos_rpm>"
}
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

View File

@ -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 <<EOF
FROM centos:latest
MAINTAINER Denis Zheleztsov <difrex.punk@gmail.com>
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 <<EOF
FROM fedora:24
MAINTAINER Denis Zheleztsov <difrex.punk@gmail.com>
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
}

72
surok.spec Normal file
View File

@ -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 <difrex.punk@gmail.com> -
- Initial build.