wazuh / wazuh-agent

Wazuh agent, the Wazuh agent for endpoints.
GNU Affero General Public License v3.0
32 stars 18 forks source link

Linux (RPM) Package Creation #133

Closed vikman90 closed 4 weeks ago

vikman90 commented 2 months ago

Parent Issue:

Description

This issue focuses on creating an RPM package to facilitate the installation of the Wazuh agent on RHEL-based distributions such as RHEL, CentOS, and Fedora. The package should handle all required dependencies and include pre/post-installation scripts to ensure the service is enabled and running upon installation.

Functional Requirements

Acceptance Criteria

mjcr99 commented 1 month ago

Update

(20/09/2024) Researching issue requirements and scope, reviewing documentation regarding common practices to properly create packages. (23/09/2024) Modified generate_package.sh in different points to let it find the new folder's name. Currently modifying rpm SPECS to change compilation and build procedure. Found that SCA policy files references are present in this SPEC file but these files have not been migrated. Pending complete build procedure and implement an installation procedure to locate generated binaries and config files. (24/09/2024) Updated Dockerfile to enable compiling with the new repository, covering different dependencies. The Dockerfile OS version must be updated to Centos 7since using Centos 6 was creating many problems covering dependencies. (25/09/2024) Working on Dockerfile to make the wazuh agent buildable, almost all the dependencies covered inside the Dockerfile have been updated: some of the new/updated RUN steps are the following:

GCC version update to allow building:

RUN wget https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz && \
    tar xzf gcc-13.2.0.tar.gz  && cd gcc-13.2.0/ && \
    ./contrib/download_prerequisites && \
    ./configure --prefix=/usr/local/gcc-13.2.0 --enable-languages=c,c++ \
        --disable-multilib --disable-libsanitizer && \
    make -j$(nproc) && make install -j$(nproc) && \
    ln -fs /usr/local/gcc-13.2.0/bin/g++ /usr/bin/c++ && \
    ln -fs /usr/local/gcc-13.2.0/bin/gcc /usr/bin/cc && cd .. && rm -rf gcc-*

ENV CPLUS_INCLUDE_PATH "/usr/local/gcc-13.2.0/include/c++/13.2.0/"
ENV LD_LIBRARY_PATH "/usr/local/gcc-13.2.0/lib64/"
ENV PATH "/usr/local/gcc-13.2.0/bin:${PATH}"

CMake version update to allow building:

RUN curl -OL https://github.com/Kitware/CMake/releases/download/v3.30.3/cmake-3.30.3.tar.gz && \
    tar -zxf cmake-3.30.3.tar.gz && cd cmake-3.30.3 && \
    ./bootstrap --no-system-curl CC=/usr/local/gcc-13.2.0/bin/gcc \
        CXX=/usr/local/gcc-13.2.0/bin/g++ && \
    make -j$(nproc) && make install && cd / && rm -rf cmake-*

Git version update via sources installation to let vcpkg work:

RUN git clone https://github.com/git/git.git --branch v2.30.2 --single-branch && \
    cd git && make prefix=/usr/local && make install prefix=/usr/local && \
    ln -fs /usr/local/bin/git /usr/bin/git && cd .. && rm -rf git*

And some other have been added.

(26/09/2024) Dockerfile finally able to compile the whole project. Working on SPECS changes to create a first package successfully. (27/09/2024) Working on SPECS changes to create packages. Researching install.sh migration to install the new project structure which improves and makes easier the package creation. (30/09/2024) Successfully built a first package. It's not functional, we need to define new directories structure and complete the creation of the install.sh script to manage correctly the package creation: wazuh-agent_5.0.0-0_x86_64_30fb36de3.zip (01/10/2024) Researching all the available information regarding the new package structure to develop install.sh script. Currently the design contemplates the following folders:

(01/10/2024) Researching all the available information regarding the new package structure to develop install.sh script. Currently the design contemplates the following folders (02/10/2024) Working on the install.sh script. Built different functions to set up installation directories and run the agent build. Still missing some more to install the created binaries and files. (03/10/2024) Created a first version of a functional install.sh in this branch. It's still pending for improves and exhaustive testing. It requires discussing with the team some topics. The service definition files are still not added and some things related to dbs location must be talked. (03/10/2024) Opened PR to add the first install.sh version: https://github.com/wazuh/wazuh-agent/pull/200 (17/10/2024) Updated Specs to work with the new install method developed in:

(18/10/2024) Moved PR to reviewable. Now it's able to generate working packages with minimal functionality.