mirror of https://github.com/sysown/proxysql
Simpler build scripts (#1964)
* feat: Add logrotate script and update log location Write to /var/log/proxysql.log by default, and add a logrotate script which manages this path. Unfortunately, the logrotate script can't use `PROXYSQL FLUSH LOGS;` to tell ProxySQL to rotate file handles*, so we use copytruncate instead. It would be nice if ProxySQL could rotate file handles following a signal in future... * For two reasons: 1. There's no safe / standard way to find admin credentials 2. mysql(1) client may not be installed * fix: Better handle unknown OS service un/install This adds an error message to `make install/uninstall` on "unsupported" distros. The behaviour is the same as before (do nothing, successfully). * fix: Unify standard, debug and clickhouse build scripts The build scripts for all three packaging targets are identical except for their Make targets. Unify them, and pass in a new environment variable PROXYSQL_BUILD_TYPE to define the build type we want. The build scripts are updated to automatically exit if any command fails (`set -e`), so the "&& \" pattern is no longer required. We also `set -u` to protect against any variable being accidentally unset. * fix: Simplify build script logic We don't need the `&& \` pattern any more now that `set -e` is defined at the top of the script. Also apply several defensive fixes suggested by the Shellcheck linter (https://github.com/koalaman/shellcheck). * fix: Add missing directory to cleanup * fix: cosmetics * fix: Don't define config file twicepull/1966/head
parent
ee219f4283
commit
39a0c9c5b9
@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Delete package if exists
|
||||
rm -f /opt/proxysql/binaries/proxysql_${CURVER}-${PKG_RELEASE}_amd64.deb || true &&
|
||||
# Cleanup relic directories from a previously failed build
|
||||
rm -f /opt/proxysql/proxysql.ctl || true &&
|
||||
# Clean and build dependancies and source
|
||||
cd /opt/proxysql && \
|
||||
${MAKE} cleanbuild && \
|
||||
${MAKE} ${MAKEOPT} build_deps_clickhouse && \
|
||||
${MAKE} clickhouse ${MAKEOPT} && \
|
||||
# Prepare package files and build RPM
|
||||
cp /root/ctl/proxysql.ctl /opt/proxysql/proxysql.ctl && \
|
||||
sed -i "s/PKG_VERSION_CURVER/${CURVER}/g" /opt/proxysql/proxysql.ctl && \
|
||||
cp /opt/proxysql/src/proxysql /opt/proxysql/ && \
|
||||
equivs-build proxysql.ctl && \
|
||||
mv /opt/proxysql/proxysql_${CURVER}_amd64.deb ./binaries/proxysql_${CURVER}-${PKG_RELEASE}_amd64.deb && \
|
||||
# Cleanup current build
|
||||
rm -f /opt/proxysql/proxysql.ctl /opt/proxysql/proxysql
|
||||
@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Delete package if exists
|
||||
rm -f /opt/proxysql/binaries/proxysql_${CURVER}-${PKG_RELEASE}_amd64.deb || true &&
|
||||
# Cleanup relic directories from a previously failed build
|
||||
rm -f /opt/proxysql/proxysql.ctl /opt/proxysql/proxysql || true &&
|
||||
# Clean and build dependancies and source
|
||||
cd /opt/proxysql && \
|
||||
${MAKE} cleanbuild && \
|
||||
${MAKE} ${MAKEOPT} build_deps_debug && \
|
||||
${MAKE} ${MAKEOPT} debug && \
|
||||
# Prepare package files and build RPM
|
||||
cp /root/ctl/proxysql.ctl /opt/proxysql/proxysql.ctl && \
|
||||
sed -i "s/PKG_VERSION_CURVER/${CURVER}/g" /opt/proxysql/proxysql.ctl && \
|
||||
cp /opt/proxysql/src/proxysql /opt/proxysql/ && \
|
||||
equivs-build proxysql.ctl && \
|
||||
mv /opt/proxysql/proxysql_${CURVER}_amd64.deb ./binaries/proxysql_${CURVER}-${PKG_RELEASE}_amd64.deb && \
|
||||
# Cleanup current build
|
||||
rm -f /opt/proxysql/proxysql.ctl /opt/proxysql/proxysql
|
||||
@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Delete package if exists
|
||||
rm -f /opt/proxysql/binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.x86_64.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
|
||||
cd /opt/proxysql && \
|
||||
${MAKE} cleanbuild && \
|
||||
${MAKE} ${MAKEOPT} build_deps_clickhouse && \
|
||||
${MAKE} clickhouse ${MAKEOPT} && \
|
||||
# Prepare package files and build RPM
|
||||
mkdir -p proxysql/usr/bin proxysql/etc && \
|
||||
cp src/proxysql proxysql/usr/bin/ && \
|
||||
cp -a etc proxysql && \
|
||||
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} && \
|
||||
mv /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES && \
|
||||
cd /root/rpmbuild && rpmbuild -ba SPECS/proxysql.spec --define "version ${CURVER}" && \
|
||||
mv /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /opt/proxysql/binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.x86_64.rpm && \
|
||||
# Cleanup current build
|
||||
rm -fr /root/.pki /root/rpmbuild/{BUILDROOT,RPMS,SRPMS,BUILD,SOURCES,tmp} /opt/proxysql/proxysql /opt/proxysql/proxysql-${CURVER}
|
||||
@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Delete package if exists
|
||||
rm -f /opt/proxysql/binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.x86_64.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
|
||||
cd /opt/proxysql && \
|
||||
${MAKE} cleanbuild && \
|
||||
${MAKE} ${MAKEOPT} build_deps_debug && \
|
||||
${MAKE} ${MAKEOPT} debug && \
|
||||
# Prepare package files and build RPM
|
||||
mkdir -p proxysql/usr/bin proxysql/etc && \
|
||||
cp src/proxysql proxysql/usr/bin/ && \
|
||||
cp -a etc proxysql && \
|
||||
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} && \
|
||||
mv /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES && \
|
||||
cd /root/rpmbuild && rpmbuild -ba SPECS/proxysql.spec --define "version ${CURVER}" && \
|
||||
mv /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /opt/proxysql/binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.x86_64.rpm && \
|
||||
# Cleanup current build
|
||||
rm -fr /root/.pki /root/rpmbuild/{BUILDROOT,RPMS,SRPMS,BUILD,SOURCES,tmp} /opt/proxysql/proxysql /opt/proxysql/proxysql-${CURVER}
|
||||
@ -1,24 +1,41 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
echo "==> Build environment:"
|
||||
env
|
||||
|
||||
echo "==> Cleaning"
|
||||
# Delete package if exists
|
||||
rm -f /opt/proxysql/binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.x86_64.rpm || true && \
|
||||
rm -f /opt/proxysql/binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.x86_64.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 && \
|
||||
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
|
||||
cd /opt/proxysql && \
|
||||
${MAKE} cleanbuild && \
|
||||
${MAKE} ${MAKEOPT} build_deps && \
|
||||
${MAKE} ${MAKEOPT} && \
|
||||
echo "==> Building"
|
||||
cd /opt/proxysql
|
||||
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"
|
||||
${MAKE} ${MAKEOPT} "${build_target[@]}"
|
||||
|
||||
# Prepare package files and build RPM
|
||||
mkdir -p proxysql/usr/bin proxysql/etc && \
|
||||
cp src/proxysql proxysql/usr/bin/ && \
|
||||
cp -a etc proxysql && \
|
||||
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} && \
|
||||
mv /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES && \
|
||||
cd /root/rpmbuild && rpmbuild -ba SPECS/proxysql.spec --define "version ${CURVER}" && \
|
||||
mv /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /opt/proxysql/binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.x86_64.rpm && \
|
||||
echo "==> Packaging"
|
||||
mkdir -p proxysql/usr/bin proxysql/etc
|
||||
cp src/proxysql proxysql/usr/bin/
|
||||
cp -a etc proxysql
|
||||
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}
|
||||
mv "/opt/proxysql/proxysql-${CURVER}.tar.gz" /root/rpmbuild/SOURCES
|
||||
cd /root/rpmbuild && rpmbuild -ba SPECS/proxysql.spec --define "version ${CURVER}"
|
||||
mv "/root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm" "/opt/proxysql/binaries/proxysql-${CURVER}-1-${PKG_RELEASE}.x86_64.rpm"
|
||||
# Cleanup current build
|
||||
rm -fr /root/.pki /root/rpmbuild/{BUILDROOT,RPMS,SRPMS,BUILD,SOURCES,tmp} /opt/proxysql/proxysql /opt/proxysql/proxysql-${CURVER}
|
||||
rm -fr /root/.pki /root/rpmbuild/{BUILDROOT,RPMS,SRPMS,BUILD,SOURCES,tmp} /opt/proxysql/proxysql "/opt/proxysql/proxysql-${CURVER}"
|
||||
|
||||
Loading…
Reference in new issue