Created
January 26, 2015 18:02
-
-
Save ivanalejandro0/e5d29c891eaa288784ca to your computer and use it in GitHub Desktop.
LEAP helper to install the needed repositories for https://bitmask.net using specific versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
###################################################################### | |
# repo-versions.sh | |
# Copyright (C) 2014 LEAP | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
###################################################################### | |
set -e # Exit immediately if a command exits with a non-zero status. | |
REPOSITORIES="bitmask_client leap_pycommon soledad keymanager leap_mail bitmask_launcher leap_assets" | |
PACKAGES="leap_pycommon keymanager soledad/common soledad/client soledad/server leap_mail bitmask_client" | |
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
REPOS_ROOT="$SCRIPT_DIR/repositories" # Root path for all the needed repositories | |
clone_repos() { | |
status="clone repositories" | |
echo "${cc_green}Status: $status...${cc_normal}" | |
set -x # show commands | |
if [[ "$1" == "rw" ]]; then | |
# read-write remotes: | |
src="ssh://[email protected]" | |
else | |
# read-only remotes: | |
src="https://leap.se/git" | |
fi | |
cd $REPOS_ROOT | |
for repo in $REPOSITORIES; do | |
[ ! -d $repo ] && git clone $src/$repo | |
done | |
set +x | |
echo "${cc_green}Status: $status done!${cc_normal}" | |
} | |
checkout_repos(){ | |
status="checkout repositories" | |
echo "${cc_green}Status: $status...${cc_normal}" | |
set -x # show commands | |
echo $1 | |
for repo in $REPOSITORIES; do | |
version=$(cat $1 | python -c "import json,sys;obj=json.load(sys.stdin);print obj['$repo'];") | |
cd $REPOS_ROOT/$repo | |
git fetch origin && git fetch --tags origin | |
git checkout -f $version | |
done | |
set +x | |
echo "${cc_green}Status: $status done!${cc_normal}" | |
} | |
create_venv() { | |
status="creating virtualenv" | |
echo "${cc_green}Status: $status...${cc_normal}" | |
set -x # show commands | |
# create and activate the virtualenv | |
cd $REPOS_ROOT | |
virtualenv bitmask.venv && source ./bitmask.venv/bin/activate | |
# source ./bitmask.venv/bin/activate | |
# symlink PySide to the venv | |
cd $REPOS_ROOT/bitmask_client | |
./pkg/postmkvenv.sh | |
set +x | |
echo "${cc_green}Status: $status done.${cc_normal}" | |
} | |
setup_develop() { | |
status="installing packages" | |
echo "${cc_green}Status: $status...${cc_normal}" | |
set -x # show commands | |
# do a setup develop in every package | |
for package in $PACKAGES; do | |
cd $REPOS_ROOT/$package | |
python setup.py develop --always-unzip | |
done | |
# hack to solve gnupg version problem | |
pip uninstall -y gnupg && pip install gnupg | |
set +x | |
echo "${cc_green}Status: $status done.${cc_normal}" | |
} | |
if [[ -z $1 ]]; then | |
echo "You need to specify a bitmask.json parameter." | |
echo "An example could be:" | |
cat << EOF | |
{ | |
"bitmask_client": "0.7.0", | |
"soledad": "0.6.3", | |
"leap_pycommon": "0.3.9", | |
"keymanager": "0.3.8", | |
"leap_mail": "0.3.10", | |
"bitmask_launcher": "0.3.3", | |
"leap_assets": "master" | |
} | |
EOF | |
exit 1 | |
fi | |
mkdir -p $REPOS_ROOT | |
JSON=`realpath $1` | |
clone_repos | |
checkout_repos $JSON | |
create_venv | |
setup_develop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment