Skip to content

Commit 36433d6

Browse files
committed
Change .deb creation to use debhelper
Signed-off-by: Nicu Siderias <nicu.siderias@analog.com>
1 parent 04730f3 commit 36433d6

File tree

13 files changed

+253
-113
lines changed

13 files changed

+253
-113
lines changed

CI/ubuntu/install_deps

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ install_deps() {
1414
libxml2-dev rpm tar bzip2 gzip flex bison git curl \
1515
python3-dev python3-setuptools python3-pip python3-all \
1616
debhelper devscripts fakeroot libserialport-dev swig dh-python \
17-
libunwind-dev libunwind8
17+
libunwind-dev libunwind8 \
18+
libgoogle-glog-dev mono-mcs cli-common-dev
1819

1920
# libiio dependencies
2021
echo "libiio packages"
@@ -43,15 +44,14 @@ install_libiio() {
4344
cd ${TOP_DIR}
4445
git clone https://github.com/analogdevicesinc/libiio.git -b $LIBIIO_VERSION libiio
4546
mkdir ./libiio/build && cd ./libiio/build
46-
cmake .. -Werror=dev -DCOMPILE_WARNING_AS_ERROR=ON -DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DWITH_DOC=ON -DWITH_SERIAL_BACKEND=ON -DWITH_MAN=ON -DCPACK_SYSTEM_NAME=${ARTIFACTNAME}
47+
cmake .. -Werror=dev -DCOMPILE_WARNING_AS_ERROR=ON -DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DWITH_DOC=ON -DWITH_SERIAL_BACKEND=ON -DWITH_MAN=ON -DCPACK_SYSTEM_NAME=${ARTIFACTNAME}
4748
make
48-
make package
49+
make package
4950
sudo apt install ./libiio-*.deb
5051
}
5152

5253
handle_default() {
5354
install_deps
54-
install_glog
5555
install_libiio
5656
}
5757

CI/ubuntu/make_linux

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,47 @@
1-
#!/bin/sh -e
1+
#!/bin/bash -e
22

33
TOP_DIR=$(pwd)
44

55
set -x
66

7-
handle_default() {
8-
mkdir -p build
9-
cd build
7+
# Extract version from CMakeLists.txt
8+
get_version() {
9+
grep -E "^set\(LIBM2K_VERSION_(MAJOR|MINOR|PATCH)" CMakeLists.txt | \
10+
sed 's/.*[^0-9]\([0-9]*\)).*/\1/' | \
11+
tr '\n' '.' | sed 's/\.$//'
12+
}
1013

11-
#create deb for bindings
12-
cmake -DENABLE_PYTHON=ON -DENABLE_TOOLS=ON -DENABLE_CSHARP=OFF -DENABLE_LOG=ON -DBUILD_EXAMPLES=ON .. && make
13-
sudo python3 setup.py --command-packages=stdeb.command sdist_dsc
14-
cd "$(find . -type d -name "debian" | head -n 1)"
15-
sudo env DEB_BUILD_OPTIONS=nocheck debuild -us -uc
16-
cp ../../*.deb ${TOP_DIR}/build/
17-
cd ${TOP_DIR}/build/
18-
#remove the tar.gz for bindings
19-
sudo rm *.tar.gz
20-
ls
21-
22-
#create simple .deb without Python bindings
23-
cmake -DENABLE_PACKAGING=ON -DDEB_DETECT_DEPENDENCIES=ON -DENABLE_PYTHON=OFF -DENABLE_CSHARP=ON -DENABLE_TOOLS=ON -DENABLE_LOG=ON -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_EXAMPLES=ON ..
24-
make && make package
25-
ls
14+
handle_default() {
15+
VERSION=$(get_version)
16+
ARCHITECTURE=$(dpkg --print-architecture)
17+
SOURCE_DIR=$(grep "^Source:" packaging/debian/control | cut -d' ' -f2)
18+
CURRENT_DIR=$(basename "$PWD")
19+
20+
# Copy debian directory from packaging to root
21+
cp -r ${TOP_DIR}/packaging/debian ${TOP_DIR}/debian
22+
23+
# Replace placeholders in debian template files
24+
sed -i "s/@VERSION@/${VERSION}/" ${TOP_DIR}/debian/changelog
25+
sed -i "s/@DATE@/$(date -R)/" ${TOP_DIR}/debian/changelog
26+
sed -i "s/@ARCHITECTURE@/${ARCHITECTURE}/" ${TOP_DIR}/debian/control
27+
28+
# Create orig tarball
29+
pushd ..
30+
tar czf ${SOURCE_DIR}_${VERSION}.orig.tar.gz ${CURRENT_DIR}
31+
popd
32+
33+
# Build debian packages
34+
debuild
35+
36+
# Move generated packages to build directory
37+
mkdir -p ${TOP_DIR}/build
38+
mv ${TOP_DIR}/../libm2k*.deb ${TOP_DIR}/build/ 2>/dev/null || true
39+
mv ${TOP_DIR}/../libm2k*.changes ${TOP_DIR}/build/ 2>/dev/null || true
40+
mv ${TOP_DIR}/../libm2k*.buildinfo ${TOP_DIR}/build/ 2>/dev/null || true
41+
mv ${TOP_DIR}/../python3-libm2k*.deb ${TOP_DIR}/build/ 2>/dev/null || true
42+
43+
# List generated packages
44+
ls -la ${TOP_DIR}/build/
2645
}
2746

2847
handle_doxygen() {
@@ -39,4 +58,4 @@ handle_ubuntu_docker() {
3958
handle_default
4059
}
4160

42-
handle_${OS_TYPE}
61+
handle_${OS_TYPE}

azure-pipelines.yml

Lines changed: 73 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ jobs:
3737
- job: LinuxBuilds
3838
strategy:
3939
matrix:
40-
ubuntu_20_04:
41-
imageName: 'ubuntu-20.04'
42-
OS_TYPE: 'ubuntu_docker'
43-
OS_VERSION: focal
44-
artifactName: 'Linux-Ubuntu-20.04'
4540
ubuntu_22_04:
4641
imageName: 'ubuntu-22.04'
4742
OS_TYPE: 'ubuntu_docker'
@@ -73,7 +68,7 @@ jobs:
7368
condition: ne(variables['System.JobName'], 'deploy_doxygen')
7469
inputs:
7570
sourceFolder: '$(Agent.BuildDirectory)/s/build/'
76-
contents: '$(Agent.BuildDirectory)/s/build/?(libm2k*.deb|libm2k*.rpm)'
71+
contents: '$(Agent.BuildDirectory)/s/build/?(libm2k*.deb|libm2k*.rpm|python3-libm2k*.deb)'
7772
targetFolder: '$(Build.ArtifactStagingDirectory)'
7873
- task: PublishPipelineArtifact@1
7974
condition: and(succeeded(), ne(variables['System.JobName'], 'deploy_doxygen'))
@@ -86,10 +81,6 @@ jobs:
8681
clean: all
8782
strategy:
8883
matrix:
89-
macOS_13_x64:
90-
poolName: 'Azure Pipelines'
91-
vmImage: 'macOS-13'
92-
artifactName: 'macOS-13-x64'
9384
macOS_14_x64:
9485
poolName: 'Azure Pipelines'
9586
vmImage: 'macOS-14'
@@ -170,85 +161,78 @@ jobs:
170161
TWINE_USERNAME: '__token__'
171162
TWINE_PASSWORD: $(TWINE_PASSWORD)
172163
173-
- job: WindowsBuilds
174-
workspace:
175-
clean: all
176-
strategy:
177-
matrix:
178-
VS_2022:
179-
poolName: 'Azure Pipelines'
180-
vmImage: 'windows-2022'
181-
COMPILER: 'Visual Studio 17 2022'
182-
ARCH: 'x64'
183-
PLATFORM: 'win64'
184-
artifactName: 'Windows-VS-2022-x64'
185-
VS_2019:
186-
poolName: 'Azure Pipelines'
187-
vmImage: 'windows-2019'
188-
COMPILER: 'Visual Studio 16 2019'
189-
ARCH: 'x64'
190-
PLATFORM: 'win64'
191-
artifactName: 'Windows-VS-2019-x64'
192-
pool:
193-
vmImage: $[ variables['vmImage'] ]
194-
steps:
195-
- checkout: self
196-
fetchDepth: 1
197-
clean: true
198-
- task: UsePythonVersion@0
199-
inputs:
200-
versionSpec: '3.11'
201-
- task: PowerShell@2
202-
displayName: 'Install Dependencies'
203-
inputs:
204-
targetType: filePath
205-
filePath: ./CI/windows/install_deps.ps1
206-
- task: PowerShell@2
207-
displayName: "Build libm2k"
208-
inputs:
209-
targetType: 'filePath'
210-
filePath: ./CI/windows/make_windows.ps1
211-
- ${{ each pyVersion in parameters.pythonVersions }}:
212-
- task: UsePythonVersion@0
213-
displayName: Use Python ${{ pyVersion }}
214-
inputs:
215-
versionSpec: '${{ pyVersion }}'
216-
- powershell: |
217-
$SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY
218-
$OUTSIDE_BUILD = $SRC_DIR.Parent.FullName
219-
220-
$BUILD_DIR = Join-Path $OUTSIDE_BUILD "libm2k-$env:PLATFORM"
221-
$TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$env:PLATFORM"
222-
223-
Set-Location $TEMP_BUILD_DIR
224-
python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv
225-
$env:COMPILE_BINDINGS = $true
226-
python.exe -m build
227-
Remove-Item Env:COMPILE_BINDINGS
228-
Copy-Item -Path "dist/libm2k*.whl" -Destination (Join-Path $BUILD_DIR "dist")
229-
Set-Location $SRC_DIR
230-
displayName: Wheel Python ${{ pyVersion }}
231-
- task: PowerShell@2
232-
displayName: 'Create libm2k-system-setup installer'
233-
condition: and(succeeded(), eq(variables['System.JobName'], 'VS_2022'))
234-
inputs:
235-
targetType: 'filePath'
236-
filePath: ./CI/windows/create_installer.ps1
237-
- task: PublishPipelineArtifact@1
238-
condition: and(succeeded(), eq(variables['System.JobName'], 'VS_2022'))
239-
inputs:
240-
targetPath: '$(Build.ArtifactStagingDirectory)/installer'
241-
artifactName: 'Libm2k-System-Setup-Exe'
242-
- task: PowerShell@2
243-
displayName: "Create ZIPs"
244-
inputs:
245-
targetType: 'filePath'
246-
filePath: ./CI/windows/create_zips.ps1
247-
- task: PublishPipelineArtifact@1
248-
condition: succeeded()
249-
inputs:
250-
targetPath: '$(Build.ArtifactStagingDirectory)/libm2k-$(PLATFORM)'
251-
artifactName: '$(artifactName)'
164+
#- job: WindowsBuilds
165+
# workspace:
166+
# clean: all
167+
# strategy:
168+
# matrix:
169+
# VS_2022:
170+
# poolName: 'Azure Pipelines'
171+
# vmImage: 'windows-2022'
172+
# COMPILER: 'Visual Studio 17 2022'
173+
# ARCH: 'x64'
174+
# PLATFORM: 'win64'
175+
# artifactName: 'Windows-VS-2022-x64'
176+
# pool:
177+
# vmImage: $[ variables['vmImage'] ]
178+
# steps:
179+
# - checkout: self
180+
# fetchDepth: 1
181+
# clean: true
182+
# - task: UsePythonVersion@0
183+
# inputs:
184+
# versionSpec: '3.11'
185+
# - task: PowerShell@2
186+
# displayName: 'Install Dependencies'
187+
# inputs:
188+
# targetType: filePath
189+
# filePath: ./CI/windows/install_deps.ps1
190+
# - task: PowerShell@2
191+
# displayName: "Build libm2k"
192+
# inputs:
193+
# targetType: 'filePath'
194+
# filePath: ./CI/windows/make_windows.ps1
195+
# - ${{ each pyVersion in parameters.pythonVersions }}:
196+
# - task: UsePythonVersion@0
197+
# displayName: Use Python ${{ pyVersion }}
198+
# inputs:
199+
# versionSpec: '${{ pyVersion }}'
200+
# - powershell: |
201+
# $SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY
202+
# $OUTSIDE_BUILD = $SRC_DIR.Parent.FullName
203+
#
204+
# $BUILD_DIR = Join-Path $OUTSIDE_BUILD "libm2k-$env:PLATFORM"
205+
# $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$env:PLATFORM"
206+
#
207+
# Set-Location $TEMP_BUILD_DIR
208+
# python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv
209+
# $env:COMPILE_BINDINGS = $true
210+
# python.exe -m build
211+
# Remove-Item Env:COMPILE_BINDINGS
212+
# Copy-Item -Path "dist/libm2k*.whl" -Destination (Join-Path $BUILD_DIR "dist")
213+
# Set-Location $SRC_DIR
214+
# displayName: Wheel Python ${{ pyVersion }}
215+
# - task: PowerShell@2
216+
# displayName: 'Create libm2k-system-setup installer'
217+
# condition: and(succeeded(), eq(variables['System.JobName'], 'VS_2022'))
218+
# inputs:
219+
# targetType: 'filePath'
220+
# filePath: ./CI/windows/create_installer.ps1
221+
# - task: PublishPipelineArtifact@1
222+
# condition: and(succeeded(), eq(variables['System.JobName'], 'VS_2022'))
223+
# inputs:
224+
# targetPath: '$(Build.ArtifactStagingDirectory)/installer'
225+
# artifactName: 'Libm2k-System-Setup-Exe'
226+
# - task: PowerShell@2
227+
# displayName: "Create ZIPs"
228+
# inputs:
229+
# targetType: 'filePath'
230+
# filePath: ./CI/windows/create_zips.ps1
231+
# - task: PublishPipelineArtifact@1
232+
# condition: succeeded()
233+
# inputs:
234+
# targetPath: '$(Build.ArtifactStagingDirectory)/libm2k-$(PLATFORM)'
235+
# artifactName: '$(artifactName)'
252236

253237

254238

packaging/debian/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
libm2k (@VERSION@) UNRELEASED; urgency=low
2+
3+
* Automated package build.
4+
5+
-- Engineerzone <https://ez.analog.com/community/linux-device-drivers> @DATE@

packaging/debian/control

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Source: libm2k
2+
Section: libs
3+
Priority: optional
4+
Maintainer: Engineerzone <https://ez.analog.com/community/linux-device-drivers>
5+
Build-Depends: debhelper-compat (= 13),
6+
cmake,
7+
libiio-dev,
8+
libgoogle-glog-dev,
9+
libserialport-dev,
10+
swig,
11+
python3-dev,
12+
dh-python,
13+
mono-mcs,
14+
cli-common-dev
15+
Standards-Version: 4.6.0
16+
Homepage: https://github.com/analogdevicesinc/libm2k
17+
Vcs-Git: https://github.com/analogdevicesinc/libm2k.git
18+
Vcs-Browser: https://github.com/analogdevicesinc/libm2k
19+
Rules-Requires-Root: no
20+
21+
Package: libm2k
22+
Architecture: @ARCHITECTURE@
23+
Multi-Arch: same
24+
Depends: libiio (>= 0.24), ${shlibs:Depends}, ${misc:Depends}
25+
Description: Library for interfacing with ADALM2000
26+
libm2k is a C++ library for interfacing with the ADALM2000, a
27+
portable lab for electronics learning and development.
28+
.
29+
This package contains the shared library.
30+
31+
Package: libm2k-dev
32+
Section: libdevel
33+
Architecture: @ARCHITECTURE@
34+
Multi-Arch: same
35+
Depends: libm2k (= ${binary:Version}), ${misc:Depends}
36+
Description: Library for interfacing with ADALM2000 - development files
37+
libm2k is a C++ library for interfacing with the ADALM2000, a
38+
portable lab for electronics learning and development.
39+
.
40+
This package contains the development files.
41+
42+
Package: libm2k-tools
43+
Section: utils
44+
Architecture: @ARCHITECTURE@
45+
Depends: libm2k (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
46+
Description: Command-line tools for ADALM2000
47+
libm2k is a C++ library for interfacing with the ADALM2000, a
48+
portable lab for electronics learning and development.
49+
.
50+
This package contains the m2kcli command-line tool.
51+
52+
Package: python3-libm2k
53+
Section: python
54+
Architecture: @ARCHITECTURE@
55+
Depends: libm2k (= ${binary:Version}), ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}
56+
Description: Python 3 bindings for libm2k
57+
libm2k is a C++ library for interfacing with the ADALM2000, a
58+
portable lab for electronics learning and development.
59+
.
60+
This package contains the Python 3 bindings.
61+
62+
Package: libm2k-csharp
63+
Section: cli-mono
64+
Architecture: @ARCHITECTURE@
65+
Depends: libm2k (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}, ${cli:Depends}
66+
Description: C# bindings for libm2k
67+
libm2k is a C++ library for interfacing with the ADALM2000, a
68+
portable lab for electronics learning and development.
69+
.
70+
This package contains the C# bindings.

packaging/debian/copyright

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: libm2k
3+
Upstream-Contact: Engineerzone <https://ez.analog.com/community/linux-device-drivers>
4+
Source: https://github.com/analogdevicesinc/libm2k
5+
6+
Files: *
7+
Copyright: 2019-2025 Analog Devices Inc.
8+
License: LGPL-2.1+
9+
This library is free software; you can redistribute it and/or
10+
modify it under the terms of the GNU Lesser General Public
11+
License as published by the Free Software Foundation; either
12+
version 2.1 of the License, or (at your option) any later version.
13+
.
14+
This library is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
Lesser General Public License for more details.
18+
.
19+
You should have received a copy of the GNU Lesser General Public
20+
License along with this library; if not, write to the Free Software
21+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22+
.
23+
On Debian systems, the complete text of the GNU Lesser General Public
24+
License version 2.1 can be found in "/usr/share/common-licenses/LGPL-2.1".
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
usr/lib/*/libm2k-sharp-cxx-wrap.so*
2+
usr/lib/cli/
3+
usr/lib/pkgconfig/libm2k-sharp.pc

0 commit comments

Comments
 (0)