Skip to content

Commit a5b3170

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

File tree

13 files changed

+256
-103
lines changed

13 files changed

+256
-103
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: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
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+
MAJOR=$(grep "set(LIBM2K_VERSION_MAJOR" CMakeLists.txt | sed 's/.*MAJOR \([0-9]*\)).*/\1/')
10+
MINOR=$(grep "set(LIBM2K_VERSION_MINOR" CMakeLists.txt | sed 's/.*MINOR \([0-9]*\)).*/\1/')
11+
PATCH=$(grep "set(LIBM2K_VERSION_PATCH" CMakeLists.txt | sed 's/.*PATCH \([0-9]*\)).*/\1/')
12+
echo "${MAJOR}.${MINOR}.${PATCH}"
13+
}
1014

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
15+
handle_default() {
16+
VERSION=$(get_version)
17+
ARCHITECTURE=$(dpkg --print-architecture)
18+
SOURCE_DIR=$(grep "^Source:" packaging/debian/control | cut -d' ' -f2)
19+
CURRENT_DIR=$(basename "$PWD")
20+
21+
# Copy debian directory from packaging to root
22+
cp -r ${TOP_DIR}/packaging/debian ${TOP_DIR}/debian
23+
24+
# Replace placeholders in debian template files
25+
sed -i "s/@VERSION@/${VERSION}/" ${TOP_DIR}/debian/changelog
26+
sed -i "s/@DATE@/$(date -R)/" ${TOP_DIR}/debian/changelog
27+
sed -i "s/@ARCHITECTURE@/${ARCHITECTURE}/" ${TOP_DIR}/debian/control
28+
29+
# Create orig tarball
30+
pushd ..
31+
tar czf ${SOURCE_DIR}_${VERSION}.orig.tar.gz ${CURRENT_DIR}
32+
popd
33+
34+
# Build debian packages
35+
debuild
36+
37+
# Move generated packages to build directory
38+
mkdir -p ${TOP_DIR}/build
39+
mv ${TOP_DIR}/../libm2k*.deb ${TOP_DIR}/build/ 2>/dev/null || true
40+
mv ${TOP_DIR}/../libm2k*.changes ${TOP_DIR}/build/ 2>/dev/null || true
41+
mv ${TOP_DIR}/../libm2k*.buildinfo ${TOP_DIR}/build/ 2>/dev/null || true
42+
mv ${TOP_DIR}/../python3-libm2k*.deb ${TOP_DIR}/build/ 2>/dev/null || true
43+
44+
# List generated packages
45+
ls -la ${TOP_DIR}/build/
2646
}
2747

2848
handle_doxygen() {
@@ -39,4 +59,4 @@ handle_ubuntu_docker() {
3959
handle_default
4060
}
4161

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

azure-pipelines.yml

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -170,85 +170,85 @@ jobs:
170170
TWINE_USERNAME: '__token__'
171171
TWINE_PASSWORD: $(TWINE_PASSWORD)
172172
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)'
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)'
252252

253253

254254

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: ${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
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
usr/include/libm2k/
2+
usr/lib/*/libm2k.so
3+
usr/lib/*/pkgconfig/libm2k.pc
4+
usr/lib/*/cmake/libm2k/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
usr/bin/m2kcli

packaging/debian/libm2k.install

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
usr/lib/*/libm2k.so.*
2+
etc/udev/rules.d/

0 commit comments

Comments
 (0)