root / fabfile.py @ a0757a1c
History | View | Annotate | Download (3.5 kB)
1 |
# Copyright 2011 GRNET S.A. All rights reserved.
|
---|---|
2 |
#
|
3 |
# Redistribution and use in source and binary forms, with or
|
4 |
# without modification, are permitted provided that the following
|
5 |
# conditions are met:
|
6 |
#
|
7 |
# 1. Redistributions of source code must retain the above
|
8 |
# copyright notice, this list of conditions and the following
|
9 |
# disclaimer.
|
10 |
#
|
11 |
# 2. Redistributions in binary form must reproduce the above
|
12 |
# copyright notice, this list of conditions and the following
|
13 |
# disclaimer in the documentation and/or other materials
|
14 |
# provided with the distribution.
|
15 |
#
|
16 |
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 |
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 |
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 |
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 |
# POSSIBILITY OF SUCH DAMAGE.
|
28 |
#
|
29 |
# The views and conclusions contained in the software and
|
30 |
# documentation are those of the authors and should not be
|
31 |
# interpreted as representing official policies, either expressed
|
32 |
# or implied, of GRNET S.A.
|
33 |
#
|
34 |
|
35 |
import os |
36 |
import sys |
37 |
|
38 |
from fabric.api import * |
39 |
from fabric.colors import * |
40 |
|
41 |
env.project_root = "./"
|
42 |
env.develop = False
|
43 |
env.autoremove = True
|
44 |
env.packages = ['snf-common', 'snf-app', 'snf-ganeti-tools', 'snf-webproject', |
45 |
'snf-okeanos-site']
|
46 |
env.capture = False
|
47 |
env.colors = True
|
48 |
|
49 |
# coloured logging
|
50 |
notice = lambda x: sys.stdout.write(yellow(x) + "\n") |
51 |
info = lambda x: sys.stdout.write(green(x) + "\n") |
52 |
error = lambda x: sys.stdout.write(red(x) + "\n") |
53 |
|
54 |
|
55 |
def dev(): |
56 |
env.develop = True
|
57 |
|
58 |
# wrap local to respect global capturing setting from env.capture
|
59 |
oldlocal = local |
60 |
def local(cmd, capture=False): |
61 |
return oldlocal(cmd, capture=env.capture)
|
62 |
|
63 |
|
64 |
def package_root(p): |
65 |
return os.path.join(env.project_root, p)
|
66 |
|
67 |
|
68 |
def remove_pkg(p): |
69 |
notice("uninstalling package: %s" % p)
|
70 |
with lcd(package_root(p)):
|
71 |
with settings(warn_only=True): |
72 |
local("pip uninstall %s -y" % p, env.capture)
|
73 |
|
74 |
|
75 |
def build_pkg(p): |
76 |
info ("building package: %s" % p)
|
77 |
with lcd(package_root(p)):
|
78 |
with settings(warn_only=True): |
79 |
local("rm -r dist build")
|
80 |
local("python setup.py sdist")
|
81 |
|
82 |
|
83 |
def install_pkg(p): |
84 |
info("installing package: %s" % p)
|
85 |
with lcd(package_root(p)):
|
86 |
if env.develop:
|
87 |
local("python setup.py develop")
|
88 |
else:
|
89 |
local("python setup.py install")
|
90 |
|
91 |
|
92 |
def install(*packages): |
93 |
for p in packages: |
94 |
install_pkg("snf-%s" % p)
|
95 |
|
96 |
|
97 |
def buildall(): |
98 |
for p in env.packages: |
99 |
build_pkg(p) |
100 |
collectdists() |
101 |
|
102 |
|
103 |
def installall(): |
104 |
for p in env.packages: |
105 |
install_pkg(p) |
106 |
|
107 |
def collectdists(): |
108 |
if os.path.exists("./packages"): |
109 |
notice("removing 'packages' directory")
|
110 |
local("rm -r packages");
|
111 |
|
112 |
local("mkdir packages");
|
113 |
for p in env.packages: |
114 |
local("cp %s/dist/*.tar.gz ./packages/" % package_root(p));
|
115 |
|
116 |
|
117 |
def removeall(): |
118 |
for p in env.packages: |
119 |
remove_pkg(p) |
120 |
|
121 |
|
122 |
def remove(*packages): |
123 |
for p in packages: |
124 |
remove_pkg("snf-%s" % p)
|
125 |
|
126 |
|
127 |
|