Skip to content

Commit 440eba3

Browse files
authored
Adding debian package generation support during build. (#74)
1 parent 1b13e63 commit 440eba3

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-2
lines changed

azure-pipelines.yml

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ stages:
4646
is_cross_compile: true
4747
gcc_prefix:
4848
gcc_suffix:
49+
deb_arch:
4950
windows-x64:
5051
poolName: Azure Pipelines
5152
imageName: 'windows-latest'
@@ -55,6 +56,7 @@ stages:
5556
is_cross_compile: false
5657
gcc_prefix:
5758
gcc_suffix:
59+
deb_arch:
5860
windows-arm64:
5961
poolName: Azure Pipelines
6062
imageName: 'windows-latest'
@@ -64,6 +66,7 @@ stages:
6466
is_cross_compile: true
6567
gcc_prefix:
6668
gcc_suffix:
69+
deb_arch:
6770
linux-x86:
6871
poolName: Azure Pipelines
6972
imageName: 'ubuntu-latest'
@@ -73,6 +76,7 @@ stages:
7376
is_cross_compile: true
7477
gcc_prefix: x86_64-linux-gnu-
7578
gcc_suffix: -x86_64-linux-gnu
79+
deb_arch: x86
7680
linux-x64:
7781
poolName: Azure Pipelines
7882
imageName: 'ubuntu-latest'
@@ -82,6 +86,7 @@ stages:
8286
is_cross_compile: false
8387
gcc_prefix:
8488
gcc_suffix:
89+
deb_arch: amd64
8590
linux-arm:
8691
poolName: Azure Pipelines
8792
imageName: 'ubuntu-latest'
@@ -91,6 +96,7 @@ stages:
9196
is_cross_compile: true
9297
gcc_prefix: arm-linux-gnueabi-
9398
gcc_suffix: -arm-linux-gnueabi
99+
deb_arch: arm
94100
linux-arm64:
95101
poolName: Azure Pipelines
96102
imageName: 'ubuntu-latest'
@@ -100,6 +106,7 @@ stages:
100106
is_cross_compile: true
101107
gcc_prefix: aarch64-linux-gnu-
102108
gcc_suffix: -aarch64-linux-gnu
109+
deb_arch: arm64
103110
macos-x64:
104111
poolName: Azure Pipelines
105112
imageName: 'macos-latest'
@@ -109,6 +116,7 @@ stages:
109116
is_cross_compile: false
110117
gcc_prefix:
111118
gcc_suffix:
119+
deb_arch:
112120

113121
pool:
114122
name: $(poolName)
@@ -314,6 +322,35 @@ stages:
314322
sourceFolder: '$(Build.SourcesDirectory)/build/pack'
315323
targetFolder: '$(Build.ArtifactStagingDirectory)/pack'
316324

325+
- bash: |
326+
deb_pkg_name=rnp_$(build.version)-1_$(DEB_ARCH)
327+
echo "Creating deb package: $deb_pkg_name"
328+
329+
echo "Copy binaries to $deb_pkg_name/usr/local/bin"
330+
mkdir -p $deb_pkg_name/usr/local/bin
331+
cp rnp $deb_pkg_name/usr/local/bin/
332+
echo ""
333+
334+
echo "Generating deb package control file: $deb_pkg_name"
335+
mkdir -p $deb_pkg_name/DEBIAN
336+
cat $(Build.SourcesDirectory)/build/templates/debian/control | sed -e 's/{build_version}/$(build.version)/g' -e 's/{deb_arch}/$(DEB_ARCH)/g' > $deb_pkg_name/DEBIAN/control
337+
echo "Deb package control file generated: $deb_pkg_name/DEBIAN/control"
338+
cat $deb_pkg_name/DEBIAN/control
339+
echo ""
340+
341+
echo "Building deb package: $deb_pkg_name"
342+
dpkg-deb --build --root-owner-group $deb_pkg_name
343+
if [ $? -ne 0 ]; then
344+
echo "Build deb package failed!"
345+
exit 1
346+
fi
347+
348+
mkdir -p $(Build.ArtifactStagingDirectory)/debian
349+
cp $deb_pkg_name.deb $(Build.ArtifactStagingDirectory)/debian/
350+
displayName: Build debian packages
351+
condition: and(succeeded(), ne(variables['deb_arch'], ''))
352+
workingDirectory: $(Build.SourcesDirectory)/target/$(TARGET)/release
353+
317354
#
318355
# Publish all pipeline artifacts
319356
#
@@ -396,12 +433,15 @@ stages:
396433
windows-x64:
397434
poolName: Azure Pipelines
398435
imageName: 'windows-latest'
436+
target_short: windows.x64
399437
linux-x64:
400438
poolName: Azure Pipelines
401439
imageName: 'ubuntu-latest'
440+
target_short: linux.x64
402441
macos-x64:
403442
poolName: Azure Pipelines
404443
imageName: 'macos-latest'
444+
target_short: macos.x64
405445

406446
pool:
407447
name: $(poolName)
@@ -446,7 +486,39 @@ stages:
446486
cargo install --path .
447487
displayName: 'Install Rnp from source package'
448488
workingDirectory: $(System.DefaultWorkingDirectory)/Source
449-
489+
490+
- bash: |
491+
echo "Checking rnp exists before installation"
492+
dpkg -l | grep rnp
493+
echo ""
494+
495+
echo "Install rnp from debian package"
496+
sudo dpkg -i ./rnp_$(build.version)-1_amd64.deb
497+
if [ $? -ne 0 ]; then
498+
echo "Failed to install rnp from debian package"
499+
exit 1
500+
fi
501+
echo ""
502+
503+
echo "Check if rnp is successfully installed"
504+
dpkg -l | grep rnp
505+
echo ""
506+
507+
echo "Uninstall rnp"
508+
sudo dpkg -r rnp
509+
if [ $? -ne 0 ]; then
510+
echo "Failed to uninstall rnp"
511+
exit 1
512+
fi
513+
echo ""
514+
515+
echo "Check if rnp is successfully uninstalled"
516+
dpkg -l | grep rnp
517+
echo ""
518+
displayName: 'Install Rnp from debian package'
519+
condition: and(succeeded(), eq(variables['target_short'], 'linux.x64'))
520+
workingDirectory: $(System.DefaultWorkingDirectory)/r12f.rnp/Pack.Pack/Releases/DebianPackages
521+
450522
- task: PublishPipelineArtifact@1
451523
displayName: Publish pipeline artifact
452524
inputs:

build/pack/PackReleasePackages.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,55 +33,64 @@ function PackAllReleasePackages() {
3333
function PackPerFlavorReleases() {
3434
New-Item -ItemType Directory -Path ".\Releases\GithubReleases"
3535
New-Item -ItemType Directory -Path ".\Releases\NugetPackages"
36+
New-Item -ItemType Directory -Path ".\Releases\DebianPackages"
3637

3738
$flavors = @{
3839
"windows.x86" = [PsCustomObject]@{
3940
"Root" = "Build.Build.windowsx86";
4041
"Target" = "i686-pc-windows-msvc";
4142
"PackZip" = $true;
4243
"PackTar" = $false;
44+
"CopyDebian" = $false;
4345
};
4446
"windows.x64" = [PsCustomObject]@{
4547
"Root" = "Build.Build.windowsx64";
4648
"Target" = "x86_64-pc-windows-msvc";
4749
"PackZip" = $true;
4850
"PackTar" = $false;
51+
"CopyDebian" = $false;
4952
};
5053
"windows.arm64" = [PsCustomObject]@{
5154
"Root" = "Build.Build.windowsarm64";
5255
"Target" = "aarch64-pc-windows-msvc";
5356
"PackZip" = $true;
5457
"PackTar" = $false;
58+
"CopyDebian" = $false;
5559
};
5660
"linux.x86" = [PsCustomObject]@{
5761
"Root" = "Build.Build.linuxx86";
5862
"Target" = "i686-unknown-linux-gnu";
5963
"PackZip" = $false;
6064
"PackTar" = $true;
65+
"CopyDebian" = $true;
6166
};
6267
"linux.x64" = [PsCustomObject]@{
6368
"Root" = "Build.Build.linuxx64";
6469
"Target" = "x86_64-unknown-linux-gnu";
6570
"PackZip" = $false;
6671
"PackTar" = $true;
72+
"CopyDebian" = $true;
6773
};
6874
"linux.arm" = [PsCustomObject]@{
6975
"Root" = "Build.Build.linuxarm";
7076
"Target" = "arm-unknown-linux-gnueabi";
7177
"PackZip" = $false;
7278
"PackTar" = $true;
79+
"CopyDebian" = $true;
7380
};
7481
"linux.arm64" = [PsCustomObject]@{
7582
"Root" = "Build.Build.linuxarm64";
7683
"Target" = "aarch64-unknown-linux-gnu";
7784
"PackZip" = $false;
7885
"PackTar" = $true;
86+
"CopyDebian" = $true;
7987
};
8088
"macos.x64" = [PsCustomObject]@{
8189
"Root" = "Build.Build.macosx64";
8290
"Target" = "x86_64-apple-darwin";
8391
"PackZip" = $false;
8492
"PackTar" = $true;
93+
"CopyDebian" = $false;
8594
};
8695
}
8796

@@ -90,7 +99,7 @@ function PackPerFlavorReleases() {
9099
$settings = $_.Value
91100
$root = $_.Value.Root
92101
$target = $_.Value.Target
93-
Write-Host "Processing build: Flavor = $flavor, Root = $root, Target = $target, PackZip = $($settings.PackZip), PackTar = $($settings.PackTar)"
102+
Write-Host "Processing build: Flavor = $flavor, Root = $root, Target = $target, PackZip = $($settings.PackZip), PackTar = $($settings.PackTar), CopyDebian = $($settings.CopyDebian)"
94103

95104
# Create zip for github release
96105
if ($settings.PackZip) {
@@ -119,6 +128,9 @@ function PackPerFlavorReleases() {
119128
Copy-Item -Path .\$root\bin\* $nugetProjectRoot -Verbose -Force
120129
EvaluateTemplateFile ".\Build.Build.windowsx64\templates\nuget_packages\rnp_nupkg.csproj" "$nugetProjectRoot\rnp_nupkg.csproj" $flavor $target
121130
dotnet pack $nugetProjectRoot\rnp_nupkg.csproj -o .\Releases\NugetPackages
131+
132+
# Copy debian packages
133+
Copy-Item -Path .\$root\debian\* ".\Releases\DebianPackages" -Verbose -Force
122134
}
123135
}
124136

build/templates/debian/control

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Package: Rnp
2+
Version: {build_version}
3+
Architecture: {deb_arch}
4+
Maintainer: r12f <r12f.code@gmail.com>
5+
Description: A simple layer 4 ping tool for cloud.

0 commit comments

Comments
 (0)