Skip to content

Commit 44833b5

Browse files
committed
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]>
1 parent fbd5aa5 commit 44833b5

File tree

3 files changed

+95
-1
lines changed

3 files changed

+95
-1
lines changed

Diff for: .github/workflows/build-deb-ubuntu-22.04.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
on:
2+
push:
3+
branches: [master, deb]
4+
release:
5+
type: [published]
6+
name: deb build for Ubuntu 22.04
7+
jobs:
8+
build:
9+
runs-on: ubuntu-22.04
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Install dependencies
16+
run: sudo apt-get update &&
17+
sudo apt-get install -y
18+
build-essential cmake git
19+
libgtk-3-dev libxml2-dev
20+
libcurl4-openssl-dev libad9361-dev
21+
libaio-dev libiio-dev libgtkdatabox-dev
22+
libjansson-dev libmatio-dev libfftw3-dev
23+
24+
- name: Generate deb package
25+
run: mkdir build && cd $_ &&
26+
cmake -DENABLE_PACKAGING=ON .. && make package
27+
28+
- name: Upload deb package
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: iio-oscilloscope-Ubuntu22.04.deb
32+
path: build/iio-oscilloscope-*-Linux.deb
33+
if-no-files-found: error

Diff for: CMakeLists.txt

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cmake_minimum_required(VERSION 3.13.0)
2020
# needed to use VERSION in 'project()'
2121
cmake_policy(SET CMP0048 NEW)
2222
set(OSC_VERSION_MAJOR 0)
23-
set(OSC_VERSION_MINOR 8)
23+
set(OSC_VERSION_MINOR 15)
2424
set(OSC_VERSION "${OSC_VERSION_MAJOR}.${OSC_VERSION_MINOR}")
2525
project(iio-oscilloscope
2626
VERSION ${OSC_VERSION}
@@ -33,6 +33,12 @@ endif()
3333

3434
include(GNUInstallDirs)
3535

36+
if(ENABLE_PACKAGING AND ${CMAKE_INSTALL_FULL_LIBDIR} STREQUAL /usr/local/lib)
37+
# /usr/local/lib might not be in LD_LIBRAY_PATH
38+
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
39+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
40+
endif()
41+
3642
# Get the GIT hash of the latest commit
3743
include(FindGit OPTIONAL)
3844
if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
@@ -348,3 +354,11 @@ if(NOT TARGET uninstall)
348354
add_custom_target(uninstall
349355
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
350356
endif()
357+
358+
option(ENABLE_PACKAGING "Create .deb/.rpm/.tar.gz packages via 'make package'" OFF)
359+
360+
if(ENABLE_PACKAGING)
361+
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
362+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_linux_packaging.cmake)
363+
endif()
364+
endif()

Diff for: cmake_linux_packaging.cmake

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# support creating some basic binpkgs via `make package`
2+
set(CPACK_SET_DESTDIR ON)
3+
set(CPACK_GENERATOR TGZ)
4+
5+
FIND_PROGRAM(RPMBUILD_CMD rpmbuild)
6+
if (RPMBUILD_CMD)
7+
# Check if optional dependency is included
8+
if(LIBAD9361_LIBRARIES)
9+
set(LIBAD9361_RPM ", libad9361 >= 0.2")
10+
endif()
11+
if(LIBAD9166_LIBRARIES)
12+
set(LIBAD9166_RPM ", libad9166 >= 0.2")
13+
endif()
14+
# Manual setup of rpm requires, Fedora >= 36 centric
15+
set(CPACK_PACKAGE_RELOCATABLE OFF)
16+
set(CPACK_GENERATOR ${CPACK_GENERATOR};RPM)
17+
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}")
18+
message(STATUS "Package dependencies (.rpm): " ${CPACK_RPM_PACKAGE_REQUIRES})
19+
endif()
20+
21+
FIND_PROGRAM(DEBBUILD_CMD dpkg)
22+
if (DEBBUILD_CMD)
23+
# Check if optional dependency is included
24+
if(LIBAD9361_LIBRARIES)
25+
set(LIBAD9361_DEB ", libad9361-0 (>= 0.2) | libad9361 (>= 0.2)")
26+
endif()
27+
if(LIBAD9166_LIBRARIES)
28+
set(LIBAD9166_DEB ", libad9166 (>= 0.2)")
29+
endif()
30+
set(CPACK_GENERATOR ${CPACK_GENERATOR};DEB)
31+
32+
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}")
33+
message(STATUS "Package dependencies (.deb): " ${CPACK_DEBIAN_PACKAGE_DEPENDS})
34+
endif()
35+
36+
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
37+
set(CPACK_PACKAGE_VERSION_MAJOR ${OSC_VERSION_MAJOR})
38+
set(CPACK_PACKAGE_VERSION_MINOR ${OSC_VERSION_MINOR})
39+
set(CPACK_PACKAGE_VERSION_PATCH ${OSC_VERSION_GIT})
40+
set(CPACK_BUNDLE_NAME osc)
41+
set(CPACK_PACKAGE_VERSION ${OSCIO_VERSION})
42+
if (DEBBUILD_CMD)
43+
# debian specific package settings
44+
set(CPACK_PACKAGE_CONTACT "Engineerzone <https://ez.analog.com/sw-interface-tools>")
45+
endif()
46+
47+
include(CPack)

0 commit comments

Comments
 (0)