Skip to content

Commit 36c3989

Browse files
anatolystanslermakrusak
authored andcommitted
feat: add notice for old java and command for installation (#82)
* 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
1 parent 52dae85 commit 36c3989

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2017 Sourcerer, Inc. https://sourcerer.io
2+
3+
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:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
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.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Prerequirements
1717

1818
* Sourcerer alpha/beta access
1919
* Linux or macOS
20-
* 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)
20+
* 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)
2121
* Git repositories with master branch with at least one commit
2222

2323
Install/uninstall

src/install/install

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Copyright 2017 Sourcerer, Inc. All Rights Reserved.
2-
#
2+
# License: MIT, https://github.com/sourcerer-io/sourcerer-app/blob/master/LICENSE.md
3+
# Source code: https://github.com/sourcerer-io
34

45
echo "Installing sourcerer app.."
5-
66
SERVER=$SERVER_EXT
77
DOWNLOAD_URL=$SERVER/app/download
88
SCRIPT_DIR=$HOME/.sourcerer
@@ -21,6 +21,9 @@ mkdir -p $JAR_DIR
2121
curl -s $DOWNLOAD_URL > $JAR_DIR/sourcerer.jar
2222

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

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

40-
if ! which java > /dev/null ; then
43+
VERSION=0
44+
if which java > /dev/null ; then
45+
VERSION_STR=\$(java -version 2>&1 | awk -F '"' '/version/ {print \$2}')
46+
if [[ "\$VERSION_STR" > "9." ]]; then # Format: 9.0.1
47+
VERSION=9
48+
elif [[ "\$VERSION_STR" > "1.8." ]]; then # Format: 1.8.1
49+
VERSION=8
50+
else
51+
echo "Installed version of Java is not supported."
52+
fi
53+
fi
54+
55+
if [ \$VERSION = 0 ] ; then
4156
if [ `uname` = "Darwin" ] ; then
42-
echo "Sourcerer requires JDK installed on the system. You can download it from here:"
57+
echo "Sourcerer requires JDK 8+ installed on the system. You can download it from:"
4358
echo "http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"
4459
else
45-
echo "Sourcerer requires JRE installed on the system. You can download it from here:"
60+
echo "Sourcerer requires JRE 8+ installed on the system. You can download it from:"
4661
echo "http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html"
4762
fi
4863
exit 1
4964
fi
5065

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

6074
chmod +x $SCRIPT_DIR/sourcerer
6175

62-
6376
{
6477
rm -f /usr/local/bin/sourcerer 2> /dev/null &&
6578
ln -s $SCRIPT_DIR/sourcerer /usr/local/bin/sourcerer 2> /dev/null &&
66-
echo "Done!" &&
67-
echo "Run sourcerer to start hashing your repos!"
79+
echo 'Done!' &&
80+
echo 'Run sourcerer to start hashing your repos!'
6881
} || {
69-
echo 'We installed app to $HOME/.sourcerer/sourcerer.'
70-
echo 'You can add it to $PATH or ln it to /usr/local/bin'
82+
echo 'We installed app to ~/.sourcerer/sourcerer.'
83+
echo 'You can add it to $PATH or run specified command to finish installation:'
84+
echo "sudo ln -s $SCRIPT_DIR/sourcerer /usr/local/bin/sourcerer"
85+
echo 'Then run sourcerer to start hashing your repos!'
7186
}

0 commit comments

Comments
 (0)