Skip to content

Commit

Permalink
Add static linked deb package for NVIDIA Jetson (Ubuntu 22.04) arm64
Browse files Browse the repository at this point in the history
As the “NVIDIA JETPACK” is based on Ubuntu 22.04. the approach is to use the packages that are available (without adding some backport package soures list) and just compile the packages from source that are missing statically.  Use that static libs to link gg-lite static, but also link against shared libs that are available in the correct version. To do this I did create a container especially for this use case. Also some CMakeLists improvements needs to be done to enable that static linking for just those libs that are not available with Ubuntu 22.04.
  • Loading branch information
thomas-roos authored Dec 19, 2024
1 parent c14fc18 commit 8fea9e7
Show file tree
Hide file tree
Showing 9 changed files with 302 additions and 10 deletions.
39 changes: 35 additions & 4 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,40 @@ jobs:
build_type: [RelWithDebInfo, MinSizeRel]
steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build container for aarch64-linux-gnu

- name: Cache Podman image
uses: actions/cache@v4
with:
path: |
~/podman-aarch64-linux-gnu-image.tar
~/podman-x86-64-image.tar
key:
${{ runner.os }}-${{ matrix.architecture }}-podman-${{
hashFiles('misc/buildtestcontainer/*') }}

- name: Build and save container for aarch64-linux-gnu
if: matrix.architecture == 'aarch64-linux-gnu'
run: |
podman build --from=docker.io/arm64v8/ubuntu:24.04 --arch=arm64 misc/buildtestcontainer -t container
- name: Build container for x86-64
if [ ! -f ~/podman-aarch64-linux-gnu-image.tar ]; then
podman build --from=docker.io/arm64v8/ubuntu:24.04 --arch=arm64 misc/buildtestcontainer -t container
podman save container:latest > ~/podman-aarch64-linux-gnu-image.tar
else
podman load < ~/podman-aarch64-linux-gnu-image.tar
fi
- name: Build and save container for x86-64
if: matrix.architecture == ''
run: |
podman build misc/buildtestcontainer -t container
if [ ! -f ~/podman-x86-64-image.tar ]; then
podman build misc/buildtestcontainer -t container
podman save container:latest > ~/podman-x86-64-image.tar
else
podman load < ~/podman-x86-64-image.tar
fi
- name: Run build in container
shell: bash
run: |
Expand All @@ -42,19 +66,24 @@ jobs:
make -C build -j$(nproc) && \
cd build && cpack -v -G DEB && cd - \
"
- name: Save package
run: |
mkdir ${{ github.workspace }}/zipfile/
cp ${{ github.workspace }}/build/*.deb ${{ github.workspace }}/zipfile/
- name: Generate readme / install file
run: |
cat ${{ github.workspace }}/.github/workflows/packaging/readme.template.txt >> ${{ github.workspace }}/zipfile/readme.txt
cp ${{ github.workspace }}/.github/workflows/packaging/install-greengrass-lite.sh ${{ github.workspace }}/zipfile/
sed -i 's|{{ VERSION_LINK }}|${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|g' ${{ github.workspace }}/zipfile/readme.txt
sed -i 's|{{ UBUNTU_VERSION }}|24.04|g' ${{ github.workspace }}/zipfile/install-greengrass-lite.sh
cat ${{ github.workspace }}/LICENSE >> ${{ github.workspace }}/zipfile/readme.txt
- name: md5sums
run: |
md5sum ${{ github.workspace }}/zipfile/*
- name: Save package
uses: actions/upload-artifact@v4
with:
Expand All @@ -64,6 +93,7 @@ jobs:
path: |
${{ github.workspace }}/zipfile/*
retention-days: 1

- name:
Save x86-64 package without build type - default package to download
if: matrix.build_type == 'MinSizeRel' && matrix.architecture == ''
Expand All @@ -73,6 +103,7 @@ jobs:
path: |
${{ github.workspace }}/zipfile/*
retention-days: 1

- name:
Save arm64 package without build type - default package to download
if:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/packaging/install-greengrass-lite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ fi
check_ubuntu_version() {
if [ -f /etc/os-release ]; then
. /etc/os-release
if [ "$ID" = "ubuntu" ] && [ "$VERSION_ID" = "24.04" ]; then
if [ "$ID" = "ubuntu" ] && [ "$VERSION_ID" = "{{ UBUNTU_VERSION }}" ]; then
return 0
fi
fi
echo "Error: This greengrass lite package is only working with Ubuntu 24.04."
echo "Error: This greengrass lite package is only working with Ubuntu {{ UBUNTU_VERSION }}"
echo "Current system: $PRETTY_NAME"
exit 1
}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/packaging/readme.template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

AWS IoT Greengrass runtime for constrained devices.

The Greengrass Lite nucleus provides a smaller alternative to the Classic
The Greengrass Lite nucleus provides a smaller alternative to the Java
nucleus for Greengrass v2 deployments.

Greengrass Lite aims to maintain compatibility with the Classic nucleus, and
Greengrass Lite aims to maintain compatibility with the Java nucleus, and
implements a subset of its functionality.

There is a arm64 and x86-64 version available of this zip file. For the latest
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/static-packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build static deb arm64 packages and put them in zip files
on:
push:
branches:
- main
workflow_dispatch:
pull_request:

jobs:
build:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
architecture: [aarch64-linux-gnu]
build_type: [RelWithDebInfo, MinSizeRel]
steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Cache Podman image
uses: actions/cache@v4
with:
path: ~/podman-image.tar
key:
${{ runner.os }}-${{ matrix.architecture }}-podman-${{
hashFiles('misc/staticbuildtestcontainer/*') }}

- name: Build and save container for aarch64-linux-gnu
if: matrix.architecture == 'aarch64-linux-gnu'
run: |
if [ ! -f ~/podman-image.tar ]; then
podman build --from=docker.io/arm64v8/ubuntu:22.04 --arch=arm64 misc/staticbuildtestcontainer -t container
podman save container:latest > ~/podman-image.tar
else
podman load < ~/podman-image.tar
fi
- name: Run build in container
shell: bash
run: |
podman run -v $PWD/.:/aws-greengrass-lite --replace --name ggl container:latest bash -c "\
cd /aws-greengrass-lite && \
rm -rf build/ && \
cmake -B build \
-DGGL_LOG_LEVEL=DEBUG \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_FIND_DEBUG_MODE=ON \
-DGGL_SYSTEMD_SYSTEM_USER=ggcore \
-DGGL_SYSTEMD_SYSTEM_GROUP=ggcore \
-DGGL_SYSTEMD_SYSTEM_DIR=/lib/systemd/system \
-DCMAKE_INSTALL_PREFIX=/usr && \
make -C build -j$(nproc) && \
cd build && cpack -v -G DEB && cd - \
"
- name: Save package
run: |
mkdir ${{ github.workspace }}/zipfile/
cp ${{ github.workspace }}/build/*.deb ${{ github.workspace }}/zipfile/
- name: Generate readme / install file
run: |
cat ${{ github.workspace }}/.github/workflows/static-packaging/readme.template.txt >> ${{ github.workspace }}/zipfile/readme.txt
cp ${{ github.workspace }}/.github/workflows/packaging/install-greengrass-lite.sh ${{ github.workspace }}/zipfile/
sed -i 's|{{ VERSION_LINK }}|${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|g' ${{ github.workspace }}/zipfile/readme.txt
sed -i 's|{{ UBUNTU_VERSION }}|22.04|g' ${{ github.workspace }}/zipfile/install-greengrass-lite.sh
cat ${{ github.workspace }}/LICENSE >> ${{ github.workspace }}/zipfile/readme.txt
- name: md5sums
run: |
md5sum ${{ github.workspace }}/zipfile/*
- name: Save package
uses: actions/upload-artifact@v4
with:
name:
aws-greengrass-lite-ubuntu-${{ matrix.architecture || 'x86-64'}}_${{
matrix.build_type }}-static
path: |
${{ github.workspace }}/zipfile/*
retention-days: 1
- name:
Save arm64 package without build type - default package to download
if:
matrix.build_type == 'MinSizeRel' && matrix.architecture ==
'aarch64-linux-gnu'
uses: actions/upload-artifact@v4
with:
name: aws-greengrass-lite-ubuntu-arm64-static
path: |
${{ github.workspace }}/zipfile/*
retention-days: 1
60 changes: 60 additions & 0 deletions .github/workflows/static-packaging/readme.template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
###############################################################################
# AWS Greengrass Lite
###############################################################################

AWS IoT Greengrass runtime for constrained devices.

The Greengrass Lite nucleus provides a smaller alternative to the java nucleus
for Greengrass v2 deployments.

Greengrass Lite aims to maintain compatibility with the Classic nucleus, and
implements a subset of its functionality.

There is a arm64 and x86-64 version available of this zip file. For the latest
version, as well as other install options check here:
https://github.com/aws-greengrass/aws-greengrass-lite/releases

This deb package only works with NVIDIA JetPack SDK 6.0 (based on Ubuntu 22.04.),
because of library version package constraints!

This package has been built from this source revision:
{{ VERSION_LINK }}

###############################################################################
# INSTALLATION
###############################################################################

copy *.deb package and the install-greengrass-lite.sh from this zip onto your
device

copy ConnectionKit zip onto your device (e.g. scp, usb stick)

The three files should be in the same folder on the device.

On the device run installation script, this will automatically detect a *.deb
and *.zip for installation in the same dir:

sudo ./install-greengrass-lite.sh

###############################################################################
# UNINSTALLATION
###############################################################################

Add a parameter "-u" to the script. Be careful this will delete /etc/greengrass
and /var/lib/greengrass!

sudo ./install-greengrass-lite.sh -u

###############################################################################
# UPGRADE
###############################################################################

When a new version of greengrass lite is available and you want to keep your
configuration and components. Install just the deb package from the zip, without
using the (initial-) installation script.

sudo apt install ./aws-greengrass-lite-x.x.x-Linux.deb

###############################################################################
# LICENSE
###############################################################################
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY

# Fix for CMake stripping pkg-config includes from compile command
unset(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES)

#
# Compiler options
#
Expand Down Expand Up @@ -256,7 +255,6 @@ endforeach()
#
# System deps
#

find_package(PkgConfig REQUIRED)

pkg_search_module(openssl REQUIRED IMPORTED_TARGET openssl)
Expand Down Expand Up @@ -425,6 +423,18 @@ endif()
# CPACK deb package generation
#

file(READ "${CMAKE_SOURCE_DIR}/version" VERSION_STRING)
string(STRIP "${VERSION_STRING}" VERSION_STRING)

set(CPACK_PACKAGE_VERSION "${VERSION_STRING}")

string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+$" "\\1"
CPACK_PACKAGE_VERSION_MAJOR "${VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+$" "\\1"
CPACK_PACKAGE_VERSION_MINOR "${VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)$" "\\1"
CPACK_PACKAGE_VERSION_PATCH "${VERSION_STRING}")

set(CPACK_GENERATOR DEB)

set(CPACK_DEBIAN_PACKAGE_RELEASE "${LINUX_DISTRO_STRING}")
Expand Down
3 changes: 3 additions & 0 deletions misc/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ corge
coverity
cpack
cpus
DBUILD
dbus
dearmor
depl
DFETCHCONTENT
DGGL
Expand All @@ -24,6 +26,7 @@ elif
EOK
epoll
EPOLLIN
esac
evbuffer
eventfd
evhttp
Expand Down
Loading

0 comments on commit 8fea9e7

Please sign in to comment.