-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
130 lines (96 loc) · 2.54 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
#
# Ecix Birdseye Server
#
# This makefile provides scripts for building
# the distribution and creating a .rpm file
#
APP=birdseye
# Remote RPM building server
BUILD_SERVER=''
### END CONFIGURATION ###
#
# Do not change anything below this line, unless you
# really know what you are doing.
#
APP_VERSION=$(shell cat VERSION)
VERSION=$(APP_VERSION)
ARCH=noarch
# Distribution directory
DIST=BUILD-RPM
REMOTE_DIST=$(APP)-$(DIST)
BUILD_ARCHIVE=.$(APP)-BUILD.tar.gz
APP_DIST=$(DIST)/opt/ecix/$(APP)
LOCAL_RPMS=RPMS
RPM=$(APP)-$(VERSION)-1.$(ARCH).rpm
dist:
mkdir -p $(LOCAL_RPMS)
mkdir -p $(DIST)/etc
# Copy configuration and startup
cp -r etc/* $(DIST)/etc/.
# Exclude local config files from dist
rm -f $(DIST)/etc/birdseye/*local*
# Create app install target
mkdir -p $(APP_DIST)
# Copy app
rsync -av \
--exclude Makefile \
--exclude $(DIST) \
--exclude $(LOCAL_RPMS) \
--exclude builds \
--exclude node_modules \
--exclude venv \
--exclude *example.conf \
--exclude *local* \
--exclude *.pid \
--exclude *.swp \
--exclude *.swo \
--exclude *.pyc \
--exclude *.sqlite3 \
* $(APP_DIST)
# Copy deploy scripts
cp -r deploy/* $(DIST)/.
rpm: dist
# Clear rpm archive (CI related stuff)
rm -fr $(LOCAL_RPMS)
mkdir -p $(LOCAL_RPMS)
fpm -s dir -t rpm -n $(APP) -v $(VERSION) -C $(DIST) \
--architecture $(ARCH) \
--depends gcc \
--depends python-virtualenv \
--config-files /etc/birdseye/birdseye.conf \
--after-install $(DIST)/after_install \
etc/ opt/
# Move rpm to target directory
mv $(RPM) $(LOCAL_RPMS)/.
#
# Build the rpm on the build server
#
$(LOCAL_RPMS)/$(RPM): dist
# Make build archive and copy to server
tar czf $(BUILD_ARCHIVE) $(DIST)/*
scp $(BUILD_ARCHIVE) $(BUILD_SERVER):.
rm $(BUILD_ARCHIVE)
# Unpack distribution build server
ssh $(BUILD_SERVER) -- rm -rf $(REMOTE_DIST)
ssh $(BUILD_SERVER) -- mkdir $(REMOTE_DIST)
ssh $(BUILD_SERVER) -- "cd $(REMOTE_DIST) && tar xzf ../$(BUILD_ARCHIVE)"
# Clean existing rpm on server
ssh $(BUILD_SERVER) -- \
rm -f $(RPM)
ssh $(BUILD_SERVER) -- \
fpm -s dir -t rpm -n $(APP) -v $(VERSION) -C $(REMOTE_DIST)/$(DIST) \
--architecture $(ARCH) \
--depends gcc \
--depends python-virtualenv \
--config-files /etc/birdseye/birdseye.conf \
--after-install $(REMOTE_DIST)/$(DIST)/after_install \
etc/ opt/
# Get rpm from server
scp $(BUILD_SERVER):$(RPM) $(LOCAL_RPMS)/.
clean:
rm -rf $(DIST)
build_server:
ifeq ($(BUILD_SERVER), '')
$(error BUILD_SERVER not configured)
endif
remote_rpm: build_server $(LOCAL_RPMS)/$(RPM)