$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 {
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 )
}
}
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 '" "') + '"'