From: Ben Soares Date: Fri, 2 Aug 2024 16:49:18 +0000 (+0100) Subject: JAL-3631 made Readlink-f work in powershell. Need to test once more in Windows\! X-Git-Tag: Release_2_11_4_0~16^2^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0c1ac54b34ca612edf58204cd1743cdd5f71b9aa;p=jalview.git JAL-3631 made Readlink-f work in powershell. Need to test once more in Windows\! --- diff --git a/utils/getdown/bin/jalview.ps1 b/utils/getdown/bin/jalview.ps1 index 382b22e..3445aad 100755 --- a/utils/getdown/bin/jalview.ps1 +++ b/utils/getdown/bin/jalview.ps1 @@ -50,32 +50,21 @@ if ( $help ) { # parent dir of this actual script (which should be the getdown appdir/bin). Follow all symlinks. Like GNU readlink -f function Readlink-f { Param($Link) - $Return = $null - $c = 0 - $max = 100 # just in case we end up in a loop - [bool] $found = 0 - $file = Get-Item -Path $Link - $prevfile = $null - While ( $c -lt $max -and "${file}" -ne "${prevfile}" -and -not $found ) { - $prevfile = $file - [string] $target = ( $file ).Target - If ( $target -eq $null -or ( $file ).LinkType -ne "SymbolicLink" ) { - $Return = $file - $found = 1 - } Else { - If ( $( Split-Path -Path $target -IsAbsolute ) ) { - $file = Get-Item -Path $target - } Else { - # symbolic link is relative: combine previous link parent dir with the link target and resolve - $file = Get-Item -Path ( Join-Path -Path ( Split-Path -Path $prevfile -Parent ) -ChildPath $target -Resolve ) - } - } - $c++ + $dirs = @() + $dir = Convert-Path $Link + while ( $dir ) { + $dirs = @( Split-Path $dir -Leaf ) + $dirs + $dir = Split-Path $dir -Parent } - if ( -not $found ) { - throw "Could not determine path to actual file $( Split-Path -Path $Link -Leaf )" + $real = Get-Item "/" + foreach ($d in $dirs) { + $real = Join-Path -Path $real -ChildPath $d + $item = Get-Item $real + if ($item.Target -ne $null) { + $real = Convert-Path $item.Target + } } - $Return + $real } # Avert problem with unix version of powershell and tell user the reason (Windows must always have .ps1 extension) diff --git a/utils/getdown/bin/update.ps1 b/utils/getdown/bin/update.ps1 index 22b7405..4928573 100644 --- a/utils/getdown/bin/update.ps1 +++ b/utils/getdown/bin/update.ps1 @@ -47,32 +47,21 @@ if ( -not ( $userspace -or -$installation ) ) { # parent dir of this actual script (which should be the getdown appdir/bin). Follow all symlinks. Like GNU readlink -f function Readlink-f { Param($Link) - $Return = $null - $c = 0 - $max = 100 # just in case we end up in a loop - [bool] $found = 0 - $file = Get-Item -Path $Link - $prevfile = $null - While ( $c -lt $max -and "${file}" -ne "${prevfile}" -and -not $found ) { - $prevfile = $file - [string] $target = ( $file ).Target - If ( $target -eq $null -or ( $file ).LinkType -ne "SymbolicLink" ) { - $Return = $file - $found = 1 - } Else { - If ( $( Split-Path -Path $target -IsAbsolute ) ) { - $file = Get-Item -Path $target - } Else { - # symbolic link is relative: combine previous link parent dir with the link target and resolve - $file = Get-Item -Path ( Join-Path -Path ( Split-Path -Path $prevfile -Parent ) -ChildPath $target -Resolve ) - } - } - $c++ + $dirs = @() + $dir = Convert-Path $Link + while ( $dir ) { + $dirs = @( Split-Path $dir -Leaf ) + $dirs + $dir = Split-Path $dir -Parent } - if ( -not $found ) { - throw "Could not determine path to actual file $( Split-Path -Path $Link -Leaf )" + $real = Get-Item "/" + foreach ($d in $dirs) { + $real = Join-Path -Path $real -ChildPath $d + $item = Get-Item $real + if ($item.Target -ne $null) { + $real = Convert-Path $item.Target + } } - $Return + $real } # Avert problem with unix version of powershell and tell user the reason (Windows must always have .ps1 extension) @@ -189,8 +178,8 @@ if ( -not ( Test-Path -Path $JAVA ) ) { } # we should always have at least one JVMARGS and GDL_ARGS so this is okay -$myJvmArgsString = '`"' + $($JVMARGS -join '`" `"') + '`"' -$myGdlArgsString = '`"' + $($GDL_ARGS -join '`" `"') + '`"' +$myJvmArgsString = '"' + $($JVMARGS -join '" "') + '"' +$myGdlArgsString = '"' + $($GDL_ARGS -join '" "') + '"' # quote the args and the command (in case of spaces) with escape chars (`) and precede with & to indicate a command not string $COMMAND = "& `"${JAVA}`" ${myJvmArgsString} -cp `"${GDL_CLASSPATH}`" com.threerings.getdown.launcher.GetdownApp ${myGdlArgsString}"