Skip to content

Commit

Permalink
github/workflow: creates deb for Ubuntu 22.04
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gastmaier committed Mar 24, 2023
1 parent 9db3469 commit b093496
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .github/workflows/build-deb-ubuntu-22.04.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cmake_minimum_required(VERSION 2.8.7)
# 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}
Expand All @@ -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")
Expand Down Expand Up @@ -337,3 +343,10 @@ if(NOT EXISTS "${TARGET_PATH}")
endif()

add_subdirectory(plugins)
option(ENABLE_PACKAGING "Create .deb/.rpm/.tar.gz packages via 'make package'" OFF)

if(ENABLE_PACKAGING)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
include(cmake/LinuxPackaging.cmake)
endif()
endif()
47 changes: 47 additions & 0 deletions cmake/LinuxPackaging.cmake
Original file line number Diff line number Diff line change
@@ -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 <https://ez.analog.com/sw-interface-tools>")
endif()

include(CPack)

0 comments on commit b093496

Please sign in to comment.