diff --git a/.gitignore b/.gitignore index 0fe6d5985e..e10d779aae 100644 --- a/.gitignore +++ b/.gitignore @@ -160,6 +160,7 @@ tizen/*/crash-info/* # Private repository files. .private_repository_url +.private_repository_branch private.h routing_common/car_model_coefs.hpp tools/android/mapswithme.keystore diff --git a/configure.sh b/configure.sh index 3ffb8308e7..6b5c1930cd 100755 --- a/configure.sh +++ b/configure.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Please run this script to configure the repository after cloning it. # Stop on the first error. @@ -17,27 +17,14 @@ PRIVATE_PUSHWOOSH_PROPERTIES="$BASE_PATH/android/pushwoosh.properties" PRIVATE_LIBNOTIFY_PROPERTIES="$BASE_PATH/android/libnotify.properties" PRIVATE_NETWORK_CONFIG="$BASE_PATH/android/res/xml/network_security_config.xml" SAVED_PRIVATE_REPO_FILE="$BASE_PATH/.private_repository_url" +SAVED_PRIVATE_BRANCH_FILE="$BASE_PATH/.private_repository_branch" TMP_REPO_DIR="$BASE_PATH/.tmp.private.repo" -# TODO: Remove these lines when XCode project is finally generated by CMake. -cd $BASE_PATH/3party/boost/ -./bootstrap.sh -./b2 headers -cd $BASE_PATH - -if [ -f "$SAVED_PRIVATE_REPO_FILE" ]; then - PRIVATE_REPO=`cat "$SAVED_PRIVATE_REPO_FILE"` - echo "Using stored private repository URL: $PRIVATE_REPO" -else - echo "If you are developer from MAPS.ME team, please specify a private repository url here." - echo "If not [yet :)], then just press Enter." - echo -n "> " - read PRIVATE_REPO - if [ -z "$PRIVATE_REPO" ]; then - echo "Initializing repository with default values in Open-Source mode." - cat "$DEFAULT_PRIVATE_HEADER" > "$PRIVATE_HEADER" - cat "$DEFAULT_PRIVATE_CAR_MODEL_COEFS" > "$PRIVATE_CAR_MODEL_COEFS" - echo 'ext { +setup_opensource() { + echo "Initializing repository with default values in Open-Source mode." + cat "$DEFAULT_PRIVATE_HEADER" > "$PRIVATE_HEADER" + cat "$DEFAULT_PRIVATE_CAR_MODEL_COEFS" > "$PRIVATE_CAR_MODEL_COEFS" + echo 'ext { spropStoreFile = "../tools/android/debug.keystore" spropStorePassword = "12345678" spropKeyAlias = "debug" @@ -45,29 +32,86 @@ else } ' > "$PRIVATE_PROPERTIES" - echo 'appId=XXXXX + echo 'appId=XXXXX projectId=00000000 ' > "$PRIVATE_LIBNOTIFY_PROPERTIES" - echo 'apiSecret=0000000000000000000000000000000000000000000000000000000000000000 + echo 'apiSecret=0000000000000000000000000000000000000000000000000000000000000000 apiKey=0000000000000000000000000000000000000000 ' > "$PRIVATE_FABRIC_PROPERTIES" - echo 'pwAppId=XXXXX + echo 'pwAppId=XXXXX pwProjectId=A123456789012 ' > "$PRIVATE_PUSHWOOSH_PROPERTIES" - echo ' + echo ' ' > "$PRIVATE_NETWORK_CONFIG" - exit +} + +setup_private() { + if git clone --depth 1 --no-single-branch "$PRIVATE_REPO" "$TMP_REPO_DIR"; then + echo "$PRIVATE_REPO" > "$SAVED_PRIVATE_REPO_FILE" + echo "$PRIVATE_BRANCH" > "$SAVED_PRIVATE_BRANCH_FILE" + echo "Saved private repository url '$PRIVATE_REPO' to '$SAVED_PRIVATE_REPO_FILE'" + echo "Saved private branch '$PRIVATE_BRANCH' to '$SAVED_PRIVATE_BRANCH_FILE'" + (cd $TMP_REPO_DIR && git checkout $PRIVATE_BRANCH) + rm -rf "$TMP_REPO_DIR/.git" "$TMP_REPO_DIR/README.md" + cp -Rv "$TMP_REPO_DIR"/* "$BASE_PATH" + rm -rf "$TMP_REPO_DIR" + echo "Private files have been updated." + fi +} + +ARGS_PRIVATE_REPO=${1-} +ARGS_PRIVATE_BRANCH=${2-} + +if [ -n "$ARGS_PRIVATE_REPO" ]; then + PRIVATE_REPO=$ARGS_PRIVATE_REPO + if [ -n "$ARGS_PRIVATE_BRANCH" ]; then + PRIVATE_BRANCH=$ARGS_PRIVATE_BRANCH + else + PRIVATE_BRANCH=master + fi +else + read -t 1 READ_PRIVATE_REPO READ_PRIVATE_BRANCH || true + if [ -n "$READ_PRIVATE_REPO" ]; then + PRIVATE_REPO=$READ_PRIVATE_REPO + if [ -n "$READ_PRIVATE_BRANCH" ]; then + PRIVATE_BRANCH=$READ_PRIVATE_BRANCH + else + PRIVATE_BRANCH=master + fi + elif [ -f "$SAVED_PRIVATE_REPO_FILE" ]; then + PRIVATE_REPO=`cat "$SAVED_PRIVATE_REPO_FILE"` + echo "Using stored private repository URL: $PRIVATE_REPO" + if [ -f "$SAVED_PRIVATE_BRANCH_FILE" ]; then + PRIVATE_BRANCH=`cat "$SAVED_PRIVATE_BRANCH_FILE"` + echo "Using stored private branch: $PRIVATE_BRANCH" + else + PRIVATE_BRANCH=master + fi + else + PRIVATE_REPO="" fi fi -if git clone --depth 1 "$PRIVATE_REPO" "$TMP_REPO_DIR"; then - echo "Saved private repository url to $SAVED_PRIVATE_REPO_FILE" - echo "$PRIVATE_REPO" > "$SAVED_PRIVATE_REPO_FILE" - rm -rf "$TMP_REPO_DIR/.git" "$TMP_REPO_DIR/README.md" - cp -Rv "$TMP_REPO_DIR"/* "$BASE_PATH" - rm -rf "$TMP_REPO_DIR" - echo "Private files have been updated." +if [ -n "$PRIVATE_REPO" ]; then + setup_private +else + setup_opensource fi +# TODO: Remove these lines when XCode project is finally generated by CMake. +if [ ! -d "$BASE_PATH/3party/boost/" ]; then + echo "You need to have boost submodule present to run bootstrap.sh" + echo "Try to do 'git submodule update --init --recursive'" + exit 1 +fi +if [ ! -d "$BASE_PATH/3party/boost/tools" ]; then + echo "Boost's submodule tools is not present, but required for bootstrap" + echo "Try to do 'git submodule update --init --recursive'" + exit 1 +fi +cd $BASE_PATH/3party/boost/ +./bootstrap.sh +./b2 headers +cd $BASE_PATH