Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deb package target and workflow #422

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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 <[email protected]>
gastmaier committed Sep 16, 2024
commit 44833b55fbc9ec62b06a1b81f646f0eea66692e8
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
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
47 changes: 47 additions & 0 deletions cmake_linux_packaging.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)