Merge pull request #836 from wazuh/fix/351-unzip-macos-binaries

Fix macOS package extraction error due to absolute build paths
This commit is contained in:
Vikman Fernandez-Castro 2025-06-18 08:06:59 +02:00 committed by GitHub
commit 927df483db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 26 deletions

View File

@ -22,10 +22,12 @@ runs:
- name: Build repository
shell: bash
run: |
mkdir -p src/build && cd src/build && cmake .. && make -j $(sysctl -n hw.ncpu)
sudo rm -rf _deps vcpkg_installed
cd ../..
zip -r wazuh-agent-binaries-${{ inputs.architecture }}.zip etc/config/wazuh-agent.yml src/build
cmake -B build src
cmake --build build -j $(sysctl -n hw.ncpu)
cmake --install build --prefix install
sudo rm -rf build/_deps build/vcpkg_installed
zip -r wazuh-agent-binaries-${{ inputs.architecture }}.zip .
- name: Upload wazuh-agent-binaries.zip
uses: actions/upload-artifact@v4

View File

@ -161,9 +161,7 @@ function build_package() {
# Build binaries
${WAZUH_PACKAGES_PATH}/package_files/build.sh "${VERBOSE}" "${PACKAGED_DIRECTORY}" "${WAZUH_PATH}" ${JOBS} ${VCPKG_KEY}
mkdir -p ${PACKAGED_DIRECTORY}/Library/LaunchDaemons
install /Library/LaunchDaemons/com.wazuh.agent.plist ${PACKAGED_DIRECTORY}/Library/LaunchDaemons/com.wazuh.agent.plist
sed -i "" "s|${PACKAGED_DIRECTORY}/|/|g" ${PACKAGED_DIRECTORY}/Library/LaunchDaemons/com.wazuh.agent.plist
sed -i "" "s|install/|/|g" ${PACKAGED_DIRECTORY}/Library/LaunchDaemons/com.wazuh.agent.plist
@ -464,7 +462,7 @@ function main() {
build_package
if [ "${NOTARIZE}" = "yes" ]; then
notarization_path="${DESTINATION}/${pkg_name}.pkg"
if [ -z "${notarization_path}" ]; then

View File

@ -13,7 +13,6 @@ DESTINATION_PATH=$2
WAZUH_PATH=$3
BUILD_JOBS=$4
VCPKG_KEY=$5
SOURCES_DIR=${WAZUH_PATH}/src
set_vcpkg_remote_binary_cache(){
local vcpkg_token="$1"
@ -52,26 +51,22 @@ function build() {
set -ex
fi
if [ ! -d "$SOURCES_DIR/build" ]; then
if [ ! -z "${VCPKG_KEY}" ]; then
set_vcpkg_remote_binary_cache $VCPKG_KEY
if [ ! -d "${WAZUH_PATH}/install" ]; then
if [ ! -d "$WAZUH_PATH/build" ]; then
if [ ! -z "${VCPKG_KEY}" ]; then
set_vcpkg_remote_binary_cache $VCPKG_KEY
fi
cmake -S $WAZUH_PATH/src -B $WAZUH_PATH/build -DVCPKG_INSTALL_OPTIONS="--debug"
cmake --build $WAZUH_PATH/build --parallel $BUILD_JOBS
fi
cmake -S $SOURCES_DIR -B $SOURCES_DIR/build -DVCPKG_INSTALL_OPTIONS="--debug"
cmake --build $SOURCES_DIR/build --parallel $BUILD_JOBS
echo "Installing sources"
cmake --install $WAZUH_PATH/build --prefix $WAZUH_PATH/install
fi
EXECUTABLE_FILES=$(find "${SOURCES_DIR}" -maxdepth 1 -type f ! -name "*.py" -exec file {} + | grep 'executable' | cut -d: -f1)
EXECUTABLE_FILES+=" $(find "${SOURCES_DIR}" -type f ! -name "*.py" ! -path "${SOURCES_DIR}/external/*" ! -path "${SOURCES_DIR}/symbols/*" -name "*.dylib" -print 2>/dev/null)"
for var in $EXECUTABLE_FILES; do
filename=$(basename "$var")
dsymutil -o "${SOURCES_DIR}/symbols/${filename}.dSYM" "$var" 2>/dev/null && strip -S "$var"
done
echo "Installing sources"
cmake --install $SOURCES_DIR/build --prefix $DESTINATION_PATH
cp -r "${WAZUH_PATH}/install/." "${DESTINATION_PATH}/"
}
build

View File

@ -16,7 +16,7 @@ function(set_common_settings)
set(PARENT_DIR "Library/Application Support/Wazuh agent.app" PARENT_SCOPE)
set(BIN_INSTALL_DIR "Library/Application Support/Wazuh agent.app/bin" PARENT_SCOPE)
set(CONFIG_INSTALL_DIR "Library/Application Support/Wazuh agent.app/etc" PARENT_SCOPE)
set(SERVICE_INSTALL_DIR "/Library/LaunchDaemons" PARENT_SCOPE)
set(SERVICE_INSTALL_DIR "Library/LaunchDaemons" PARENT_SCOPE)
set(DATA_INSTALL_DIR "Library/Application Support/Wazuh agent.app/var" PARENT_SCOPE)
set(RUN_INSTALL_DIR "private/var/run" PARENT_SCOPE)
set(SERVICE_FILE "${CMAKE_SOURCE_DIR}/agent/service/com.wazuh.agent.plist" PARENT_SCOPE)