Commit 207b2eeb authored by Jonathan Harker's avatar Jonathan Harker

Merge branch 'update-venv' into 'master'

Update the Python environment at the appropriate junctures.



See merge request !4
parents 12e0f077 9f8a2f7b
maharadocs (16.10-2) unstable; urgency=medium
* Use a Python virtual environment.
* Fix checks for existing git checkouts of the user manual.
* Warn the installer about running the crons manually if necessary.
* Suppress Apache DocumentRoot configuration check error.
-- Jonathan Harker <jonathan@catalyst.net.nz> Fri, 21 Oct 2016 15:00:07 +1300
maharadocs (16.10-1) stable; urgency=medium
* Move old versions of manuals from daily to monthly cron.
......
......@@ -24,6 +24,21 @@ case "$1" in
;;
esac
function update_venv {
echo "Updating Python virtual environment:"
# If the Python virtual environment doesn't exist, try creating it.
if [ ! -d $DIRNAME/venv ]; then
echo "Virtual environment missing, creating a new one."
virtualenv $DIRNAME/venv || \
echo "${bold}*** ERROR: failed to create a virtual environment in $DIRNAME/venv${normal}"
fi
echo "${bold}Updating Python virtual environment...${normal}"
. $DIRNAME/venv/bin/activate
pip install --upgrade -r $DIRNAME/requirements.txt || \
echo "${bold}*** ERROR: pip install failed, you may need to use a wheelhouse.${normal}"
deactivate
}
# Check if we seem to have the correct git contents, not very trustworthy
# but better than no check :D
......@@ -36,6 +51,10 @@ then
# packaging do its thing.
echo "Data already exists pulling from the correct source."
echo "Not doing any alteration of $DIRNAME."
# Update the Python virtual environment first, though
update_venv
exit
else
# However if it looks wrong, check if its a-ok to overwrite
......@@ -57,6 +76,12 @@ then
exit
fi
fi
else
echo "${bold}*******************************************************************${normal}"
echo "${bold}* Fetching the Mahara manual code for the first time. The build *${normal}"
echo "${bold}* dir will not be built until the cron job(s) run, so you may *${normal}"
echo "${bold}* want to run them manually after this installation. *${normal}"
echo "${bold}*******************************************************************${normal}"
fi
# Make our lovely new install from the git address.
......@@ -85,20 +110,11 @@ else
exit -1
fi
# Set up the Python virtual environment
# Update the Python virtual environment
update_venv
if [ -d $DIRNAME/venv ]
then
echo "Python virtual environment already exists, skipping."
else
echo "${bold}Setting up Python virtual environment...${normal}"
# TODO: If this fails, see README about installing from the wheelhouse.
virtualenv $DIRNAME/venv
. $DIRNAME/venv/bin/activate
pip install -r $DIRNAME/requirements.txt || \
echo "${bold}*** ERROR: pip install failed, you may need to use a wheelhouse.${normal}"
deactivate
fi
# Make an empty build directory to suppress the Apache configcheck error
mkdir -p $DIRNAME/build/html
# Make the sitelogs directory...
mkdir -p /var/log/sitelogs/mahara-manual-sphinx
......
......@@ -6,6 +6,9 @@
set -e
. /usr/share/debconf/confmodule
bold=`tput bold`
normal=`tput sgr0`
# summary of how this script can be called:
# * <postrm> `remove'
# * <postrm> `purge'
......@@ -28,10 +31,10 @@ case "$1" in
db_get maharadocs/installdir
DIRNAME=$RET
echo "Disabling apache site config"
a2dissite mahara-manual-sphinx.conf
a2dissite mahara-manual-sphinx.conf || true
echo "Removing apache site config"
rm -f /etc/apache2/sites-available/mahara-manual-sphinx.conf
echo "NOTE: The directory $DIRNAME has not been removed and must be deleted manually!"
rm -f /etc/apache2/sites-available/mahara-manual-sphinx.conf || true
echo "${bold}NOTE: The directory $DIRNAME has not been removed and must be deleted manually!${normal}"
;;
*)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment