-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
120 lines (81 loc) · 1.96 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
#
# Makefile for One-Shot Docker Builder
#
# Note that this is for development and container image builds.
#
# What should be tested. This should be 'rpm' or 'deb'.
TEST_WITH := rpm
ifndef GNUPGHOME
export GNUPGHOME := ./test-keyring
endif
KEY := Test Key
PASSPHRASE_FILE := ./test-keyring/passphrase
# ----- NO USER-SERVICEABLE PARTS BELOW THIS LINE -----
# What container to use/build
ifeq ($(TEST_WITH),rpm)
CONTAINER_FROM := almalinux:latest
endif
ifeq ($(TEST_WITH),deb)
CONTAINER_FROM := debian:latest
endif
ifndef CONTAINER_FROM
$(error TEST_WITH should be 'rpm' or 'deb')
endif
# Which repository should be used for testing
TEST_REPO := ./test-repos/$(TEST_WITH)
# How to invoke Docker
ifneq ($(shell id -u),0)
DOCKER=sudo docker
else
DOCKER=docker
endif
default: run
# Where the build happens.
IMAGE := signer-test
CONTAINER_NAME := signer-test
default: run
BUILT := .built
ifdef CONTAINER_FROM
IMAGE_ARG := --build-arg 'FROM=$(CONTAINER_FROM)'
endif
$(BUILT): prep Dockerfile Makefile
$(DOCKER) build \
$(IMAGE_ARG) \
--tag $(IMAGE) \
.
touch $@
TO_CLEAN += $(BUILT)
TEST_DIR := ./test
$(TEST_DIR):
rm -rf $@
cp -r "$(TEST_REPO)" $@
TO_CLEAN += $(TEST_DIR)
image: $(BUILT)
SIGN_ARGS += \
--name "$(CONTAINER_NAME)" \
--container "$(IMAGE)" \
--passphrase "$(PASSPHRASE_FILE)" \
"$(TEST_DIR)" "$(KEY)"
# Show the command to run the container (for debug)
command::
./sign --command $(SIGN_ARGS)
RUN_DEPS := $(BUILT) $(BUILD_DIR) $(TEST_DIR)
# Run the container and exit
run: $(RUN_DEPS)
./sign $(SIGN_ARGS)
# Run the container but don't exit (for debug)
persist: $(RUN_DEPS)
./sign --no-halt $(SIGN_ARGS)
# Log into the persisted container
shell:
$(DOCKER) exec -it "$(CONTAINER_NAME)" bash
# Stop the persisted container
halt:
$(DOCKER) exec -it "$(CONTAINER_NAME)" halt
# Remove the container
rm:
$(DOCKER) rm -f "$(CONTAINER_NAME)"
clean: rm
make -C prep clean
$(DOCKER) image rm -f "$(IMAGE)"
rm -rf $(TO_CLEAN) *~