-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
123 lines (95 loc) · 3.77 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
# Sandstorm Blackrock
# Copyright (c) 2015 Sandstorm Development Group, Inc.
# All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Blackrock's Makefile augments Sandstorm's.
# You may override the following vars on the command line to suit
# your config.
CC=clang
CXX=clang++
CFLAGS=-O2 -g -Wall
CXXFLAGS=$(CFLAGS)
BUILD=0
PARALLEL=$(shell nproc)
.PHONY: all fast clean continuous deps update-deps
define color
printf '\033[0;34m==== $1 ====\033[0m\n'
endef
all: blackrock.tar.xz
fast: blackrock-fast.tar.xz
clean:
rm -rf blackrock*.tar.xz local-config
make -f deps/sandstorm/Makefile clean
continuous: tmp/.deps
make -f deps/sandstorm/Makefile continuous
bundle: tmp/.deps
make -f deps/sandstorm/Makefile bundle
bin/e2fsck: tmp/e2fsprogs/e2fsck/e2fsck check-e2fsprogs.sh
./check-e2fsprogs.sh
shell-env: tmp/.deps
make -f deps/sandstorm/Makefile shell-env
deps: tmp/.deps
tmp/.deps: deps/sandstorm
cd deps/sandstorm && make deps
@mkdir -p tmp
@touch tmp/.deps
deps/sandstorm:
@$(call color,downloading sandstorm)
@mkdir -p deps
git clone https://github.com/sandstorm-io/sandstorm.git deps/sandstorm
deps/e2fsprogs:
@$(call color,downloading e2fsprogs)
@mkdir -p deps
git clone https://github.com/tytso/e2fsprogs.git deps/e2fsprogs
tmp/e2fsprogs/e2fsck/e2fsck: deps/e2fsprogs
@$(call color,build e2fsprogs)
@mkdir -p tmp/e2fsprogs
cd tmp/e2fsprogs && ../../deps/e2fsprogs/configure CFLAGS='-Os -DEXT2_SKIP_UUID' LDFLAGS='-static' && make -j$(PARALLEL)
update-deps:
@$(call color,updating sandstorm)
@cd deps/sandstorm && echo "pulling sandstorm..." && git pull && make update-deps
bin/blackrock.unstripped: bundle
@ # TODO(cleanup): This is ugly.
@$(call color,strip binaries)
@cp bin/blackrock bin/blackrock.unstripped
@strip bin/blackrock
blackrock.tar.xz: bundle bin/e2fsck bin/blackrock.unstripped
@$(call color,compress release bundle)
@tar c --transform="s,^,blackrock/,S" bin/blackrock bin/e2fsck bin/tune2fs bin/resize2fs bundle | xz -c -9e > blackrock.tar.xz
blackrock-fast.tar.xz: bundle bin/e2fsck bin/blackrock.unstripped
@$(call color,compress fast bundle)
@tar c --transform="s,^,blackrock/,S" bin/blackrock bin/e2fsck bin/tune2fs bin/resize2fs bundle | xz -c -0 > blackrock-fast.tar.xz
# ========================================================================================
# Local testing
.local/mongo:
@mkdir -p .local
truncate -s 10737418240 .local/mongo
/sbin/mkfs.ext4 .local/mongo
.local/storage:
@mkdir -p .local
truncate -s 10737418240 .local/storage
/sbin/mkfs.ext4 .local/storage
local-config: test-config.capnp
capnp eval --binary -Isrc test-config.capnp vagrant > local-config
run-local: bundle bin/e2fsck local-config .local/mongo .local/storage
# We need to bring up one VM in advance to make the vboxnet0 network interface appear.
(vagrant status --machine-readable | grep -q 'storage0,state,running') || vagrant up storage0
bin/blackrock master local-config -r
kill-local:
vagrant destroy -f
local-mongo:
mongo -u sandstorm --password="$$(vagrant ssh mongo0 -c 'cat /var/blackrock/bundle/mongo/passwd')" --authenticationDatabase admin 172.28.128.50/meteor
local-admintoken:
vagrant ssh frontend0 -c 'echo -n testtoken > /var/blackrock/bundle/sandstorm/adminToken'
@echo "Now go to: http://localrock.sandstorm.io:6080/setup/token/testtoken"