From 2cf8bdaf3cbc03f7622378bec943832d988208c8 Mon Sep 17 00:00:00 2001 From: f-galland Date: Wed, 19 Feb 2025 16:20:30 -0300 Subject: [PATCH 1/5] Manually bring VERSION.json changes from 4.12.0 --- VERSION | 1 - VERSION.json | 4 ++++ build-scripts/REFERENCE.md | 2 +- build-scripts/assemble.sh | 6 +++--- build-scripts/baptizer.sh | 2 +- build-scripts/build-and-push-docker-image.sh | 2 +- build-scripts/build.sh | 4 ++-- build-scripts/builder/Dockerfile | 1 + build-scripts/builder/builder.sh | 2 +- build-scripts/builder/entrypoint.sh | 2 +- build-scripts/check-version.sh | 8 ++++---- build-scripts/docker/Dockerfile | 6 +++--- build-scripts/product_version.sh | 15 +++++++++++++++ build-scripts/provision.sh | 2 +- distribution/archives/build.gradle | 7 ++++++- distribution/build.gradle | 2 +- distribution/packages/build.gradle | 7 ++++++- distribution/packages/src/deb/debmake_install.sh | 2 +- .../packages/src/rpm/wazuh-indexer.rpm.spec | 4 ++-- 19 files changed, 54 insertions(+), 25 deletions(-) delete mode 100644 VERSION create mode 100644 VERSION.json create mode 100644 build-scripts/product_version.sh diff --git a/VERSION b/VERSION deleted file mode 100644 index 28cbf7c0aae3b..0000000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -5.0.0 \ No newline at end of file diff --git a/VERSION.json b/VERSION.json new file mode 100644 index 0000000000000..fccca3fb90998 --- /dev/null +++ b/VERSION.json @@ -0,0 +1,4 @@ +{ + "version": "5.0.0.", + "stage": "alpha0" +} diff --git a/build-scripts/REFERENCE.md b/build-scripts/REFERENCE.md index e354f8198e2b2..cf7f7773fb745 100644 --- a/build-scripts/REFERENCE.md +++ b/build-scripts/REFERENCE.md @@ -72,7 +72,7 @@ Arguments: -p PLATFORM [Optional] Platform, default is 'uname -s'. -a ARCHITECTURE [Optional] Build architecture, default is 'uname -m'. -d DISTRIBUTION [Optional] Distribution, default is 'tar'. --b BRANCH [Optional] Branch from wazuh/wazuh to download the index template from, default is ' Date: Wed, 19 Feb 2025 16:23:59 -0300 Subject: [PATCH 2/5] Make all scripts use product_version.sh --- build-scripts/REFERENCE.md | 2 +- build-scripts/assemble.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build-scripts/REFERENCE.md b/build-scripts/REFERENCE.md index cf7f7773fb745..e1a5e638110c3 100644 --- a/build-scripts/REFERENCE.md +++ b/build-scripts/REFERENCE.md @@ -72,7 +72,7 @@ Arguments: -p PLATFORM [Optional] Platform, default is 'uname -s'. -a ARCHITECTURE [Optional] Build architecture, default is 'uname -m'. -d DISTRIBUTION [Optional] Distribution, default is 'tar'. --b BRANCH [Optional] Branch from wazuh/wazuh to download the index template from, default is 'jq -r .version Date: Wed, 19 Feb 2025 17:01:31 -0300 Subject: [PATCH 3/5] Make assemble.sh get version before switching to tmp folder --- build-scripts/assemble.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/build-scripts/assemble.sh b/build-scripts/assemble.sh index e2f228e128a76..85a9f07476db3 100644 --- a/build-scripts/assemble.sh +++ b/build-scripts/assemble.sh @@ -272,6 +272,9 @@ function clean() { # Tar assemble # ==== function assemble_tar() { + local version + version="$(bash build-scripts/product_version.sh)" + cd "${TMP_DIR}" # Extract @@ -280,9 +283,6 @@ function assemble_tar() { local decompressed_tar_dir decompressed_tar_dir=$(ls -d wazuh-indexer-*/) - local version - version="$(bash build-scripts/product_version.sh)" - PATH_CONF="${decompressed_tar_dir}/config" PATH_BIN="${decompressed_tar_dir}/bin" PATH_PLUGINS="${decompressed_tar_dir}/plugins" @@ -309,6 +309,9 @@ function assemble_tar() { # RPM assemble # ==== function assemble_rpm() { + local version + version="$(bash build-scripts/product_version.sh)" + # Copy spec cp "distribution/packages/src/rpm/wazuh-indexer.rpm.spec" "${TMP_DIR}" # Copy performance analyzer service file @@ -324,9 +327,6 @@ function assemble_rpm() { echo "Extract ${ARTIFACT_BUILD_NAME} archive" rpm2cpio "${ARTIFACT_BUILD_NAME}" | cpio -imdv - local version - version="$(bash build-scripts/product_version.sh)" - # Install plugins install_plugins "${version}" fix_log_rotation ${PATH_CONF} @@ -360,6 +360,9 @@ function assemble_rpm() { # DEB assemble # ==== function assemble_deb() { + local version + version="$(bash build-scripts/product_version.sh)" + # Copy spec cp "distribution/packages/src/deb/Makefile" "${TMP_DIR}" cp "distribution/packages/src/deb/debmake_install.sh" "${TMP_DIR}" @@ -379,9 +382,6 @@ function assemble_deb() { ar xf "${ARTIFACT_BUILD_NAME}" data.tar.gz tar zvxf data.tar.gz - local version - version="$(bash build-scripts/product_version.sh)" - # Install plugins install_plugins "${version}" fix_log_rotation ${PATH_CONF} From 3de8ba7fb77c6ec4aff22ad107d0b94d56002a0b Mon Sep 17 00:00:00 2001 From: f-galland Date: Wed, 19 Feb 2025 17:04:49 -0300 Subject: [PATCH 4/5] Use global version in assemble.sh --- build-scripts/assemble.sh | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/build-scripts/assemble.sh b/build-scripts/assemble.sh index 85a9f07476db3..b44541cedb178 100644 --- a/build-scripts/assemble.sh +++ b/build-scripts/assemble.sh @@ -272,9 +272,6 @@ function clean() { # Tar assemble # ==== function assemble_tar() { - local version - version="$(bash build-scripts/product_version.sh)" - cd "${TMP_DIR}" # Extract @@ -288,16 +285,16 @@ function assemble_tar() { PATH_PLUGINS="${decompressed_tar_dir}/plugins" # Install plugins - install_plugins "${version}" + install_plugins "${VERSION}" fix_log_rotation "${PATH_CONF}" add_demo_certs_installer # Swap configuration files add_configuration_files remove_unneeded_files - add_wazuh_tools "${version}" + add_wazuh_tools "${VERSION}" # Pack - archive_name="wazuh-indexer-${version}" + archive_name="wazuh-indexer-${VERSION}" tar -cvf "${archive_name}-${SUFFIX}.${EXT}" "${archive_name}" cd ../../.. cp "${TMP_DIR}/${archive_name}-${SUFFIX}.${EXT}" "${OUTPUT}/dist/$ARTIFACT_PACKAGE_NAME" @@ -309,9 +306,6 @@ function assemble_tar() { # RPM assemble # ==== function assemble_rpm() { - local version - version="$(bash build-scripts/product_version.sh)" - # Copy spec cp "distribution/packages/src/rpm/wazuh-indexer.rpm.spec" "${TMP_DIR}" # Copy performance analyzer service file @@ -328,14 +322,14 @@ function assemble_rpm() { rpm2cpio "${ARTIFACT_BUILD_NAME}" | cpio -imdv # Install plugins - install_plugins "${version}" + install_plugins "${VERSION}" fix_log_rotation ${PATH_CONF} enable_performance_analyzer_rca ${src_path} add_demo_certs_installer # Swap configuration files add_configuration_files remove_unneeded_files - add_wazuh_tools "${version}" + add_wazuh_tools "${VERSION}" # Generate final package local topdir @@ -343,14 +337,14 @@ function assemble_rpm() { topdir=$(pwd) rpmbuild --bb \ --define "_topdir ${topdir}" \ - --define "_version ${version}" \ + --define "_version ${VERSION}" \ --define "_architecture ${SUFFIX}" \ --define "_release ${REVISION}" \ ${spec_file} # Move to the root folder, copy the package and clean. cd ../../.. - package_name="wazuh-indexer-${version}-${REVISION}.${SUFFIX}.${EXT}" + package_name="wazuh-indexer-${VERSION}-${REVISION}.${SUFFIX}.${EXT}" cp "${TMP_DIR}/RPMS/${SUFFIX}/${package_name}" "${OUTPUT}/dist/$ARTIFACT_PACKAGE_NAME" clean @@ -360,9 +354,6 @@ function assemble_rpm() { # DEB assemble # ==== function assemble_deb() { - local version - version="$(bash build-scripts/product_version.sh)" - # Copy spec cp "distribution/packages/src/deb/Makefile" "${TMP_DIR}" cp "distribution/packages/src/deb/debmake_install.sh" "${TMP_DIR}" @@ -383,14 +374,14 @@ function assemble_deb() { tar zvxf data.tar.gz # Install plugins - install_plugins "${version}" + install_plugins "${VERSION}" fix_log_rotation ${PATH_CONF} enable_performance_analyzer_rca ${src_path} add_demo_certs_installer # Swap configuration files add_configuration_files remove_unneeded_files - add_wazuh_tools "${version}" + add_wazuh_tools "${VERSION}" # Configure debmake to only generate binaries echo 'DEBUILD_DPKG_BUILDPACKAGE_OPTS="-us -uc -ui -b"' >~/.devscripts @@ -405,7 +396,7 @@ function assemble_deb() { --package wazuh-indexer \ --native \ --revision "${REVISION}" \ - --upstreamversion "${version}-${REVISION}" + --upstreamversion "${VERSION}-${REVISION}" # Move to the root folder, copy the package and clean. cd ../../.. From 568343003af35affc95decd7a58077d55d9d8e8b Mon Sep 17 00:00:00 2001 From: f-galland Date: Thu, 20 Feb 2025 11:13:40 -0300 Subject: [PATCH 5/5] Make opensearch and wazuh versions global variables in assemble.sh --- build-scripts/assemble.sh | 27 ++++++++++++++------------- build-scripts/build.sh | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/build-scripts/assemble.sh b/build-scripts/assemble.sh index b44541cedb178..fc2802fa85176 100644 --- a/build-scripts/assemble.sh +++ b/build-scripts/assemble.sh @@ -236,9 +236,9 @@ function install_plugins() { echo "Installing OpenSearch plugins" local maven_repo_local="$HOME/.m2" for plugin in "${plugins[@]}"; do - local plugin_from_maven="org.opensearch.plugin:${plugin}:${VERSION}.0" + local plugin_from_maven="org.opensearch.plugin:${plugin}:${UPSTREAM_VERSION}.0" mvn -Dmaven.repo.local="${maven_repo_local}" org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=https://repo1.maven.org/maven2 -Dartifact="${plugin_from_maven}:zip" - OPENSEARCH_PATH_CONF=$PATH_CONF "${PATH_BIN}/opensearch-plugin" install --batch --verbose "file:${maven_repo_local}/org/opensearch/plugin/${plugin}/${VERSION}.0/${plugin}-${VERSION}.0.zip" + OPENSEARCH_PATH_CONF=$PATH_CONF "${PATH_BIN}/opensearch-plugin" install --batch --verbose "file:${maven_repo_local}/org/opensearch/plugin/${plugin}/${UPSTREAM_VERSION}.0/${plugin}-${UPSTREAM_VERSION}.0.zip" done echo "Installing Wazuh plugins" @@ -285,16 +285,16 @@ function assemble_tar() { PATH_PLUGINS="${decompressed_tar_dir}/plugins" # Install plugins - install_plugins "${VERSION}" + install_plugins "${PRODUCT_VERSION}" fix_log_rotation "${PATH_CONF}" add_demo_certs_installer # Swap configuration files add_configuration_files remove_unneeded_files - add_wazuh_tools "${VERSION}" + add_wazuh_tools "${PRODUCT_VERSION}" # Pack - archive_name="wazuh-indexer-${VERSION}" + archive_name="wazuh-indexer-${PRODUCT_VERSION}" tar -cvf "${archive_name}-${SUFFIX}.${EXT}" "${archive_name}" cd ../../.. cp "${TMP_DIR}/${archive_name}-${SUFFIX}.${EXT}" "${OUTPUT}/dist/$ARTIFACT_PACKAGE_NAME" @@ -322,14 +322,14 @@ function assemble_rpm() { rpm2cpio "${ARTIFACT_BUILD_NAME}" | cpio -imdv # Install plugins - install_plugins "${VERSION}" + install_plugins "${PRODUCT_VERSION}" fix_log_rotation ${PATH_CONF} enable_performance_analyzer_rca ${src_path} add_demo_certs_installer # Swap configuration files add_configuration_files remove_unneeded_files - add_wazuh_tools "${VERSION}" + add_wazuh_tools "${PRODUCT_VERSION}" # Generate final package local topdir @@ -337,14 +337,14 @@ function assemble_rpm() { topdir=$(pwd) rpmbuild --bb \ --define "_topdir ${topdir}" \ - --define "_version ${VERSION}" \ + --define "_version ${PRODUCT_VERSION}" \ --define "_architecture ${SUFFIX}" \ --define "_release ${REVISION}" \ ${spec_file} # Move to the root folder, copy the package and clean. cd ../../.. - package_name="wazuh-indexer-${VERSION}-${REVISION}.${SUFFIX}.${EXT}" + package_name="wazuh-indexer-${PRODUCT_VERSION}-${REVISION}.${SUFFIX}.${EXT}" cp "${TMP_DIR}/RPMS/${SUFFIX}/${package_name}" "${OUTPUT}/dist/$ARTIFACT_PACKAGE_NAME" clean @@ -374,14 +374,14 @@ function assemble_deb() { tar zvxf data.tar.gz # Install plugins - install_plugins "${VERSION}" + install_plugins "${PRODUCT_VERSION}" fix_log_rotation ${PATH_CONF} enable_performance_analyzer_rca ${src_path} add_demo_certs_installer # Swap configuration files add_configuration_files remove_unneeded_files - add_wazuh_tools "${VERSION}" + add_wazuh_tools "${PRODUCT_VERSION}" # Configure debmake to only generate binaries echo 'DEBUILD_DPKG_BUILDPACKAGE_OPTS="-us -uc -ui -b"' >~/.devscripts @@ -396,7 +396,7 @@ function assemble_deb() { --package wazuh-indexer \ --native \ --revision "${REVISION}" \ - --upstreamversion "${VERSION}-${REVISION}" + --upstreamversion "${PRODUCT_VERSION}-${REVISION}" # Move to the root folder, copy the package and clean. cd ../../.. @@ -415,7 +415,8 @@ function main() { echo "Assembling wazuh-indexer for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE" - VERSION=$(bash build-scripts/upstream-version.sh) + UPSTREAM_VERSION=$(bash build-scripts/upstream-version.sh) + PRODUCT_VERSION=$(bash build-scripts/product_version.sh) ARTIFACT_BUILD_NAME=$(ls "${OUTPUT}/dist/" | grep "wazuh-indexer-min.*$SUFFIX.*\.$EXT") ARTIFACT_PACKAGE_NAME=${ARTIFACT_BUILD_NAME/-min/} diff --git a/build-scripts/build.sh b/build-scripts/build.sh index 3a5218df773de..f39af163601b4 100644 --- a/build-scripts/build.sh +++ b/build-scripts/build.sh @@ -79,7 +79,7 @@ function parse_args() { [ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}') [ -z "$ARCHITECTURE" ] && ARCHITECTURE=$(uname -m) [ -z "$DISTRIBUTION" ] && DISTRIBUTION="tar" - [ -z "$BRANCH" ] && BRANCH=$(bash build-scripts/product_name.sh) + [ -z "$BRANCH" ] && BRANCH=$(bash build-scripts/product_version.sh) case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in linux-tar-x64 | darwin-tar-x64)