Skip to content

Commit 7191f1a

Browse files
committed
fix rpm package
1 parent 3a754d4 commit 7191f1a

File tree

1 file changed

+37
-30
lines changed

1 file changed

+37
-30
lines changed

helpers.build.psm1

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,7 @@ function Build-DscMsixPackage {
19331933
)
19341934

19351935
begin {
1936+
Write-Verbose -Verbose "Starting MSIX package creation for architecture '$Architecture' and package type '$packageType'"
19361937
if (!$IsWindows) {
19371938
throw "MSIX packaging is only supported on Windows"
19381939
}
@@ -2136,26 +2137,6 @@ function Build-DscRpmPackage {
21362137
if ($null -eq (Get-Command rpmbuild -ErrorAction Ignore)) {
21372138
throw "rpmbuild not found. Please install rpm-build package (e.g., 'sudo apt install rpm build-essential' or 'sudo dnf install rpm-build')"
21382139
}
2139-
}
2140-
2141-
process {
2142-
$rpmTarget = Join-Path $PSScriptRoot 'bin' $architecture 'rpm'
2143-
if (Test-Path $rpmTarget) {
2144-
Remove-Item $rpmTarget -Recurse -ErrorAction Stop -Force
2145-
}
2146-
2147-
New-Item -ItemType Directory $rpmTarget > $null
2148-
2149-
# Create RPM build directories
2150-
$rpmBuildRoot = Join-Path $rpmTarget 'rpmbuild'
2151-
$rpmDirs = @('BUILD', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS')
2152-
foreach ($dir in $rpmDirs) {
2153-
New-Item -ItemType Directory -Path (Join-Path $rpmBuildRoot $dir) -Force > $null
2154-
}
2155-
2156-
# Create a staging directory for the files
2157-
$stagingDir = Join-Path $rpmBuildRoot 'SOURCES' 'dsc_files'
2158-
New-Item -ItemType Directory $stagingDir > $null
21592140

21602141
if ($null -eq $BuildData) {
21612142
$BuildData = Import-DscBuildData
@@ -2164,16 +2145,10 @@ function Build-DscRpmPackage {
21642145
if ($null -eq $ArtifactDirectory) {
21652146
$artifactDirectory = Get-ArtifactDirectoryPath -Architecture $Architecture -Release:$Release
21662147
}
2167-
$target = $artifactDirectory.RootTarget
2168-
2169-
foreach ($file in $filesForPackage) {
2170-
if ((Get-Item "$target\$file") -is [System.IO.DirectoryInfo]) {
2171-
Copy-Item "$target\$file" "$stagingDir\$file" -Recurse -ErrorAction Stop
2172-
} else {
2173-
Copy-Item "$target\$file" $stagingDir -ErrorAction Stop
2174-
}
2175-
}
21762148

2149+
$rpmTarget = $artifactDirectory.RpmTarget
2150+
$bin = $artifactDirectory.Bin
2151+
$productVersion = Get-DscCliVersion
21772152
# Determine RPM architecture
21782153
$rpmArch = if ($architecture -eq 'current') {
21792154
# Detect current system architecture
@@ -2193,9 +2168,39 @@ function Build-DscRpmPackage {
21932168
throw "Unsupported architecture for RPM: $architecture"
21942169
}
21952170

2171+
Write-Verbose -Verbose "Building RPM package"
2172+
$rpmPackageName = "dsc_$productVersion-1_$rpmArch.rpm"
2173+
$finalRpmPath = Join-Path $artifactDirectory.BinRoot $rpmPackageName
2174+
}
2175+
2176+
process {
2177+
if (Test-Path $rpmTarget) {
2178+
Remove-Item $rpmTarget -Recurse -ErrorAction Stop -Force
2179+
}
2180+
2181+
New-Item -ItemType Directory $rpmTarget > $null
2182+
2183+
# Create RPM build directories
2184+
$rpmBuildRoot = Join-Path $rpmTarget 'rpmbuild'
2185+
$rpmDirs = @('BUILD', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS')
2186+
foreach ($dir in $rpmDirs) {
2187+
New-Item -ItemType Directory -Path (Join-Path $rpmBuildRoot $dir) -Force > $null
2188+
}
2189+
2190+
# Create a staging directory for the files
2191+
$stagingDir = Join-Path $rpmBuildRoot 'SOURCES' 'dsc_files'
2192+
New-Item -ItemType Directory $stagingDir > $null
2193+
2194+
foreach ($file in $filesForPackage) {
2195+
if ((Get-Item "$bin\$file") -is [System.IO.DirectoryInfo]) {
2196+
Copy-Item "$bin\$file" "$stagingDir\$file" -Recurse -ErrorAction Stop
2197+
} else {
2198+
Copy-Item "$bin\$file" $stagingDir -ErrorAction Stop
2199+
}
2200+
}
2201+
21962202
# Read the spec template and replace placeholders
21972203
$specTemplate = Get-Content "$PSScriptRoot/packaging/rpm/dsc.spec" -Raw
2198-
$productVersion = Get-DscCliVersion
21992204
$specContent = $specTemplate.Replace('VERSION_PLACEHOLDER', $productVersion.Replace('-','~')).Replace('ARCH_PLACEHOLDER', $rpmArch)
22002205
$specFile = Join-Path $rpmBuildRoot 'SPECS' 'dsc.spec'
22012206
Set-Content -Path $specFile -Value $specContent
@@ -2243,6 +2248,7 @@ function Build-DscZipPackage {
22432248
)
22442249

22452250
begin {
2251+
Write-Verbose -Verbose "Starting ZIP package creation for architecture '$Architecture'"
22462252
if ($Architecture -eq 'current') {
22472253
throw 'Building a zip package requires a specific architecture targeting Windows'
22482254
}
@@ -2306,6 +2312,7 @@ function Build-DscTgzPackage {
23062312
)
23072313

23082314
begin {
2315+
Write-Verbose -Verbose "Starting tgz package creation for architecture '$Architecture'"
23092316
if ($Architecture -eq 'current') {
23102317
throw 'Building a tgz package requires a specific architecture targeting Linux or macOS'
23112318
}

0 commit comments

Comments
 (0)