Merge pull request #200 from luzfcb/issue-34

add requirements file of non-python dependencies and helper scripts - fix issue #34
This commit is contained in:
Fábio C. Barrionuevo da Luz 2015-04-12 22:40:13 -03:00
commit 6626c922f9
4 changed files with 151 additions and 1 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
*.pot
*.pyc
local_settings.py
repo_name
repo_name
.idea

View File

@ -0,0 +1,82 @@
#!/bin/bash
OS_REQUIREMENTS_FILENAME="requirements.apt"
# Handle call with wrong command
function wrong_command()
{
echo "${0##*/} - unknown command: '${1}'"
usage_message
}
# Print help / script usage
function usage_message()
{
echo "usage: ./${0##*/} <command>"
echo "available commands are:"
echo -e "\tlist\t\tPrint a list of all packages defined on ${OS_REQUIREMENTS_FILENAME} file"
echo -e "\thelp\t\tPrint this help"
echo -e "\n\tCommands that require superuser permission:"
echo -e "\tinstall\t\tInstall packages defined on ${OS_REQUIREMENTS_FILENAME} file. Note: This\n\t\t\t does not upgrade the packages already installed for new\n\t\t\t versions, even if new version is available in the repository."
echo -e "\tupgrade\t\tSame that install, but upgrate the already installed packages,\n\t\t\t if new version is available."
}
# Read the requirements.apt file, and remove comments and blank lines
function list_packages(){
cat ${OS_REQUIREMENTS_FILENAME} | grep -v "#" | grep -v "^$";
}
function install()
{
list_packages | xargs apt-get --no-upgrade install -y;
}
function upgrade()
{
list_packages | xargs apt-get install -y;
}
function install_or_upgrade()
{
P=${1}
PARAN=${P:-"install"}
if [[ $EUID -ne 0 ]]; then
echo -e "\nYou must run this with root privilege" 2>&1
echo -e "Please do:\n" 2>&1
echo "sudo ./${0##*/} $PARAN" 2>&1
echo -e "\n" 2>&1
exit 1
else
apt-get update
# Install the basic compilation dependencies and other required libraries of this project
if [ "$PARAN" == "install" ]; then
install;
else
upgrade;
fi
# cleaning downloaded packages from apt-get cache
apt-get clean
exit 0
fi
}
# Handle command argument
case "$1" in
install) install_or_upgrade;;
upgrade) install_or_upgrade "upgrade";;
list) list_packages;;
help) usage_message;;
*) wrong_command $1;;
esac

View File

@ -0,0 +1,40 @@
#!/bin/bash
pip --version >/dev/null 2>&1 || {
echo >&2 -e "\npip is required but it's not installed."
echo >&2 -e "You can install it by running the following command:\n"
echo >&2 "wget https://bootstrap.pypa.io/get-pip.py; chmod +x get-pip.py; sudo ./get-pip.py"
echo >&2 -e "\n"
echo >&2 -e "\nFor more information, see pip documentation: https://pip.pypa.io/en/latest/"
exit 1;
}
virtualenv --version >/dev/null 2>&1 || {
echo >&2 -e "\nvirtualenv is required but it's not installed."
echo >&2 -e "You can install it by running the following command:\n"
echo >&2 "sudo pip install virtualenv"
echo >&2 -e "\n"
echo >&2 -e "\nFor more information, see virtualenv documentation: https://virtualenv.pypa.io/en/latest/"
exit 1;
}
if [ -z "$VIRTUAL_ENV" ]; then
echo >&2 -e "\nYou need activate a virtualenv first"
echo >&2 -e 'If you do not have a virtualenv created, run the following command to create and automatically activate a new virtualenv named "venv" on current folder:\n'
echo >&2 -e "virtualenv venv"
echo >&2 -e "\nTo leave/disable the currently active virtualenv, run the following command:\n"
echo >&2 "deactivate"
echo >&2 -e "\nTo activate the virtualenv again, run the following command:\n"
echo >&2 "source venv/bin/activate"
echo >&2 -e "\nFor more information, see virtualenv documentation: https://virtualenv.pypa.io/en/latest/"
echo >&2 -e "\n"
exit 1;
else
pip install -r requirements/local.txt
pip install -r requirements/test.txt
pip install -r requirements.txt
fi

View File

@ -0,0 +1,27 @@
##basic build dependencies of various Django apps for Ubuntu 14.04
#build-essential metapackage install: make, gcc, g++,
build-essential
#required to translate
gettext
python-dev
##shared dependencies of:
##Pillow, pylibmc
zlib1g-dev
##Postgresql and psycopg2 dependencies
libpq-dev
##Pillow dependencies
libtiff4-dev
libjpeg8-dev
libfreetype6-dev
liblcms1-dev
libwebp-dev
##pylibmc
libmemcached-dev
libssl-dev
##django-extensions
graphviz-dev