$myIsMacOS = $IsMacOS
}
+$USAGE = "Please use either --installation or --userspace."
+
[bool] $debug = 0
[bool] $userspace = 0
[bool] $installation = 0
Continue
}
Default {
- throw "Unknown option '$_'. Please use either --installation or --userspace."
+ throw "Unknown option '$_'. ${USAGE}."
}
}
+if ( -not ( $userspace -or -$installation ) ) {
+ Write-Output "${USAGE}."
+ Exit
+}
+
# 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)
# USER space update
if ( $userspace ) {
if ( Test-Path -Path $VMOPTIONS ) {
+ $LINENUM = 0
foreach ( $line in Get-Content $VMOPTIONS ) {
+ # remove comments
$line -Replace "#.*", ""
+ # remove leading and trailing whitespace
+ $line -Replace "(^\s+|\s+$)", ""
+ $LINENUM++
+
if ( $line -Match "^-Dsetuserappdirpath=" ) {
$JVMARGS += $line
}
if ( $line -Match "^-Dnouserdefaultappdir=" ) {
$NOUSERUPDATEVALUE = ( $line -Replace ".*=", "" ).ToLower()
if ( $NOUSERUPDATEVALUE -eq "true" ) {
- ### HERE
+ throw "Cannot perform manual user-space update when user-space updates are disabled.`nSee line ${LINENUM} (${line}) in file '${VMOPTIONS}'."
}
$JVMARGS += $line
}
}
}
+ $JVMARGS += "-Duserdefaultappdir=true"
+ $JVMARGS += "-Dnouserdefaultappdir=false"
}
+# INSTALLATION update
+if ( $installation ) {
+ $JVMARGS += "-Duserdefaultappdir=false"
+ $JVMARGS += "-Dnouserdefaultappdir=true"
+ $JVMARGS += "-Dlauncher.appdir=${APPDIR}"
+ $JVMARGS += "-Dappdir=${APPDIR}"
+}
+# setting the appdir arg[0] and appid arg[1] to blank values
+# so appDir is determined by EnvConfig.getUserAppdir() or appdir property
+# and appId is passed as system property appid
+$GDL_ARGS = @( "", "" )
-
-# get console width
-$JVMARGS += "-Dgetdownappdir=${APPDIR}"
+# both USER and INSTALLATION updates
$JVMARGS += "-Dinstaller.appdir=${APPDIR}"
+$JVMARGS += "-Dinstaller.application_folder=${US_NAME}"
$JVMARGS += "-Dlauncher.script=${SCRIPT}"
+$JVMARGS += "-Dlauncher.update=true"
+$JVMARGS += "-Dchannel.app_name=${NAME}"
+$JVMARGS += "-Dappid=jalview"
+
+# IMPORTANT! tell getdown to update jalview withouth launching
+$JVMARGS += "-Dsilent=true"
+
+# add these Just In Case although jalview shouldn't be launched due to -Dsilent=true
+$GDL_ARGS += ( "--headless", "--quit", "--nojavaconsole", "--nosplash", "--nonews" )
# look for bundled JRE. Might not be there if unix installer used in which case just invoke "java"
-if ( -not ( Test-Path -Path "${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
+# we should always have at least one JVMARGS and GDL_ARGS so this is okay
$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
-if ( $myArgs.count -eq 0 ) {
- $COMMAND = "& `"${JAVA}`" ${myJvmArgsString} -cp `"${CLASSPATH}`" $CLASS"
-} else {
- $myArgsString = '"' + $($myArgs -join '" "') + '"'
- $COMMAND = "& `"${JAVA}`" ${myJvmArgsString} -cp `"${CLASSPATH}`" $CLASS ${myArgsString}"
-}
+$COMMAND = "& `"${JAVA}`" ${myJvmArgsString} -cp `"${GDL_CLASSPATH}`" com.threerings.getdown.launcher.GetdownApp ${myGdlArgsString}"
-if ( $debug -or $help ) {
+if ( $debug ) {
Write-Error -Message "Shell running: ${COMMAND}"
}
Invoke-Expression -Command ${COMMAND}
+# move updated getdown-launcher.jar into place
+$COMMAND = "& `"${JAVA}`" ${myJvmArgsString} -cp `"${GDC_CLASSPATH}`" jalview.bin.GetdownLauncherUpdate"
+
+if ( $debug ) {
+ Write-Error -Message "Shell running: ${COMMAND}"
+}
+
+Invoke-Expression -Command ${COMMAND}
ISMACOS=1
fi
+USAGE="Please use either --installation or --userspace"
+
DEBUG=0
USERSPACE=0
INSTALLATION=0
USERSPACE=1
;;
*)
- echo "Unknown option '${ARG}'. Please use either --installation or --userspace." >&2
+ echo "Unknown option '${ARG}'. ${USAGE}." >&2
exit 2
esac
done
+if [ "${USERSPACE}${INSTALLATION}" = "00" ]; then
+ echo "${USAGE}."
+ exit
+fi
+
# this whole next part is because there's no readlink -f in Darwin
function readlinkf() {
FINDFILE="$1"
while IFS= read -r line; do
# remove comments
line=${line%%#*}
- # remove trailing whitespace
+ # remove leading and trailing whitespace
line="${line%"${line##*[![:space:]]}"}"
+ line="${line#"${line%%[![:space:]]*}"}"
LINENUM=$((LINENUM+1))
# add settings for user appdir
fi
JVMARGS=( "${JVMARGS[@]}" "-Duserdefaultappdir=true" )
JVMARGS=( "${JVMARGS[@]}" "-Dnouserdefaultappdir=false" )
- # setting the appdir arg[0] to a blank value so appDir is determined by EnvConfig.getUserAppdir()
fi
# INSTALLATION update
JVMARGS=( "${JVMARGS[@]}" "-Dnouserdefaultappdir=true" )
JVMARGS=( "${JVMARGS[@]}" "-Dlauncher.appdir=${APPDIR}" )
JVMARGS=( "${JVMARGS[@]}" "-Dappdir=${APPDIR}" )
- # set GDL_ARGS to these two values
fi
+# setting the appdir arg[0] and appid arg[1] to blank values
+# so appDir is determined by EnvConfig.getUserAppdir() or appdir property
+# and appId is passed as system property appid
GDL_ARGS=( "" "" )
# both USER and INSTALLATION updates