diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c01946875f96c..4b17fbc040159 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,7 @@ name: Build packages (on demand) # This workflow runs when any of the following occur: # - Run manually +# - Invoked from another workflow on: workflow_dispatch: inputs: diff --git a/.github/workflows/build_on_push.yml b/.github/workflows/build_on_push.yml index 2c0fbe4fc3ddb..bc278450d3069 100644 --- a/.github/workflows/build_on_push.yml +++ b/.github/workflows/build_on_push.yml @@ -1,5 +1,7 @@ name: Build packages (on push) +# This workflow runs when any of the following occur: +# - On push to branches named after ci/* on: push: # Sequence of patterns matched against refs/heads diff --git a/.github/workflows/build_single.yml b/.github/workflows/build_single.yml index ec516623f6bb8..669a987bdfd27 100644 --- a/.github/workflows/build_single.yml +++ b/.github/workflows/build_single.yml @@ -1,5 +1,7 @@ name: Build packages (single) +# This workflow runs when any of the following occur: +# - Run manually on: workflow_dispatch: inputs: diff --git a/scripts/README.md b/scripts/README.md index 7cfa2a63387f5..15f6926dfcaab 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -14,10 +14,16 @@ Each section includes instructions to generate packages locally, using Act or Do - [Install Act](https://github.com/nektos/act) +The names of the packages are managed by the `baptizer.sh` script. + ## Build -... -... +For local package generation, use the `build.sh` script. Take a look at the `build.yml` +workflow file for an example of usage. + +```bash +bash scripts/build.sh -a x64 -d tar -n $(bash scripts/baptizer.sh -a x64 -d tar -m) +``` #### Act (GitHub Workflow locally) @@ -32,89 +38,101 @@ act -j build -W .github/workflows/build.yml --artifact-server-path ./artifacts Using the [Docker environment](../docker): ```console -docker exec -it wi-build_$( -### DEB +The assembly process for tarballs consists on: -The script will: +1. Extract. +2. Install plugins. +3. Add Wazuh's configuration files and tools. +4. Compress. -- Extract the deb package using `ar` and `tar` tools. - - > By default, `ar` and `tar` tools expect the package to be in `wazuh-indexer/artifacts/tmp/deb`. The script takes care of creating the required folder structure, copying also the min package and the Makefile. - - Current folder loadout at this stage: - - ``` - artifacts/ - |-- dist - | |-- wazuh-indexer-min_4.9.0_amd64.deb - `-- tmp - `-- deb - |-- Makefile - |-- data.tar.gz - |-- debmake_install.sh - |-- etc - |-- usr - |-- var - `-- wazuh-indexer-min_4.9.0_amd64.deb - ``` - - `usr`, `etc` and `var` folders contain `wazuh-indexer` files, extracted from `wazuh-indexer-min-*.deb`. - `Makefile` and the `debmake_install` are copied over from `wazuh-indexer/distribution/packages/src/deb`. - The `wazuh-indexer-performance-analyzer.service` file is also copied from the same folder. It is a dependency of the SPEC file. - -- Install the plugins using the `opensearch-plugin` CLI tool. -- Set up configuration files. - - > Included in `min-package`. Default files are overwritten. - -- Bundle a DEB file with `debmake` and the `Makefile`. - - > `debmake` and other dependencies can be installed using the provision.sh script. The - > script is invoked by the GitHub Workflow. - - Current folder loadout at this stage: - - ``` - artifacts/ - |-- artifact_name.txt - |-- dist - | |-- wazuh-indexer-min_4.9.0_amd64.deb - | `-- wazuh-indexer_4.9.0_amd64.deb - `-- tmp - `-- deb - |-- Makefile - |-- data.tar.gz - |-- debmake_install.sh - |-- etc - |-- usr - |-- var - |-- wazuh-indexer-min_4.9.0_amd64.deb - `-- debian/ - | -- control - | -- copyright - | -- rules - | -- preinst - | -- prerm - | -- postinst - ``` - -### Running in Act +```console +bash scripts/assemble.sh -a x64 -d tar -r 1 +``` + +### DEB + +For DEB packages, the `assemble.sh` script will perform the following operations: + +1. Extract the deb package using `ar` and `tar` tools. + + > By default, `ar` and `tar` tools expect the package to be in `wazuh-indexer/artifacts/tmp/deb`. + > The script takes care of creating the required folder structure, copying also the min package + > and the Makefile. + + Current folder loadout at this stage: + + ``` + artifacts/ + |-- dist + | |-- wazuh-indexer-min_4.9.0_amd64.deb + `-- tmp + `-- deb + |-- Makefile + |-- data.tar.gz + |-- debmake_install.sh + |-- etc + |-- usr + |-- var + `-- wazuh-indexer-min_4.9.0_amd64.deb + ``` + + `usr`, `etc` and `var` folders contain `wazuh-indexer` files, extracted from `wazuh-indexer-min-*.deb`. + `Makefile` and the `debmake_install` are copied over from `wazuh-indexer/distribution/packages/src/deb`. + The `wazuh-indexer-performance-analyzer.service` file is also copied from the same folder. It is a dependency of the SPEC file. + +2. Install the plugins using the `opensearch-plugin` CLI tool. +3. Set up configuration files. + + > Included in `min-package`. Default files are overwritten. + +4. Bundle a DEB file with `debmake` and the `Makefile`. + + > `debmake` and other dependencies can be installed using the `provision.sh` script. + > The script is invoked by the GitHub Workflow. + + Current folder loadout at this stage: + + ``` + artifacts/ + |-- artifact_name.txt + |-- dist + | |-- wazuh-indexer-min_4.9.0_amd64.deb + | `-- wazuh-indexer_4.9.0_amd64.deb + `-- tmp + `-- deb + |-- Makefile + |-- data.tar.gz + |-- debmake_install.sh + |-- etc + |-- usr + |-- var + |-- wazuh-indexer-min_4.9.0_amd64.deb + `-- debian/ + | -- control + | -- copyright + | -- rules + | -- preinst + | -- prerm + | -- postinst + ``` + +#### Running in Act ```console -act -j assemble -W .github/workflows/build.yml --artifact-server-path ./artifacts --matrix distribution:deb --matrix architecture:x64 --var OPENSEARCH_VERSION=2.11.1 +act -j assemble -W .github/workflows/build.yml --artifact-server-path ./artifacts --matrix distribution:deb --matrix architecture:x64 [Build slim packages/build] 🏁 Job succeeded ``` @@ -128,7 +146,7 @@ Pre-requisites: - Using the [Docker environment](../docker): ```console -docker exec -it wi-assemble_$( By default, `rpm2cpio` and `cpio` tools expect the package to be in `wazuh-indexer/artifacts/tmp/rpm`. The script takes care of creating the required folder structure, copying also the min package and the SPEC file. + > By default, `rpm2cpio` and `cpio` tools expect the package to be in `wazuh-indexer/artifacts/tmp/rpm`.The script takes care of creating the required folder structure, copying also the min package and the SPEC file. - Current folder loadout at this stage: + Current folder loadout at this stage: - ``` - /rpm/$ARCH - /etc - /usr - /var - wazuh-indexer-min-*.rpm - wazuh-indexer.rpm.spec - ``` + ``` + /rpm/$ARCH + /etc + /usr + /var + wazuh-indexer-min-*.rpm + wazuh-indexer.rpm.spec + ``` - `usr`, `etc` and `var` folders contain `wazuh-indexer` files, extracted from `wazuh-indexer-min-*.rpm`. - `wazuh-indexer.rpm.spec` is copied over from `wazuh-indexer/distribution/packages/src/rpm/wazuh-indexer.rpm.spec`. - The `wazuh-indexer-performance-analyzer.service` file is also copied from the same folder. It is a dependency of the SPEC file. + `usr`, `etc` and `var` folders contain `wazuh-indexer` files, extracted from `wazuh-indexer-min-*.rpm`. + `wazuh-indexer.rpm.spec` is copied over from `wazuh-indexer/distribution/packages/src/rpm/wazuh-indexer.rpm.spec`. + The `wazuh-indexer-performance-analyzer.service` file is also copied from the same folder. It is a dependency of the SPEC file. -- Install the plugins using the `opensearch-plugin` CLI tool. -- Set up configuration files. +2. Install the plugins using the `opensearch-plugin` CLI tool. +3. Set up configuration files. - > Included in `min-package`. Default files are overwritten. + > Included in `min-package`. Default files are overwritten. -- Bundle an RPM file with `rpmbuild` and the SPEC file `wazuh-indexer.rpm.spec`. +4. Bundle an RPM file with `rpmbuild` and the SPEC file `wazuh-indexer.rpm.spec`. - - `rpmbuild` is part of the `rpm` OS package. + > `rpmbuild` is part of the `rpm` OS package. - > `rpmbuild` is invoked from `wazuh-indexer/artifacts/tmp/rpm`. It creates the {BUILD,RPMS,SOURCES,SRPMS,SPECS,TMP} folders and applies the rules in the SPEC file. If successful, `rpmbuild` will generate the package in the `RPMS/` folder. The script will copy it to `wazuh-indexer/artifacts/dist` and clean: remove the `tmp\` folder and its contents. + > `rpmbuild` is invoked from `wazuh-indexer/artifacts/tmp/rpm`. It creates the {BUILD,RPMS,SOURCES,SRPMS,SPECS,TMP} folders and applies the rules in the SPEC file. If successful, `rpmbuild` will generate the package in the `RPMS/` folder. The script will copy it to `wazuh-indexer/artifacts/dist` and clean: remove the `tmp\` folder and its contents. - Current folder loadout at this stage: + Current folder loadout at this stage: - ``` - /rpm/$ARCH - /{BUILD,RPMS,SOURCES,SRPMS,SPECS,TMP} - /etc - /usr - /var - wazuh-indexer-min-*.rpm - wazuh-indexer.rpm.spec - ``` + ``` + /rpm/$ARCH + /{BUILD,RPMS,SOURCES,SRPMS,SPECS,TMP} + /etc + /usr + /var + wazuh-indexer-min-*.rpm + wazuh-indexer.rpm.spec + ``` -### Running in Act +#### Running in Act ```console act -j assemble -W .github/workflows/build.yml --artifact-server-path ./artifacts --matrix distribution:rpm --matrix architecture:x64 --var OPENSEARCH_VERSION=2.11.1 @@ -198,45 +216,49 @@ Pre-requisites: - Using the [Docker environment](../docker): ```console -docker exec -it wi-assemble_$(