From 39a0c9c5b94b2c0ee81e0a89709855c46ce5fb8a Mon Sep 17 00:00:00 2001 From: Alex Jurkiewicz Date: Thu, 21 Mar 2019 00:40:09 +1100 Subject: [PATCH] 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 twice --- Makefile | 14 +++- docker-compose.yml | 66 ++++++++++++------- .../ch-entrypoint/entrypoint.bash | 18 ----- .../dbg-entrypoint/entrypoint.bash | 18 ----- .../deb-compliant/entrypoint/entrypoint.bash | 34 ++++++---- .../ch-entrypoint/entrypoint.bash | 24 ------- .../dbg-entrypoint/entrypoint.bash | 24 ------- .../rhel-compliant/entrypoint/entrypoint.bash | 53 ++++++++++----- 8 files changed, 114 insertions(+), 137 deletions(-) delete mode 100755 docker/images/proxysql/deb-compliant/ch-entrypoint/entrypoint.bash delete mode 100755 docker/images/proxysql/deb-compliant/dbg-entrypoint/entrypoint.bash delete mode 100755 docker/images/proxysql/rhel-compliant/ch-entrypoint/entrypoint.bash delete mode 100755 docker/images/proxysql/rhel-compliant/dbg-entrypoint/entrypoint.bash diff --git a/Makefile b/Makefile index e3500a47ce..a5719e9859 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,11 @@ DEBUG=${ALL_DEBUG} export MAKE export CURVER?=2.0.3 export MAKEOPT=-j 4 -DISTRO := $(shell gawk -F= '/^NAME/{print $$2}' /etc/os-release) +ifneq (,$(wildcard /etc/os-release)) + DISTRO := $(shell gawk -F= '/^NAME/{print $$2}' /etc/os-release) +else + DISTRO := unknown +endif ifeq ($(wildcard /usr/lib/systemd/system), /usr/lib/systemd/system) SYSTEMD=1 else @@ -373,6 +377,10 @@ ifeq ($(DISTRO),"Ubuntu") else ifeq ($(DISTRO),"Debian GNU/Linux") update-rc.d proxysql defaults +else +ifeq ($(DISTRO),"Unknown") + $(warning Not sure how to install proxysql service on this OS) +endif endif endif endif @@ -405,6 +413,10 @@ else ifeq ($(DISTRO),"Debian GNU/Linux") if [ -f /etc/init.d/proxysql ]; then rm /etc/init.d/proxysql ; fi update-rc.d proxysql remove +else +ifeq ($(DISTRO),"Unknown") + $(warning Not sure how to uninstall proxysql service on this OS) +endif endif endif endif diff --git a/docker-compose.yml b/docker-compose.yml index 2b63fc5800..faf292ec32 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,13 +17,14 @@ services: image: proxysql/packaging:build-centos5 volumes: - ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/ - - ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-centos5 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash centos67_build: @@ -43,13 +44,14 @@ services: image: proxysql/packaging:build-centos6.7 volumes: - ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/ - - ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-centos67 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash centos7_build: @@ -69,26 +71,28 @@ services: image: proxysql/packaging:build-centos7 volumes: - ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/ - - ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-centos7 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash centos7_ch_build: image: proxysql/packaging:build-centos7 volumes: - ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/ - - ./docker/images/proxysql/rhel-compliant/ch-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=clickhouse-centos7 + - PROXYSQL_BUILD_TYPE=clickhouse command: - /opt/entrypoint/entrypoint.bash fedora24_build: @@ -108,26 +112,28 @@ services: image: proxysql/packaging:build-fedora24 volumes: - ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/ - - ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-fedora24 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash fedora24_ch_build: image: proxysql/packaging:build-fedora24 volumes: - ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/ - - ./docker/images/proxysql/rhel-compliant/ch-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=clickhouse-fedora24 + - PROXYSQL_BUILD_TYPE=clickhouse command: - /opt/entrypoint/entrypoint.bash fedora27_build: @@ -147,26 +153,28 @@ services: image: proxysql/packaging:build-fedora27 volumes: - ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/ - - ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-fedora27 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash fedora27_ch_build: image: proxysql/packaging:build-fedora27 volumes: - ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/ - - ./docker/images/proxysql/rhel-compliant/ch-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=clickhouse-fedora27 + - PROXYSQL_BUILD_TYPE=clickhouse command: - /opt/entrypoint/entrypoint.bash fedora28_build: @@ -186,26 +194,28 @@ services: image: proxysql/packaging:build-fedora28 volumes: - ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/ - - ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-fedora28 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash fedora28_ch_build: image: proxysql/packaging:build-fedora28 volumes: - ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/ - - ./docker/images/proxysql/rhel-compliant/ch-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=clickhouse-fedora28 + - PROXYSQL_BUILD_TYPE=clickhouse command: - /opt/entrypoint/entrypoint.bash debian7_build: @@ -225,13 +235,14 @@ services: image: proxysql/packaging:build-debian7 volumes: - ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-debian7 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash debian8_build: @@ -251,13 +262,14 @@ services: image: proxysql/packaging:build-debian8 volumes: - ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-debian8 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash debian9_build: @@ -277,26 +289,28 @@ services: image: proxysql/packaging:build-debian9 volumes: - ./docker/images/proxysql/deb-compliant/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-debian9 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash debian9_ch_build: image: proxysql/packaging:build-debian9 volumes: - ./docker/images/proxysql/deb-compliant/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/ch-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=clickhouse-debian9 + - PROXYSQL_BUILD_TYPE=clickhouse command: - /opt/entrypoint/entrypoint.bash debian9.4_build: @@ -316,26 +330,28 @@ services: image: proxysql/packaging:build-debian9.4 volumes: - ./docker/images/proxysql/deb-compliant/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-debian9.4 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash debian9.4_ch_build: image: proxysql/packaging:build-debian9.4 volumes: - ./docker/images/proxysql/deb-compliant/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/ch-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=clickhouse-debian9.4 + - PROXYSQL_BUILD_TYPE=clickhouse command: - /opt/entrypoint/entrypoint.bash ubuntu12_build: @@ -355,13 +371,14 @@ services: image: proxysql/packaging:build-ubuntu12 volumes: - ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-ubuntu12 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash ubuntu14_build: @@ -381,13 +398,14 @@ services: image: proxysql/packaging:build-ubuntu14 volumes: - ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-ubuntu14 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash ubuntu16_build: @@ -407,26 +425,28 @@ services: image: proxysql/packaging:build-ubuntu16 volumes: - ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-ubuntu16 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash ubuntu16_ch_build: image: proxysql/packaging:build-ubuntu16 volumes: - ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/ch-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=clickhouse-ubuntu16 + - PROXYSQL_BUILD_TYPE=clickhouse command: - /opt/entrypoint/entrypoint.bash ubuntu18_build: @@ -446,25 +466,27 @@ services: image: proxysql/packaging:build-ubuntu18 volumes: - ./docker/images/proxysql/deb-compliant/bionic-package/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=dbg-ubuntu18 + - PROXYSQL_BUILD_TYPE=debug command: - /opt/entrypoint/entrypoint.bash ubuntu18_ch_build: image: proxysql/packaging:build-ubuntu18 volumes: - ./docker/images/proxysql/deb-compliant/bionic-package/ctl/:/root/ctl/ - - ./docker/images/proxysql/deb-compliant/ch-entrypoint/:/opt/entrypoint/ + - ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/ - ./:/opt/proxysql/ environment: - MAKE - MAKEOPT - CURVER - PKG_RELEASE=clickhouse-ubuntu18 + - PROXYSQL_BUILD_TYPE=clickhouse command: - /opt/entrypoint/entrypoint.bash diff --git a/docker/images/proxysql/deb-compliant/ch-entrypoint/entrypoint.bash b/docker/images/proxysql/deb-compliant/ch-entrypoint/entrypoint.bash deleted file mode 100755 index 548947c3d3..0000000000 --- a/docker/images/proxysql/deb-compliant/ch-entrypoint/entrypoint.bash +++ /dev/null @@ -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 diff --git a/docker/images/proxysql/deb-compliant/dbg-entrypoint/entrypoint.bash b/docker/images/proxysql/deb-compliant/dbg-entrypoint/entrypoint.bash deleted file mode 100755 index 0f2b724bce..0000000000 --- a/docker/images/proxysql/deb-compliant/dbg-entrypoint/entrypoint.bash +++ /dev/null @@ -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 diff --git a/docker/images/proxysql/deb-compliant/entrypoint/entrypoint.bash b/docker/images/proxysql/deb-compliant/entrypoint/entrypoint.bash index a25f2ed549..e37dc1a3aa 100755 --- a/docker/images/proxysql/deb-compliant/entrypoint/entrypoint.bash +++ b/docker/images/proxysql/deb-compliant/entrypoint/entrypoint.bash @@ -1,28 +1,38 @@ #!/bin/bash + +set -eu + # Delete package if exists -rm -f /opt/proxysql/binaries/proxysql_${CURVER}-${PKG_RELEASE}_amd64.deb || true && \ +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 && \ +rm -f /opt/proxysql/proxysql.ctl /opt/proxysql/proxysql || true # Clean and build dependancies and source -cd /opt/proxysql && \ +cd /opt/proxysql # Patch for Ubuntu 12 if [ "`grep Ubuntu /etc/issue | awk '{print $2}' | cut -d. -f1`" == "12" ]; then sed -i -e 's/c++11/c++0x/' lib/Makefile sed -i -e 's/c++11/c++0x/' src/Makefile cd /opt/proxysql/deps/re2/ mv re2.tar.gz /tmp/ - wget -O re2.tar.gz https://github.com/sysown/proxysql/raw/v1.3.9/deps/re2/re2-20140304.tgz + wget -O re2.tar.gz https://github.com/sysown/proxysql/raw/v1.3.9/deps/re2/re2-20140304.tgz cd /opt/proxysql fi -${MAKE} cleanbuild && \ -${MAKE} ${MAKEOPT} build_deps && \ -${MAKE} ${MAKEOPT} && \ +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 -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 && \ +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 # Unpatch Ubuntu 12 if [ "`grep Ubuntu /etc/issue | awk '{print $2}' | cut -d. -f1`" == "12" ]; then diff --git a/docker/images/proxysql/rhel-compliant/ch-entrypoint/entrypoint.bash b/docker/images/proxysql/rhel-compliant/ch-entrypoint/entrypoint.bash deleted file mode 100755 index 60338f1d6e..0000000000 --- a/docker/images/proxysql/rhel-compliant/ch-entrypoint/entrypoint.bash +++ /dev/null @@ -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} diff --git a/docker/images/proxysql/rhel-compliant/dbg-entrypoint/entrypoint.bash b/docker/images/proxysql/rhel-compliant/dbg-entrypoint/entrypoint.bash deleted file mode 100755 index 51ee704706..0000000000 --- a/docker/images/proxysql/rhel-compliant/dbg-entrypoint/entrypoint.bash +++ /dev/null @@ -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} diff --git a/docker/images/proxysql/rhel-compliant/entrypoint/entrypoint.bash b/docker/images/proxysql/rhel-compliant/entrypoint/entrypoint.bash index 59c7669ff9..4b41cfa486 100755 --- a/docker/images/proxysql/rhel-compliant/entrypoint/entrypoint.bash +++ b/docker/images/proxysql/rhel-compliant/entrypoint/entrypoint.bash @@ -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}"