From efe4c2910931d23047113b8da6516e2cb8a07c10 Mon Sep 17 00:00:00 2001 From: Thomas Roos Date: Wed, 6 Nov 2024 16:01:55 +0100 Subject: [PATCH] cmake-multiplatform: fix for others than x86-64 --- .github/workflows/cmake-multi-platform.yml | 163 +++++++++++++----- .../install-greengrass-lite.sh | 16 ++ .../cmake-multi-platform/readme.template.txt | 58 +++++++ CMakeLists.txt | 6 +- 4 files changed, 198 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/cmake-multi-platform/install-greengrass-lite.sh create mode 100644 .github/workflows/cmake-multi-platform/readme.template.txt diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 8d3509535..97fac3ab5 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -9,18 +9,26 @@ jobs: strategy: fail-fast: false matrix: - build_type: [RelWithDebInfo, MinSizeRel] - architecture: [aarch64-linux-gnu, arm-linux-gnueabihf, ""] + architecture: [aarch64-linux-gnu, ""] # arm-linux-gnueabihf + build_type: [RelWithDebInfo] # MinSizeRel 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 \ + systemd \ + systemd-sysv \ + dbus \ + ca-certificates \ + file + - name: Install x86-64 dependencies / settings + if: matrix.architecture == '' + run: | + sudo apt-get -y install \ + build-essential \ libcurl4-openssl-dev \ libevent-dev \ libssl-dev \ @@ -28,52 +36,109 @@ jobs: libsystemd-dev \ liburiparser-dev \ libyaml-dev \ - libzip-dev \ - pkg-config \ + libzip-dev \ 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 \ + sudo apt-get -y install \ binutils-aarch64-linux-gnu \ - gcc-aarch64-linux-gnu - cat << EOF | tee -a ${{ matrix.architecture }}.cmake + g++-aarch64-linux-gnu \ + gcc-aarch64-linux-gnu \ + cmake \ + build-essential + sudo rm -rf /etc/apt/sources.list.d/* + cat << EOF | sudo tee -a /etc/apt/sources.list.d/cross-packages.list + deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble main restricted universe multiverse + deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main restricted universe multiverse + deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main restricted universe multiverse + deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-security main restricted universe multiverse + EOF + sudo dpkg --add-architecture arm64 + sudo apt clean && sudo apt update + sudo apt-get -y remove \ + libzip-dev \ + libcurl4-openssl-dev \ + libevent-dev \ + libssl-dev \ + libsqlite3-dev \ + libsystemd-dev \ + liburiparser-dev \ + libyaml-dev \ + libzip-dev \ + uuid-dev \ + cmake + sudo apt-get autoremove + sudo apt-get -y install \ + libzip-dev:arm64 \ + libcurl4-openssl-dev:arm64 \ + libevent-dev:arm64 \ + libssl-dev:arm64 \ + libsqlite3-dev:arm64 \ + libsystemd-dev:arm64 \ + liburiparser-dev:arm64 \ + libyaml-dev:arm64 \ + uuid-dev:arm64 + cat << EOF | tee -a ${{ github.workspace }}/${{ 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_C_COMPILER_WORKS TRUE) + set(CMAKE_CXX_COMPILER_WORKS TRUE) 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) + find_program(CMAKE_LINKER_FULL_PATH NAMES ${{ matrix.architecture }}-ld) + if(NOT CMAKE_LINKER_FULL_PATH) + message(FATAL_ERROR "Cross Linker for ${CMAKE_C_COMPILER_TARGET} not found") + endif() + set(CMAKE_LINKER ${CMAKE_LINKER_FULL_PATH}) + find_program(C_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-gcc) + if(NOT C_COMPILER_FULL_PATH) + message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") + endif() 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}) + find_program(CXX_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-g++) + if(NOT CXX_COMPILER_FULL_PATH) + message(FATAL_ERROR "C++ Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") endif() + set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) + set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/${{ matrix.architecture }}/pkgconfig") EOF - echo "CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV" + echo CMAKE_SETTINGS="-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/${{ 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 \ + sudo rm -rf /etc/apt/sources.list.d/* + cat << EOF | sudo tee -a /etc/apt/sources.list.d/cross-packages.list + deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble main restricted universe multiverse + deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main restricted universe multiverse + deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main restricted universe multiverse + deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble-security main restricted universe multiverse + EOF + sudo dpkg --add-architecture armhf + sudo apt clean && sudo apt update + sudo apt-get -y install \ + libc6-dev-armhf-cross \ + libc6-armhf-cross \ + binutils-arm-linux-gnueabihf \ g++-arm-linux-gnueabihf \ - binutils-arm-linux-gnueabihf - cat << EOF | tee -a ${{ matrix.architecture }}.cmake + gcc-arm-linux-gnueabihf \ + libcurl4-openssl-dev:armhf \ + libevent-dev:armhf \ + libssl-dev:armhf \ + libsqlite3-dev:armhf \ + libsystemd-dev:armhf \ + liburiparser-dev:armhf \ + libyaml-dev:armhf \ + libzip-dev:armhf \ + uuid-dev:armhf \ + libcurl4-openssl-dev:armhf + cat << EOF | tee -a ${{ github.workspace }}/${{ matrix.architecture }}.cmake set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_SYSTEM_VERSION 1) @@ -85,13 +150,17 @@ jobs: 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) + if(NOT C_COMPILER_FULL_PATH) + message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") + endif() 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}) + find_program(CXX_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-g++) + if(NOT CXX_COMPILER_FULL_PATH) + message(FATAL_ERROR "C++ Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") endif() + set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) EOF - echo "CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV" + echo CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV" - name: Set reusable strings id: strings shell: bash @@ -99,20 +168,34 @@ jobs: 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 }} + shell: bash + 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 }} \ + -DCMAKE_C_COMPILER_TARGET=${{ matrix.architecture }} \ + -DCMAKE_FIND_DEBUG_MODE=ON \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - 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 + run: | + cpack -G DEB + mkdir ${{ github.workspace }}/zipfile/ + cp ${{ steps.strings.outputs.build-output-dir }}/*.deb ${{ github.workspace }}/zipfile/ + - name: Generate readme / install file + run: | + cat ${{ github.workspace }}/.github/workflows/cmake-multi-platform/readme.template.txt >> ${{ github.workspace }}/zipfile/readme.txt + cp ${{ github.workspace }}/.github/workflows/cmake-multi-platform/install-greengrass-lite.sh ${{ github.workspace }}/zipfile/ - name: Save package uses: actions/upload-artifact@v4 with: - name: ${{ matrix.architecture }}_${{ matrix.build_type }}.deb - path: ${{ steps.strings.outputs.build-output-dir }}/*.deb + name: aws-greengrass-lite-ubuntu-${{ matrix.architecture || 'x86-64'}}_${{ matrix.build_type }} + path: | + ${{ github.workspace }}/zipfile/* retention-days: 1 diff --git a/.github/workflows/cmake-multi-platform/install-greengrass-lite.sh b/.github/workflows/cmake-multi-platform/install-greengrass-lite.sh new file mode 100644 index 000000000..c181b8528 --- /dev/null +++ b/.github/workflows/cmake-multi-platform/install-greengrass-lite.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +WIP + + + install -d ${D}/${gg_rundir} + chown ${gg_user}:${gg_group} ${D}/${gg_rundir} + + install -d ${D}/${sysconfdir}/greengrass + install -d ${D}/${sysconfdir}/greengrass/config.d + + install -m 0644 ${WORKDIR}/greengrass-lite.yaml ${D}/${sysconfdir}/greengrass/config.d + sed -i -e 's,@GG_WORKING_DIR@,${gg_workingdir},g' \ + -e 's,@GG_USER@,${gg_user},g' \ + -e 's,@GG_GROUP@,${gg_group},g' \ + ${D}/${sysconfdir}/greengrass/config.d/greengrass-lite.yaml \ No newline at end of file diff --git a/.github/workflows/cmake-multi-platform/readme.template.txt b/.github/workflows/cmake-multi-platform/readme.template.txt new file mode 100644 index 000000000..8671f1000 --- /dev/null +++ b/.github/workflows/cmake-multi-platform/readme.template.txt @@ -0,0 +1,58 @@ +This readme file will be generated by the build process, done now for the bug bash manually. + +################## + +SOME GENERAL INFO about gg-lite + + +################## + +INSTALLATION: +################## + +copy *.deb package from zip onto your device (e.g. scp) + +copy ConnectionKit zip onto your device (e.g. scp) + +sudo apt update + +sudo apt install aws-greengrass-lite-0.1.1-Linux.deb + +sudo apt install zip + +sudo mkdir /etc/greengrass/ + +sudo unzip -jo connectionKit.zip -d /etc/greengrass/ + +sudo sed -i -e s:{{config_dir}}:\/etc\/greengrass:g -e s:{{data_dir}}:\/var\/lib\/aws-greengrass-v2:g -e s:{{nucleus_component}}:aws.greengrass.Nucleus-Lite:g /etc/greengrass/config.yaml + +add greengrass lite config fragment to /etc/greengrass/config.d/greengrass-lite.yaml + +replace @GG_WORKING_DIR@ with the directory you want to run it - can be the Desktop for testing: e.g. /home/ubuntu/Desktop +replace @GG_USER@ and @GG_GROUP@ with user and group you want to run it - e.g. ubuntu or the user you created. + +--- +system: + rootPath: "@GG_WORKING_DIR@" +services: + aws.greengrass.Nucleus-Lite: + componentType: "NUCLEUS" + configuration: + runWithDefault: + posixUser: "@GG_USER@:@GG_GROUP@" + greengrassDataPlanePort: "8443" + tesCredUrl: "http://127.0.0.1:8080/" + + +run_nucleus + +################## + + +SOME ADDITIONAL INFO + + +################## + + +SOME LICENSE TEXT HERE \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index b233d420a..32591a9c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -387,11 +387,7 @@ set(CPACK_GENERATOR DEB) set(CPACK_DEBIAN_PACKAGE_RELEASE "${LINUX_DISTRO_STRING}") -if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") - set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64) -elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686") - set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386) -endif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all") set(CPACK_PACKAGE_CONTACT "https://github.com/aws-greengrass/aws-greengrass-lite")