forked from TritonDataCenter/sdc-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
149 lines (124 loc) · 4.47 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
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
#
# Copyright (c) 2014, Joyent, Inc.
#
NAME:=docker
DOC_FILES = index.md images.md
EXTRA_DOC_DEPS += deps/restdown-brand-remora/.git
RESTDOWN_FLAGS = --brand-dir=deps/restdown-brand-remora
TAPE := ./node_modules/.bin/tape
JS_FILES := $(shell find lib test -name '*.js' | grep -v '/tmp/')
JSL_CONF_NODE = tools/jsl.node.conf
JSL_FILES_NODE = $(JS_FILES)
JSSTYLE_FILES = $(JS_FILES)
JSSTYLE_FLAGS = -f tools/jsstyle.conf
SMF_MANIFESTS_IN = smf/manifests/docker.xml.in
CLEAN_FILES += ./node_modules
NODE_PREBUILT_VERSION=v0.10.32
ifeq ($(shell uname -s),SunOS)
NODE_PREBUILT_TAG=zone
NODE_PREBUILT_IMAGE=de411e86-548d-11e4-a4b7-3bb60478632a
endif
include ./tools/mk/Makefile.defs
ifeq ($(shell uname -s),SunOS)
include ./tools/mk/Makefile.node_prebuilt.defs
else
NPM := $(shell which npm)
NPM_EXEC=$(NPM)
endif
include ./tools/mk/Makefile.smf.defs
VERSION=$(shell json -f $(TOP)/package.json version)
COMMIT=$(shell git describe --all --long | awk -F'-g' '{print $$NF}')
RELEASE_TARBALL:=$(NAME)-pkg-$(STAMP).tar.bz2
RELSTAGEDIR:=/tmp/$(STAMP)
#
# Targets
#
.PHONY: all
all: $(SMF_MANIFESTS) build/build.json | $(TAPE) $(NPM_EXEC) sdc-scripts
$(NPM) install
build/build.json:
mkdir -p build
echo "{\"version\": \"$(VERSION)\", \"commit\": \"$(COMMIT)\", \"stamp\": \"$(STAMP)\"}" | json >$@
sdc-scripts: deps/sdc-scripts/.git
$(TAPE): | $(NPM_EXEC)
$(NPM) install
CLEAN_FILES += $(TAPE) ./node_modules/tape
.PHONY: test
test: $(TAPE)
@echo '# Running sdc-docker unit tests.'
@echo '#'
@echo '# Note: to run *integration tests*, run this from the *GZ* of an SDC with Docker setup:'
@echo '# /zones/$$(vmadm lookup -1 alias=docker0)/root/opt/smartdc/docker/test/runtests'
@echo
@(for F in test/unit/*.test.js; do \
echo "# $$F" ;\
$(NODE) $(TAPE) $$F ;\
[[ $$? == "0" ]] || exit 1; \
done)
.PHONY: git-hooks
git-hooks:
[[ -e .git/hooks/pre-commit ]] || ln -s ../../tools/pre-commit.sh .git/hooks/pre-commit
#
# Packaging targets
#
.PHONY: release
release: all
@echo "Building $(RELEASE_TARBALL)"
# boot
mkdir -p $(RELSTAGEDIR)/root/opt/smartdc/boot
cp -R $(TOP)/deps/sdc-scripts/* $(RELSTAGEDIR)/root/opt/smartdc/boot/
cp -R $(TOP)/boot/* $(RELSTAGEDIR)/root/opt/smartdc/boot/
# docker
mkdir -p $(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/{etc,build}
cp -r \
$(TOP)/package.json \
$(TOP)/bin \
$(TOP)/lib \
$(TOP)/node_modules \
$(TOP)/smf \
$(TOP)/tls \
$(TOP)/test \
$(TOP)/sapi_manifests \
$(RELSTAGEDIR)/root/opt/smartdc/$(NAME)
cp build/build.json $(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/etc/
cp -r \
$(TOP)/build/node \
$(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/build
# Trim node
rm -rf \
$(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/build/node/bin/npm \
$(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/build/node/lib/node_modules \
$(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/build/node/include \
$(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/build/node/share
# Trim node_modules (this is death of a 1000 cuts, try for some
# easy wins).
# XXX these inherited from imgapi, review them
find $(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/node_modules -name test | xargs -n1 rm -rf
find $(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/node_modules -name tests | xargs -n1 rm -rf
find $(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/node_modules -name examples | xargs -n1 rm -rf
find $(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/node_modules -name "draft-*" | xargs -n1 rm -rf # draft xml stuff in json-schema
find $(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/node_modules -name libusdt | xargs -n1 rm -rf # dtrace-provider
find $(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/node_modules -name obj.target | xargs -n1 rm -rf # dtrace-provider
find $(RELSTAGEDIR)/root/opt/smartdc/$(NAME)/node_modules -name deps | grep 'extsprintf/deps$$' | xargs -n1 rm -rf # old extsprintf shipped dev bits
# Tar
(cd $(RELSTAGEDIR) && $(TAR) -jcf $(TOP)/$(RELEASE_TARBALL) root)
@rm -rf $(RELSTAGEDIR)
.PHONY: publish
publish: release
@if [[ -z "$(BITS_DIR)" ]]; then \
@echo "error: 'BITS_DIR' must be set for 'publish' target"; \
exit 1; \
fi
mkdir -p $(BITS_DIR)/$(NAME)
cp $(TOP)/$(RELEASE_TARBALL) $(BITS_DIR)/$(NAME)/$(RELEASE_TARBALL)
include ./tools/mk/Makefile.deps
ifeq ($(shell uname -s),SunOS)
include ./tools/mk/Makefile.node_prebuilt.targ
endif
include ./tools/mk/Makefile.smf.targ
include ./tools/mk/Makefile.targ