Revision f3d68c6f
b/fabfile.py | ||
---|---|---|
35 | 35 |
import os |
36 | 36 |
import sys |
37 | 37 |
|
38 |
from contextlib import contextmanager |
|
38 | 39 |
from fabric.api import * |
39 | 40 |
from fabric.colors import * |
40 | 41 |
|
... | ... | |
43 | 44 |
env.autoremove = True |
44 | 45 |
env.packages = ['snf-common', 'snf-app', 'snf-ganeti-tools', 'snf-webproject', |
45 | 46 |
'snf-okeanos-site'] |
47 |
env.deb_packages = ['snf-common', 'snf-app', 'snf-ganeti-tools', 'snf-webproject'] |
|
46 | 48 |
env.capture = False |
47 | 49 |
env.colors = True |
48 | 50 |
|
... | ... | |
57 | 59 |
|
58 | 60 |
# wrap local to respect global capturing setting from env.capture |
59 | 61 |
oldlocal = local |
60 |
def local(cmd, capture=False): |
|
61 |
return oldlocal(cmd, capture=env.capture) |
|
62 |
def local(cmd, capture="default"): |
|
63 |
if capture != "default": |
|
64 |
capture = capture |
|
65 |
else: |
|
66 |
capture = env.capture |
|
67 |
return oldlocal(cmd, capture=capture) |
|
62 | 68 |
|
63 | 69 |
|
64 | 70 |
def package_root(p): |
... | ... | |
113 | 119 |
for p in env.packages: |
114 | 120 |
local("cp %s/dist/*.tar.gz ./packages/" % package_root(p)); |
115 | 121 |
|
116 |
|
|
117 | 122 |
def removeall(): |
118 | 123 |
for p in env.packages: |
119 | 124 |
remove_pkg(p) |
... | ... | |
124 | 129 |
remove_pkg("snf-%s" % p) |
125 | 130 |
|
126 | 131 |
|
132 |
# |
|
133 |
# GIT helpers |
|
134 |
# |
|
135 |
|
|
136 |
|
|
137 |
def git(params, locl=True): |
|
138 |
cmd = local if locl else run |
|
139 |
return cmd("git %s" % params, capture=True) |
|
140 |
|
|
141 |
|
|
142 |
def branch(): |
|
143 |
return git("symbolic-ref HEAD").split("/")[-1] |
|
144 |
|
|
145 |
|
|
146 |
@contextmanager |
|
147 |
def co(c): |
|
148 |
current_branch = branch(); |
|
149 |
git("checkout %s" % c) |
|
150 |
yield |
|
151 |
git("checkout %s" % current_branch) |
|
152 |
|
|
153 |
|
|
154 |
# |
|
155 |
# Debian packaging helpers |
|
156 |
# |
|
157 |
|
|
158 |
|
|
159 |
def builddeb(p, master="master", branch="debian-0.8"): |
|
160 |
with lcd(package_root(p)): |
|
161 |
with settings(warn_only=True): |
|
162 |
local("mkdir .git") |
|
163 |
local("git-buildpackage --git-upstream-branch=%s --git-debian-branch=%s \ |
|
164 |
--git-export=INDEX --git-ignore-new" % (master, branch)) |
|
165 |
local("rm -rf .git") |
|
166 |
local("git co .") |
|
167 |
|
|
168 |
|
|
169 |
def builddeball(b="debian-0.8"): |
|
170 |
with co(b): |
|
171 |
for p in env.deb_packages: |
|
172 |
builddeb(p, b) |
|
173 |
collectdebs() |
|
174 |
|
|
175 |
|
|
176 |
def collectdebs(): |
|
177 |
build_area = env.get('build_area', '../build-area') |
|
178 |
for p in env.deb_packages: |
|
179 |
local("cp %s/%s*.deb ./packages/" % (build_area, p)) |
|
127 | 180 |
|
Also available in: Unified diff