mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Add powershell to /etc/shells (#1939)
Manages /etc/shells with after (un)install scripts for CentOS and Ubuntu Fixes #1913
This commit is contained in:
1 parent
35f046a8df
commit
77a37f7773
1 file changed
+70
-2
+70
-2
@@ -1046,6 +1046,61 @@ It consists of a cross-platform command-line shell and associated scripting lang
|
||||
|
||||
New-Item -Force -ItemType SymbolicLink -Path "/tmp/$Name" -Target "$Destination/$Name" >$null
|
||||
|
||||
if ($IsCentos) {
|
||||
$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
|
||||
}
|
||||
elseif ($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
|
||||
}
|
||||
|
||||
|
||||
# there is a weird bug in fpm
|
||||
# if the target of the powershell symlink exists, `fpm` aborts
|
||||
# with a `utime` error on OS X.
|
||||
@@ -1128,12 +1183,19 @@ It consists of a cross-platform command-line shell and associated scripting lang
|
||||
"--depends", $libunwind,
|
||||
"--depends", $libicu,
|
||||
"-t", $Type,
|
||||
"-s", "dir",
|
||||
"-s", "dir"
|
||||
)
|
||||
if ($AfterInstallScript) {
|
||||
$Arguments += @("--after-install", $AfterInstallScript)
|
||||
}
|
||||
if ($AfterRemoveScript) {
|
||||
$Arguments += @("--after-remove", $AfterRemoveScript)
|
||||
}
|
||||
$Arguments += @(
|
||||
"$Staging/=$Destination/",
|
||||
"$GzipFile=$ManFile",
|
||||
"/tmp/$Name=$Link"
|
||||
)
|
||||
|
||||
# Build package
|
||||
try {
|
||||
$Output = Start-NativeExecution { fpm $Arguments }
|
||||
@@ -1145,6 +1207,12 @@ It consists of a cross-platform command-line shell and associated scripting lang
|
||||
Move-Item $hack_dest $symlink_dest
|
||||
}
|
||||
}
|
||||
if ($AfterInstallScript) {
|
||||
Remove-Item -erroraction 'silentlycontinue' $AfterInstallScript
|
||||
}
|
||||
if ($AfterRemoveScript) {
|
||||
Remove-Item -erroraction 'silentlycontinue' $AfterRemoveScript
|
||||
}
|
||||
}
|
||||
|
||||
# Magic to get path output
|
||||
|
||||
Reference in new issue
Block a user