Skip to content

Instantly share code, notes, and snippets.

@ildarmf
Last active March 12, 2020 15:35
Show Gist options
  • Save ildarmf/c054997735579232e59ecfb7cedc6b12 to your computer and use it in GitHub Desktop.
Save ildarmf/c054997735579232e59ecfb7cedc6b12 to your computer and use it in GitHub Desktop.
%define package_name %{getenv:NAME}
%define package_version %{getenv:VERSION}
%define package_release %{getenv:RELEASE}
Name: %{package_name}
Version: %{package_version}
Release: %{?package_release}
Summary: This is %{package_name}
License: Comagic
URL: https://gitlab/infra/%{package_name}
Prefix: /opt/
%define full_dir %{prefix}/%{package_name}/%{package_version}
%define _python_bytecompile_errors_terminate_build 0
%define __strip /bin/true
%global __python %{full_dir}/venv/bin/python3.7
%define __requires_exclude %{full_dir}/venv
%description
Runapp application for deploy projects.
%prep
%{__rm} -rf %{full_dir}
%{__mkdir} -p %{fulldir}/venv
%build
%{__rm} -rf %{buildroot}%{full_dir}
%{__mkdir} -p %{buildroot}%{full_dir}
/opt/python-3.7.0/bin/python3.7 -m venv %{full_dir}/venv --clear --copies
source %{full_dir}/venv/bin/activate
%{__cp} -R /builds/${CI_PROJECT_PATH}/%{package_name} -t %{full_dir}/venv/
%{__cp} /builds/${CI_PROJECT_PATH}/%{package_name}/server.py -t %{full_dir}/
pip install -r /builds/${CI_PROJECT_PATH}/requirements.txt
deactivate
%install
mkdir -p %{buildroot}%{full_dir}
cp -rf %{full_dir}* %{buildroot}%{full_dir}/
sed -i "s/VERSION/$VERSION/g" /builds/${CI_PROJECT_PATH}/conf/%{package_name}.service
install -p -D -m 0644 /builds/${CI_PROJECT_PATH}/conf/%{package_name}.service \
%{buildroot}%{_unitdir}/runapp.service
%post
%systemd_post %{package_name}.service
%postun
%systemd_postun %{package_name}.service
%files
%{full_dir}/*
%{_unitdir}/%{package_name}.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment