mirror of https://github.com/sysown/proxysql
parent
1c51cac80a
commit
93c41fd74a
@ -0,0 +1,64 @@
|
||||
# Don't try fancy stuff like debuginfo, which is useless on binary-only
|
||||
# packages. Don't strip binary too
|
||||
# Be sure buildpolicy set to do nothing
|
||||
%define __spec_install_post %{nil}
|
||||
%define debug_package %{nil}
|
||||
%define __os_install_post %{_dbpath}/brp-compress
|
||||
|
||||
Summary: A high-performance MySQL proxy
|
||||
Name: proxysql
|
||||
Version: %{version}
|
||||
Release: 1
|
||||
License: GPL+
|
||||
Group: Development/Tools
|
||||
SOURCE0 : %{name}-%{version}.tar.gz
|
||||
URL: http://www.proxysql.com/
|
||||
Requires: gnutls
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||
|
||||
%description
|
||||
%{summary}
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
# Empty section.
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
mkdir -p %{buildroot}
|
||||
|
||||
# in builddir
|
||||
cp -a * %{buildroot}
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%post
|
||||
if [ ! -d /var/run/%{name} ]; then mkdir /var/run/%{name} ; fi
|
||||
if [ ! -d /var/lib/%{name} ]; then mkdir /var/lib/%{name} ; fi
|
||||
if ! id -u %{name} > /dev/null 2>&1; then useradd -r -U -s /bin/false -d /var/lib/%{name} -c "ProxySQL Server" %{name}; fi
|
||||
chown -R %{name}: /var/lib/%{name} /var/run/%{name}
|
||||
chown root:%{name} /etc/%{name}.cnf
|
||||
chmod 640 /etc/%{name}.cnf
|
||||
chkconfig --add %{name}
|
||||
|
||||
%preun
|
||||
/etc/init.d/%{name} stop
|
||||
chkconfig --del %{name}
|
||||
|
||||
%postun
|
||||
rm -rf /var/run/%{name}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%config(noreplace) %{_sysconfdir}/%{name}.cnf
|
||||
%attr(640,root,%{name}) %{_sysconfdir}/%{name}.cnf
|
||||
%config(noreplace) %attr(640,root,%{name}) %{_sysconfdir}/logrotate.d/%{name}
|
||||
%{_bindir}/*
|
||||
%{_sysconfdir}/init.d/%{name}
|
||||
/usr/share/proxysql/tools/proxysql_galera_checker.sh
|
||||
/usr/share/proxysql/tools/proxysql_galera_writer.pl
|
||||
|
||||
%changelog
|
||||
@ -1,74 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
echo "==> Build environment:"
|
||||
env
|
||||
|
||||
ARCH=$(rpm --eval '%{_arch}')
|
||||
echo "==> '${ARCH}' architecture detected for package"
|
||||
|
||||
DIST=$(source /etc/os-release; echo ${ID%%[-._ ]*}${VERSION%%[-._ ]*})
|
||||
echo "==> '${DIST}' distro detected for package"
|
||||
|
||||
echo -e "==> C compiler: ${CC} -> $(readlink -e $(which ${CC}))\n$(${CC} --version)"
|
||||
echo -e "==> C++ compiler: ${CXX} -> $(readlink -e $(which ${CXX}))\n$(${CXX} --version)"
|
||||
#echo -e "==> linker version:\n$ ${LD} -> $(readlink -e $(which ${LD}))\n$(${LD} --version)"
|
||||
|
||||
echo "==> Cleaning"
|
||||
# Delete package if exists
|
||||
rm -f /opt/proxysql/binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.${ARCH}.rpm || true
|
||||
# Cleanup relic directories from a previously failed build
|
||||
rm -fr /root/.pki /root/rpmbuild/{BUILDROOT,RPMS,SRPMS,BUILD,SOURCES,tmp} /opt/proxysql/proxysql /opt/proxysql/proxysql-${CURVER} || true
|
||||
|
||||
# Clean and build dependancies and source
|
||||
echo "==> Building"
|
||||
git config --system --add safe.directory '/opt/proxysql'
|
||||
cd /opt/proxysql
|
||||
echo "==> ProxySQL '$(git describe --long --abbrev=7)'"
|
||||
export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)
|
||||
echo "==> Setting SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}"
|
||||
find /opt/proxysql -not -path "/opt/proxysql/binaries/*" -exec touch -h --date=@${SOURCE_DATE_EPOCH} {} \;
|
||||
|
||||
if [[ -z ${PROXYSQL_BUILD_TYPE:-} ]] ; then
|
||||
deps_target="build_deps"
|
||||
build_target=""
|
||||
else
|
||||
deps_target="build_deps_$PROXYSQL_BUILD_TYPE"
|
||||
build_target="$PROXYSQL_BUILD_TYPE"
|
||||
fi
|
||||
${MAKE} cleanbuild
|
||||
${MAKE} ${MAKEOPT} "${deps_target}"
|
||||
|
||||
if [[ -z ${build_target} ]] ; then
|
||||
${MAKE} ${MAKEOPT}
|
||||
else
|
||||
${MAKE} ${MAKEOPT} "${build_target}"
|
||||
fi
|
||||
touch /opt/proxysql/src/proxysql
|
||||
|
||||
# Prepare package files and build RPM
|
||||
echo "==> Packaging"
|
||||
mkdir -p proxysql/usr/bin proxysql/etc
|
||||
cp src/proxysql proxysql/usr/bin/
|
||||
cp -a systemd proxysql/etc/
|
||||
cp -a etc/proxysql.cnf proxysql/etc/
|
||||
cp -a etc/logrotate.d proxysql/etc/
|
||||
mkdir -p proxysql/usr/share/proxysql/tools
|
||||
cp -a tools/proxysql_galera_checker.sh tools/proxysql_galera_writer.pl proxysql/usr/share/proxysql/tools
|
||||
mv proxysql "proxysql-${CURVER}"
|
||||
tar czvf "proxysql-${CURVER}.tar.gz" proxysql-${CURVER}
|
||||
mkdir -p /root/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}
|
||||
chown -R root:root /root/rpmbuild/SPECS
|
||||
mv "/opt/proxysql/proxysql-${CURVER}.tar.gz" /root/rpmbuild/SOURCES
|
||||
# build package
|
||||
cd /root/rpmbuild && rpmbuild -ba SPECS/proxysql.spec --define "version ${CURVER}"
|
||||
cp "/root/rpmbuild/RPMS/${ARCH}/proxysql-${CURVER}-1.${ARCH}.rpm" "/opt/proxysql/binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.${ARCH}.rpm"
|
||||
# get SHA1 of the packaged executable
|
||||
mkdir -p /opt/proxysql/pkgroot/tmp
|
||||
pushd /opt/proxysql/pkgroot
|
||||
rpm2cpio /root/rpmbuild/RPMS/${ARCH}/proxysql-${CURVER}-1.${ARCH}.rpm | cpio -iu --to-stdout ./usr/bin/proxysql > tmp/proxysql
|
||||
sha1sum tmp/proxysql | sed 's|tmp/||' | tee tmp/proxysql.sha1
|
||||
cp tmp/proxysql.sha1 ../binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.${ARCH}.id-hash
|
||||
popd
|
||||
# cleanup
|
||||
rm -fr /root/.pki /root/rpmbuild/{BUILDROOT,RPMS,SRPMS,BUILD,SOURCES,tmp} /opt/proxysql/proxysql /opt/proxysql/proxysql-${CURVER} ./pkgroot
|
||||
@ -1,91 +0,0 @@
|
||||
%define __spec_install_post %{nil}
|
||||
%define debug_package %{nil}
|
||||
%define __os_install_post %{_dbpath}/brp-compress
|
||||
|
||||
Summary: A high-performance MySQL proxy
|
||||
Name: proxysql
|
||||
Version: %{version}
|
||||
Release: 1
|
||||
License: GPL+
|
||||
Group: Development/Tools
|
||||
SOURCE0 : %{name}-%{version}.tar.gz
|
||||
URL: https://proxysql.com/
|
||||
Requires: gnutls
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||
|
||||
%description
|
||||
%{summary}
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%pre
|
||||
# Cleanup artifacts
|
||||
if [ -f /var/lib/%{name}/PROXYSQL_UPGRADE ]; then
|
||||
rm -fr /var/lib/%{name}/PROXYSQL_UPGRADE
|
||||
fi
|
||||
|
||||
%build
|
||||
# Packages are pre-built, nothing to do
|
||||
|
||||
%install
|
||||
# Clean buildroot and install files
|
||||
/bin/rm -rf %{buildroot}
|
||||
/bin/mkdir -p %{buildroot}
|
||||
/bin/cp -a * %{buildroot}
|
||||
|
||||
%clean
|
||||
/bin/rm -rf %{buildroot}
|
||||
|
||||
%post
|
||||
# Create relevant user, directories and configuration files
|
||||
if [ ! -d /var/run/%{name} ]; then /bin/mkdir /var/run/%{name} ; fi
|
||||
if [ ! -d /var/lib/%{name} ]; then /bin/mkdir /var/lib/%{name} ; fi
|
||||
if ! id -u %{name} > /dev/null 2>&1; then useradd -r -U -s /bin/false -d /var/lib/%{name} -c "ProxySQL Server" %{name}; fi
|
||||
/bin/chown -R %{name}: /var/lib/%{name} /var/run/%{name}
|
||||
/bin/chown root:%{name} /etc/%{name}.cnf
|
||||
/bin/chmod 640 /etc/%{name}.cnf
|
||||
# Configure systemd appropriately.
|
||||
/bin/systemctl daemon-reload
|
||||
/bin/systemctl enable %{name}.service
|
||||
# Notify that a package update is in progress in order to start service.
|
||||
if [ $1 -eq 2 ]; then /bin/touch /var/lib/%{name}/PROXYSQL_UPGRADE ; fi
|
||||
|
||||
%preun
|
||||
# When uninstalling always try stop the service, ignore failures
|
||||
/bin/systemctl stop %{name} || true
|
||||
|
||||
%postun
|
||||
if [ $1 -eq 0 ]; then
|
||||
# This is a pure uninstall, systemd unit file removed
|
||||
# only daemon-reload is needed.
|
||||
/bin/systemctl daemon-reload
|
||||
else
|
||||
# This is an upgrade, ProxySQL should be started. This
|
||||
# logic works for packages newer than 2.0.7 and ensures
|
||||
# a faster restart time.
|
||||
/bin/systemctl start %{name}.service
|
||||
/bin/rm -fr /var/lib/%{name}/PROXYSQL_UPGRADE
|
||||
fi
|
||||
|
||||
%posttrans
|
||||
if [ -f /var/lib/%{name}/PROXYSQL_UPGRADE ]; then
|
||||
# This is a safeguard to start the service after an update
|
||||
# which supports legacy "preun" / "postun" logic and will
|
||||
# only execute for packages before 2.0.7.
|
||||
/bin/systemctl start %{name}.service
|
||||
/bin/rm -fr /var/lib/%{name}/PROXYSQL_UPGRADE
|
||||
fi
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%config(noreplace) %{_sysconfdir}/%{name}.cnf
|
||||
%attr(640,root,%{name}) %{_sysconfdir}/%{name}.cnf
|
||||
%config(noreplace) %attr(640,root,%{name}) %{_sysconfdir}/logrotate.d/%{name}
|
||||
%{_bindir}/*
|
||||
%{_sysconfdir}/systemd/system/%{name}.service
|
||||
%{_sysconfdir}/systemd/system/%{name}-initial.service
|
||||
/usr/share/proxysql/tools/proxysql_galera_checker.sh
|
||||
/usr/share/proxysql/tools/proxysql_galera_writer.pl
|
||||
|
||||
%changelog
|
||||
Loading…
Reference in new issue