This repository has been archived by the owner on May 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Makefile
161 lines (134 loc) · 4.46 KB
/
Makefile
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
SHELL=bash
# set REAL_BUILD in the env to actually do the build; otherwise,
# presumes existence of BUILD_PRODUCT_TGZ and merely packages
SRC := $(shell pwd)
# set these only if not set with ?=
VERSION ?= $(shell $(SRC)/get-versions.sh VERSION)
REVISION ?= $(shell $(SRC)/get-versions.sh REVISION)
BUILD_PRODUCT_TGZ=$(SRC)/calamari-clients-build-output.tar.gz
RPM_REVISION ?= $(shell $(SRC)/get-versions.sh -r REVISION)
RPMBUILD=$(SRC)/../rpmbuild
DIST ?= unstable
BPTAG ?= ""
DEBEMAIL ?= dan.mick@inktank.com
ARCH ?= x86_64
TSCOMMIT=$(shell git log -n1 --pretty=format:"%ct.%h")
SUSE_PKG=calamari-clients-$(VERSION)+git.$(TSCOMMIT)
SUSE_DEST=/srv/www/calamari
SUSE_TAR=$(SUSE_PKG).tar.gz
DISTNAMEVER=calamari-clients_$(VERSION)
PKGDIR=calamari-clients-$(VERSION)
TARNAME = ../$(DISTNAMEVER).tar.gz
INSTALL=/usr/bin/install
UI_BASEDIR = $(DESTDIR)/opt/calamari/webapp/content
UI_SUBDIRS = manage admin login dashboard
CONFIG_JSON = dashboard/dist/scripts/config.json
FINDCMD =find . \
-name .git -prune \
-o -name node_modules -prune \
-o -name .tmp -prune \
-o -name .sass-cache -prune \
-o -name debian -prune \
-o -print0
default: build
DATESTR=$(shell /bin/echo -n "built on "; date)
set_deb_version:
DEBEMAIL=$(DEBEMAIL) dch \
--newversion $(VERSION)-$(REVISION)$(BPTAG) \
-D $(DIST) --force-bad-version --force-distribution "$(DATESTR)"
build:
if [ "$(REAL_BUILD)" = y ] ; then \
$(MAKE) build-real; \
fi
build-real: build-ui $(CONFIG_JSON)
build-ui:
@echo "building ui"
set -e ;\
for d in $(UI_SUBDIRS); do \
echo $$d; cd $$d; $(MAKE) build; cd .. ; \
done
# for right now, this contains two useful things that should be set
# when running against a live cluster. We could preinstall it in the
# package or do it in a postinstall; it has more visibility here
$(CONFIG_JSON): build-ui
echo '{ "offline": false, "graphite-host": "/graphite" }' \
> $(CONFIG_JSON)
clean:
if [ "$(REAL_BUILD)" = y ] ; then \
$(MAKE) clean-real; \
fi
clean-real:
for d in $(UI_SUBDIRS); do \
echo $$d; cd $$d; $(MAKE) clean; cd .. ; \
done ;
rm -f $(BUILD_PRODUCT_TGZ)
# NB we do not build source packages
dpkg: set_deb_version
# don't require Build-Depends if not Ubuntu
if [ "$(REAL_BUILD)" = y ] ; then \
dpkg-buildpackage -b -us -uc ; \
else \
dpkg-buildpackage -d -b -us -uc ; \
fi
build-product:
if [ "$(REAL_BUILD)" = y ] ; then \
( \
cd debian/calamari-clients; \
tar cvfz $(BUILD_PRODUCT_TGZ) opt ; \
) \
fi
# magic rpm build target: assumes build/install has already happened on
# precise, and uses the prebuilt BUILD_PRODUCT_TGZ with rpmbuild
rpm:
mkdir -p $(RPMBUILD)/{SPECS,RPMS,BUILDROOT}
cp clients.spec $(RPMBUILD)/SPECS
( \
cd $(RPMBUILD); \
rpmbuild -bb --define "_topdir $(RPMBUILD)" --define "version $(VERSION)" --define "revision $(RPM_REVISION)" --define "tarname $(BUILD_PRODUCT_TGZ)" SPECS/clients.spec; \
)
# either put the build files into $DESTDIR on Ubuntu, or
# untar them from BUILD_PRODUCT_TGZ on other distros
install: build
@echo "target: install"
@echo "install"
if [ "$(REAL_BUILD)" = y ] ; then \
for d in $(UI_SUBDIRS); do \
instdir=$$(basename $$d); \
$(INSTALL) -d $(UI_BASEDIR)/$$instdir; \
cp -rp $$d/dist/* $(UI_BASEDIR)/$$instdir; \
done; \
else \
cd $(DESTDIR); \
tar xvfz $(BUILD_PRODUCT_TGZ); \
fi
# Does build-real (thus requiring grunt, bower and compass be installed),
# then packs everything into a tarball like the install target above,
# except it's created in the .tmp subdirectory of the source tree, and
# packed with a name in the form:
# calamari-clients-1.2+git.1406029226.d2b9ccc.tar.bz",
# i.e. the commit timestamp and hash are included in the tarball name.
# Note: the directory structure here is /srv/www/calamari, to follow
# SUSE packaging conventions for web apps.
suse-tarball: build-real
rm -rf .tmp
mkdir -p .tmp/$(SUSE_PKG)$(SUSE_DEST)/content
for d in $(UI_SUBDIRS); do \
instdir=$$(basename $$d); \
$(INSTALL) -d .tmp/$(SUSE_PKG)$(SUSE_DEST)/content/$$instdir; \
cp -rp $$d/dist/* .tmp/$(SUSE_PKG)$(SUSE_DEST)/content/$$instdir; \
done;
( cd .tmp ; tar cvfz ../$(SUSE_TAR) $(SUSE_PKG) )
dist:
@echo "making dist tarball in $(TARNAME)"
for d in $(UI_SUBDIRS); do \
echo $$d; \
(cd $$d; \
npm install --silent; \
grunt --no-color saveRevision) \
done
@rm -rf $(PKGDIR)
@$(FINDCMD) | cpio --null -p -d $(PKGDIR)
@tar -zcf $(TARNAME) $(PKGDIR)
@rm -rf $(PKGDIR)
@echo "tar file made in $(TARNAME)"
.PHONY: dist clean build dpkg install