-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathMakefile
120 lines (102 loc) · 2.86 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
pidfile = $(abspath web/logs/nginx.pid)
webpath = $(abspath web/)
openresty = openresty
opm = $(abspath bin/opm) --cwd
opm_pkg_indexer = $(abspath util/opm-pkg-indexer.pl) -i 1
tt2_files := $(sort $(wildcard web/templates/*.tt2))
templates_lua = web/lua/opmserver/templates.lua
md2html = ./util/fmtMd.js
md_files := $(wildcard web/docs/md/*.md)
html_files := $(patsubst web/docs/md/%.md,web/docs/html/%.html,$(md_files))
INSTALL ?= install
CP ?= cp
VERSION ?= 0.1
RELEASE ?= 1
.PRECIOUS: $(md_files)
.DELETE_ON_ERRORS: $(templates_lua)
.PHONY: all
all: $(templates_lua) $(html_files)
$(templates_lua): $(tt2_files)
mkdir -p web/lua/opmserver/
lemplate --compile $^ > $@
.PHONY: html
html: $(html_files)
web/docs/html/%.html: web/docs/md/%.md
@mkdir -p web/docs/html
$(md2html) $< > $@
.PHONY: test
test: | initdb restart
#./bin/opm build
#-time ./bin/opm upload
rm -rf /tmp/final /tmp/failed /tmp/original *.pid
mkdir -p /tmp/incoming /tmp/final /tmp/failed
cd ../lua-resty-lrucache && $(opm) build
cd ../lua-resty-lrucache && $(opm) upload
PATH=$$PWD/bin:$$PATH time $(opm_pkg_indexer)
$(opm) get openresty/lua-resty-lrucache
cd ../lua-resty-core && $(opm) build
cd ../lua-resty-core && $(opm) upload
PATH=$$PWD/bin:$$PATH time $(opm_pkg_indexer)
$(opm) remove openresty/lua-resty-lrucache
$(opm) get openresty/lua-resty-core
curl -H 'Server: opm.openresyt.org' http://localhost:8080/
.PHONY: restart
$(MAKE) stop start
.PHONY: run
run: all
mkdir -p $(webpath)/logs
cd web && $(openresty) -p $$PWD/
.PHONY: reload
reload: all
$(openresty) -p $(webpath)/ -t
test -f $(pidfile)
rm -f $(webpath)/logs/error.log
#rm -f /tmp/openresty/*
#kill -USR1 `cat $(pidfile)`
kill -HUP `cat $(pidfile)`
sleep 0.002
.PHONY: stop
stop:
test -f $(pidfile)
kill -QUIT `cat $(pidfile)`
.PHONY: restart
restart:
-$(MAKE) stop
sleep 0.01
$(MAKE) run
.PHONY: check
check: clean
find . -name "*.lua" | lj-releng -L
.PHONY: initdb
initdb: $(tsv_files)
psql -Uopm opm -f init.sql
.PHONY: install
install:
$(MAKE) all
$(INSTALL) -d $(DESTDIR)
$(INSTALL) -d $(DESTDIR)web/
$(CP) -r bin $(DESTDIR)bin
$(CP) -r util $(DESTDIR)util
$(CP) -r web/conf $(DESTDIR)web/conf
rm -f $(DESTDIR)web/conf/config.ini
$(CP) -r web/css $(DESTDIR)web/css
$(CP) -r web/js $(DESTDIR)web/js
$(CP) -r web/images $(DESTDIR)web/images
$(CP) -r web/docs/ $(DESTDIR)web/docs/
$(CP) -r web/lua $(DESTDIR)web/lua
.PHONY: rpm
rpm:
rm -rf buildroot
$(MAKE) install DESTDIR=$$PWD/buildroot/usr/local/opm/
fpm -f -s dir -t rpm -v "$(VERSION)" --iteration "$(RELEASE)" \
-n opm-server \
-C $$PWD/buildroot/ -p ./buildroot \
--vendor "OpenResty.org" --license Proprietary \
--description 'opm server' --url 'https://www.openresty.org/' \
-m 'OpenResty <[email protected]>' \
--license proprietary -a all \
usr/local/opm
.PHONY: clean
clean:
rm -f $(webpath)/lua/opmserver/templates.lua
rm -f $(html_files)