Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Cesium
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
Cesium-grp
Cesium
Commits
c5c37091
Commit
c5c37091
authored
4 years ago
by
Benoit Lavenier
Browse files
Options
Downloads
Patches
Plain Diff
[fix] Refactor scripts env*.sh : now use POSIX format, to be able to source this files
parent
3acc0153
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/env-android.sh
+36
-24
36 additions, 24 deletions
scripts/env-android.sh
scripts/env-global.sh
+53
-46
53 additions, 46 deletions
scripts/env-global.sh
with
89 additions
and
70 deletions
scripts/env-android.sh
+
36
−
24
View file @
c5c37091
#!/bin/
ba
sh
#!/bin/sh
# Get to the root project
# Get to the root project
if
[[
"_"
==
"
_
${
PROJECT_DIR
}
"
]]
;
then
if
test
-z
"
${
PROJECT_DIR
}
"
;
then
SCRIPT_DIR
=
$(
dirname
$0
)
SCRIPT_DIR
=
$(
dirname
$0
)
PROJECT_DIR
=
$(
cd
"
${
SCRIPT_DIR
}
/.."
&&
pwd
)
PROJECT_DIR
=
$(
cd
"
${
SCRIPT_DIR
}
/.."
&&
pwd
)
export
PROJECT_DIR
export
PROJECT_DIR
fi
;
fi
;
# Preparing environment
# Preparing environment
.
${
PROJECT_DIR
}
/scripts/env-global.sh
.
"
${
PROJECT_DIR
}
/scripts/env-global.sh"
[[
$?
-ne
0
]]
&&
exit
1
if
[[
"_"
==
"_
${
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
}
"
]]
;
then
if
test
-z
"
${
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
}
"
;
then
echo
"Missing Gradle distribution URL - please export env variable 'CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'"
echo
"ERROR: Missing Gradle distribution URL - please export env variable 'CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'"
exit
1
fi
fi
echo
"Preparing Android environment:"
echo
"Preparing Android environment:"
...
@@ -25,48 +23,62 @@ echo " - project dir: ${PROJECT_DIR}"
...
@@ -25,48 +23,62 @@ echo " - project dir: ${PROJECT_DIR}"
# Make sure javac exists
# Make sure javac exists
JAVAC_PATH
=
$(
which javac
)
JAVAC_PATH
=
$(
which javac
)
if
[[
"_"
==
"
_
${
JAVAC_PATH
}
"
]]
;
then
if
test
-z
"
${
JAVAC_PATH
}
"
;
then
echo
"ERROR: 'javac' executable not found in PATH. Make sure you have installed a complete Java JDK, and not only a JRE."
echo
"ERROR: 'javac' executable not found in PATH. Make sure you have installed a complete Java JDK, and not only a JRE."
exit
1
#
exit 1
fi
fi
# Prepare Android SDK tools
# Prepare Android SDK tools
if
[[
!
-d
"
${
ANDROID_SDK_TOOLS_ROOT
}
"
]]
;
then
if
!
test
-d
"
${
ANDROID_SDK_TOOLS_ROOT
}
"
;
then
cd
"
${
PROJECT_DIR
}
/scripts"
cd
"
${
PROJECT_DIR
}
/scripts"
./install-android-sdk-tools.sh
./install-android-sdk-tools.sh
[[
$?
-ne
0
]]
&&
exit
1
if
test
$?
-ne
0
;
then
echo
"ERROR: Unable to install Android SDK Tools"
fi
fi
fi
# Install Gradle
# Install Gradle
if
[[
"_"
==
"
_
$(
which gradle
)
"
&&
!
-d
"
${
GRADLE_HOME
}
"
]]
;
then
if
test
-z
"
$(
which gradle
)
"
&&
!
test
-d
"
${
GRADLE_HOME
}
"
;
then
cd
"
${
PROJECT_DIR
}
/scripts"
cd
"
${
PROJECT_DIR
}
/scripts"
echo
"Installing gradle...
${
GRADLE_HOME
}
"
echo
"Installing gradle...
${
GRADLE_HOME
}
"
test
-e
"gradle-
${
GRADLE_VERSION
}
-all.zip"
||
wget
-kL
${
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
}
test
-e
"gradle-
${
GRADLE_VERSION
}
-all.zip"
||
wget
-kL
${
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
}
GRADLE_PARENT
=
$(
dirname
$GRADLE_HOME
)
GRADLE_PARENT
=
$(
dirname
$GRADLE_HOME
)
test
-e
"
${
GRADLE_PARENT
}
"
||
mkdir
-p
${
GRADLE_PARENT
}
test
-e
"
${
GRADLE_PARENT
}
"
||
mkdir
-p
${
GRADLE_PARENT
}
test
-e
"
${
GRADLE_PARENT
}
/gradle-
${
GRADLE_VERSION
}
"
||
unzip
-qq
gradle-
${
GRADLE_VERSION
}
-all
.zip
-d
"
${
GRADLE_PARENT
}
"
test
-e
"
${
GRADLE_PARENT
}
/gradle-
${
GRADLE_VERSION
}
"
||
unzip
-qq
gradle-
${
GRADLE_VERSION
}
-all
.zip
-d
"
${
GRADLE_PARENT
}
"
[[
$?
-ne
0
]]
&&
exit
1
if
test
$?
-eq
0
;
then
test
-e
"
${
GRADLE_HOME
}
"
||
mv
"
${
GRADLE_PARENT
}
/gradle-
${
GRADLE_VERSION
}
"
"
${
GRADLE_HOME
}
"
test
-e
"
${
GRADLE_HOME
}
"
||
mv
"
${
GRADLE_PARENT
}
/gradle-
${
GRADLE_VERSION
}
"
"
${
GRADLE_HOME
}
"
[[
$?
-ne
0
]]
&&
exit
1
if
test
$?
-eq
0
;
then
test
-e
"
${
GRADLE_PARENT
}
/gradle-
${
GRADLE_VERSION
}
"
||
rm
"
${
GRADLE_PARENT
}
/gradle-
${
GRADLE_VERSION
}
"
test
-e
"
${
GRADLE_PARENT
}
/gradle-
${
GRADLE_VERSION
}
"
||
rm
"
${
GRADLE_PARENT
}
/gradle-
${
GRADLE_VERSION
}
"
fi
fi
if
test
$?
-ne
0
;
then
echo
"ERROR: Unable to install Gradle"
fi
fi
fi
# Prepare Android platform
# Prepare Android platform
if
[[
!
-d
"
${
PROJECT_DIR
}
/platforms/android"
]]
;
then
if
!
test
-d
"
${
PROJECT_DIR
}
/platforms/android"
;
then
echo
"Adding Cordova Android platform..."
echo
"Adding Cordova Android platform..."
cd
"
${
PROJECT_DIR
}
"
cd
"
${
PROJECT_DIR
}
"
ionic cordova prepare android
--color
--verbose
ionic cordova prepare android
--color
--verbose
[[
$?
-ne
0
]]
&&
exit
1
if
test
$?
-ne
0
;
then
echo
"ERROR: Cannot install Android platform (using cordova)"
fi
fi
fi
# Copy local files
# Copy local files
if
[[
-d
"
${
PROJECT_DIR
}
/.local/android"
]]
;
then
ANDROID_OVERWRITE_DIR
=
${
PROJECT_DIR
}
/.local/android
echo
"Copying files from directory '
${
PROJECT_DIR
}
/.local/android' into '
${
PROJECT_DIR
}
/platforms/android'..."
if
test
-d
"
${
ANDROID_OVERWRITE_DIR
}
"
;
then
cp
-rf
${
PROJECT_DIR
}
/.local/android/
*
${
PROJECT_DIR
}
/platforms/android
echo
"Copying files from directory '
${
ANDROID_OVERWRITE_DIR
}
' into '
${
PROJECT_DIR
}
/platforms/android'..."
[[
$?
-ne
0
]]
&&
exit
1
cp
-rf
${
ANDROID_OVERWRITE_DIR
}
/
*
${
PROJECT_DIR
}
/platforms/android
if
test
$?
-ne
0
;
then
echo
"ERROR: Cannot copy local files '
${
ANDROID_OVERWRITE_DIR
}
/*'"
fi
else
else
echo
"No directory '
${
PROJECT_DIR
}
/.local/android'
found. Please create it, with a file 'release-signing.properties' for release signing"
echo
"No directory '
${
ANDROID_OVERWRITE_DIR
}
' not
found. Please create it, with a file 'release-signing.properties' for release signing"
fi
fi
echo
"Environment is ready!"
export
PATH
=
${
GRADLE_HOME
}
/bin:
${
PATH
}
echo
"Android environment is ready!"
This diff is collapsed.
Click to expand it.
scripts/env-global.sh
+
53
−
46
View file @
c5c37091
#!/bin/
ba
sh
#!/bin/sh
# Get to the root project
# Get to the root project
if
[[
"_"
==
"_
${
PROJECT_DIR
}
"
]]
;
then
SCRIPT_DIR
=
$(
dirname
"
$(
readlink
"
$BASH_SOURCE
"
||
echo
"
$BASH_SOURCE
"
)
"
)
SCRIPT_DIR
=
$(
dirname
$0
)
PROJECT_DIR
=
$(
cd
"
${
SCRIPT_DIR
}
/.."
&&
pwd
-P
)
PROJECT_DIR
=
$(
cd
${
SCRIPT_DIR
}
/..
&&
pwd
)
export
PROJECT_DIR
export
PROJECT_DIR
fi
;
echo
"Project dir:
$PROJECT_DIR
"
if
[[
!
-f
"
${
PROJECT_DIR
}
/package.json"
]]
;
then
if
!
test
-f
"
${
PROJECT_DIR
}
/package.json"
;
then
echo
"Invalid project dir: file 'package.json' not found in
${
PROJECT_DIR
}
"
echo
"
ERROR:
Invalid project dir: file 'package.json' not found in
${
PROJECT_DIR
}
"
echo
"-> Make sure to run the script inside his directory, or export env variable 'PROJECT_DIR'"
echo
"
-> Make sure to run the script inside his directory, or export env variable 'PROJECT_DIR'"
exit
1
#
exit 1
fi
;
fi
;
echo
"Preparing project environment.."
echo
"Preparing project environment..
.
"
PROJECT_NAME
=
"cesium"
PROJECT_NAME
=
"cesium"
REPO
=
"duniter/cesium"
REPO
=
"duniter/cesium"
REPO_API_URL
=
"https://api.github.com/repos/
${
REPO
}
"
REPO_API_URL
=
"https://api.github.com/repos/
${
REPO
}
"
REPO_PUBLIC_URL
=
"https://github.com/
${
REPO
}
"
REPO_PUBLIC_URL
=
"https://github.com/
${
REPO
}
"
NODEJS_VERSION
=
1
0
NODEJS_VERSION
=
1
2
ANDROID_NDK_VERSION
=
r19c
ANDROID_NDK_VERSION
=
r19c
ANDROID_SDK_VERSION
=
r29.0.2
ANDROID_SDK_VERSION
=
r29.0.2
...
@@ -46,43 +47,40 @@ GRADLE_HOME=${HOME}/.gradle/${GRADLE_VERSION}
...
@@ -46,43 +47,40 @@ GRADLE_HOME=${HOME}/.gradle/${GRADLE_VERSION}
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
=
https://services.gradle.org/distributions/gradle-
${
GRADLE_VERSION
}
-all
.zip
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
=
https://services.gradle.org/distributions/gradle-
${
GRADLE_VERSION
}
-all
.zip
# Override with a local file, if any
# Override with a local file, if any
if
[[
-f
"
${
PROJECT_DIR
}
/.local/env.sh"
]]
;
then
if
test
-f
"
${
PROJECT_DIR
}
/.local/env.sh"
;
then
echo
"Loading environment variables from: '.local/env.sh'"
echo
"Loading environment variables from: '.local/env.sh'"
source
${
PROJECT_DIR
}
/.local/env.sh
.
${
PROJECT_DIR
}
/.local/env.sh
[[
$?
-ne
0
]]
&&
exit
1
else
else
echo
"No file '
${
PROJECT_DIR
}
/.local/env.sh' found. Will use defaults"
echo
"No file '
${
PROJECT_DIR
}
/.local/env.sh' found. Will use defaults"
fi
fi
# Checking Java installed
# Checking Java installed
if
[[
"_"
==
"
_
${
JAVA_HOME
}
"
]]
;
then
if
test
-z
"
${
JAVA_HOME
}
"
;
then
JAVA_CMD
=
`
which java
`
JAVA_CMD
=
`
which java
`
if
[[
"_"
==
"
_
${
JAVA_CMD
}
"
]]
;
then
if
test
-z
"
${
JAVA_CMD
}
"
;
then
echo
"No Java installed. Please install java, or set env variable JAVA_HOME "
echo
"
ERROR:
No Java installed. Please install java, or set env variable JAVA_HOME "
exit
1
#
exit 1
fi
fi
# Check the Java version
# Check the Java version
JAVA_VERSION
=
`
java
-version
2>&1 | egrep
"(java|openjdk) version"
|
awk
'{print $3}'
|
tr
-d
\"
`
JAVA_VERSION
=
$(
java
-version
2>&1 | egrep
"(java|openjdk) version"
|
awk
'{print $3}'
|
tr
-d
\"
)
if
[[
$?
-ne
0
]]
;
then
if
test
$?
-ne
0
||
test
-z
"
${
JAVA_VERSION
}
"
;
then
echo
"No Java JRE 1.8 found in machine. This is required for Android artifacts."
echo
"No Java JRE 1.8 found in machine. This is required for Android artifacts."
exit
1
else
fi
JAVA_MAJOR_VERSION
=
$(
echo
${
JAVA_VERSION
}
|
awk
'{split($0, array, ".")} END{print array[1]}'
)
JAVA_MAJOR_VERSION
=
`
echo
${
JAVA_VERSION
}
|
awk
'{split($0, array, ".")} END{print array[1]}'
`
JAVA_MINOR_VERSION
=
$(
echo
${
JAVA_VERSION
}
|
awk
'{split($0, array, ".")} END{print array[2]}'
)
JAVA_MINOR_VERSION
=
`
echo
${
JAVA_VERSION
}
|
awk
'{split($0, array, ".")} END{print array[2]}'
`
if
!
test
"
${
JAVA_MAJOR_VERSION
}
"
==
"1"
||
!
test
"
${
JAVA_MINOR_VERSION
}
"
==
"8"
;
then
if
[[
${
JAVA_MAJOR_VERSION
}
-ne
1
]]
||
[[
${
JAVA_MINOR_VERSION
}
-ne
8
]]
;
then
echo
"ERROR: Require a Java JRE in version 1.8, but found
${
JAVA_VERSION
}
. You can override your default JAVA_HOME in '.local/env.sh'."
echo
"Require a Java JRE in version 1.8, but found
${
JAVA_VERSION
}
. You can override your default JAVA_HOME in '.local/env.sh'."
fi
exit
1
fi
fi
fi
fi
# Check Android SDK root path
# Check Android SDK root path
if
[[
"_"
==
"
_
${
ANDROID_SDK_ROOT
}
"
||
!
-d
"
${
ANDROID_SDK_ROOT
}
"
]]
;
then
if
test
-z
"
${
ANDROID_SDK_ROOT
}
"
||
!
test
-d
"
${
ANDROID_SDK_ROOT
}
"
;
then
if
[[
-d
"
${
ANDROID_ALTERNATIVE_SDK_ROOT
}
"
]]
;
then
if
test
-d
"
${
ANDROID_ALTERNATIVE_SDK_ROOT
}
"
;
then
export
ANDROID_SDK_ROOT
=
"
${
ANDROID_ALTERNATIVE_SDK_ROOT
}
"
export
ANDROID_SDK_ROOT
=
"
${
ANDROID_ALTERNATIVE_SDK_ROOT
}
"
else
else
echo
"Please set env variable ANDROID_SDK_ROOT to an existing directory"
echo
"ERROR: Please set env variable ANDROID_SDK_ROOT to an existing directory"
exit
1
fi
fi
fi
fi
...
@@ -100,22 +98,20 @@ export PATH \
...
@@ -100,22 +98,20 @@ export PATH \
# Node JS
# Node JS
export
NVM_DIR
=
"
$HOME
/.nvm"
export
NVM_DIR
=
"
$HOME
/.nvm"
if
[[
-d
"
${
NVM_DIR
}
"
]]
;
then
if
test
-d
"
${
NVM_DIR
}
"
;
then
# Load NVM
# Load NVM
.
${
NVM_DIR
}
/nvm.sh
.
"
${
NVM_DIR
}
/nvm.sh
"
# Switch to expected version
# Switch to expected version
nvm use
${
NODEJS_VERSION
}
nvm use
${
NODEJS_VERSION
}
# Or install it
# Or install it
if
[[
$?
-ne
0
]]
;
then
if
test
$?
-ne
0
;
then
nvm
install
${
NODEJS_VERSION
}
nvm
install
${
NODEJS_VERSION
}
[[
$?
-ne
0
]]
&&
exit
1
fi
fi
else
else
echo
"nvm (Node version manager) not found (directory
${
NVM_DIR
}
not found). Please install, and retry"
echo
"nvm (Node version manager) not found (directory
${
NVM_DIR
}
not found). Please install, and retry"
exit
-1
fi
fi
# Install global dependencies
# Install global dependencies
...
@@ -125,29 +121,40 @@ CORDOVA_PATH=`which cordova`
...
@@ -125,29 +121,40 @@ CORDOVA_PATH=`which cordova`
CORDOVA_RES_PATH
=
`
which cordova-res
`
CORDOVA_RES_PATH
=
`
which cordova-res
`
NATIVE_RUN_PATH
=
`
which native-run
`
NATIVE_RUN_PATH
=
`
which native-run
`
WEB_EXT_PATH
=
`
which web-ext
`
WEB_EXT_PATH
=
`
which web-ext
`
if
[[
"_"
==
"
_
${
YARN_PATH
}
"
||
"_"
==
"
_
${
IONIC_PATH
}
"
||
"_"
==
"
_
${
CORDOVA_PATH
}
"
||
"_"
==
"
_
${
CORDOVA_RES_PATH
}
"
||
"_"
==
"
_
${
NATIVE_RUN_PATH
}
"
||
"_"
==
"
_
${
WEB_EXT_PATH
}
"
]]
;
then
if
test
-z
"
${
YARN_PATH
}
"
||
test
-z
"
${
IONIC_PATH
}
"
||
test
-z
"
${
CORDOVA_PATH
}
"
||
test
-z
"
${
CORDOVA_RES_PATH
}
"
||
test
-z
"
${
NATIVE_RUN_PATH
}
"
||
test
-z
"
${
WEB_EXT_PATH
}
"
;
then
echo
"Installing global dependencies..."
echo
"Installing global dependencies..."
npm
install
-g
yarn cordova cordova-res @ionic/cli web-ext native-run
npm
install
-g
yarn cordova cordova-res @ionic/cli web-ext native-run
[[
$?
-ne
0
]]
&&
exit
1
if
!
test
$?
==
0
;
then
echo
"ERROR: Unable to install global dependencies"
#exit 1
fi
# Make sure Ionic use yarn
# Make sure Ionic use yarn
ionic config
set
-g
yarn
true
ionic config
set
-g
yarn
true
fi
fi
# Install project dependencies
# Install project dependencies
if
[[
!
-d
"
${
PROJECT_DIR
}
/node_modules"
]]
;
then
if
!
test
-d
"
${
PROJECT_DIR
}
/node_modules"
;
then
echo
"Installing project dependencies..."
echo
"Installing project dependencies..."
cd
${
PROJECT_DIR
}
cd
"
${
PROJECT_DIR
}
"
yarn
install
yarn
install
fi
fi
# Install project submodules
# Install project submodules
if
[[
!
-d
"
${
PROJECT_DIR
}
/platforms/android"
||
!
-d
"
${
PROJECT_DIR
}
/dist/desktop"
]]
;
then
if
!
test
-d
"
${
PROJECT_DIR
}
/platforms/android"
||
!
test
-d
"
${
PROJECT_DIR
}
/dist/desktop"
;
then
echo
"Installing project submodules..."
echo
"Installing project submodules..."
cd
${
PROJECT_DIR
}
cd
"
${
PROJECT_DIR
}
"
git submodule init
&&
git submodule
sync
&&
git submodule update
--remote
--merge
git submodule init
&&
git submodule
sync
&&
git submodule update
--remote
--merge
if
[[
$?
-ne
0
]]
;
then
if
!
test
$?
==
0
;
then
echo
"Unable to sync git submodule. Will not be able to build android and desktop artifacts!"
echo
"
ERROR:
Unable to sync git submodule. Will not be able to build android and desktop artifacts!"
exit
1
#
exit 1
fi
fi
fi
fi
export
PROJECT_DIR PROJECT_NAME REPO REPO_API_URL REPO_PUBLIC_URL NODEJS_VERSION
\
ANDROID_NDK_VERSION ANDROID_SDK_VERSION ANDROID_SDK_TOOLS_VERSION ANDROID_SDK_ROOT ANDROID_ALTERNATIVE_SDK_ROOT
\
ANDROID_SDK_TOOLS_ROOT ANDROID_OUTPUT_APK ANDROID_OUTPUT_APK_DEBUG ANDROID_OUTPUT_APK_RELEASE DIST_WEB
\
DIST_ANDROID WEB_EXT_ID
echo
"Project environment is ready!"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment