diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml new file mode 100644 index 000000000..8d3509535 --- /dev/null +++ b/.github/workflows/cmake-multi-platform.yml @@ -0,0 +1,118 @@ +name: CMake on multiple platforms +on: + workflow_dispatch: + push: + pull_request: +jobs: + build: + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + build_type: [RelWithDebInfo, MinSizeRel] + architecture: [aarch64-linux-gnu, arm-linux-gnueabihf, ""] + steps: + - uses: actions/checkout@v4 + - name: Install generic dependencies + run: | + sudo apt clean && sudo apt update + sudo apt-get -y install --no-install-recommends \ + cmake \ + curl \ + libc6-dev-i386 \ + git \ + libcurl4-openssl-dev \ + libevent-dev \ + libssl-dev \ + libsqlite3-dev \ + libsystemd-dev \ + liburiparser-dev \ + libyaml-dev \ + libzip-dev \ + pkg-config \ + uuid-dev + - name: Install x86-64 dependencies / settings + if: matrix.architecture == '' + run: | + sudo apt-get -y install \ + build-essential + echo "cmake_settings=" >> "$GITHUB_OUTPUT" + - name: Install arm64 dependencies / settings + if: matrix.architecture == 'aarch64-linux-gnu' + run: | + sudo apt-get -y install --no-install-recommends \ + qemu-user-static \ + g++-aarch64-linux-gnu \ + binutils-aarch64-linux-gnu \ + gcc-aarch64-linux-gnu + cat << EOF | tee -a ${{ matrix.architecture }}.cmake + set(CMAKE_SYSTEM_NAME Linux) + set(CMAKE_SYSTEM_PROCESSOR aarch64) + set(CMAKE_SYSTEM_VERSION 1) + set(CMAKE_C_COMPILER_TARGET ${{ matrix.architecture }}) + set(CMAKE_CXX_COMPILER_TARGET ${{ matrix.architecture }}) + set(CMAKE_CROSSCOMPILING TRUE) + set(CMAKE_CROSSCOMPILING_EMULATOR qemu-aarch64-static -L /usr/${{ matrix.architecture }}/) + SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + find_program(C_COMPILER_FULL_PATH NAMES aarch64-linux-gnu-gcc) + set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) + find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++) + if(CXX_COMPILER_FULL_PATH) + set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) + endif() + EOF + echo "CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV" + - name: Install arm32 dependencies / settings + if: matrix.architecture == 'arm-linux-gnueabihf' + run: | + sudo apt-get -y install --no-install-recommends \ + qemu-user-static \ + libc-dev-armel-cross \ + gcc-arm-linux-gnueabihf \ + g++-arm-linux-gnueabihf \ + binutils-arm-linux-gnueabihf + cat << EOF | tee -a ${{ matrix.architecture }}.cmake + set(CMAKE_SYSTEM_NAME Linux) + set(CMAKE_SYSTEM_PROCESSOR arm) + set(CMAKE_SYSTEM_VERSION 1) + set(CMAKE_C_COMPILER_TARGET "${{ matrix.architecture }}") + set(CMAKE_CXX_COMPILER_TARGET "${{ matrix.architecture }}") + set(CMAKE_CROSSCOMPILING TRUE) + set(CMAKE_CROSSCOMPILING_EMULATOR qemu-arm-static -L /usr/${{ matrix.architecture }}/) + SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + find_program(C_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-gcc) + set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) + find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++) + if(CXX_COMPILER_FULL_PATH) + set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) + endif() + EOF + echo "CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV" + - name: Set reusable strings + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + - name: + Configure CMake ${{ matrix.build_type }} / ${{ matrix.architecture }} + run: > + cmake ${{ env.CMAKE_SETTINGS }} -B ${{ + steps.strings.outputs.build-output-dir }} + -DCMAKE_INSTALL_PREFIX=/opt/aws-greengrass-lite -DGGL_LOG_LEVEL=DEBUG + -S ${{ github.workspace }} + - name: Build + run: | + make -C ${{ steps.strings.outputs.build-output-dir }} -j$(nproc) + - name: Package + working-directory: ${{ steps.strings.outputs.build-output-dir }} + run: cpack -G DEB + - name: Save package + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.architecture }}_${{ matrix.build_type }}.deb + path: ${{ steps.strings.outputs.build-output-dir }}/*.deb + retention-days: 1 diff --git a/ggdeploymentd/src/deployment_handler.c b/ggdeploymentd/src/deployment_handler.c index 37060c221..195b69a6c 100644 --- a/ggdeploymentd/src/deployment_handler.c +++ b/ggdeploymentd/src/deployment_handler.c @@ -1047,8 +1047,14 @@ static GglError parse_dataplane_response_and_save_recipe( if (ret != GGL_ERR_OK) { return ret; } + assert(cloud_component_version->buf.len <= NAME_MAX); - *cloud_version = cloud_component_version->buf; + memcpy( + cloud_version->data, + cloud_component_version->buf.data, + cloud_component_version->buf.len + ); + cloud_version->len = cloud_component_version->buf.len; if (vendor_guidance != NULL) { if (ggl_buffer_eq(vendor_guidance->buf, GGL_STR("DISCONTINUED"))) { @@ -1568,7 +1574,7 @@ static GglError resolve_dependencies( return ret; } if (existing_requirements) { - static uint8_t new_req_buf[PATH_MAX]; + uint8_t new_req_buf[PATH_MAX]; GglByteVec new_req_vec = GGL_BYTE_VEC(new_req_buf); ret = ggl_byte_vec_append( &new_req_vec, existing_requirements->buf @@ -1583,7 +1589,22 @@ static GglError resolve_dependencies( return ret; } - *existing_requirements = GGL_OBJ_BUF(new_req_vec.buf); + uint8_t *new_req = GGL_ALLOCN( + &version_requirements_balloc.alloc, + uint8_t, + new_req_vec.buf.len + ); + if (new_req == NULL) { + GGL_LOGE("Ran out of memory while trying to create " + "new requirements"); + return GGL_ERR_NOMEM; + } + + memcpy( + new_req, new_req_vec.buf.data, new_req_vec.buf.len + ); + *existing_requirements = GGL_OBJ_BUF((GglBuffer + ) { .data = new_req, .len = new_req_vec.buf.len }); } // If we haven't resolved it yet, and it doesn't have an