Skip to content

Commit 3a754d4

Browse files
committed
fix deb package creation
1 parent a71b839 commit 3a754d4

File tree

2 files changed

+40
-38
lines changed

2 files changed

+40
-38
lines changed

.pipelines/DSC-Official.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ trigger: none
44
pr:
55
branches:
66
include:
7-
- onebranch
87
- release/v*
8+
- test/*
99

1010
parameters:
1111
- name: OfficialBuild

helpers.build.psm1

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,7 @@ function Build-DscDebPackage{
18041804
)
18051805

18061806
begin {
1807+
Write-Verbose -Verbose "Starting DEB package creation for architecture '$Architecture'"
18071808
if (!$IsLinux) {
18081809
throw "DEB package creation is only supported on Linux"
18091810
}
@@ -1812,10 +1813,43 @@ function Build-DscDebPackage{
18121813
if ($null -eq (Get-Command dpkg-deb -ErrorAction Ignore)) {
18131814
throw "dpkg-deb not found. Please install dpkg package (e.g., 'sudo apt install dpkg' or 'sudo dnf install dpkg')"
18141815
}
1816+
1817+
if ($null -eq $BuildData) {
1818+
$BuildData = Import-DscBuildData
1819+
}
1820+
$filesForPackage = $BuildData.PackageFiles.Linux
1821+
if ($null -eq $ArtifactDirectory) {
1822+
$artifactDirectory = Get-ArtifactDirectoryPath -Architecture $Architecture -Release:$Release
1823+
}
1824+
1825+
$debTarget = $artifactDirectory.DebTarget
1826+
$bin = $artifactDirectory.Bin
1827+
$productVersion = Get-DscCliVersion
1828+
# Determine DEB architecture
1829+
$debArch = if ($architecture -eq 'current') {
1830+
# Detect current system architecture
1831+
$currentArch = uname -m
1832+
if ($currentArch -eq 'x86_64') {
1833+
'amd64'
1834+
} elseif ($currentArch -eq 'aarch64') {
1835+
'arm64'
1836+
} else {
1837+
throw "Unsupported current architecture for DEB: $currentArch"
1838+
}
1839+
} elseif ($architecture -eq 'aarch64-unknown-linux-musl' -or $architecture -eq 'aarch64-unknown-linux-gnu') {
1840+
'arm64'
1841+
} elseif ($architecture -eq 'x86_64-unknown-linux-musl' -or $architecture -eq 'x86_64-unknown-linux-gnu') {
1842+
'amd64'
1843+
} else {
1844+
throw "Unsupported architecture for DEB: $architecture"
1845+
}
1846+
1847+
Write-Verbose -Verbose "Building DEB package"
1848+
$debPackageName = "dsc_$productVersion-1_$debArch.deb"
1849+
$finalDebPath = Join-Path $artifactDirectory.BinRoot $debPackageName
18151850
}
18161851

18171852
process {
1818-
$debTarget = Join-Path $PSScriptRoot 'bin' $architecture 'deb'
18191853
if (Test-Path $debTarget) {
18201854
Remove-Item $debTarget -Recurse -ErrorAction Stop -Force
18211855
}
@@ -1829,21 +1863,13 @@ function Build-DscDebPackage{
18291863
New-Item -ItemType Directory -Path (Join-Path $debBuildRoot $dir) -Force > $null
18301864
}
18311865

1832-
if ($null -eq $BuildData) {
1833-
$BuildData = Import-DscBuildData
1834-
}
1835-
$filesForPackage = $BuildData.PackageFiles.Linux
1836-
if ($null -eq $ArtifactDirectory) {
1837-
$artifactDirectory = Get-ArtifactDirectoryPath -Architecture $Architecture -Release:$Release
1838-
}
1839-
$target = $artifactDirectory.DebTarget
18401866
$stagingDir = Join-Path $debBuildRoot 'opt' 'dsc'
18411867

18421868
foreach ($file in $filesForPackage) {
1843-
if ((Get-Item "$target\$file") -is [System.IO.DirectoryInfo]) {
1844-
Copy-Item "$target\$file" "$stagingDir\$file" -Recurse -ErrorAction Stop
1869+
if ((Get-Item "$bin\$file") -is [System.IO.DirectoryInfo]) {
1870+
Copy-Item "$bin\$file" "$stagingDir\$file" -Recurse -ErrorAction Stop
18451871
} else {
1846-
Copy-Item "$target\$file" $stagingDir -ErrorAction Stop
1872+
Copy-Item "$bin\$file" $stagingDir -ErrorAction Stop
18471873
}
18481874
}
18491875

@@ -1854,35 +1880,12 @@ function Build-DscDebPackage{
18541880
$symlinkPath = Join-Path $debBuildRoot 'usr' 'bin' 'dsc-bicep-ext'
18551881
New-Item -ItemType SymbolicLink -Path $symlinkPath -Target '/opt/dsc/dsc-bicep-ext' -Force > $null
18561882

1857-
# Determine DEB architecture
1858-
$debArch = if ($architecture -eq 'current') {
1859-
# Detect current system architecture
1860-
$currentArch = uname -m
1861-
if ($currentArch -eq 'x86_64') {
1862-
'amd64'
1863-
} elseif ($currentArch -eq 'aarch64') {
1864-
'arm64'
1865-
} else {
1866-
throw "Unsupported current architecture for DEB: $currentArch"
1867-
}
1868-
} elseif ($architecture -eq 'aarch64-unknown-linux-musl' -or $architecture -eq 'aarch64-unknown-linux-gnu') {
1869-
'arm64'
1870-
} elseif ($architecture -eq 'x86_64-unknown-linux-musl' -or $architecture -eq 'x86_64-unknown-linux-gnu') {
1871-
'amd64'
1872-
} else {
1873-
throw "Unsupported architecture for DEB: $architecture"
1874-
}
1875-
18761883
# Read the control template and replace placeholders
18771884
$controlTemplate = Get-Content "$PSScriptRoot/packaging/deb/control" -Raw
1878-
$productVersion = Get-DscCliVersion
18791885
$controlContent = $controlTemplate.Replace('VERSION_PLACEHOLDER', $productVersion).Replace('ARCH_PLACEHOLDER', $debArch)
18801886
$controlFile = Join-Path $debBuildRoot 'DEBIAN' 'control'
18811887
Set-Content -Path $controlFile -Value $controlContent
18821888

1883-
Write-Verbose -Verbose "Building DEB package"
1884-
$debPackageName = "dsc_$productVersion-1_$debArch.deb"
1885-
18861889
# Build the DEB
18871890
dpkg-deb --build $debBuildRoot 2>&1 > $debTarget/debbuild.log
18881891

@@ -1897,9 +1900,7 @@ function Build-DscDebPackage{
18971900
throw "DEB package was not created"
18981901
}
18991902

1900-
$finalDebPath = Join-Path $PSScriptRoot 'bin' $debPackageName
19011903
Move-Item $builtDeb $finalDebPath -Force
1902-
19031904
Write-Host -ForegroundColor Green "`nDEB package is created at $finalDebPath"
19041905
}
19051906
}
@@ -2126,6 +2127,7 @@ function Build-DscRpmPackage {
21262127
)
21272128

21282129
begin {
2130+
Write-Verbose -Verbose "Starting RPM package creation for architecture '$Architecture'"
21292131
if (!$IsLinux) {
21302132
throw "RPM package creation is only supported on Linux"
21312133
}

0 commit comments

Comments
 (0)