forked from gvagenas/jboss71-clickstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.mk
84 lines (64 loc) · 1.93 KB
/
plugin.mk
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
# plugin.mk
#
# This file can be included in CloudBees clickstack plugin makefiles to
# provide common build features.
#
#===================================================================
# Variables
#===================================================================
s3cfg = s3cfg
#===================================================================
# Functions
#===================================================================
UNAME := $(shell uname)
ifeq ($(UNAME),Darwin)
check-md5 = echo "$(2) $(1)" | md5 -r
else
check-md5 = echo "$(2) $(1)" | md5sum --check
endif
define check-val
@if [ "$1" = "" ]; then \
echo "Missing required Makefile variable $2"; \
exit 1; \
fi
endef
#===================================================================
# Targets
#===================================================================
all: pkg
clean: clean-deps clean-pkg
deps: $(deps)
clean-deps:
@if [ ! "$(deps)" = "" ]; then \
echo "rm -rf $(deps)"; \
rm -rf $(deps); \
fi
pkg: pkg_files-var plugin_name-var deps clean-pkg
mkdir pkg
cp -a $(pkg_files) pkg
cd pkg; zip -r ../$(plugin_name).zip *
clean-pkg: plugin_name-var
rm -rf pkg
rm -f $(plugin_name).zip
publish: plugin_name-var publish_url-var s3cfg s3cmd pkg republish
republish:
s3cmd put -Pc $(s3cfg) $(plugin_name).zip $(publish_url)
s3cfg:
@if [ ! -e $(s3cfg) ]; then \
echo "To publish to s3, copy s3cfg.in to s3cfg and edit" \
"s3cfg specifying your AWS credentials for s3." | fold -s; \
exit 1; \
fi
s3cmd:
@if [ "$$(which s3cmd)" = "" ]; then \
echo "To publish to s3, you must install s3cmd. If a system" \
"package isn't available, you can download the source from" \
"http://s3tools.org/s3cmd." | fold -s; \
exit 1; \
fi
pkg_files-var:
$(call check-val,$(pkg_files),pkg_files)
plugin_name-var:
$(call check-val,$(plugin_name),plugin_name)
publish_url-var:
$(call check-val,$(publish_url),publish_url)