diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml new file mode 100644 index 0000000..d2d85ca --- /dev/null +++ b/.github/workflows/packages.yml @@ -0,0 +1,267 @@ +name: Packages + +on: + push: + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: packages-${{ github.ref }} + cancel-in-progress: true + +env: + RPM_RELEASE: 1 + DEB_RELEASE: 1 + +jobs: + source: + name: Source tarball + runs-on: ubuntu-latest + container: oraclelinux:8 + timeout-minutes: 60 + steps: + - name: Install checkout prerequisites + run: dnf -y install git tar gzip findutils + + - name: Checking out source tree + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + + - name: Mark workspace safe for git + run: git config --global --add safe.directory '*' + + - name: Extract version + id: version + run: | + version=$(sed -n \ + 's/.*app_version{\([0-9]*\)U,[[:space:]]*\([0-9]*\)U,[[:space:]]*\([0-9]*\)U}.*/\1.\2.\3/p' \ + src/app_version.hpp) + test -n "${version}" + echo "version=${version}" >> "${GITHUB_OUTPUT}" + echo "Building version ${version}" + + - name: Create source tarballs + run: | + mkdir -p "${GITHUB_WORKSPACE}/build" + ./packaging/scripts/binlog-server_builder.sh \ + --builddir="${GITHUB_WORKSPACE}/build" \ + --install_deps=0 \ + --get_sources=1 \ + --repo="file://${GITHUB_WORKSPACE}" \ + --branch="$(git rev-parse HEAD)" \ + --version="${{ steps.version.outputs.version }}" \ + --rpm_release="${RPM_RELEASE}" \ + --deb_release="${DEB_RELEASE}" + + - name: Uploading source tarballs + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: source-tarball + path: source_tarball/*.tar.gz + if-no-files-found: error + retention-days: 7 + + srpm: + name: Source RPM + needs: source + runs-on: ubuntu-latest + container: oraclelinux:8 + timeout-minutes: 60 + steps: + - name: Install checkout prerequisites + run: dnf -y install git tar gzip findutils rpm-build + + - name: Checking out source tree + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Downloading source tarballs + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: source-tarball + path: source_tarball + + - name: Building source RPM + run: | + mkdir -p "${GITHUB_WORKSPACE}/build" + ./packaging/scripts/binlog-server_builder.sh \ + --builddir="${GITHUB_WORKSPACE}/build" \ + --install_deps=0 \ + --get_sources=0 \ + --build_src_rpm=1 \ + --rpm_release="${RPM_RELEASE}" + + - name: Uploading source RPM + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: srpm + path: srpm/*.src.rpm + if-no-files-found: error + retention-days: 30 + + sdeb: + name: Source DEB + needs: source + runs-on: ubuntu-latest + container: ubuntu:jammy + timeout-minutes: 60 + env: + DEBIAN_FRONTEND: noninteractive + steps: + - name: Install checkout prerequisites + run: | + apt-get update + apt-get install -y --no-install-recommends \ + git ca-certificates tar gzip xz-utils lsb-release \ + devscripts debhelper dpkg-dev + + - name: Checking out source tree + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Downloading source tarballs + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: source-tarball + path: source_tarball + + - name: Building source DEB + run: | + mkdir -p "${GITHUB_WORKSPACE}/build" + ./packaging/scripts/binlog-server_builder.sh \ + --builddir="${GITHUB_WORKSPACE}/build" \ + --install_deps=1 \ + --get_sources=0 \ + --build_src_deb=1 \ + --deb_release="${DEB_RELEASE}" + + - name: Uploading source DEB + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: source-deb + path: | + source_deb/*.dsc + source_deb/*.tar.gz + source_deb/*.tar.xz + source_deb/*_source.changes + if-no-files-found: error + retention-days: 7 + + rpm: + name: RPM ${{ matrix.target.name }} ${{ matrix.arch.name }} + needs: srpm + runs-on: ${{ matrix.arch.runner }} + container: ${{ matrix.target.image }} + timeout-minutes: 180 + strategy: + fail-fast: false + matrix: + target: + - { image: 'oraclelinux:9', name: 'el9' } + - { image: 'oraclelinux:10', name: 'el10' } + - { image: 'amazonlinux:2023', name: 'amzn2023' } + arch: + - { runner: 'ubuntu-latest', name: 'x86_64' } + - { runner: 'ubuntu-24.04-arm', name: 'aarch64' } + steps: + - name: Install checkout prerequisites + run: dnf -y install git tar gzip findutils + + - name: Checking out source tree + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Downloading source RPM + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: srpm + path: srpm + + - name: Building RPM + run: | + mkdir -p "${GITHUB_WORKSPACE}/build" + ./packaging/scripts/binlog-server_builder.sh \ + --builddir="${GITHUB_WORKSPACE}/build" \ + --install_deps=1 \ + --get_sources=0 \ + --build_rpm=1 \ + --rpm_release="${RPM_RELEASE}" + + - name: Package contents + run: | + for package in rpm/*.rpm; do + echo "=== ${package}" + rpm -qlp "${package}" + rpm -qp --requires "${package}" + done + + - name: Uploading RPM + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: rpm-${{ matrix.target.name }}-${{ matrix.arch.name }} + path: rpm/*.rpm + if-no-files-found: error + retention-days: 30 + + deb: + name: DEB ${{ matrix.target.name }} ${{ matrix.arch.name }} + needs: sdeb + runs-on: ${{ matrix.arch.runner }} + container: ${{ matrix.target.image }} + timeout-minutes: 180 + env: + DEBIAN_FRONTEND: noninteractive + strategy: + fail-fast: false + matrix: + target: + - { image: 'ubuntu:jammy', name: 'jammy' } + - { image: 'ubuntu:noble', name: 'noble' } + - { image: 'ubuntu:resolute', name: 'resolute' } + - { image: 'debian:bookworm', name: 'bookworm' } + - { image: 'debian:trixie', name: 'trixie' } + arch: + - { runner: 'ubuntu-latest', name: 'x86_64' } + - { runner: 'ubuntu-24.04-arm', name: 'aarch64' } + steps: + - name: Install checkout prerequisites + run: | + apt-get update + apt-get install -y --no-install-recommends \ + git ca-certificates tar gzip xz-utils lsb-release + + - name: Checking out source tree + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Downloading source DEB + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: source-deb + path: source_deb + + - name: Building DEB + run: | + mkdir -p "${GITHUB_WORKSPACE}/build" + ./packaging/scripts/binlog-server_builder.sh \ + --builddir="${GITHUB_WORKSPACE}/build" \ + --install_deps=1 \ + --get_sources=0 \ + --build_deb=1 \ + --deb_release="${DEB_RELEASE}" + + - name: Package contents + run: | + for package in deb/*.deb; do + echo "=== ${package}" + dpkg -c "${package}" + dpkg -I "${package}" + done + + - name: Uploading DEB + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: deb-${{ matrix.target.name }}-${{ matrix.arch.name }} + path: deb/*.deb + if-no-files-found: error + retention-days: 30 diff --git a/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json b/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json index 2c43b96..195a219 100644 --- a/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json +++ b/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json @@ -21,7 +21,8 @@ "FORCE_SHARED_CRT": "OFF", "ENABLE_TESTING": "OFF", "AUTORUN_UNIT_TESTS": "OFF", - "BUILD_ONLY": "s3-crt" + "BUILD_ONLY": "s3-crt", + "ENFORCE_SUBMODULE_VERSIONS": "OFF" } }, diff --git a/extra/cmake_presets/boost/CMakePresets.json b/extra/cmake_presets/boost/CMakePresets.json index 32f2838..d985787 100644 --- a/extra/cmake_presets/boost/CMakePresets.json +++ b/extra/cmake_presets/boost/CMakePresets.json @@ -18,7 +18,8 @@ "CMAKE_CXX_EXTENSIONS": "OFF", "CMAKE_CXX_FLAGS_INIT": "$env{ASAN_FLAGS} $env{STDLIB_FLAGS}", "BUILD_SHARED_LIBS": "OFF", - "BUILD_TESTING": "OFF" + "BUILD_TESTING": "OFF", + "BOOST_INCLUDE_LIBRARIES": "algorithm;align;asio;container;date_time;describe;icl;io;json;lexical_cast;math;mp11;mpl;scope;system;test;url;uuid" } }, diff --git a/packaging/debian/compat b/packaging/debian/compat deleted file mode 100644 index f599e28..0000000 --- a/packaging/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/packaging/debian/control b/packaging/debian/control index e65f182..e78c554 100644 --- a/packaging/debian/control +++ b/packaging/debian/control @@ -2,11 +2,21 @@ Source: percona-binlog-server Maintainer: Percona Development Team Section: misc Priority: optional +Build-Depends: debhelper-compat (= 13), + cmake (>= 3.21), + g++, + libcurl4-openssl-dev, + zlib1g-dev, + libssl-dev, + libperconaserverclient24-dev Standards-Version: 4.6.2 - +Rules-Requires-Root: no Package: percona-binlog-server Architecture: any -Depends: percona-server-client +Depends: ${shlibs:Depends}, + ${misc:Depends}, + zlib1g, + percona-server-client Description: Percona Binary Log Server Command line utility that can be considered as an enhanced version of mysqlbinlog. diff --git a/packaging/debian/copyright b/packaging/debian/copyright new file mode 100644 index 0000000..a78bb60 --- /dev/null +++ b/packaging/debian/copyright @@ -0,0 +1,29 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: percona-binlog-server +Upstream-Contact: Percona Development Team +Source: https://github.com/Percona-Lab/percona-binlog-server + +Files: * +Copyright: 2023-2026 Percona and/or its affiliates +License: GPL-2 + +Files: extra/mysql_protocol/* +Copyright: 2015-2026 Oracle and/or its affiliates +License: GPL-2 + +License: GPL-2 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License, version 2.0, for more details. + . + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + . + On Debian systems, the complete text of the GNU General Public License + version 2 can be found in "/usr/share/common-licenses/GPL-2". diff --git a/packaging/debian/rules b/packaging/debian/rules index 55088c6..c286ec9 100755 --- a/packaging/debian/rules +++ b/packaging/debian/rules @@ -2,122 +2,92 @@ export DH_VERBOSE=1 export DEB_BUILD_MAINT_OPTIONS=hardening=+all -export DEB_CMAKE_GENERATOR=Ninja -export DISTRO := $(shell dpkg-vendor --query Vendor) -export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) -export CODENAME := $(shell . /etc/os-release && echo $$VERSION_CODENAME) +include /usr/share/dpkg/architecture.mk -# Versions -export DEB_VERSION=0.3.1 -export BOOST_VERSION=1.90.0 -export AWS_VERSION=1.11.774 +CODENAME := $(shell . /etc/os-release && echo $$VERSION_CODENAME) # CMake presets export BUILD_PRESET_DEBUG=debug_gcc14 export BUILD_PRESET_RELEASE=release_gcc14 -# Source dir SRC_DIR := $(CURDIR) +BOOST_SRC := $(SRC_DIR)/boost +AWS_SRC := $(SRC_DIR)/aws-sdk-cpp +BOOST_INSTALL := $(SRC_DIR)/boost-install-$(BUILD_PRESET_RELEASE) +AWS_INSTALL := $(SRC_DIR)/aws-sdk-cpp-install-$(BUILD_PRESET_RELEASE) + +ifeq ($(CODENAME),bullseye) + CC_BIN := gcc-10 + CXX_BIN := g++-10 +else ifneq (,$(filter $(CODENAME),jammy bookworm forky)) + CC_BIN := gcc-13 + CXX_BIN := g++-13 +else + CC_BIN := gcc-14 + CXX_BIN := g++-14 +endif + +CMAKE_COMMON_ARGS := \ + -DCMAKE_C_COMPILER=$(CC_BIN) \ + -DCMAKE_CXX_COMPILER=$(CXX_BIN) + +CMAKE_APP_ARGS := $(CMAKE_COMMON_ARGS) \ + -DCMAKE_PREFIX_PATH="$(AWS_INSTALL);$(BOOST_INSTALL)" \ + -DMYSQL_LIBRARY=/usr/lib/$(DEB_HOST_MULTIARCH)/libperconaserverclient.so + +NUMJOBS := $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) +ifeq (,$(NUMJOBS)) + NUMJOBS := $(shell nproc) +endif + +DEBUG_BUILD_DIR := $(SRC_DIR)/build-$(BUILD_PRESET_DEBUG) +RELEASE_BUILD_DIR := $(SRC_DIR)/build-$(BUILD_PRESET_RELEASE) + %: - dh $@ --buildsystem=cmake --parallel + dh $@ --buildsystem=cmake override_dh_auto_configure: - # handled manually in build override_dh_auto_build: - set -e; \ - \ - echo "Ubuntu VERSION: $(DISTRO)"; \ - echo "Ubuntu CODENAME: $(CODENAME)"; \ - echo "OS ARCH: $(DEB_HOST_ARCH)"; \ - if [ "$(CODENAME)" = "bullseye" ]; then \ - sed -i 's:gcc-14:gcc-10:' $(SRC_DIR)/extra/cmake_presets/boost/CMakePresets.json; \ - sed -i 's:g++-14:g++-10:' $(SRC_DIR)/extra/cmake_presets/boost/CMakePresets.json; \ - sed -i 's:gcc-14:gcc-10:' $(SRC_DIR)/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json; \ - sed -i 's:g++-14:g++-10:' $(SRC_DIR)/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json; \ - sed -i 's:gcc-14:gcc-10:' $(SRC_DIR)/CMakePresets.json; \ - sed -i 's:g++-14:g++-10:' $(SRC_DIR)/CMakePresets.json; \ - elif [ "$(CODENAME)" = "jammy" ] || [ "$(CODENAME)" = "bookworm" ] || [ "$(CODENAME)" = "forky" ]; then \ - sed -i 's:gcc-14:gcc-13:' $(SRC_DIR)/extra/cmake_presets/boost/CMakePresets.json; \ - sed -i 's:g++-14:g++-13:' $(SRC_DIR)/extra/cmake_presets/boost/CMakePresets.json; \ - sed -i 's:gcc-14:gcc-13:' $(SRC_DIR)/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json; \ - sed -i 's:g++-14:g++-13:' $(SRC_DIR)/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json; \ - sed -i 's:gcc-14:gcc-13:' $(SRC_DIR)/CMakePresets.json; \ - sed -i 's:g++-14:g++-13:' $(SRC_DIR)/CMakePresets.json; \ - fi; \ - if [ "$(DEB_HOST_ARCH)" = "amd64" ]; then \ - sed -i '/"BUILD_TESTING"[[:space:]]*:[[:space:]]*"ON"/i\ "MYSQL_LIBRARY": "/usr/lib/x86_64-linux-gnu/libperconaserverclient.so",' $(SRC_DIR)/CMakePresets.json; \ - elif [ "$(DEB_HOST_ARCH)" = "arm64" ]; then \ - sed -i '/"BUILD_TESTING"[[:space:]]*:[[:space:]]*"ON"/i\ "MYSQL_LIBRARY": "/usr/lib/aarch64-linux-gnu/libperconaserverclient.so",' $(SRC_DIR)/CMakePresets.json; \ - fi; \ - ######################## - # DEBUG BUILD - ######################## - mkdir -p debug; \ - sed -i 's:/boost-install-:/percona-binlog-server-$(DEB_VERSION)/debug/boost-install-:' CMakePresets.json; \ - sed -i 's:/aws-sdk-cpp-install-:/percona-binlog-server-$(DEB_VERSION)/debug/aws-sdk-cpp-install-:' CMakePresets.json; \ - sed -i 's:$${sourceParentDir}/$${sourceDirName}-:$${sourceParentDir}/$${sourceDirName}/$${sourceDirName}-:g' CMakePresets.json - \ - cd debug; \ - git clone --recurse-submodules -b boost-$(BOOST_VERSION) https://github.com/boostorg/boost.git boost; \ - cd boost && git switch -c required_release && cd ..; \ - cp $(SRC_DIR)/extra/cmake_presets/boost/CMakePresets.json boost; \ - cmake ./boost --preset $(BUILD_PRESET_DEBUG); \ - cmake --build ./boost-build-$(BUILD_PRESET_DEBUG); \ - cmake --install ./boost-build-$(BUILD_PRESET_DEBUG); \ - \ - git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git aws-sdk-cpp; \ - cd aws-sdk-cpp && git checkout --recurse-submodules -b required_release $(AWS_VERSION) && cd ..; \ - cp $(SRC_DIR)/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json aws-sdk-cpp; \ - cmake ./aws-sdk-cpp --preset $(BUILD_PRESET_DEBUG); \ - cmake --build ./aws-sdk-cpp-build-$(BUILD_PRESET_DEBUG); \ - cmake --install ./aws-sdk-cpp-build-$(BUILD_PRESET_DEBUG); \ - \ - cd ..; \ - cmake . --preset $(BUILD_PRESET_DEBUG); \ - cmake --build ./percona-binlog-server-$(DEB_VERSION)-build-$(BUILD_PRESET_DEBUG); \ - ./percona-binlog-server-$(DEB_VERSION)-build-$(BUILD_PRESET_DEBUG)/binlog_server version; \ - \ - ######################## - # RELEASE BUILD - ######################## - mkdir -p release; \ - sed -i 's:debug/boost-install-:release/boost-install-:' CMakePresets.json; \ - sed -i 's:debug/aws-sdk-cpp-install-:release/aws-sdk-cpp-install-:' CMakePresets.json; \ - \ - cd release; \ - git clone --recurse-submodules -b boost-$(BOOST_VERSION) https://github.com/boostorg/boost.git boost; \ - cd boost && git switch -c required_release && cd ..; \ - cp $(SRC_DIR)/extra/cmake_presets/boost/CMakePresets.json boost; \ - cmake ./boost --preset $(BUILD_PRESET_RELEASE); \ - cmake --build ./boost-build-$(BUILD_PRESET_RELEASE); \ - cmake --install ./boost-build-$(BUILD_PRESET_RELEASE); \ - \ - git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git aws-sdk-cpp; \ - cd aws-sdk-cpp && git checkout --recurse-submodules -b required_release $(AWS_VERSION) && cd ..; \ - cp $(SRC_DIR)/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json aws-sdk-cpp; \ - cmake ./aws-sdk-cpp --preset $(BUILD_PRESET_RELEASE); \ - cmake --build ./aws-sdk-cpp-build-$(BUILD_PRESET_RELEASE); \ - cmake --install ./aws-sdk-cpp-build-$(BUILD_PRESET_RELEASE); \ - \ - cd ..; \ - cmake . --preset $(BUILD_PRESET_RELEASE); \ - cmake --build ./percona-binlog-server-$(DEB_VERSION)-build-$(BUILD_PRESET_RELEASE) - ./percona-binlog-server-$(DEB_VERSION)-build-$(BUILD_PRESET_RELEASE)/binlog_server version; \ + echo "DISTRO: $(CODENAME) ARCH: $(DEB_HOST_ARCH) COMPILER: $(CXX_BIN) JOBS: $(NUMJOBS)" + cp $(SRC_DIR)/extra/cmake_presets/boost/CMakePresets.json $(BOOST_SRC)/ + cmake $(BOOST_SRC) --preset $(BUILD_PRESET_RELEASE) \ + -B $(SRC_DIR)/boost-build-$(BUILD_PRESET_RELEASE) $(CMAKE_COMMON_ARGS) + cmake --build $(SRC_DIR)/boost-build-$(BUILD_PRESET_RELEASE) --parallel $(NUMJOBS) + cmake --install $(SRC_DIR)/boost-build-$(BUILD_PRESET_RELEASE) + cp $(SRC_DIR)/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json $(AWS_SRC)/ + cmake $(AWS_SRC) --preset $(BUILD_PRESET_RELEASE) \ + -B $(SRC_DIR)/aws-sdk-cpp-build-$(BUILD_PRESET_RELEASE) $(CMAKE_COMMON_ARGS) + cmake --build $(SRC_DIR)/aws-sdk-cpp-build-$(BUILD_PRESET_RELEASE) --parallel $(NUMJOBS) + cmake --install $(SRC_DIR)/aws-sdk-cpp-build-$(BUILD_PRESET_RELEASE) + cmake $(SRC_DIR) --preset $(BUILD_PRESET_DEBUG) -B $(DEBUG_BUILD_DIR) \ + $(CMAKE_APP_ARGS) -DBUILD_TESTING=OFF + cmake --build $(DEBUG_BUILD_DIR) --parallel $(NUMJOBS) + $(DEBUG_BUILD_DIR)/binlog_server version + cmake $(SRC_DIR) --preset $(BUILD_PRESET_RELEASE) -B $(RELEASE_BUILD_DIR) \ + $(CMAKE_APP_ARGS) -DBUILD_TESTING=ON + cmake --build $(RELEASE_BUILD_DIR) --parallel $(NUMJOBS) + $(RELEASE_BUILD_DIR)/binlog_server version + +override_dh_auto_test: +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) + cd $(RELEASE_BUILD_DIR) && ctest --output-on-failure +endif override_dh_auto_install: - install -d debian/percona-binlog-server/usr/bin - install -m 0755 \ - percona-binlog-server-$(DEB_VERSION)-build-$(BUILD_PRESET_DEBUG)/binlog_server \ - debian/percona-binlog-server/usr/bin/binlog_server-debug - install -m 0755 \ - percona-binlog-server-$(DEB_VERSION)-build-$(BUILD_PRESET_RELEASE)/binlog_server \ + install -D -m 0755 $(RELEASE_BUILD_DIR)/binlog_server \ debian/percona-binlog-server/usr/bin/binlog_server - install -d debian/percona-binlog-server/etc/percona-binlog-server - install -m 0640 main_config.json \ + install -D -m 0755 $(DEBUG_BUILD_DIR)/binlog_server \ + debian/percona-binlog-server/usr/bin/binlog_server-debug + install -D -m 0640 main_config.json \ debian/percona-binlog-server/etc/percona-binlog-server/main_config.json -override_dh_auto_test: - # no tests +override_dh_shlibdeps: + dh_shlibdeps -- --ignore-missing-info + +override_dh_auto_clean: + rm -rf $(DEBUG_BUILD_DIR) $(RELEASE_BUILD_DIR) \ + $(SRC_DIR)/boost-build-$(BUILD_PRESET_RELEASE) $(BOOST_INSTALL) \ + $(SRC_DIR)/aws-sdk-cpp-build-$(BUILD_PRESET_RELEASE) $(AWS_INSTALL) diff --git a/packaging/rpm/binlog-server.spec b/packaging/rpm/binlog-server.spec index 08cd99e..a2bad9c 100644 --- a/packaging/rpm/binlog-server.spec +++ b/packaging/rpm/binlog-server.spec @@ -1,12 +1,18 @@ %global percona_binlog_server_version @@PBS_RELEASE@@ %global rpm_release @@RPM_RELEASE@@ -%global BUILD_PRESET_DEBUG debug_gcc14 -%global BUILD_PRESET_RELEASE release_gcc14 -%global BOOST_VERSION 1.90.0 -%global AWS_VERSION 1.11.774 +%global build_preset_debug debug_gcc14 +%global build_preset_release release_gcc14 +%global boost_version 1.90.0 +%global aws_sdk_version 1.11.774 %global release %{rpm_release}%{?dist} %global optflags %(echo %{optflags} | sed 's/-specs=[^ ]*annobin[^ ]*//g') +%global boost_src %{_builddir}/boost-%{boost_version} +%global aws_src %{_builddir}/aws-sdk-cpp-%{aws_sdk_version} +%global app_src %{_builddir}/%{name}-%{version} +%global boost_install %{_builddir}/boost-%{boost_version}-install-%{build_preset_release} +%global aws_install %{_builddir}/aws-sdk-cpp-%{aws_sdk_version}-install-%{build_preset_release} + Name: percona-binlog-server Version: %{percona_binlog_server_version} Release: %{release} @@ -15,123 +21,108 @@ Summary: Percona Binary Log Server License: GPLv2 URL: https://github.com/Percona-Lab/percona-binlog-server Source0: %{name}-%{version}.tar.gz +Source1: boost-%{boost_version}.tar.gz +Source2: aws-sdk-cpp-%{aws_sdk_version}.tar.gz + +BuildRequires: cmake >= 3.21 +BuildRequires: make +BuildRequires: libcurl-devel +BuildRequires: zlib-devel +BuildRequires: percona-server-devel +%if 0%{?amzn} +BuildRequires: gcc14 +BuildRequires: gcc14-c++ +%else +BuildRequires: openssl-devel +%if 0%{?rhel} && 0%{?rhel} < 10 +BuildRequires: gcc-toolset-14-gcc +BuildRequires: gcc-toolset-14-gcc-c++ +BuildRequires: gcc-toolset-14-binutils +%else +BuildRequires: gcc +BuildRequires: gcc-c++ +%endif +%endif %description Percona Binary Log Server is a command-line utility that acts as an enhanced version of mysqlbinlog in --read-from-remote-server mode. It serves as a replication client and can stream binary log events from a remote Oracle MySQL Server / Percona Server for MySQL both to a local filesystem and to a cloud storage (currently AWS S3). The tool is capable of automatically reconnecting to the remote server and resuming operations from the point where it was previously stopped. %prep %setup -q +tar -xf %{SOURCE1} -C %{_builddir} +tar -xf %{SOURCE2} -C %{_builddir} +cp -v extra/cmake_presets/boost/CMakePresets.json %{boost_src}/ +cp -v extra/cmake_presets/aws-sdk-cpp/CMakePresets.json %{aws_src}/ %build -# Build Debug version -mkdir -p debug -( %if 0%{?amzn} - echo "Running Amazon Linux–specific command" - sed -i 's:gcc-14:gcc14-gcc:' ../percona-binlog-server-%{version}/extra/cmake_presets/boost/CMakePresets.json - sed -i 's:g++-14:gcc14-g++:' ../percona-binlog-server-%{version}/extra/cmake_presets/boost/CMakePresets.json - export CFLAGS="${CFLAGS//-Werror*/}" - export CXXFLAGS="${CXXFLAGS//-Werror*/}" - export LDFLAGS="${LDFLAGS//-Werror*/}" - export CFLAGS="${CFLAGS//-specs*annobin*/}" - export CXXFLAGS="${CXXFLAGS//-specs*annobin*/}" - export LDFLAGS="${LDFLAGS//-specs*annobin*/}" - export CFLAGS="${CFLAGS//-specs*redhat-hardened-cc1*/}" - export CXXFLAGS="${CXXFLAGS//-specs*redhat-hardened-cc1*/}" - export LDFLAGS="${LDFLAGS//-specs*redhat-hardened-ld*/}" +echo "Running Amazon Linux-specific command" +export CFLAGS="${CFLAGS//-Werror*/}" +export CXXFLAGS="${CXXFLAGS//-Werror*/}" +export LDFLAGS="${LDFLAGS//-Werror*/}" +export CFLAGS="${CFLAGS//-specs*annobin*/}" +export CXXFLAGS="${CXXFLAGS//-specs*annobin*/}" +export LDFLAGS="${LDFLAGS//-specs*annobin*/}" +export CFLAGS="${CFLAGS//-specs*redhat-hardened-cc1*/}" +export CXXFLAGS="${CXXFLAGS//-specs*redhat-hardened-cc1*/}" +export LDFLAGS="${LDFLAGS//-specs*redhat-hardened-ld*/}" +compiler_args="-DCMAKE_C_COMPILER=gcc14-gcc -DCMAKE_CXX_COMPILER=gcc14-g++" +%else +%if 0%{?rhel} && 0%{?rhel} < 10 +. /opt/rh/gcc-toolset-14/enable %endif - sed -i 's:/boost-install-:/percona-binlog-server-%{version}/debug/boost-install-:' ../percona-binlog-server-%{version}/CMakePresets.json - sed -i 's:/aws-sdk-cpp-install-:/percona-binlog-server-%{version}/debug/aws-sdk-cpp-install-:' ../percona-binlog-server-%{version}/CMakePresets.json - cd debug - # Build Boost Libraries - git clone --recurse-submodules -b boost-%{BOOST_VERSION} --jobs=8 https://github.com/boostorg/boost.git boost - cd boost - git switch -c required_release - cd .. - cp -v ../../percona-binlog-server-%{version}/extra/cmake_presets/boost/CMakePresets.json boost - - cmake ./boost \ - --preset %{BUILD_PRESET_DEBUG} - cmake --build ./boost-build-%{BUILD_PRESET_DEBUG} --parallel - cmake --install ./boost-build-%{BUILD_PRESET_DEBUG} - - # Build AWS SDK for C++ Libraries - git clone --recurse-submodules --jobs=8 https://github.com/aws/aws-sdk-cpp.git aws-sdk-cpp - cd aws-sdk-cpp - git checkout --recurse-submodules -b required_release %{AWS_VERSION} - cd .. - cp -v ../../percona-binlog-server-%{version}/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json aws-sdk-cpp - cmake ./aws-sdk-cpp --preset %{BUILD_PRESET_DEBUG} - cmake --build ./aws-sdk-cpp-build-%{BUILD_PRESET_DEBUG} --parallel - cmake --install ./aws-sdk-cpp-build-%{BUILD_PRESET_DEBUG} - - # Build Percona Binlog Server - cd ../.. - cmake ./percona-binlog-server-%{version} --preset %{BUILD_PRESET_DEBUG} - cmake --build ./percona-binlog-server-%{version}-build-%{BUILD_PRESET_DEBUG} --parallel -) - -# Build Release version -mkdir -p release -( -%if 0%{?amzn} - echo "Running Amazon Linux–specific command" - export CFLAGS="${CFLAGS//-Werror*/}" - export CXXFLAGS="${CXXFLAGS//-Werror*/}" - export LDFLAGS="${LDFLAGS//-Werror*/}" - export CFLAGS="${CFLAGS//-specs*annobin*/}" - export CXXFLAGS="${CXXFLAGS//-specs*annobin*/}" - export LDFLAGS="${LDFLAGS//-specs*annobin*/}" - export CFLAGS="${CFLAGS//-specs*redhat-hardened-cc1*/}" - export CXXFLAGS="${CXXFLAGS//-specs*redhat-hardened-cc1*/}" - export LDFLAGS="${LDFLAGS//-specs*redhat-hardened-ld*/}" +compiler_args="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++" %endif - sed -i 's:debug/boost-install-:release/boost-install-:' ../percona-binlog-server-%{version}/CMakePresets.json - sed -i 's:debug/aws-sdk-cpp-install-:release/aws-sdk-cpp-install-:' ../percona-binlog-server-%{version}/CMakePresets.json - cd release - # Build Boost Libraries - git clone --recurse-submodules -b boost-%{BOOST_VERSION} --jobs=8 https://github.com/boostorg/boost.git boost - cd boost - git switch -c required_release - cd .. - cp -v ../../percona-binlog-server-%{version}/extra/cmake_presets/boost/CMakePresets.json boost - - cmake ./boost \ - --preset %{BUILD_PRESET_RELEASE} - cmake --build ./boost-build-%{BUILD_PRESET_RELEASE} --parallel - cmake --install ./boost-build-%{BUILD_PRESET_RELEASE} - - # Build AWS SDK for C++ Libraries - git clone --recurse-submodules --jobs=8 https://github.com/aws/aws-sdk-cpp.git aws-sdk-cpp - cd aws-sdk-cpp - git checkout --recurse-submodules -b required_release %{AWS_VERSION} - cd .. - cp -v ../../percona-binlog-server-%{version}/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json aws-sdk-cpp - cmake ./aws-sdk-cpp --preset %{BUILD_PRESET_RELEASE} - cmake --build ./aws-sdk-cpp-build-%{BUILD_PRESET_RELEASE} --parallel - cmake --install ./aws-sdk-cpp-build-%{BUILD_PRESET_RELEASE} - - # Build Percona Binlog Server - cd ../.. - cmake ./percona-binlog-server-%{version} --preset %{BUILD_PRESET_RELEASE} - cmake --build ./percona-binlog-server-%{version}-build-%{BUILD_PRESET_RELEASE} --parallel -) -%install -install -d %{buildroot}/usr/bin -install -m 755 ../percona-binlog-server-%{version}-build-%{BUILD_PRESET_DEBUG}/binlog_server %{buildroot}/usr/bin/binlog_server-debug -install -m 755 ../percona-binlog-server-%{version}-build-%{BUILD_PRESET_RELEASE}/binlog_server %{buildroot}/usr/bin/binlog_server -install -m 0755 -d %{buildroot}/%{_sysconfdir} -install -D -m 0644 main_config.json %{buildroot}/%{_sysconfdir}/percona-binlog-server/main_config.json +build_jobs=%{?_smp_build_ncpus}%{!?_smp_build_ncpus:$(nproc)} + +build_dependency() { + local src="$1" + local build_dir="$2" + cmake "${src}" --preset %{build_preset_release} ${compiler_args} + cmake --build "${build_dir}" --parallel "${build_jobs}" + cmake --install "${build_dir}" +} + +build_dependency %{boost_src} \ + %{_builddir}/boost-%{boost_version}-build-%{build_preset_release} +build_dependency %{aws_src} \ + %{_builddir}/aws-sdk-cpp-%{aws_sdk_version}-build-%{build_preset_release} + +for preset in %{build_preset_debug} %{build_preset_release}; do + testing=ON + if [ "${preset}" = "%{build_preset_debug}" ]; then + testing=OFF + fi + cmake %{app_src} --preset "${preset}" ${compiler_args} \ + -DCMAKE_PREFIX_PATH="%{aws_install};%{boost_install}" \ + -DBUILD_TESTING="${testing}" + cmake --build %{_builddir}/%{name}-%{version}-build-"${preset}" \ + --parallel "${build_jobs}" +done + +%check +cd %{_builddir}/%{name}-%{version}-build-%{build_preset_release} +./binlog_server version +ctest --output-on-failure +%install +install -Dpm 0755 \ + %{_builddir}/%{name}-%{version}-build-%{build_preset_release}/binlog_server \ + %{buildroot}%{_bindir}/binlog_server +install -Dpm 0755 \ + %{_builddir}/%{name}-%{version}-build-%{build_preset_debug}/binlog_server \ + %{buildroot}%{_bindir}/binlog_server-debug +install -Dpm 0640 main_config.json \ + %{buildroot}%{_sysconfdir}/%{name}/main_config.json %files %license LICENSE %doc README.md -%config(noreplace) %attr(0640,root,root) /%{_sysconfdir}/percona-binlog-server/main_config.json -/usr/bin/binlog_server-debug -/usr/bin/binlog_server - +%dir %{_sysconfdir}/%{name} +%config(noreplace) %attr(0640,root,root) %{_sysconfdir}/%{name}/main_config.json +%{_bindir}/binlog_server +%{_bindir}/binlog_server-debug %changelog * Thu Jun 11 2026 Yura Sorokin - 0.3.1-1 diff --git a/packaging/scripts/binlog-server_builder.sh b/packaging/scripts/binlog-server_builder.sh old mode 100644 new mode 100755 index 5b37290..7e22548 --- a/packaging/scripts/binlog-server_builder.sh +++ b/packaging/scripts/binlog-server_builder.sh @@ -1,7 +1,38 @@ #!/bin/sh -shell_quote_string() { - echo "$1" | sed -e 's,\([^a-zA-Z0-9/_.=-]\),\\\1,g' +set -eu + +PRODUCT=percona-binlog-server +PROPERTIES=percona-binlog-server.properties +BOOST_UPSTREAM=https://github.com/boostorg/boost.git +AWS_SDK_UPSTREAM=https://github.com/aws/aws-sdk-cpp.git + +CURDIR=$(pwd) +WORKDIR= +REPO=https://github.com/Percona-Lab/percona-binlog-server +BRANCH=main +VERSION=1.0.0 +RPM_RELEASE=1 +DEB_RELEASE=1 +INSTALL=0 +SOURCE=0 +SRPM=0 +SDEB=0 +RPM=0 +DEB=0 + +OS= +OS_NAME= +RHEL= +ARCH= + +msg() { + echo "$*" +} + +die() { + echo "$*" >&2 + exit 1 } usage() { @@ -9,512 +40,484 @@ usage() { Usage: $0 [OPTIONS] The following options may be given : --builddir=DIR Absolute path to the dir where all actions will be performed - --get_sources Source will be downloaded from github - --build_src_rpm If it is set - src rpm will be built - --build_src_deb If it is set - source deb package will be built - --build_rpm If it is set - rpm will be built - --build_deb If it is set - deb will be built - --install_deps Install build dependencies(root privileges are required) - --branch Branch for build - --repo Repo for build - --version Version to build - --rpm_release RPM version( default = 1) - --deb_release DEB version( default = 1) - --help) usage ;; + --get_sources=1 Source will be downloaded from github + --build_src_rpm=1 If it is set - src rpm will be built + --build_src_deb=1 If it is set - source deb package will be built + --build_rpm=1 If it is set - rpm will be built + --build_deb=1 If it is set - deb will be built + --install_deps=1 Install build dependencies (root privileges are required) + --branch=NAME Branch for build + --repo=URL Repo for build + --version=X.Y.Z Version to build + --rpm_release=N RPM release ( default = 1 ) + --deb_release=N DEB release ( default = 1 ) + --help Show this help + Example $0 --builddir=/tmp/percona-binlog-server --get_sources=1 --build_src_rpm=1 --build_rpm=1 EOF exit 1 } -append_arg_to_args() { - args="$args "$(shell_quote_string "$1") -} - parse_arguments() { - pick_args= - if test "$1" = PICK-ARGS-FROM-ARGV; then - pick_args=1 - shift - fi - for arg; do - val=$(echo "$arg" | sed -e 's;^--[^=]*=;;') - case "$arg" in - --builddir=*) WORKDIR="$val" ;; - --build_src_rpm=*) SRPM="$val" ;; - --build_src_deb=*) SDEB="$val" ;; - --build_rpm=*) RPM="$val" ;; - --build_deb=*) DEB="$val" ;; - --get_sources=*) SOURCE="$val" ;; - --branch=*) BRANCH="$val" ;; - --repo=*) REPO="$val" ;; - --version=*) VERSION="$val" ;; - --install_deps=*) INSTALL="$val" ;; - --rpm_release=*) RPM_RELEASE="$val" ;; - --deb_release=*) DEB_RELEASE="$val" ;; + val=${arg#*=} + case "${arg}" in + --builddir=*) WORKDIR="${val}" ;; + --build_src_rpm=*) SRPM="${val}" ;; + --build_src_deb=*) SDEB="${val}" ;; + --build_rpm=*) RPM="${val}" ;; + --build_deb=*) DEB="${val}" ;; + --get_sources=*) SOURCE="${val}" ;; + --install_deps=*) INSTALL="${val}" ;; + --branch=*) BRANCH="${val}" ;; + --repo=*) REPO="${val}" ;; + --version=*) VERSION="${val}" ;; + --rpm_release=*) RPM_RELEASE="${val}" ;; + --deb_release=*) DEB_RELEASE="${val}" ;; --help) usage ;; - *) - if test -n "$pick_args"; then - append_arg_to_args "$arg" - fi - ;; + *) die "Unknown option: ${arg}" ;; esac done } -check_workdir() { - if [ "x$WORKDIR" = "x$CURDIR" ]; then - echo >&2 "Current directory cannot be used for building!" - exit 1 - else - if ! test -d "$WORKDIR"; then - echo >&2 "$WORKDIR is not a directory." - exit 1 +require_workdir() { + [ -n "${WORKDIR}" ] || die "No build directory given, use --builddir=DIR" + [ "${WORKDIR}" != "${CURDIR}" ] || die "Current directory cannot be used for building!" + [ -d "${WORKDIR}" ] || die "${WORKDIR} is not a directory." +} + +find_artifact() { + artifact_dir=$1 + artifact_pattern=$2 + for base in "${WORKDIR}" "${CURDIR}"; do + found=$(find "${base}/${artifact_dir}" -maxdepth 1 -name "${artifact_pattern}" 2>/dev/null | sort | tail -n1) + if [ -n "${found}" ]; then + echo "${found}" + return 0 fi - fi - return + done + return 1 } -get_sources() { - cd "${WORKDIR}" - if [ "${SOURCE}" = 0 ]; then - echo "Sources will not be downloaded" - return 0 - fi - PRODUCT=percona-binlog-server - PRODUCT_FULL=${PRODUCT}-${VERSION} - echo "PRODUCT=${PRODUCT}" >percona-binlog-server.properties - echo "BUILD_NUMBER=${BUILD_NUMBER}" >>percona-binlog-server.properties - echo "BUILD_ID=${BUILD_ID}" >>percona-binlog-server.properties - echo "VERSION=${VERSION}" >>percona-binlog-server.properties - echo "BRANCH=${BRANCH}" >>percona-binlog-server.properties - echo "RPM_RELEASE=${RPM_RELEASE}" >>percona-binlog-server.properties - echo "DEB_RELEASE=${DEB_RELEASE}" >>percona-binlog-server.properties - git clone "$REPO" ${PRODUCT} - retval=$? - if [ $retval != 0 ]; then - echo "There were some issues during repo cloning from github. Please retry one more time" - exit 1 - fi - cd percona-binlog-server - if [ ! -z "$BRANCH" ]; then - git reset --hard - git clean -xdf - git checkout "$BRANCH" - fi - sed -i "s:@@PBS_RELEASE@@:${VERSION}:g" packaging/rpm/binlog-server.spec - sed -i "s:@@RPM_RELEASE@@:${RPM_RELEASE}:g" packaging/rpm/binlog-server.spec - REVISION=$(git rev-parse --short HEAD) - GITCOMMIT=$(git rev-parse HEAD 2>/dev/null) - GITBRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) - echo "VERSION=${VERSION}" >VERSION - echo "REVISION=${REVISION}" >>VERSION - echo "GITCOMMIT=${GITCOMMIT}" >>VERSION - echo "GITBRANCH=${GITBRANCH}" >>VERSION - echo "REVISION=${REVISION}" >>${WORKDIR}/percona-binlog-server.properties - rm -fr rpm - cd ${WORKDIR} - - mv percona-binlog-server ${PRODUCT}-${VERSION} - tar --owner=0 --group=0 -czf ${PRODUCT}-${VERSION}.tar.gz ${PRODUCT}-${VERSION} - echo "UPLOAD=UPLOAD/experimental/BUILDS/${PRODUCT}/${PRODUCT}-${VERSION}/${BRANCH}/${REVISION}/${BUILD_ID}" >>percona-binlog-server.properties - mkdir $WORKDIR/source_tarball - mkdir $CURDIR/source_tarball - cp ${PRODUCT}-${VERSION}.tar.gz $WORKDIR/source_tarball - cp ${PRODUCT}-${VERSION}.tar.gz $CURDIR/source_tarball - cd $CURDIR - rm -rf percona-binlog-server - return +fetch_artifact() { + artifact_dir=$1 + artifact_pattern=$2 + artifact_hint=$3 + artifact_path=$(find_artifact "${artifact_dir}" "${artifact_pattern}") || + die "There is no ${artifact_pattern} in ${artifact_dir}. ${artifact_hint}" + cp "${artifact_path}" "${WORKDIR}/" + basename "${artifact_path}" +} + +publish() { + publish_dir=$1 + shift + mkdir -p "${WORKDIR}/${publish_dir}" "${CURDIR}/${publish_dir}" + cp "$@" "${WORKDIR}/${publish_dir}/" + cp "$@" "${CURDIR}/${publish_dir}/" + ls -la "${WORKDIR}/${publish_dir}" } -get_system() { +append_property() { + echo "$1" >>"${WORKDIR}/${PROPERTIES}" +} + +detect_system() { if [ -f /etc/redhat-release ]; then - GLIBC_VER_TMP="$(rpm glibc -qa --qf %{VERSION})" RHEL=$(rpm --eval %rhel) - ARCH=$(echo $(uname -m) | sed -e 's:i686:i386:g') - OS_NAME="el$RHEL" - OS="rpm" + OS_NAME="el${RHEL}" + OS=rpm elif [ -f /etc/amazon-linux-release ]; then - GLIBC_VER_TMP="$(rpm glibc -qa --qf %{VERSION})" RHEL=$(rpm --eval %amzn) - ARCH=$(echo $(uname -m) | sed -e 's:i686:i386:g') - OS_NAME="amzn$RHEL" - OS="rpm" + OS_NAME="amzn${RHEL}" + OS=rpm else - GLIBC_VER_TMP="$(dpkg-query -W -f='${Version}' libc6 | awk -F'-' '{print $1}')" - ARCH=$(uname -m) - OS_NAME="$( . /etc/os-release && echo $VERSION_CODENAME)" - OS="deb" + OS_NAME=$(. /etc/os-release && echo "${VERSION_CODENAME}") + OS=deb fi - export GLIBC_VER=".glibc${GLIBC_VER_TMP}" - return + ARCH=$(uname -m | sed -e 's:i686:i386:g') } -install_gcc() { - local GCC_VERSION="$1" - if [[ -z "$GCC_VERSION" ]]; then - local GCC_VERSION="14.3.0" - fi - pushd /tmp - wget https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz - tar -zxvf gcc-${GCC_VERSION}.tar.gz - cd gcc-${GCC_VERSION} - ./contrib/download_prerequisites - mkdir build && cd build - ../configure --prefix=/opt/gcc-${GCC_VERSION::2} --disable-multilib - make -j$(nproc) - make install - export PATH=/opt/gcc-${GCC_VERSION::2}/bin:$PATH - export LD_LIBRARY_PATH=/opt/gcc-${GCC_VERSION::2}/lib64:$LD_LIBRARY_PATH - gcc --version - alternatives --install /usr/bin/gcc-${GCC_VERSION::2} gcc-${GCC_VERSION::2} /opt/gcc-${GCC_VERSION::2}/bin/gcc 140 - alternatives --install /usr/bin/g++-${GCC_VERSION::2} g++-${GCC_VERSION::2} /opt/gcc-${GCC_VERSION::2}/bin/g++ 140 - popd +require_os() { + [ "${OS}" = "$1" ] || die "$2 cannot be built on this system" } -install_deps() { - if [ $INSTALL = 0 ]; then - echo "Dependencies will not be installed" - return - fi - if [ ! $(id -u) -eq 0 ]; then - echo "It is not possible to install dependencies. Please run as root" - exit 1 +install_dependencies() { + if [ "${INSTALL}" = 0 ]; then + msg "Dependencies will not be installed" + return 0 fi - CURPLACE=$(pwd) - - if [ "x$OS" = "xrpm" ]; then - yum clean all - if [ "x${RHEL}" != "x2023" ]; then - if [ "x${RHEL}" = "x10" ]; then - dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm - /usr/bin/crb enable - else - yum -y install epel-release - fi - fi - yum -y install git wget - yum -y install rpm-build make rpmdevtools cmake3 libcurl-devel zlib-devel - if [ "${RHEL}" != "10" ]; then - yum -y install rpmlint - fi - yum -y install gcc gcc-c++ - yum -y install libatomic - if [ "x${RHEL}" != "x2023" ]; then - yum -y install curl openssl-devel - if [ "x$RHEL" = "x8" -o "x$RHEL" = "x9" ]; then - yum -y install gcc-toolset-14-gcc gcc-toolset-14-gcc-c++ gcc-toolset-14-binutils - source /opt/rh/gcc-toolset-14/enable - alternatives --install /usr/bin/gcc-14 gcc-14 /opt/rh/gcc-toolset-14/root/usr/bin/gcc 140 - alternatives --install /usr/bin/g++-14 g++-14 /opt/rh/gcc-toolset-14/root/usr/bin/g++ 140 - else - alternatives --install /usr/bin/gcc-14 gcc-14 /usr/bin/gcc 140 - alternatives --install /usr/bin/g++-14 g++-14 /usr/bin/g++ 140 - fi - else - yum -y install gcc14 gcc14-c++ - alternatives --install /usr/bin/gcc-14 gcc-14 /usr/bin/gcc14-gcc 140 - alternatives --install /usr/bin/g++-14 g++-14 /usr/bin/gcc14-g++ 140 - #yum -y install tar gzip bzip2 diffutils - #install_gcc 14.3.0 - fi - yum -y install https://repo.percona.com/yum/percona-release-latest.noarch.rpm - if [ "x$RHEL" = "x8" ]; then - dnf module disable mysql -y - fi - percona-release enable ps-84-lts release - yum -y install percona-server-devel + [ "$(id -u)" -eq 0 ] || die "Dependencies can only be installed as root" + + if [ "${OS}" = rpm ]; then + enable_repos_rpm + install_toolchain_rpm + install_build_deps_rpm else - apt-get update - DEBIAN_FRONTEND=noninteractive apt-get -y install curl lsb-release gnupg2 wget apt-transport-https - wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb && dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb - export DEBIAN_FRONTEND="noninteractive" - export DIST="$(lsb_release -sc)" - percona-release enable pdps-84-lts release - apt-get install -y cmake autotools-dev autoconf automake build-essential devscripts debconf debhelper fakeroot - apt-get install -y git - if [ "${OS_NAME}" == "bullseye" ]; then - apt-get install -y ca-certificates xz-utils - wget https://github.com/Kitware/CMake/releases/download/v3.21.7/cmake-3.21.7-linux-x86_64.tar.gz - tar -xf cmake-3.21.7-linux-x86_64.tar.gz - mv cmake-3.21.7-linux-x86_64 /opt/cmake-3.21.7 - export PATH=/opt/cmake-3.21.7/bin:$PATH - cmake --version - rm -f /usr/bin/cmake - update-alternatives --install /usr/bin/cmake cmake /opt/cmake-3.21.7/bin/cmake 210 - update-alternatives --config cmake - apt-get -y install gcc g++ - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 - update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-10 100 - fi - if [ "${OS_NAME}" == "jammy" ]; then - apt-get -y install software-properties-common - add-apt-repository ppa:ubuntu-toolchain-r/test -y - apt-get -y install gcc-13 g++-13 - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 --slave /usr/bin/g++ g++ /usr/bin/g++-13 - update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-13 100 - elif [ "${OS_NAME}" = "bookworm" ]; then - apt remove -y lintian - echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list.d/testing.list - apt update - apt-get -y install gcc-13 g++-13 - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 --slave /usr/bin/g++ g++ /usr/bin/g++-13 - update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-13 100 - else - apt-get -y install gcc-14 g++-14 - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 --slave /usr/bin/g++ g++ /usr/bin/g++-14 - update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-14 100 - fi - if [ "${OS_NAME}" = "trixie" ]; then - apt install -y libzstd-dev - fi - apt install -y zlib1g-dev libcurl4-openssl-dev libssl-dev - apt install -y libperconaserverclient24-dev + enable_repos_deb + install_build_deps_deb + install_toolchain_deb fi - return } -get_tar() { - TARBALL=$1 - TARFILE=$(basename $(find $WORKDIR/$TARBALL -name 'percona-binlog-server*.tar.gz' | sort | tail -n1)) - if [ -z $TARFILE ]; then - TARFILE=$(basename $(find $CURDIR/$TARBALL -name 'percona-binlog-server*.tar.gz' | sort | tail -n1)) - if [ -z $TARFILE ]; then - echo "There is no $TARBALL for build" - exit 1 +enable_repos_rpm() { + yum clean all + if [ "${RHEL}" != 2023 ]; then + if [ "${RHEL}" = 10 ]; then + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm + /usr/bin/crb enable else - cp $CURDIR/$TARBALL/$TARFILE $WORKDIR/$TARFILE + yum -y install epel-release fi + fi + yum -y install https://repo.percona.com/yum/percona-release-latest.noarch.rpm + if [ "${RHEL}" = 8 ]; then + dnf module disable mysql -y + fi + percona-release enable ps-84-lts release +} + +register_gcc14_rpm() { + alternatives --install /usr/bin/gcc-14 gcc-14 "$1" 140 + alternatives --install /usr/bin/g++-14 g++-14 "$2" 140 +} + +install_toolchain_rpm() { + yum -y install gcc gcc-c++ libatomic + if [ "${RHEL}" = 2023 ]; then + yum -y install gcc14 gcc14-c++ + register_gcc14_rpm /usr/bin/gcc14-gcc /usr/bin/gcc14-g++ + elif [ "${RHEL}" = 8 ] || [ "${RHEL}" = 9 ]; then + yum -y install gcc-toolset-14-gcc gcc-toolset-14-gcc-c++ gcc-toolset-14-binutils + register_gcc14_rpm /opt/rh/gcc-toolset-14/root/usr/bin/gcc \ + /opt/rh/gcc-toolset-14/root/usr/bin/g++ else - cp $WORKDIR/$TARBALL/$TARFILE $WORKDIR/$TARFILE + register_gcc14_rpm /usr/bin/gcc /usr/bin/g++ fi - return } -build_srpm() { - if [ $SRPM = 0 ]; then - echo "SRC RPM will not be created" - return +install_build_deps_rpm() { + yum -y install git wget rpm-build make rpmdevtools cmake libcurl-devel zlib-devel + if [ "${RHEL}" != 10 ]; then + yum -y install rpmlint || true fi - if [ "x$OS" = "xdeb" ]; then - echo "It is not possible to build src rpm here" - exit 1 + if [ "${RHEL}" != 2023 ]; then + yum -y install curl openssl-devel fi - cd $WORKDIR - get_tar "source_tarball" - rm -fr rpmbuild - ls | grep -v tar.gz | xargs rm -rf - TARFILE=$(find . -name 'percona-binlog-server*.tar.gz' | sort | tail -n1) - SRC_DIR=${TARFILE%.tar.gz} - mkdir -vp rpmbuild/{SOURCES,SPECS,BUILD,SRPMS,RPMS} - tar vxzf ${WORKDIR}/${TARFILE} --wildcards '*/packaging' --strip=1 - tar vxzf ${WORKDIR}/${TARFILE} --wildcards '*/VERSION' --strip=1 - source VERSION - # - sed -e "s:@@PBS_RELEASE@@:${VERSION}:g" \ - -e "s:@RPM_@RELEASE@@:${RPM_RELEASE}:g" \ - -e "s:@@REVISION@@:${REVISION}:g" \ - packaging/rpm/binlog-server.spec >rpmbuild/SPECS/binlog-server.spec - mv -fv ${TARFILE} ${WORKDIR}/rpmbuild/SOURCES - rpmbuild -bs --define "_topdir ${WORKDIR}/rpmbuild" --define "version ${VERSION}" --define "dist .generic" rpmbuild/SPECS/binlog-server.spec - mkdir -p ${WORKDIR}/srpm - mkdir -p ${CURDIR}/srpm - cp rpmbuild/SRPMS/*.src.rpm ${CURDIR}/srpm - cp rpmbuild/SRPMS/*.src.rpm ${WORKDIR}/srpm - ls -la ${WORKDIR}/srpm - ls -la ${CURDIR}/srpm - return + yum -y install percona-server-devel } -build_rpm() { - if [ $RPM = 0 ]; then - echo "RPM will not be created" - return - fi - if [ "x$OS" = "xdeb" ]; then - echo "It is not possible to build rpm here" - exit 1 +enable_repos_deb() { + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get -y install --no-install-recommends \ + ca-certificates curl wget gnupg2 gpgv lsb-release apt-transport-https + percona_release_deb="percona-release_latest.$(lsb_release -sc)_all.deb" + wget "https://repo.percona.com/apt/${percona_release_deb}" + dpkg -i "${percona_release_deb}" + rm -f "${percona_release_deb}" + percona-release enable pdps-84-lts release + apt-get update +} + +register_gcc_deb() { + gcc_version=$1 + update-alternatives --install /usr/bin/gcc gcc "/usr/bin/gcc-${gcc_version}" 100 \ + --slave /usr/bin/g++ g++ "/usr/bin/g++-${gcc_version}" + update-alternatives --install /usr/bin/cc cc "/usr/bin/gcc-${gcc_version}" 100 +} + +install_toolchain_deb() { + case "${OS_NAME}" in + bullseye) + install_cmake_bullseye + apt-get -y install gcc-10 g++-10 + register_gcc_deb 10 + ;; + jammy) + apt-get -y install software-properties-common + add-apt-repository ppa:ubuntu-toolchain-r/test -y + apt-get -y install gcc-13 g++-13 + register_gcc_deb 13 + ;; + bookworm) + echo "deb http://deb.debian.org/debian testing main" >/etc/apt/sources.list.d/testing.list + apt-get update + apt-get -y install gcc-13 g++-13 + register_gcc_deb 13 + ;; + *) + apt-get -y install gcc-14 g++-14 + register_gcc_deb 14 + ;; + esac +} + +install_cmake_bullseye() { + cmake_version=3.21.7 + cmake_dir="cmake-${cmake_version}-linux-x86_64" + apt-get -y install ca-certificates xz-utils + wget "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/${cmake_dir}.tar.gz" + tar -xf "${cmake_dir}.tar.gz" + rm -f "${cmake_dir}.tar.gz" + mv "${cmake_dir}" "/opt/cmake-${cmake_version}" + rm -f /usr/bin/cmake + update-alternatives --install /usr/bin/cmake cmake "/opt/cmake-${cmake_version}/bin/cmake" 210 +} + +install_build_deps_deb() { + apt-get -y install cmake build-essential devscripts debconf debhelper fakeroot git \ + zlib1g-dev libcurl4-openssl-dev libssl-dev libperconaserverclient24-dev + if [ "${OS_NAME}" = trixie ]; then + apt-get -y install libzstd-dev fi - ls -la $WORKDIR - ls -la $CURDIR - ls -la $WORKDIR/srpm - ls -la $CURDIR/srpm - SRC_RPM=$(basename $(find $WORKDIR/srpm -name 'percona-binlog-server*.src.rpm' | sort | tail -n1)) - if [ -z $SRC_RPM ]; then - SRC_RPM=$(basename $(find $CURDIR/srpm -name 'percona-binlog-server*.src.rpm' | sort | tail -n1)) - if [ -z $SRC_RPM ]; then - echo "There is no src rpm for build" - echo "You can create it using key --build_src_rpm=1" - exit 1 - else - cp $CURDIR/srpm/$SRC_RPM $WORKDIR - fi - else - cp $WORKDIR/srpm/$SRC_RPM $WORKDIR +} + +fetch_product_sources() { + if [ "${SOURCE}" = 0 ]; then + msg "Sources will not be downloaded" + return 0 fi - cd $WORKDIR - rm -fr rpmbuild - mkdir -vp rpmbuild/{SOURCES,SPECS,BUILD,SRPMS,RPMS} - cp $SRC_RPM rpmbuild/SRPMS/ - - RHEL=$(rpm --eval %rhel) - ARCH=$(echo $(uname -m) | sed -e 's:i686:i386:g') - - echo "RHEL=${RHEL}" >>percona-binlog-server.properties - echo "ARCH=${ARCH}" >>percona-binlog-server.properties - #fi - rpmbuild --define "_topdir ${WORKDIR}/rpmbuild" --define "dist .$OS_NAME" --rebuild rpmbuild/SRPMS/$SRC_RPM - - return_code=$? - if [ $return_code != 0 ]; then - exit $return_code + cd "${WORKDIR}" + + { + echo "PRODUCT=${PRODUCT}" + echo "BUILD_NUMBER=${BUILD_NUMBER:-}" + echo "BUILD_ID=${BUILD_ID:-}" + echo "VERSION=${VERSION}" + echo "BRANCH=${BRANCH}" + echo "RPM_RELEASE=${RPM_RELEASE}" + echo "DEB_RELEASE=${DEB_RELEASE}" + } >"${WORKDIR}/${PROPERTIES}" + + rm -rf "${PRODUCT}" "${PRODUCT}-${VERSION}" + git clone "${REPO}" "${PRODUCT}" || + die "There were some issues during repo cloning from github. Please retry one more time" + cd "${PRODUCT}" + if [ -n "${BRANCH}" ]; then + git reset --hard + git clean -xdf + git checkout "${BRANCH}" fi - mkdir -p ${WORKDIR}/rpm - mkdir -p ${CURDIR}/rpm - cp rpmbuild/RPMS/*/*.rpm ${WORKDIR}/rpm - cp rpmbuild/RPMS/*/*.rpm ${CURDIR}/rpm + + sed -i "s:@@PBS_RELEASE@@:${VERSION}:g" packaging/rpm/binlog-server.spec + sed -i "s:@@RPM_RELEASE@@:${RPM_RELEASE}:g" packaging/rpm/binlog-server.spec + + revision=$(git rev-parse --short HEAD) + { + echo "VERSION=${VERSION}" + echo "REVISION=${revision}" + echo "GITCOMMIT=$(git rev-parse HEAD)" + echo "GITBRANCH=$(git rev-parse --abbrev-ref HEAD)" + } >VERSION + + cd "${WORKDIR}" + append_property "REVISION=${revision}" + append_property "UPLOAD=UPLOAD/experimental/BUILDS/${PRODUCT}/${PRODUCT}-${VERSION}/${BRANCH}/${revision}/${BUILD_ID:-}" + + mv "${PRODUCT}" "${PRODUCT}-${VERSION}" + tar --owner=0 --group=0 -czf "${PRODUCT}-${VERSION}.tar.gz" "${PRODUCT}-${VERSION}" + publish source_tarball "${PRODUCT}-${VERSION}.tar.gz" + + fetch_dependency_sources "${WORKDIR}/${PRODUCT}-${VERSION}/packaging/rpm/binlog-server.spec" + cd "${CURDIR}" } -get_deb_sources(){ - param=$1 - echo $param - FILE=$(basename $(find $WORKDIR/source_deb -iname "percona-binlog-server*.$param" | sort | tail -n1)) - if [ -z $FILE ] - then - FILE=$(basename $(find $CURDIR/source_deb -iname "percona-binlog-server*.$param" | sort | tail -n1)) - if [ -z $FILE ] - then - echo "There is no sources for build" - exit 1 - else - cp $CURDIR/source_deb/$FILE $WORKDIR/ - fi - else - cp $WORKDIR/source_deb/$FILE $WORKDIR/ - fi - return +fetch_dependency_sources() { + spec_file=$1 + + boost_version=$(awk '/^%global boost_version/ {print $3; exit}' "${spec_file}") + aws_version=$(awk '/^%global aws_sdk_version/ {print $3; exit}' "${spec_file}") + [ -n "${boost_version}" ] && [ -n "${aws_version}" ] || + die "Cannot determine Boost / AWS SDK versions from ${spec_file}" + + boost_dir="boost-${boost_version}" + aws_dir="aws-sdk-cpp-${aws_version}" + + cd "${WORKDIR}" + rm -rf "${boost_dir}" "${aws_dir}" + + git clone --depth 1 --recurse-submodules --shallow-submodules \ + -b "boost-${boost_version}" "${BOOST_UPSTREAM}" "${boost_dir}" + git clone --depth 1 --recurse-submodules --shallow-submodules \ + -b "${aws_version}" "${AWS_SDK_UPSTREAM}" "${aws_dir}" + + find "${boost_dir}" "${aws_dir}" -name .git -exec rm -rf {} + 2>/dev/null || true + prune_boost "${boost_dir}" + prune_aws_sdk "${aws_dir}" + + tar --owner=0 --group=0 -czf "${boost_dir}.tar.gz" "${boost_dir}" + tar --owner=0 --group=0 -czf "${aws_dir}.tar.gz" "${aws_dir}" + rm -rf "${boost_dir}" "${aws_dir}" + + publish source_tarball "${boost_dir}.tar.gz" "${aws_dir}.tar.gz" +} + +prune_boost() { + boost_tree=$1 + find "${boost_tree}/libs" -mindepth 2 -maxdepth 3 -type d \ + \( -name test -o -name doc -o -name example -o -name examples \) \ + -exec rm -rf {} + 2>/dev/null || true + rm -rf "${boost_tree}/doc" +} + +prune_aws_sdk() { + aws_tree=$1 + find "${aws_tree}/generated/src" -mindepth 1 -maxdepth 1 -type d \ + ! -name 'aws-cpp-sdk-s3-crt' -exec rm -rf {} + 2>/dev/null || true + rm -rf "${aws_tree}/tests" "${aws_tree}/code-generation" \ + "${aws_tree}/tools/code-generation" "${aws_tree}/docs" + find "${aws_tree}/crt" -mindepth 2 -maxdepth 5 -type d \ + \( -name tests -o -name test -o -name docs \) \ + -exec rm -rf {} + 2>/dev/null || true +} + +fetch_source_tarballs() { + product_tarball=$(fetch_artifact source_tarball "${PRODUCT}-*.tar.gz" \ + "You can create it using key --get_sources=1") + boost_tarball=$(fetch_artifact source_tarball 'boost-*.tar.gz' \ + "You can create it using key --get_sources=1") + aws_tarball=$(fetch_artifact source_tarball 'aws-sdk-cpp-*.tar.gz' \ + "You can create it using key --get_sources=1") } -build_sdeb(){ - if [ $SDEB = 0 ] - then - echo "source deb package will not be created" - return; +build_srpm() { + if [ "${SRPM}" = 0 ]; then + msg "SRC RPM will not be created" + return 0 fi - if [ "x$OS" = "xrpm" ] - then - echo "It is not possible to build source deb here" - exit 1 + require_os rpm "Source RPM" + + cd "${WORKDIR}" + fetch_source_tarballs + rm -rf rpmbuild packaging VERSION + mkdir -vp rpmbuild/SOURCES rpmbuild/SPECS rpmbuild/BUILD rpmbuild/SRPMS rpmbuild/RPMS + + tar xzf "${product_tarball}" --wildcards '*/packaging' --strip=1 + tar xzf "${product_tarball}" --wildcards '*/VERSION' --strip=1 + . ./VERSION + + sed -e "s:@@PBS_RELEASE@@:${VERSION}:g" \ + -e "s:@@RPM_RELEASE@@:${RPM_RELEASE}:g" \ + packaging/rpm/binlog-server.spec >rpmbuild/SPECS/binlog-server.spec + + mv -f "${product_tarball}" "${boost_tarball}" "${aws_tarball}" rpmbuild/SOURCES/ + rpmbuild -bs \ + --define "_topdir ${WORKDIR}/rpmbuild" \ + --define "version ${VERSION}" \ + --define "dist .generic" \ + rpmbuild/SPECS/binlog-server.spec + + publish srpm rpmbuild/SRPMS/*.src.rpm +} + +build_rpm() { + if [ "${RPM}" = 0 ]; then + msg "RPM will not be created" + return 0 fi - rm -rf percona-* - get_tar "source_tarball" - rm -f *.dsc *.orig.tar.gz *.debian.tar.gz *.changes - # - - TARFILE=$(basename $(find . -name 'percona-binlog-server-*.tar.gz' | sort | tail -n1)) - - NAME=$(echo ${TARFILE}| awk -F '-' '{print $1"-"$2"-"$3}') - VERSION=$(echo ${TARFILE}| awk -F '-' '{print $4}' | awk -F . '{print $1"."$2"."$3}') - SHORTVER=$(echo ${VERSION} | awk -F '.' '{print $1"."$2}') - #TMPREL=$(echo ${TARFILE}| awk -F '-' '{print $4}') - #RELEASE=${TMPREL%.tar.gz} - # - NEWTAR=percona-binlog-server_${VERSION}.orig.tar.gz - mv ${TARFILE} ${NEWTAR} - - tar xzf ${NEWTAR} - cd percona-binlog-server-${VERSION} - cp -av packaging/debian . - sed -i "s:export DEB_VERSION=.*:export DEB_VERSION=${VERSION}:g" debian/rules - export DEBEMAIL="support@percona.com" - export DEBFULLNAME="Percona" - dch -D unstable --force-distribution -v "${VERSION}-${DEB_RELEASE}" "Update to new upstream release Percona Binlog Server ${VERSION}-${DEB_RELEASE}" - #copyright-update -d debian/copyright - dpkg-buildpackage -S + require_os rpm "RPM" - cd ${WORKDIR} - ls -la + cd "${WORKDIR}" + src_rpm=$(fetch_artifact srpm "${PRODUCT}-*.src.rpm" \ + "You can create it using key --build_src_rpm=1") - mkdir -p $WORKDIR/source_deb - mkdir -p $CURDIR/source_deb + rm -rf rpmbuild + mkdir -vp rpmbuild/SOURCES rpmbuild/SPECS rpmbuild/BUILD rpmbuild/SRPMS rpmbuild/RPMS + cp "${src_rpm}" rpmbuild/SRPMS/ - cp *.tar.xz* $WORKDIR/source_deb - cp *_source.changes $WORKDIR/source_deb - cp *.dsc $WORKDIR/source_deb - cp *.orig.tar.gz $WORKDIR/source_deb + append_property "RHEL=${RHEL}" + append_property "ARCH=${ARCH}" - cp *.tar.xz* $CURDIR/source_deb - cp *_source.changes $CURDIR/source_deb - cp *.dsc $CURDIR/source_deb - cp *.orig.tar.gz $CURDIR/source_deb + rpmbuild \ + --define "_topdir ${WORKDIR}/rpmbuild" \ + --define "dist .${OS_NAME}" \ + --rebuild "rpmbuild/SRPMS/${src_rpm}" + + publish rpm rpmbuild/RPMS/*/*.rpm } -build_deb(){ - if [ $DEB = 0 ] - then - echo "source deb package will not be created" - return; +build_sdeb() { + if [ "${SDEB}" = 0 ]; then + msg "Source DEB will not be created" + return 0 fi - if [ "x$OS" = "xrmp" ] - then - echo "It is not possible to build source deb here" - exit 1 + require_os deb "Source DEB" + + cd "${WORKDIR}" + rm -rf "${PRODUCT}"-* + rm -f ./*.dsc ./*.orig.tar.gz ./*.orig-*.tar.gz ./*.debian.tar.xz ./*.changes + fetch_source_tarballs + + VERSION=$(echo "${product_tarball}" | sed -e "s:^${PRODUCT}-::" -e 's:\.tar\.gz$::') + [ -n "${VERSION}" ] || die "Cannot determine version from ${product_tarball}" + + mv "${product_tarball}" "${PRODUCT}_${VERSION}.orig.tar.gz" + cp "${boost_tarball}" "${PRODUCT}_${VERSION}.orig-boost.tar.gz" + cp "${aws_tarball}" "${PRODUCT}_${VERSION}.orig-aws-sdk-cpp.tar.gz" + + tar xzf "${PRODUCT}_${VERSION}.orig.tar.gz" + cd "${PRODUCT}-${VERSION}" + for component in boost aws-sdk-cpp; do + mkdir -p "${component}" + tar xzf "../${PRODUCT}_${VERSION}.orig-${component}.tar.gz" \ + -C "${component}" --strip-components=1 + done + + cp -a packaging/debian . + export DEBEMAIL=support@percona.com + export DEBFULLNAME=Percona + dch -D unstable --force-distribution -v "${VERSION}-${DEB_RELEASE}" \ + "Update to new upstream release Percona Binlog Server ${VERSION}-${DEB_RELEASE}" + dpkg-buildpackage -S + + cd "${WORKDIR}" + publish source_deb ./*.dsc ./*.orig.tar.gz ./*.orig-*.tar.gz \ + ./*.debian.tar.xz ./*_source.changes +} + +build_deb() { + if [ "${DEB}" = 0 ]; then + msg "DEB will not be created" + return 0 fi - for file in 'dsc' 'orig.tar.gz' 'changes' 'debian.tar.xz' - do - get_deb_sources $file + require_os deb "DEB" + + cd "${WORKDIR}" + for pattern in '*.dsc' '*.orig.tar.gz' '*.orig-boost.tar.gz' \ + '*.orig-aws-sdk-cpp.tar.gz' '*.debian.tar.xz' '*_source.changes'; do + fetch_artifact source_deb "${PRODUCT}${pattern}" \ + "You can create it using key --build_src_deb=1" >/dev/null done - cd $WORKDIR - #TARFILE=$(basename $(find . -name 'percona-binlog-server*.tar.gz' | sort | tail -n1)) - #tar zxf ${TARFILE} - #rm -fv *.deb - # - export DEBIAN=$(lsb_release -sc) - export ARCH=$(echo $(uname -m) | sed -e 's:i686:i386:g') - # - echo "DEBIAN=${DEBIAN}" >> percona-binlog-server.properties - echo "ARCH=${ARCH}" >> percona-binlog-server.properties - # - DSC=$(basename $(find . -name '*.dsc' | sort | tail -n1)) - # - dpkg-source -x ${DSC} - # - cd ${PRODUCT}-${VERSION} - dch -m -D "${DEBIAN}" --force-distribution -v "${VERSION}-${RELEASE}.${DEBIAN}" 'Update distribution' + + dsc=$(find . -maxdepth 1 -name '*.dsc' | sort | tail -n1) + VERSION=$(awk '/^Version:/ {sub(/-[^-]*$/, "", $2); print $2; exit}' "${dsc}") + [ -n "${VERSION}" ] || die "Cannot determine version from ${dsc}" + + append_property "DEBIAN=${OS_NAME}" + append_property "ARCH=${ARCH}" + + rm -rf "${PRODUCT}-${VERSION}" + dpkg-source -x "${dsc}" + cd "${PRODUCT}-${VERSION}" + dch -m -D "${OS_NAME}" --force-distribution \ + -v "${VERSION}-${DEB_RELEASE}.${OS_NAME}" 'Update distribution' dpkg-buildpackage -rfakeroot -us -uc -b - mkdir -p $CURDIR/deb - mkdir -p $WORKDIR/deb - cp $WORKDIR/*.*deb $WORKDIR/deb - cp $WORKDIR/*.*deb $CURDIR/deb + + cd "${WORKDIR}" + publish deb ./*.*deb } -CURDIR=$(pwd) -VERSION_FILE=$CURDIR/percona-binlog-server.properties -args= -WORKDIR= -SRPM=0 -SDEB=0 -RPM=0 -DEB=0 -SOURCE=0 -TARBALL=0 -OS_NAME= -ARCH= -OS= -INSTALL=0 -VERSION="1.0.0" -RELEASE="1" -REVISION=0 -BRANCH="main" -REPO="https://github.com/Percona-Lab/percona-binlog-server" -PRODUCT=percona-binlog-server -parse_arguments PICK-ARGS-FROM-ARGV "$@" - -check_workdir -get_system -install_deps -get_sources -build_srpm -build_sdeb -build_rpm -build_deb +main() { + parse_arguments "$@" + require_workdir + detect_system + install_dependencies + fetch_product_sources + build_srpm + build_sdeb + build_rpm + build_deb +} + +main "$@"