From 44833b55fbc9ec62b06a1b81f646f0eea66692e8 Mon Sep 17 00:00:00 2001 From: Jorge Marques Date: Tue, 21 Mar 2023 15:18:35 -0300 Subject: [PATCH 1/3] github/workflow: creates deb for Ubuntu 22.04 Include files to generate debs, targeting Ubuntu 22.04. Uses the ENABLE_PACKAGING cmake flag to generate the packages. Uses dependencies available in the main package manager repositories. The workflow runs in master, this branch and on published release. Can also create rpm, but this is not uploaded by the workflow. Note: Ubuntu libcurl4 flavor is openssl, rpm generated in Ubuntu will mostly not work with Fedora/OpenSUSE. Signed-off-by: Jorge Marques --- .github/workflows/build-deb-ubuntu-22.04.yml | 33 ++++++++++++++ CMakeLists.txt | 16 ++++++- cmake_linux_packaging.cmake | 47 ++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-deb-ubuntu-22.04.yml create mode 100644 cmake_linux_packaging.cmake diff --git a/.github/workflows/build-deb-ubuntu-22.04.yml b/.github/workflows/build-deb-ubuntu-22.04.yml new file mode 100644 index 00000000..518bce0f --- /dev/null +++ b/.github/workflows/build-deb-ubuntu-22.04.yml @@ -0,0 +1,33 @@ +on: + push: + branches: [master, deb] + release: + type: [published] +name: deb build for Ubuntu 22.04 +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install dependencies + run: sudo apt-get update && + sudo apt-get install -y + build-essential cmake git + libgtk-3-dev libxml2-dev + libcurl4-openssl-dev libad9361-dev + libaio-dev libiio-dev libgtkdatabox-dev + libjansson-dev libmatio-dev libfftw3-dev + + - name: Generate deb package + run: mkdir build && cd $_ && + cmake -DENABLE_PACKAGING=ON .. && make package + + - name: Upload deb package + uses: actions/upload-artifact@v3 + with: + name: iio-oscilloscope-Ubuntu22.04.deb + path: build/iio-oscilloscope-*-Linux.deb + if-no-files-found: error diff --git a/CMakeLists.txt b/CMakeLists.txt index 79522fa9..217cdd1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ cmake_minimum_required(VERSION 3.13.0) # needed to use VERSION in 'project()' cmake_policy(SET CMP0048 NEW) set(OSC_VERSION_MAJOR 0) -set(OSC_VERSION_MINOR 8) +set(OSC_VERSION_MINOR 15) set(OSC_VERSION "${OSC_VERSION_MAJOR}.${OSC_VERSION_MINOR}") project(iio-oscilloscope VERSION ${OSC_VERSION} @@ -33,6 +33,12 @@ endif() include(GNUInstallDirs) +if(ENABLE_PACKAGING AND ${CMAKE_INSTALL_FULL_LIBDIR} STREQUAL /usr/local/lib) + # /usr/local/lib might not be in LD_LIBRAY_PATH + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +endif() + # Get the GIT hash of the latest commit include(FindGit OPTIONAL) if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") @@ -348,3 +354,11 @@ if(NOT TARGET uninstall) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) endif() + +option(ENABLE_PACKAGING "Create .deb/.rpm/.tar.gz packages via 'make package'" OFF) + +if(ENABLE_PACKAGING) + if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_linux_packaging.cmake) + endif() +endif() diff --git a/cmake_linux_packaging.cmake b/cmake_linux_packaging.cmake new file mode 100644 index 00000000..35167b9d --- /dev/null +++ b/cmake_linux_packaging.cmake @@ -0,0 +1,47 @@ +# support creating some basic binpkgs via `make package` +set(CPACK_SET_DESTDIR ON) +set(CPACK_GENERATOR TGZ) + +FIND_PROGRAM(RPMBUILD_CMD rpmbuild) +if (RPMBUILD_CMD) + # Check if optional dependency is included + if(LIBAD9361_LIBRARIES) + set(LIBAD9361_RPM ", libad9361 >= 0.2") + endif() + if(LIBAD9166_LIBRARIES) + set(LIBAD9166_RPM ", libad9166 >= 0.2") + endif() + # Manual setup of rpm requires, Fedora >= 36 centric + set(CPACK_PACKAGE_RELOCATABLE OFF) + set(CPACK_GENERATOR ${CPACK_GENERATOR};RPM) + set(CPACK_RPM_PACKAGE_REQUIRES "libiio >= 0.23, gtk3 >= 3.24, gtkdatabox >= 1.0.0, jansson >= 2.12, matio >= 1.5.17, fftw >= 3.3.8, curl >= 7.68.0${LIBAD9361_RPM}${LIBAD9166_RPM}") + message(STATUS "Package dependencies (.rpm): " ${CPACK_RPM_PACKAGE_REQUIRES}) +endif() + +FIND_PROGRAM(DEBBUILD_CMD dpkg) +if (DEBBUILD_CMD) + # Check if optional dependency is included + if(LIBAD9361_LIBRARIES) + set(LIBAD9361_DEB ", libad9361-0 (>= 0.2) | libad9361 (>= 0.2)") + endif() + if(LIBAD9166_LIBRARIES) + set(LIBAD9166_DEB ", libad9166 (>= 0.2)") + endif() + set(CPACK_GENERATOR ${CPACK_GENERATOR};DEB) + + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libiio0 (>= 0.23) | libiio (>= 0.23), libgtk-3-0 (>= 3.24.18), libgtkdatabox1 (>= 1.0.0), libjansson4 (>= 2.12), libmatio11 (>= 1.5.21), libfftw3-3 (>= 3.3.8), libcurl4 (>= 7.68.0)${LIBAD9361_DEB}${LIBAD9166_DEB}") + message(STATUS "Package dependencies (.deb): " ${CPACK_DEBIAN_PACKAGE_DEPENDS}) +endif() + +set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0) +set(CPACK_PACKAGE_VERSION_MAJOR ${OSC_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${OSC_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${OSC_VERSION_GIT}) +set(CPACK_BUNDLE_NAME osc) +set(CPACK_PACKAGE_VERSION ${OSCIO_VERSION}) +if (DEBBUILD_CMD) + # debian specific package settings + set(CPACK_PACKAGE_CONTACT "Engineerzone ") +endif() + +include(CPack) From 877c460275a9652e042cf068e35636fd058b1424 Mon Sep 17 00:00:00 2001 From: Jorge Marques Date: Fri, 24 Mar 2023 12:00:38 -0300 Subject: [PATCH 2/3] README.md: Add deb status badge Badge will only show status for builds at master branch. Signed-off-by: Jorge Marques --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7e9d4743..e0f9a2a4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![windows-mingw build](https://github.com/analogdevicesinc/iio-oscilloscope/actions/workflows/buildmingw.yml/badge.svg?branch=master)](https://github.com/analogdevicesinc/iio-oscilloscope/actions/workflows/buildmingw.yml?query=branch%3Amaster+) +[![deb build](https://github.com/analogdevicesinc/iio-oscilloscope/actions/workflows/build-deb-ubuntu-22.04.yml/badge.svg?branch=master)](https://github.com/analogdevicesinc/iio-oscilloscope/actions/workflows/build-deb-ubuntu-22.04.yml?query=branch%3Amaster+) IIO Oscilloscope [![GitHub Release](https://img.shields.io/github/release/analogdevicesinc/iio-oscilloscope.svg)](https://github.com/analogdevicesinc/iio-oscilloscope/releases/latest) [![Application License](https://img.shields.io/badge/license-GPL2-blue.svg)](https://github.com/analogdevicesinc/libiio/blob/master/COPYING_GPL.txt) ================ From c5c6e8acfa8e515797bb9428200b9e69168e5d7f Mon Sep 17 00:00:00 2001 From: Jorge Marques Date: Mon, 16 Sep 2024 13:10:56 -0300 Subject: [PATCH 3/3] github/workflow: Update actions versions Fix deprecated notice. Signed-off-by: Jorge Marques --- .github/workflows/build-deb-ubuntu-22.04.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deb-ubuntu-22.04.yml b/.github/workflows/build-deb-ubuntu-22.04.yml index 518bce0f..fdb712eb 100644 --- a/.github/workflows/build-deb-ubuntu-22.04.yml +++ b/.github/workflows/build-deb-ubuntu-22.04.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install dependencies run: sudo apt-get update && @@ -26,7 +26,7 @@ jobs: cmake -DENABLE_PACKAGING=ON .. && make package - name: Upload deb package - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: iio-oscilloscope-Ubuntu22.04.deb path: build/iio-oscilloscope-*-Linux.deb