From: Ben Soares Date: Thu, 1 Aug 2024 15:33:39 +0000 (+0100) Subject: JAL-3631 Small change to update.sh. update.ps1 NOT COMPLETED YET X-Git-Tag: Release_2_11_4_0~16^2^2~5 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b7ba02e238c3c5ec8dddabc5fac1bbe247c17bf3;p=jalview.git JAL-3631 Small change to update.sh. update.ps1 NOT COMPLETED YET --- diff --git a/utils/getdown/bin/update.ps1 b/utils/getdown/bin/update.ps1 index 4914dd8..171bece 100644 --- a/utils/getdown/bin/update.ps1 +++ b/utils/getdown/bin/update.ps1 @@ -16,36 +16,26 @@ if ( $IsWindows -eq $null ) { $myIsMacOS = $IsMacOS } -[bool] $headless = 0 -[bool] $gui = 0 -[bool] $help = 0 [bool] $debug = 0 -Switch -Regex ($args) { - "--help|--help-|--version|-h" { - $help = 1 - $headless = 1 +[bool] $userspace = 0 +[bool] $installation = 0 +Switch ($args) { + "--debug" { + $debug = 1 Continue } - "--gui" { - $gui = 1 + "--installation" { + $installation = 1 Continue } - "--headless" { - $headless = 1 + "--userspace" { + $userspace = 1 Continue } - "--debug" { - $debug = 1 - Continue + Default { + throw "Unknown option '$_'. Please use either --installation or --userspace." } } -if ( $help ) { - # --help takes precedence - $gui = 0 -} elseif ( $gui ) { - # --gui takes precedence over --headless - $headless = 0 -} # parent dir of this actual script (which should be the getdown appdir/bin). Follow all symlinks. Like GNU readlink -f function Readlink-f { @@ -66,7 +56,7 @@ function Readlink-f { 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 + # 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 ) } } @@ -83,52 +73,84 @@ if ( $MyInvocation.MyCommand.Path -eq $null ) { throw "Script or link to script must have extension .ps1" } +# args for the JVM +$JVMARGS = @() + $CMDPATH = ( Get-Item $MyInvocation.MyCommand.Path ) $SCRIPTPATH = Readlink-f -Link $CMDPATH $SCRIPT = $SCRIPTPATH $DIR = Split-Path -Path $SCRIPTPATH -Parent - $APPDIR = If ( ( Split-Path -Path $DIR -Leaf ) -eq "bin" ) { Split-Path -Path $DIR -Parent } Else { $DIR } $JAVAEXE = If ( $myIsWindows ) { "java.exe" } Else { "java" } -$JAVA = Join-Path -Path $APPDIR -ChildPath ( "jre/" + $( If ( $myIsMacOS ) { "Contents/Home/" } Else { "" } ) + "bin/${JAVAEXE}" ) -$JVMARGS = @() +if ( $myIsMacOS ) { + $JAVABIN = Join-Path -Path $APPDIR -ChildPath "jre/Contents/Home/bin" + $APPFOLDER = ( $APPDIR -Replace "\.app.*", "" ) + ".app" + $VMOPTIONS = Join-Path -Path $APPFOLDER -ChildPath "Contents/vmoptions.txt" +} else { + $JAVABIN = Join-Path -Path $APPDIR -ChildPath "jre" | Join-Path -ChildPath "bin" + $APPFOLDER = $APPDIR + $VMOPTIONS = Join-Path -Path $APPDIR -ChildPath "jalviewg.vmoptions" +} +$JAVA = Join-Path -Path $JAVABIN -ChildPath $JAVAEXE -if ( $headless ) { - # not setting java.awt.headless in java invocation of running jalview due to problem with Jmol - if ( $help ) { - $JVMARGS += "-Djava.awt.headless=true" - } - # this suppresses the Java icon appearing in the macOS Dock - if ( $myIsMacOS ) { - $JVMARGS += "-Dapple.awt.UIElement=true" - } +$JVMARGS += "-Djava.awt.headless=true" +if ( $myIsMacOS ) { + $JVMARGS += "-Dapple.awt.UIElement=true" } -$GETDOWNTXT = Join-Path -Path $APPDIR -ChildPath "getdown.txt" +$GETDOWNLAUNCHERJAR = Join-Path -Path $APPDIR -ChildPath "getdown-launcher.jar" +$GETDOWNCOREJAR = Join-Path -Path $APPDIR -ChildPath "resource" | Join-Path -ChildPath "getdown-core.jar" +$CHANNELPROPS = Join-Path -Path $APPDIR -ChildPath "channel.props" +$NAME = ( Select-String -Path "${CHANNELPROPS}" -Pattern "^app_name=(.*)$" ).Matches.Groups[1].Value +$US_NAME = $NAME -Replace " ", "_" -# look for bundled JRE. Might not be there if unix installer used in which case just invoke "java" -if ( -not ( Test-Path -Path "${JAVA}" ) ) { - Write-Host "Cannot find bundled ${JAVA}. Using system ${JAVAEXE} and hoping for the best!" - $JAVA = $JAVAEXE +# getdown-launcher classpath +if ( Test-Path -Path $GETDOWNLAUNCHERJAR ) { + $GDL_CLASSPATH = "${GETDOWNLAUNCHERJAR}" +} else { + throw "Cannot find ${GETDOWNLAUNCHERJAR} to run update" } -# launching Jalview with jalview.bin.Launcher instead of getdown-launcher.jar -$CLASS = "jalview.bin.Launcher" -# look for getdown.txt -- needed to create classpath -if ( -not ( Test-Path -Path "${GETDOWNTXT}" ) ) { - throw "Cannot find ${GETDOWNTXT}" +# getdown-core classpath +if ( Test-Path -Path $GETDOWNCOREJAR ) { + $GDC_CLASSPATH = "${GETDOWNCOREJAR}" +} else { + throw "Cannot find ${GETDOWNCOREJAR} to run update" } -# get CLASSPATH from the code= entries in getdown.txt -$CLASSPATH = ( Select-String -Path "${GETDOWNTXT}" -AllMatches -Pattern "code\s*=\s*(.*)$" | foreach { Join-Path -Path $APPDIR -ChildPath $($_.Matches.Groups[1].Value ) } ) -join $( If ( $myIsWindows ) { ";" } Else { ":" } ) + +# USER space update +if ( $userspace ) { + if ( Test-Path -Path $VMOPTIONS ) { + foreach ( $line in Get-Content $VMOPTIONS ) { + $line -Replace "#.*", "" + if ( $line -Match "^-Dsetuserappdirpath=" ) { + $JVMARGS += $line + } + if ( $line -Match "^-Dnouserdefaultappdir=" ) { + $NOUSERUPDATEVALUE = ( $line -Replace ".*=", "" ).ToLower() + if ( $NOUSERUPDATEVALUE -eq "true" ) { + ### HERE + } + $JVMARGS += $line + } + } + } +} + + + # get console width -$COLUMNS = $Host.UI.RawUI.WindowSize.Width -$JVMARGS += "-DCONSOLEWIDTH=${COLUMNS}" $JVMARGS += "-Dgetdownappdir=${APPDIR}" $JVMARGS += "-Dinstaller.appdir=${APPDIR}" -$JVMARGS += "-Dlauncher.appdir=${APPDIR}" $JVMARGS += "-Dlauncher.script=${SCRIPT}" +# look for bundled JRE. Might not be there if unix installer used in which case just invoke "java" +if ( -not ( Test-Path -Path "${JAVA}" ) ) { + Write-Host "Cannot find bundled ${JAVA}. Using system ${JAVAEXE} and hoping for the best!" + $JAVA = $JAVAEXE +} + # we should always have at least one JVMARGS so this is okay $myJvmArgsString = '"' + $($JVMARGS -join '" "') + '"' diff --git a/utils/getdown/bin/update.sh b/utils/getdown/bin/update.sh index f918abf..bfb0ba1 100755 --- a/utils/getdown/bin/update.sh +++ b/utils/getdown/bin/update.sh @@ -88,7 +88,6 @@ if [ "${ISMACOS}" = 1 ]; then fi SYSJAVA=java -GETDOWNTXT="${APPDIR}/getdown.txt" GETDOWNLAUNCHERJAR="${APPDIR}/getdown-launcher.jar" GETDOWNCOREJAR="${APPDIR}/resource/getdown-core.jar" CHANNELPROPS="${APPDIR}/channel.props" @@ -107,7 +106,7 @@ if [ -e "${GETDOWNLAUNCHERJAR}" ]; then GDL_CLASSPATH="${GETDOWNLAUNCHERJAR}" GDL_JARPATHS=( "${GDL_JARPATHS[@]}" "${GETDOWNLAUNCHERJAR}" ) else - echo "Cannot find $( basename "${GETDOWNLAUNCHERJAR}" ) to run update" >&2 + echo "Cannot find ${GETDOWNLAUNCHERJAR} to run update" >&2 exit 3 fi