mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-24 02:04:07 +08:00
Move packaging strings to .psd1 file (#4333)
Move here strings in packaging module to psd1 file for easier maintenance of strings and code.
This commit is contained in:
parent
f3dd2f0414
commit
1c42ed253a
@ -1,4 +1,7 @@
|
||||
$Environment = Get-EnvironmentInformation
|
||||
|
||||
$packagingStrings = Import-PowerShellDataFile "$PSScriptRoot\packaging.strings.psd1"
|
||||
|
||||
function Start-PSPackage {
|
||||
[CmdletBinding(DefaultParameterSetName='Version',SupportsShouldProcess=$true)]
|
||||
param(
|
||||
@ -245,10 +248,7 @@ function New-UnixPackage {
|
||||
}
|
||||
}
|
||||
|
||||
$Description = @"
|
||||
PowerShell is an automation and configuration management platform.
|
||||
It consists of a cross-platform command-line shell and associated scripting language.
|
||||
"@
|
||||
$Description = $packagingStrings.Description
|
||||
|
||||
# Suffix is used for side-by-side package installation
|
||||
$Suffix = $Name -replace "^powershell"
|
||||
@ -308,55 +308,14 @@ It consists of a cross-platform command-line shell and associated scripting lang
|
||||
|
||||
$AfterInstallScript = [io.path]::GetTempFileName()
|
||||
$AfterRemoveScript = [io.path]::GetTempFileName()
|
||||
@'
|
||||
#!/bin/sh
|
||||
if [ ! -f /etc/shells ] ; then
|
||||
echo "{0}" > /etc/shells
|
||||
else
|
||||
grep -q "^{0}$" /etc/shells || echo "{0}" >> /etc/shells
|
||||
fi
|
||||
'@ -f "$Link/$Name" | Out-File -FilePath $AfterInstallScript -Encoding ascii
|
||||
|
||||
@'
|
||||
if [ "$1" = 0 ] ; then
|
||||
if [ -f /etc/shells ] ; then
|
||||
TmpFile=`/bin/mktemp /tmp/.powershellmXXXXXX`
|
||||
grep -v '^{0}$' /etc/shells > $TmpFile
|
||||
cp -f $TmpFile /etc/shells
|
||||
rm -f $TmpFile
|
||||
fi
|
||||
fi
|
||||
'@ -f "$Link/$Name" | Out-File -FilePath $AfterRemoveScript -Encoding ascii
|
||||
$packagingStrings.RedHatAfterInstallScript -f "$Link/$Name" | Out-File -FilePath $AfterInstallScript -Encoding ascii
|
||||
$packagingStrings.RedHatAfterRemoveScript -f "$Link/$Name" | Out-File -FilePath $AfterRemoveScript -Encoding ascii
|
||||
}
|
||||
elseif ($Environment.IsUbuntu) {
|
||||
$AfterInstallScript = [io.path]::GetTempFileName()
|
||||
$AfterRemoveScript = [io.path]::GetTempFileName()
|
||||
@'
|
||||
#!/bin/sh
|
||||
set -e
|
||||
case "$1" in
|
||||
(configure)
|
||||
add-shell "{0}"
|
||||
;;
|
||||
(abort-upgrade|abort-remove|abort-deconfigure)
|
||||
exit 0
|
||||
;;
|
||||
(*)
|
||||
echo "postinst called with unknown argument '$1'" >&2
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
'@ -f "$Link/$Name" | Out-File -FilePath $AfterInstallScript -Encoding ascii
|
||||
|
||||
@'
|
||||
#!/bin/sh
|
||||
set -e
|
||||
case "$1" in
|
||||
(remove)
|
||||
remove-shell "{0}"
|
||||
;;
|
||||
esac
|
||||
'@ -f "$Link/$Name" | Out-File -FilePath $AfterRemoveScript -Encoding ascii
|
||||
$packagingStrings.UbuntuAfterInstallScript -f "$Link/$Name" | Out-File -FilePath $AfterInstallScript -Encoding ascii
|
||||
$packagingStrings.UbuntuAfterRemoveScript -f "$Link/$Name" | Out-File -FilePath $AfterRemoveScript -Encoding ascii
|
||||
}
|
||||
|
||||
|
||||
|
51
tools/packaging/packaging.strings.psd1
Normal file
51
tools/packaging/packaging.strings.psd1
Normal file
@ -0,0 +1,51 @@
|
||||
@{
|
||||
Description = @'
|
||||
PowerShell is an automation and configuration management platform.
|
||||
It consists of a cross-platform command-line shell and associated scripting language.
|
||||
'@
|
||||
|
||||
RedHatAfterInstallScript = @'
|
||||
#!/bin/sh
|
||||
if [ ! -f /etc/shells ] ; then
|
||||
echo "{0}" > /etc/shells
|
||||
else
|
||||
grep -q "^{0}$" /etc/shells || echo "{0}" >> /etc/shells
|
||||
fi
|
||||
'@
|
||||
|
||||
RedHatAfterRemoveScript = @'
|
||||
if [ "$1" = 0 ] ; then
|
||||
if [ -f /etc/shells ] ; then
|
||||
TmpFile=`/bin/mktemp /tmp/.powershellmXXXXXX`
|
||||
grep -v '^{0}$' /etc/shells > $TmpFile
|
||||
cp -f $TmpFile /etc/shells
|
||||
rm -f $TmpFile
|
||||
fi
|
||||
fi
|
||||
'@
|
||||
UbuntuAfterInstallScript = @'
|
||||
#!/bin/sh
|
||||
set -e
|
||||
case "$1" in
|
||||
(configure)
|
||||
add-shell "{0}"
|
||||
;;
|
||||
(abort-upgrade|abort-remove|abort-deconfigure)
|
||||
exit 0
|
||||
;;
|
||||
(*)
|
||||
echo "postinst called with unknown argument '$1'" >&2
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
'@
|
||||
UbuntuAfterRemoveScript = @'
|
||||
#!/bin/sh
|
||||
set -e
|
||||
case "$1" in
|
||||
(remove)
|
||||
remove-shell "{0}"
|
||||
;;
|
||||
esac
|
||||
'@
|
||||
}
|
Loading…
Reference in New Issue
Block a user