Skip to content

Commit 7dcd4c8

Browse files
tomconteTravisEz13
authored andcommitted
Fix build/package/installation scripts for SLES (#5918)
Small changes to the SUSE installation script so that it allows installing on SLES 12+ in addition to openSUSE 42+
1 parent beffdcf commit 7dcd4c8

3 files changed

Lines changed: 38 additions & 12 deletions

File tree

build.psm1

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ function Get-EnvironmentInformation
135135
$environment += @{'IsCentOS' = $LinuxInfo.ID -match 'centos' -and $LinuxInfo.VERSION_ID -match '7'}
136136
$environment += @{'IsFedora' = $LinuxInfo.ID -match 'fedora' -and $LinuxInfo.VERSION_ID -ge 24}
137137
$environment += @{'IsOpenSUSE' = $LinuxInfo.ID -match 'opensuse'}
138-
$environment += @{'IsOpenSUSE13' = $Environment.IsOpenSUSE -and $LinuxInfo.VERSION_ID -match '13'}
138+
$environment += @{'IsSLES' = $LinuxInfo.ID -match 'sles'}
139+
$environment += @{'IsOpenSUSE13' = $Environmenst.IsOpenSUSE -and $LinuxInfo.VERSION_ID -match '13'}
139140
$environment += @{'IsOpenSUSE42.1' = $Environment.IsOpenSUSE -and $LinuxInfo.VERSION_ID -match '42.1'}
140-
$environment += @{'IsRedHatFamily' = $Environment.IsCentOS -or $Environment.IsFedora -or $Environment.IsOpenSUSE}
141+
$environment += @{'IsRedHatFamily' = $Environment.IsCentOS -or $Environment.IsFedora}
142+
$environment += @{'IsSUSEFamily' = $Environment.IsSLES -or $Environment.IsOpenSUSE}
141143

142144
# Workaround for temporary LD_LIBRARY_PATH hack for Fedora 24
143145
# https://github.com/PowerShell/PowerShell/issues/2511
@@ -1486,8 +1488,6 @@ function Get-RedHatPackageManager {
14861488
"yum install -y -q"
14871489
} elseif ($Environment.IsFedora) {
14881490
"dnf install -y -q"
1489-
} elseif ($Environment.IsOpenSUSE) {
1490-
"zypper --non-interactive install"
14911491
} else {
14921492
throw "Error determining package manager for this distribution."
14931493
}
@@ -1577,6 +1577,26 @@ function Start-PSBootstrap {
15771577
$baseCommand = $PackageManager
15781578
}
15791579

1580+
# Install dependencies
1581+
Start-NativeExecution {
1582+
Invoke-Expression "$baseCommand $Deps"
1583+
}
1584+
} elseif ($Environment.IsSUSEFamily) {
1585+
# Build tools
1586+
$Deps += "gcc", "cmake", "make"
1587+
1588+
# Packaging tools
1589+
if ($Package) { $Deps += "ruby-devel", "rpmbuild", "groff" }
1590+
1591+
$PackageManager = "zypper --non-interactive install"
1592+
$baseCommand = "$sudo $PackageManager"
1593+
1594+
# On OpenSUSE 13.2 container, sudo does not exist, so don't use it if not needed
1595+
if($NoSudo)
1596+
{
1597+
$baseCommand = $PackageManager
1598+
}
1599+
15801600
# Install dependencies
15811601
Start-NativeExecution {
15821602
Invoke-Expression "$baseCommand $Deps"

tools/installpsh-suse.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,19 @@ if [[ "$SUDO" -eq "sudo" ]]; then
104104
fi
105105

106106
#Collect any variation details if required for this distro
107-
REV=`cat /etc/SuSE-release | grep 'VERSION' | sed s/.*=\ //`
108-
MAJORREV=`echo $REV | sed 's/\..*//'`
107+
source /etc/os-release
108+
MAJORREV=`echo $VERSION_ID | sed 's/\..*//'`
109109
#END Collect any variation details if required for this distro
110110

111111
#If there are known incompatible versions of this distro, put the test, message and script exit here:
112-
if [[ $MAJORREV < 42 ]]; then
112+
if [[ $ID == 'opensuse' && $MAJORREV < 42 ]]; then
113113
echo "OpenSUSE $VERSION_ID is not supported!" >&2
114114
exit 2
115115
fi
116+
if [[ $ID == 'sles' && $MAJORREV < 12 ]]; then
117+
echo "SLES $VERSION_ID is not supported!" >&2
118+
exit 2
119+
fi
116120

117121
#END Verify The Installer Choice
118122

tools/packaging/packaging.psm1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ function Start-PSPackage {
196196
"deb", "nupkg"
197197
} elseif ($Environment.IsRedHatFamily) {
198198
"rpm", "nupkg"
199+
} elseif ($Environment.IsSUSEFamily) {
200+
"rpm", "nupkg"
199201
} else {
200202
throw "Building packages for $($Environment.LinuxInfo.PRETTY_NAME) is unsupported!"
201203
}
@@ -576,8 +578,8 @@ function New-UnixPackage {
576578
$Iteration += ".$DebDistro"
577579
}
578580
"rpm" {
579-
if (!$Environment.IsRedHatFamily) {
580-
throw ($ErrorMessage -f "Redhat Family")
581+
if (!$Environment.IsRedHatFamily -and !$Environment.IsSUSEFamily) {
582+
throw ($ErrorMessage -f "Redhat or SUSE Family")
581583
}
582584
}
583585
"osxpkg" {
@@ -614,9 +616,9 @@ function New-UnixPackage {
614616

615617
# Destination for symlink to powershell executable
616618
$Link = if ($Environment.IsLinux) {
617-
"/usr/bin"
619+
"/usr/bin/"
618620
} elseif ($Environment.IsMacOS) {
619-
"/usr/local/bin"
621+
"/usr/local/bin/"
620622
}
621623
$linkSource = "/tmp/pwsh"
622624

@@ -1038,7 +1040,7 @@ function New-AfterScripts
10381040
$packagingStrings.RedHatAfterInstallScript -f "$Link/pwsh" | Out-File -FilePath $AfterInstallScript -Encoding ascii
10391041
$packagingStrings.RedHatAfterRemoveScript -f "$Link/pwsh" | Out-File -FilePath $AfterRemoveScript -Encoding ascii
10401042
}
1041-
elseif ($Environment.IsUbuntu -or $Environment.IsDebian) {
1043+
elseif ($Environment.IsUbuntu -or $Environment.IsDebian -or $Environment.IsSUSEFamily) {
10421044
$AfterInstallScript = [io.path]::GetTempFileName()
10431045
$AfterRemoveScript = [io.path]::GetTempFileName()
10441046
$packagingStrings.UbuntuAfterInstallScript -f "$Link/pwsh" | Out-File -FilePath $AfterInstallScript -Encoding ascii

0 commit comments

Comments
 (0)