1 # Copyright 2011 GRNET S.A. All rights reserved.
3 # Redistribution and use in source and binary forms, with or
4 # without modification, are permitted provided that the following
7 # 1. Redistributions of source code must retain the above
8 # copyright notice, this list of conditions and the following
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.
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.
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.
38 from contextlib import contextmanager
39 from fabric.api import *
40 from fabric.colors import *
42 env.project_root = "./"
45 env.packages = ['snf-pithos-lib', 'snf-pithos-backend', 'snf-pithos-app',
47 env.deb_packages = ['snf-pithos-lib', 'snf-pithos-backend']
50 env.pypi_root = 'pypi'
52 'docs': ['docs.dev.grnet.gr'],
53 'pypi': ['docs.dev.grnet.gr']
57 notice = lambda x: sys.stdout.write(yellow(x) + "\n")
58 info = lambda x: sys.stdout.write(green(x) + "\n")
59 error = lambda x: sys.stdout.write(red(x) + "\n")
65 # wrap local to respect global capturing setting from env.capture
67 def local(cmd, capture="default"):
68 if capture != "default":
72 return oldlocal(cmd, capture=capture)
76 return os.path.join(env.project_root, p)
80 notice("uninstalling package: %s" % p)
81 with lcd(package_root(p)):
82 with settings(warn_only=True):
83 local("pip uninstall %s -y" % p, env.capture)
87 info ("building package: %s" % p)
88 with lcd(package_root(p)):
89 with settings(warn_only=True):
90 local("rm -r dist build")
91 local("python setup.py egg_info -d sdist")
95 info("installing package: %s" % p)
96 with lcd(package_root(p)):
99 local("python setup.py develop")
101 local("python setup.py install")
104 def install(*packages):
106 install_pkg("snf-%s" % p)
110 for p in env.packages:
116 for p in env.packages:
120 if os.path.exists("./packages"):
121 notice("removing 'packages' directory")
122 local("rm -r packages");
124 local("mkdir packages");
125 for p in env.packages:
126 local("cp %s/dist/*.tar.gz ./packages/" % package_root(p));
129 for p in env.packages:
133 def remove(*packages):
135 remove_pkg("snf-%s" % p)
143 def git(params, locl=True):
144 cmd = local if locl else run
145 return cmd("git %s" % params, capture=True)
149 return git("symbolic-ref HEAD").split("/")[-1]
154 current_branch = branch();
155 git("checkout %s" % c)
157 git("checkout %s" % current_branch)
161 # Debian packaging helpers
165 def builddeb(p, master="master", branch="debian-0.8"):
166 with lcd(package_root(p)):
167 with settings(warn_only=True):
169 local("python setup.py clean")
170 local("git add synnefo/versions/*.py -f")
171 local("git-buildpackage --git-upstream-branch=%s --git-debian-branch=%s \
172 --git-export=INDEX --git-ignore-new" % (master, branch))
174 local("git reset synnefo/versions/*.py")
177 def builddeball(b="debian-0.8"):
179 for p in env.deb_packages:
185 build_area = env.get('build_area', '../build-area')
186 for p in env.deb_packages:
187 local("cp %s/%s*.deb ./packages/" % (build_area, p))
191 put("packages/*.tar.gz", 'www/pypi/')