Skip to content

Commit 7ac2644

Browse files
committed
fixing some dependancies and adding install shell script
1 parent 4eb37f8 commit 7ac2644

File tree

3 files changed

+95
-55
lines changed

3 files changed

+95
-55
lines changed

fabfile.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22
# A Fabric file for carrying out various administrative tasks with InaSAFE.
33
# Tim Sutton, Jan 2013
44
from fabric import *
5-
import fabgis.fabgis
65
from fabric.api import *
76
from fabric.contrib.files import contains, exists, append, sed
87
import fabtools
9-
8+
import fabgis.fabgis
9+
from fabgis.fabgis import *
1010
###############################################################################
1111
# Next section contains actual tasks
1212
###############################################################################
13+
14+
1315
@task
1416
@hosts('192.168.1.1:22')
1517
def get_foo_dump():
1618
"""This is an example of how you can wrap fabgis tasks in your fabfile."""
1719
fabgis.get_postgres_dump('foodb')
1820

21+
1922
@task
2023
def build_server():
2124
"""Build a complete functioning fossgis server instance.

fabgis/fabgis.py

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def setup_latex():
8383
fabtools.deb.update_index(quiet=True)
8484
fabtools.require.deb.package('texlive-latex-extra')
8585
fabtools.require.deb.package('texinfo')
86+
fabtools.require.deb.package('texlive-fonts-recommended')
8687

8788

8889
@task
@@ -152,31 +153,6 @@ def clone_qgis(branch='master'):
152153
run('git pull')
153154

154155

155-
@task
156-
def install_qgis1_8():
157-
"""Install QGIS 1.8 under /usr/local/qgis-1.8."""
158-
setup_env()
159-
add_ubuntugis_ppa()
160-
setup_ccache()
161-
sudo('apt-get build-dep -y qgis')
162-
fabtools.require.deb.package('cmake-curses-gui')
163-
fabtools.require.deb.package('git')
164-
fabtools.require.deb.package('python-gdal')
165-
clone_qgis(branch='release-1_8')
166-
workspace = '%s/cpp' % env.fg.workspace
167-
code_path = '%s/Quantum-GIS' % workspace
168-
build_path = '%s/build-qgis18' % code_path
169-
build_prefix = '/usr/local/qgis-1.8'
170-
fabtools.require.directory(build_path)
171-
with cd(build_path):
172-
fabtools.require.directory(
173-
build_prefix,
174-
use_sudo=True,
175-
owner=env.fg.user)
176-
run('cmake .. -DCMAKE_INSTALL_PREFIX=%s' % build_prefix)
177-
run('make install')
178-
179-
180156
@task
181157
def setup_ccache():
182158
"""Setup ccache."""
@@ -195,30 +171,10 @@ def setup_inasafe():
195171
fabtools.require.deb.package('python-nosexcover')
196172

197173

198-
@task
199-
def install_qgis2():
200-
"""Install QGIS 2 under /usr/local/qgis-master.
201-
202-
TODO: create one function from this and the 1.8 function above for DRY.
203-
204-
"""
205-
setup_env()
206-
setup_ccache()
207-
add_ubuntugis_ppa()
208-
209-
sudo('apt-get build-dep -y qgis')
210-
174+
def compile_qgis(build_path, build_prefix):
175+
fabtools.require.deb.package('python-gdal')
211176
fabtools.require.deb.package('cmake-curses-gui')
212177
fabtools.require.deb.package('git')
213-
fabtools.require.deb.package('python-qscintilla2')
214-
fabtools.require.deb.package('libqscintilla2-dev')
215-
fabtools.require.deb.package('libspatialindex-dev')
216-
fabtools.require.deb.package('python-gdal')
217-
clone_qgis(branch='master')
218-
workspace = '%s/cpp' % env.fg.workspace
219-
code_path = '%s/Quantum-GIS' % workspace
220-
build_path = '%s/build-master' % code_path
221-
build_prefix = '/usr/local/qgis-master'
222178
fabtools.require.directory(build_path)
223179
with cd(build_path):
224180
fabtools.require.directory(
@@ -239,9 +195,56 @@ def install_qgis2():
239195
'-DWITH_INTERNAL_SPATIALITE=ON '
240196
'%s'
241197
% (build_prefix, extra))
242-
run('cmake .. -DCMAKE_INSTALL_PREFIX=%s' % build_prefix)
198+
run('cmake .. %s' % cmake)
199+
processor_count = run('cat /proc/cpuinfo | grep processor | wc -l')
200+
run('time make -j %s install' % processor_count)
201+
243202

244-
run('make install')
203+
@task
204+
def install_qgis1_8():
205+
"""Install QGIS 1.8 under /usr/local/qgis-1.8."""
206+
setup_env()
207+
add_ubuntugis_ppa()
208+
setup_ccache()
209+
sudo('apt-get build-dep -y qgis')
210+
clone_qgis(branch='release-1_8')
211+
workspace = '%s/cpp' % env.fg.workspace
212+
code_path = '%s/Quantum-GIS' % workspace
213+
build_path = '%s/build-qgis18' % code_path
214+
build_prefix = '/usr/local/qgis-1.8'
215+
compile_qgis(build_path, build_prefix)
216+
217+
218+
@task
219+
def install_qgis2():
220+
"""Install QGIS 2 under /usr/local/qgis-master.
221+
222+
TODO: create one function from this and the 1.8 function above for DRY.
223+
224+
"""
225+
setup_env()
226+
setup_ccache()
227+
add_ubuntugis_ppa()
228+
sudo('apt-get build-dep -y qgis')
229+
230+
fabtools.require.deb.package('python-pyspatialite')
231+
fabtools.require.deb.package('python-psycopg2')
232+
fabtools.require.deb.package('python-qscintilla2')
233+
fabtools.require.deb.package('libqscintilla2-dev')
234+
fabtools.require.deb.package('libspatialindex-dev')
235+
236+
clone_qgis(branch='master')
237+
workspace = '%s/cpp' % env.fg.workspace
238+
code_path = '%s/Quantum-GIS' % workspace
239+
build_path = '%s/build-master' % code_path
240+
build_prefix = '/usr/local/qgis-master'
241+
compile_qgis(build_path, build_prefix)
242+
243+
244+
@task
245+
def setup_qgis2_and_postgis():
246+
create_postgis_1_5_db('gis', env.user)
247+
install_qgis2()
245248

246249

247250
@task
@@ -269,7 +272,7 @@ def setup_postgres_superuser(user, password=''):
269272

270273

271274
@task
272-
def setup_postgis():
275+
def setup_postgis_1_5():
273276
"""Set up postgis.
274277
275278
You can call this multiple times without it actually installing all over
@@ -336,14 +339,14 @@ def create_postgis_1_5_template():
336339
@task
337340
def create_postgis_1_5_db(dbname, user):
338341
"""Create a postgis database."""
339-
setup_postgis()
340-
require_postgres_user(user)
342+
setup_postgis_1_5()
341343
setup_postgres_superuser(env.user)
344+
require_postgres_user(user)
342345
create_user()
343346
fabtools.require.postgres.database(
344347
'%s' % dbname, owner='%s' % user, template='template_postgis')
345348

346-
grant_sql = 'grant all on schema public to %s;' % user
349+
grant_sql = 'GRANT ALL ON schema public to %s;' % user
347350
# assumption is env.repo_alias is also database name
348351
run('psql %s -c "%s"' % (dbname, grant_sql))
349352
grant_sql = (

install_fabgis.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
FABRICMIN=1.6.0
3+
FABTOOMIN=0.13.0
4+
if [ -z `which pip 2>/dev/null` ]; then sudo apt-get install python-pip; fi
5+
if [ -z `pip freeze | grep Fabric` ]
6+
then
7+
sudo pip install fabric
8+
else
9+
VERSION=`pip freeze | grep Fabric`
10+
FABRICVER=`(echo ${VERSION#*=} | cut -f2 -d= )`
11+
if [[ $FABRICVER < $FABRICMIN ]]
12+
then
13+
echo Your Version of Fabric is $FABRICVER but you must
14+
echo have at least Version 1.6.0 of Fabric installed
15+
fi
16+
fi
17+
if [ -z `pip freeze | grep fabtools` ]
18+
then
19+
sudo pip install fabtools
20+
else
21+
VERSION=`pip freeze | grep fabtools`
22+
FABTOOVER=`(echo ${VERSION#*=} | cut -f2 -d= )`
23+
if [[ $FABTOOVER < $FABTOOMIN ]]
24+
then
25+
echo Your Version of fabtools is $FABTOOVER but you must
26+
echo have at least Versgrant all on schema publicion 0.13.0 of Fabric installed
27+
fi
28+
fi
29+
if [ -z `which git 2>/dev/null` ]; then sudo apt-get install git; fi
30+
echo Checking for local ssh-server needs root access
31+
if [ -z `sudo which sshd 2>/dev/null` ]; then sudo apt-get install openssh-server; fi
32+
if [ ! -d $HOME/fabgis ]; then git clone git://github.com/timlinux/fabgis; fi
33+
cd $HOME/fabgis
34+
fab -H localhost fabgis.fabgis.setup_qgis2_and_postgis

0 commit comments

Comments
 (0)