Skip to content

Commit

Permalink
feat: add notice for old java and command for installation (#82)
Browse files Browse the repository at this point in the history
* docs: java 8

* feat: add info and check of java version

* chore: command to finish install on linux

* wip: update script

* chore: message

* docs: license

* fix: java version
  • Loading branch information
anatolystansler authored and makrusak committed Dec 5, 2017
1 parent 52dae85 commit 36c3989
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2017 Sourcerer, Inc. https://sourcerer.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Prerequirements

* Sourcerer alpha/beta access
* Linux or macOS
* Java Platform ([JRE](http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html) for Linux or [JDK](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) for macOS)
* Java 8+ Platform ([JRE](http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html) for Linux or [JDK](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) for macOS)
* Git repositories with master branch with at least one commit

Install/uninstall
Expand Down
39 changes: 27 additions & 12 deletions src/install/install
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright 2017 Sourcerer, Inc. All Rights Reserved.
#
# License: MIT, https://github.com/sourcerer-io/sourcerer-app/blob/master/LICENSE.md
# Source code: https://github.com/sourcerer-io

echo "Installing sourcerer app.."

SERVER=$SERVER_EXT
DOWNLOAD_URL=$SERVER/app/download
SCRIPT_DIR=$HOME/.sourcerer
Expand All @@ -21,6 +21,9 @@ mkdir -p $JAR_DIR
curl -s $DOWNLOAD_URL > $JAR_DIR/sourcerer.jar

cat <<EOF > $SCRIPT_DIR/sourcerer
# Copyright 2017 Sourcerer, Inc. All Rights Reserved.
# License: MIT, https://github.com/sourcerer-io/sourcerer-app/blob/master/LICENSE.md
# Source code: https://github.com/sourcerer-io

if [ "\$1" = "--uninstall" ] ; then
read -p "The script will uninstall sourcerer app. Proceed? [Y/n] " yesno < /dev/tty
Expand All @@ -37,20 +40,31 @@ if [ "\$1" = "--uninstall" ] ; then
exit
fi

if ! which java > /dev/null ; then
VERSION=0
if which java > /dev/null ; then
VERSION_STR=\$(java -version 2>&1 | awk -F '"' '/version/ {print \$2}')
if [[ "\$VERSION_STR" > "9." ]]; then # Format: 9.0.1
VERSION=9
elif [[ "\$VERSION_STR" > "1.8." ]]; then # Format: 1.8.1
VERSION=8
else
echo "Installed version of Java is not supported."
fi
fi

if [ \$VERSION = 0 ] ; then
if [ `uname` = "Darwin" ] ; then
echo "Sourcerer requires JDK installed on the system. You can download it from here:"
echo "Sourcerer requires JDK 8+ installed on the system. You can download it from:"
echo "http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"
else
echo "Sourcerer requires JRE installed on the system. You can download it from here:"
echo "Sourcerer requires JRE 8+ installed on the system. You can download it from:"
echo "http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html"
fi
exit 1
fi

# Java 9 requires additional parameters.
version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
if [[ "$version" > "9." ]]; then # Version example for Java 9: 9.0.1
if [ \$VERSION = 9 ] ; then
java --add-modules java.activation --add-opens java.base/java.nio=ALL-UNNAMED -jar $JAR_DIR/sourcerer.jar "\$@"
else
java -jar $JAR_DIR/sourcerer.jar "\$@"
Expand All @@ -59,13 +73,14 @@ EOF

chmod +x $SCRIPT_DIR/sourcerer


{
rm -f /usr/local/bin/sourcerer 2> /dev/null &&
ln -s $SCRIPT_DIR/sourcerer /usr/local/bin/sourcerer 2> /dev/null &&
echo "Done!" &&
echo "Run sourcerer to start hashing your repos!"
echo 'Done!' &&
echo 'Run sourcerer to start hashing your repos!'
} || {
echo 'We installed app to $HOME/.sourcerer/sourcerer.'
echo 'You can add it to $PATH or ln it to /usr/local/bin'
echo 'We installed app to ~/.sourcerer/sourcerer.'
echo 'You can add it to $PATH or run specified command to finish installation:'
echo "sudo ln -s $SCRIPT_DIR/sourcerer /usr/local/bin/sourcerer"
echo 'Then run sourcerer to start hashing your repos!'
}

0 comments on commit 36c3989

Please sign in to comment.