1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
PYTHON ?= python
CURDIR ?= $(shell pwd)
DESTDIR ?= /
LPRESULTS_CONFIG ?= default
PY = $(CURDIR)/bin/py
PYTHONPATH := $(CURDIR)/lib:${PYTHONPATH}
MANAGE = $(CURDIR)/bin/manage.py
# Only mention things genuinely produced by buildout.
BUILDOUT_FLAGS = -N
BUILDOUT_CFG = buildout.cfg
BUILDOUT_BIN = $(PY) $(MANAGE) bin/jslint bin/lint bin/site.wsgi
# The add-apt-repository command later introduced the --yes option.
SOFTWARE_PROPERTIES_VERSION = $(shell dpkg-query -W -f='$${Version}' python-software-properties)
SOFTWARE_PROPERTIES_OPTS = $(shell dpkg --compare-versions $(SOFTWARE_PROPERTIES_VERSION) ge 0.81.9 && echo '--yes')
# This can be replaced with launchpad-results-dependencies to simulate
# the environment where launchpad-results-server will be installed.
LPRESULTS_DEPENDENCIES_PACKAGE ?= launchpad-results-developer-dependencies
LPRESULTS_DEPENDENCIES_PPA ?= launchpad-results
# If this is not set or set to a non-existing directory, a clean
# checkout will be performed for you, but this can take a while.
LPRESULTS_DOWNLOAD_CACHE ?= $(CURDIR)/build/download-cache
# To update dependencies, call "make build BUILDOUT_FLAGS='-n'" which
# will force a "bzr pull" for each dependency in the source directory.
LPRESULTS_SOURCE_DEPENDENCIES ?= $(CURDIR)/build/source-dependencies
TEMPLATES_DIR = templates
TEMPLATES_MACROS = $(TEMPLATES_DIR)/base-layout-macros.html
MEDIA_DIR = static
MEDIA_BUILD_DIR = $(MEDIA_DIR)/build
MEDIA_TEMPLATE = $(MEDIA_DIR)/launchpad/style-3-0.css.in
APIDOC_DIR = $(TEMPLATES_DIR)/apidoc
APIDOC_FORMAT = $(APIDOC_DIR).tmp/wadl-%(version)s.xml
APIDOC_STYLESHEET = lib/lpresults/tracker/wadl-to-refhtml.xsl
STORAGE_BUCKETS_ATTACHMENTS=attachments
ifeq "$(LPRESULTS_CONFIG)" "default"
STORM_STORES_SESSION=lpresults-session
STORM_STORES_TEST_1=lpresults-test-1
STORM_STORES_TRACKER=lpresults-tracker
else
STORM_STORES_SESSION=lpresults-$(LPRESULTS_CONFIG)-session
STORM_STORES_TEST_1=lpresults-$(LPRESULTS_CONFIG)-test-1
STORM_STORES_TRACKER=lpresults-$(LPRESULTS_CONFIG)-tracker
endif
check-source-dependencies:
ifeq "$(origin LPRESULTS_SOURCE_DEPENDENCIES)" "file"
@echo
@echo "!!! WARNING !!!"
@echo "*** You have not provided a value for LPRESULTS_SOURCE_DEPENDENCIES!"
@echo "*** A clean checkout will be performed under $(LPRESULTS_SOURCE_DEPENDENCIES)."
@echo
endif
@[ -d "$(LPRESULTS_SOURCE_DEPENDENCIES)/eggs" ] || \
mkdir -p $(LPRESULTS_SOURCE_DEPENDENCIES)/eggs
@[ -d "build" ] || mkdir -p build
ifneq "$(LPRESULTS_SOURCE_DEPENDENCIES)" "$(CURDIR)/build/source-dependencies"
@rm -rf build/source-dependencies
@ln -s $(LPRESULTS_SOURCE_DEPENDENCIES) build/source-dependencies
endif
check-download-cache:
ifeq "$(origin LPRESULTS_DOWNLOAD_CACHE)" "file"
@echo
@echo "!!! WARNING !!!"
@echo "*** You have not provided a value for LPRESULTS_DOWNLOAD_CACHE!"
@echo "*** A clean checkout will be performed under $(LPRESULTS_DOWNLOAD_CACHE)."
@echo
endif
@[ -d "$(LPRESULTS_DOWNLOAD_CACHE)" ] || \
bzr co --lightweight \
http://bazaar.launchpad.net/~launchpad-results/launchpad-results-dependencies/trunk \
$(LPRESULTS_DOWNLOAD_CACHE)
@[ -d "build" ] || mkdir -p build
ifneq "$(LPRESULTS_DOWNLOAD_CACHE)" "$(CURDIR)/build/download-cache"
@rm -rf build/download-cache
@ln -s $(LPRESULTS_DOWNLOAD_CACHE) build/download-cache
endif
ifeq (n, $(findstring n,$(BUILDOUT_FLAGS)))
@bzr up build/download-cache
endif
bin/buildout: check-source-dependencies check-download-cache
PYTHONPATH= $(PYTHON) build/download-cache/dist/bootstrap.py \
--version=1.5.1 \
--setup-source=ez_setup.py \
--download-base=build/download-cache/dist \
--eggs=build/source-dependencies/eggs
$(BUILDOUT_BIN): bin/buildout versions.cfg $(BUILDOUT_CFG) setup.py
$(RM) $@
PYTHONPATH= ./bin/buildout $(BUILDOUT_FLAGS) \
-c configs/$(LPRESULTS_CONFIG)/$(BUILDOUT_CFG) \
"buildout:directory=$(CURDIR)" \
"buildout:config=$(LPRESULTS_CONFIG)" \
| grep -v "Unused options" | grep -v "warning: no files found"
compile: $(MANAGE)
$(APIDOC_DIR): $(APIDOC_STYLESHEET)
mkdir -p $(APIDOC_DIR).tmp
$(MANAGE) apidoc \
--format="$(APIDOC_FORMAT)" \
--stylesheet="$(APIDOC_STYLESHEET)"
$(RM) -r $(APIDOC_DIR)
mv $(APIDOC_DIR).tmp $(APIDOC_DIR)
apidoc: compile $(APIDOC_DIR)
apidoc-clean:
$(RM) -r $(APIDOC_DIR)
$(RM) -r $(APIDOC_DIR).tmp
# Used to generate HTML developer documentation.
doc:
$(MAKE) -C doc/ html
doc-clean:
$(MAKE) -C doc/ clean
media: compile $(TEMPLATES_MACROS) $(MEDIA_TEMPLATE)
$(MANAGE) media \
--builddir="$(MEDIA_BUILD_DIR)" \
--macros="$(TEMPLATES_MACROS)" \
--template="$(MEDIA_TEMPLATE)"
media-clean:
$(RM) -r $(MEDIA_BUILD_DIR)
check: clean build
./bin/manage.py test
lint:
./bin/lint
build: compile apidoc doc media
$(PYTHON) setup.py build \
$(PYTHON_BUILD_ARGS)
# Removing the buildout deps to avoid dealing with divergent branches.
build-clean:
$(RM) .installed.cfg
$(RM) placeholder.txt
$(RM) -r build
$(RM) -r bin
# Setting locale to C to make the database server run in that locale.
build-depends:
ifneq "$(shell dpkg-query -W -f='$${Status}' $(LPRESULTS_DEPENDENCIES_PACKAGE) 2>/dev/null)" \
"install ok installed"
@echo
@echo "!!! WARNING !!!"
@echo "*** The $(LPRESULTS_DEPENDENCIES_PACKAGE) meta package"
@echo "*** will be installed from the $(LPRESULTS_DEPENDENCIES_PPA) PPA."
@echo
-sudo apt-get --yes install python-software-properties
-sudo add-apt-repository $(SOFTWARE_PROPERTIES_OPTS) ppa:$(LPRESULTS_DEPENDENCIES_PPA)
endif
-sudo apt-get update
-LC_ALL=C sudo apt-get --yes install $(LPRESULTS_DEPENDENCIES_PACKAGE)
-sudo -u postgres createuser --superuser --createdb $(USER) || true
clean: build-clean apidoc-clean doc-clean media-clean
-find . -name \*.py[co] -print0 | xargs -r0 $(RM)
createtestdb:
-createdb $(STORM_STORES_SESSION) || true
-createdb $(STORM_STORES_TEST_1) || true
-createdb $(STORM_STORES_TRACKER) || true
createdb: createtestdb
droptestdb:
-dropdb $(STORM_STORES_SESSION) || true
-dropdb $(STORM_STORES_TEST_1) || true
-dropdb $(STORM_STORES_TRACKER) || true
droptestlayerdb:
-psql -l | awk '/lpresults.*layer/ {print $$1}' | xargs -r -n1 dropdb
dropdb: droptestdb droptestlayerdb
syncdb: $(MANAGE)
STORM_STORES_SESSION=postgres:$(STORM_STORES_SESSION) \
STORM_STORES_TEST_1=postgres:$(STORM_STORES_TEST_1) \
STORM_STORES_TRACKER=postgres:$(STORM_STORES_TRACKER) \
$(MANAGE) syncdb
createstorage:
mkdir -p $(STORAGE_BUCKETS_ATTACHMENTS)
dropstorage:
$(RM) -r $(STORAGE_BUCKETS_ATTACHMENTS)
install:
$(PYTHON) setup.py install \
$(PYTHON_INSTALL_ARGS) \
--root=$(DESTDIR)
setup: build-depends build createdb syncdb createstorage
.PHONY: apidoc apidoc-clean build build-clean build-depends check \
check-download-cache check-source-dependencies clean compile \
createdb createstorage createtestdb doc doc-clean dropdb dropstorage \
droptestdb droptestlayerdb install lint media media-clean setup syncdb
|