Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .devcontainer/fedora30/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

FROM mcr.microsoft.com/powershell:preview-fedora-30

# Configure apt and install packages
RUN dnf install -y git procps wget findutils \
&& dnf clean all
16 changes: 16 additions & 0 deletions .devcontainer/fedora30/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"name": "Fedora 30",
"dockerFile": "Dockerfile",

// Uncomment the next line to run commands after the container is created.
"postCreateCommand": "pwsh -c 'import-module ./build.psm1;start-psbootstrap'",

"extensions": [
"ms-azure-devops.azure-pipelines",
"ms-vscode.csharp",
"ms-vscode.powershell",
"DavidAnson.vscode-markdownlint",
"vitaliymaz.vscode-svg-previewer"
]
}
1 change: 1 addition & 0 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function Get-EnvironmentInformation
$environment += @{'IsRedHat7' = $Environment.IsRedHat -and $LinuxInfo.VERSION_ID -match '7' }
$environment += @{'IsOpenSUSE13' = $Environmenst.IsOpenSUSE -and $LinuxInfo.VERSION_ID -match '13'}
$environment += @{'IsOpenSUSE42.1' = $Environment.IsOpenSUSE -and $LinuxInfo.VERSION_ID -match '42.1'}
$environment += @{'IsDebianFamily' = $Environment.IsDebian -or $Environment.IsUbuntu}
$environment += @{'IsRedHatFamily' = $Environment.IsCentOS -or $Environment.IsFedora -or $Environment.IsRedHat}
$environment += @{'IsSUSEFamily' = $Environment.IsSLES -or $Environment.IsOpenSUSE}
$environment += @{'IsAlpine' = $LinuxInfo.ID -match 'alpine'}
Expand Down
112 changes: 87 additions & 25 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ $RepoRoot = (Resolve-Path -Path "$PSScriptRoot/../..").Path

$packagingStrings = Import-PowerShellDataFile "$PSScriptRoot\packaging.strings.psd1"
Import-Module "$PSScriptRoot\..\Xml" -ErrorAction Stop -Force
$DebianDistributions = @("ubuntu.16.04", "ubuntu.18.04", "debian.9")
$DebianDistributions = @("ubuntu.16.04", "ubuntu.18.04", "debian.9", "debian.10", "debian.11")
$RedhatDistributions = @("rhel.7","centos.8")

function Start-PSPackage {
[CmdletBinding(DefaultParameterSetName='Version',SupportsShouldProcess=$true)]
Expand Down Expand Up @@ -426,6 +427,22 @@ function Start-PSPackage {
}
}
}
'rpm' {
$Arguments = @{
Type = 'rpm'
PackageSourcePath = $Source
Name = $Name
Version = $Version
Force = $Force
NoSudo = $NoSudo
}
foreach ($Distro in $Script:RedhatDistributions) {
$Arguments["Distribution"] = $Distro
if ($PSCmdlet.ShouldProcess("Create RPM Package for $Distro")) {
New-UnixPackage @Arguments
}
}
}
default {
$Arguments = @{
Type = $_
Expand Down Expand Up @@ -659,11 +676,18 @@ function New-UnixPackage {
)

DynamicParam {
if ($Type -eq "deb") {
if ($Type -eq "deb" -or $Type -eq 'rpm') {
# Add a dynamic parameter '-Distribution' when the specified package type is 'deb'.
# The '-Distribution' parameter can be used to indicate which Debian distro this pacakge is targeting.
$ParameterAttr = New-Object "System.Management.Automation.ParameterAttribute"
$ValidateSetAttr = New-Object "System.Management.Automation.ValidateSetAttribute" -ArgumentList $Script:DebianDistributions
if($type -eq 'deb')
{
$ValidateSetAttr = New-Object "System.Management.Automation.ValidateSetAttribute" -ArgumentList $Script:DebianDistributions
}
else
{
$ValidateSetAttr = New-Object "System.Management.Automation.ValidateSetAttribute" -ArgumentList $Script:RedHatDistributions
}
$Attributes = New-Object "System.Collections.ObjectModel.Collection``1[System.Attribute]"
$Attributes.Add($ParameterAttr) > $null
$Attributes.Add($ValidateSetAttr) > $null
Expand Down Expand Up @@ -706,6 +730,15 @@ function New-UnixPackage {
$Iteration += ".$DebDistro"
}
"rpm" {
if ($PSBoundParameters.ContainsKey('Distribution')) {
$DebDistro = $PSBoundParameters['Distribution']

} elseif ($Environment.IsRedHatFamily) {
$DebDistro = "rhel.7"
} else {
throw "The current distribution is not supported."
}

$packageVersion = Get-LinuxPackageSemanticVersion -Version $Version
if (!$Environment.IsRedHatFamily -and !$Environment.IsSUSEFamily) {
throw ($ErrorMessage -f "Redhat or SUSE Family")
Expand All @@ -716,6 +749,8 @@ function New-UnixPackage {
if (!$Environment.IsMacOS) {
throw ($ErrorMessage -f "macOS")
}

$DebDistro = 'macOS'
}
}

Expand Down Expand Up @@ -764,7 +799,7 @@ function New-UnixPackage {
New-Item -Force -ItemType SymbolicLink -Path $linkSource -Target "$Destination/pwsh" > $null

# Generate After Install and After Remove scripts
$AfterScriptInfo = New-AfterScripts -Link $Link
$AfterScriptInfo = New-AfterScripts -Link $Link -Distribution $DebDistro

# there is a weird bug in fpm
# if the target of the powershell symlink exists, `fpm` aborts
Expand Down Expand Up @@ -830,6 +865,7 @@ function New-UnixPackage {
-LinkSource $LinkSource `
-LinkDestination $Link `
-AppsFolder $AppsFolder `
-Distribution $DebDistro `
-ErrorAction Stop

# Build package
Expand Down Expand Up @@ -1033,7 +1069,8 @@ function Get-FpmArguments
}
return $true
})]
[String]$AppsFolder
[String]$AppsFolder,
[String]$Distribution = 'rhel.7'
)

$Arguments = @(
Expand All @@ -1051,7 +1088,7 @@ function Get-FpmArguments
"-s", "dir"
)
if ($Environment.IsRedHatFamily) {
$Arguments += @("--rpm-dist", "rhel.7")
$Arguments += @("--rpm-dist", $Distribution)
$Arguments += @("--rpm-os", "linux")
}

Expand Down Expand Up @@ -1092,15 +1129,21 @@ function Test-Distribution
$Distribution
)

if ( ($Environment.IsUbuntu -or $Environment.IsDebian) -and !$Distribution )
if ( $Environment.IsDebianFamily -and !$Distribution )
{
throw "$Distribution is required for a Debian based distribution."
}

if ($Script:DebianDistributions -notcontains $Distribution)
if ( $Environment.IsDebianFamily -and $Script:DebianDistributions -notcontains $Distribution)
{
throw "$Distribution should be one of the following: $Script:DebianDistributions"
}

if ( $Environment.IsRedHatFamily -and $Script:RedHatDistributions -notcontains $Distribution)
{
throw "$Distribution should be one of the following: $Script:RedHatDistributions"
}

return $true
}
function Get-PackageDependencies
Expand All @@ -1114,7 +1157,7 @@ function Get-PackageDependencies
End {
# These should match those in the Dockerfiles, but exclude tools like Git, which, and curl
$Dependencies = @()
if ($Environment.IsUbuntu -or $Environment.IsDebian) {
if ($Environment.IsDebianFamily) {
$Dependencies = @(
"libc6",
"libgcc1",
Expand All @@ -1124,11 +1167,10 @@ function Get-PackageDependencies
"zlib1g"
)

switch ($Distribution) {
"ubuntu.16.04" { $Dependencies += @("libssl1.0.0", "libicu55") }
"ubuntu.17.10" { $Dependencies += @("libssl1.0.0", "libicu57") }
"ubuntu.18.04" { $Dependencies += @("libssl1.0.0", "libicu60") }
"debian.9" { $Dependencies += @("libssl1.0.2", "libicu57") }
switch -regex ($Distribution) {
"ubuntu\.16\.04" { $Dependencies += @("libssl1.0.0", "libicu55") }
"ubuntu\.18\.04" { $Dependencies += @("libssl1.0.0", "libicu60") }
"debian\.(9|10|11)" { $Dependencies += @("libssl1.0.2", "libicu57") }
default { throw "Debian distro '$Distribution' is not supported." }
}
} elseif ($Environment.IsRedHatFamily) {
Expand Down Expand Up @@ -1178,34 +1220,54 @@ function New-AfterScripts
param(
[Parameter(Mandatory)]
[string]
$Link
$Link,

[Parameter(Mandatory)]
[string]
$Distribution
)

if ($Environment.IsRedHatFamily) {
# add two symbolic links to system shared libraries that libmi.so is dependent on to handle
# platform specific changes. This is the only set of platforms needed for this currently
# as Ubuntu has these specific library files in the platform and macOS builds for itself
# against the correct versions.
New-Item -Force -ItemType SymbolicLink -Target "/lib64/libssl.so.10" -Path "$Staging/libssl.so.1.0.0" > $null
New-Item -Force -ItemType SymbolicLink -Target "/lib64/libcrypto.so.10" -Path "$Staging/libcrypto.so.1.0.0" > $null
switch -regex ($Distribution)
{
# add two symbolic links to system shared libraries that libmi.so is dependent on to handle
# platform specific changes. This is the only set of platforms needed for this currently
# as Ubuntu has these specific library files in the platform and macOS builds for itself
# against the correct versions.
'centos\.8' {
New-Item -Force -ItemType SymbolicLink -Target "/lib64/libssl.so.1.1" -Path "$Staging/libssl.so.1.0.0" > $null
New-Item -Force -ItemType SymbolicLink -Target "/lib64/libcrypto.so.1.1.1" -Path "$Staging/libcrypto.so.1.0.0" > $null
}
default {
New-Item -Force -ItemType SymbolicLink -Target "/lib64/libssl.so.10" -Path "$Staging/libssl.so.1.0.0" > $null
New-Item -Force -ItemType SymbolicLink -Target "/lib64/libcrypto.so.10" -Path "$Staging/libcrypto.so.1.0.0" > $null
}
}

$AfterInstallScript = [io.path]::GetTempFileName()
$AfterRemoveScript = [io.path]::GetTempFileName()
$packagingStrings.RedHatAfterInstallScript -f "$Link" | Out-File -FilePath $AfterInstallScript -Encoding ascii
$packagingStrings.RedHatAfterRemoveScript -f "$Link" | Out-File -FilePath $AfterRemoveScript -Encoding ascii
}
elseif ($Environment.IsUbuntu -or $Environment.IsDebian -or $Environment.IsSUSEFamily) {
elseif ($Environment.IsDebianFamily -or $Environment.IsSUSEFamily) {
$AfterInstallScript = [io.path]::GetTempFileName()
$AfterRemoveScript = [io.path]::GetTempFileName()
$packagingStrings.UbuntuAfterInstallScript -f "$Link" | Out-File -FilePath $AfterInstallScript -Encoding ascii
$packagingStrings.UbuntuAfterRemoveScript -f "$Link" | Out-File -FilePath $AfterRemoveScript -Encoding ascii

if ($Environment.IsDebian9) {
switch -regex ($Distribution)
{
# add two symbolic links to system shared libraries that libmi.so is dependent on to handle
# platform specific changes. This appears to be a change in Debian 9; Debian 8 did not need these
# symlinks.
New-Item -Force -ItemType SymbolicLink -Target "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.2" -Path "$Staging/libssl.so.1.0.0" > $null
New-Item -Force -ItemType SymbolicLink -Target "/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2" -Path "$Staging/libcrypto.so.1.0.0" > $null
'debian\.(9|10)' {
New-Item -Force -ItemType SymbolicLink -Target "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.2" -Path "$Staging/libssl.so.1.0.0" > $null
New-Item -Force -ItemType SymbolicLink -Target "/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2" -Path "$Staging/libcrypto.so.1.0.0" > $null
}
'debian\.11' {
New-Item -Force -ItemType SymbolicLink -Target "/usr/lib/x86_64-linux-gnu/libssl.so.1.1" -Path "$Staging/libssl.so.1.0.0" > $null
New-Item -Force -ItemType SymbolicLink -Target "/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1" -Path "$Staging/libcrypto.so.1.0.0" > $null
}
}
}
elseif ($Environment.IsMacOS) {
Expand Down