-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
build_template.mustache
170 lines (144 loc) · 8.04 KB
/
build_template.mustache
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
{{#include}}
include $(SOURCE_DIR){{{include}}}
{{/include}}
{{pkg_name_upper}}_BUILD_DIR=$(BUILD_DIR)/{{{source_name}}}-$({{{pkg_name_upper}}}_VERSION)
BUILD_DIRS+=$({{pkg_name_upper}}_BUILD_DIR)
{{pkg_name_upper}}_DEPS=$({{{pkg_name_upper}}}_BUILD_DIR)
{{pkg_name_upper}}_ASSETS={{#copy_assets}}$({{{pkg_name_upper}}}_BUILD_DIR)/{{{to}}} {{/copy_assets}}{{#get_assets}}$({{{pkg_name_upper}}}_BUILD_DIR)/{{{file_name}}} {{/get_assets}}
{{#shasums}}
{{pkg_name_upper}}_SHASUMS_SIG=$(BUILD_DIR)/{{{source_name}}}-$({{{pkg_name_upper}}}_VERSION)-shasums{{#detached_sig}}.sig{{/detached_sig}}{{^detached_sig}}.asc{{/detached_sig}}
{{pkg_name_upper}}_FILTERED_SHASUMS_FILENAME={{{source_name}}}-$({{{pkg_name_upper}}}_VERSION)-shasums{{#detached_sig}}-filtered{{/detached_sig}}
{{pkg_name_upper}}_FILTERED_SHASUMS=$(BUILD_DIR)/$({{pkg_name_upper}}_FILTERED_SHASUMS_FILENAME)
{{/shasums}}
{{pkg_name_upper}}_FETCH_FILES=$(addprefix $(BUILD_DIR)/,{{#clone_url}}fetch-{{{source_name}}}.stamp{{/clone_url}} {{#unpack}}{{{file_name}}}{{/unpack}} {{#fingerprint}}{{{fingerprint}}}-raw.gpg{{/fingerprint}}) {{#shasums}}$({{{pkg_name_upper}}}_SHASUMS_SIG){{#detached_sig}} $(BUILD_DIR)/{{{source_name}}}-$({{{pkg_name_upper}}}_VERSION)-shasums{{/detached_sig}}{{/shasums}}
{{#clone_url}}
$(BUILD_DIR)/fetch-{{{source_name}}}.stamp: | $(BUILD_DIR)
git clone --recursive {{#git_tag}}-b {{{git_tag}}}{{/git_tag}} '{{{clone_url}}}' $({{{pkg_name_upper}}}_BUILD_DIR)
{{#remove}}
rm -rf "$({{{pkg_name_upper}}}_BUILD_DIR)/{{{path}}}"
{{/remove}}
cd $({{{pkg_name_upper}}}_BUILD_DIR) && DEB_ARCH=$(DEB_ARCH) $(SOURCE_DIR)/buildsystems/{{build_system}}/fetch_deps.sh
mustache "$(SOURCE_DIR)build_rules/`echo {{pkg_name_snake}}.yaml | tr '_' '-'`" $(SOURCE_DIR)buildsystems/{{build_system}}/debian-makefile-template > $({{{pkg_name_upper}}}_BUILD_DIR)/Makefile
touch $@
$({{{pkg_name_upper}}}_BUILD_DIR)/: $(BUILD_DIR)/fetch-{{{source_name}}}.stamp
{{#fingerprint}}
$(BUILD_DIR)/{{fingerprint}}-gnupg-home.stamp: $(BUILD_DIR)/{{{fingerprint}}}$(KEY_INPUT_SUFFIX)
mkdir -p $(BUILD_DIR)/{{fingerprint}}-gnupg-home
gpg --no-default-keyring --keyring $< --export {{fingerprint}} | GNUPGHOME=$(BUILD_DIR)/{{fingerprint}}-gnupg-home gpg --import -
touch $@
{{/fingerprint}}
{{/clone_url}}
{{#unpack}}
$(BUILD_DIR)/{{{file_name}}}: | $(BUILD_DIR)
wget -O $@ '{{{url}}}'
{{/unpack}}
{{^clone_url}}
{{^unpack}}
$({{{pkg_name_upper}}}_BUILD_DIR)/: | $(BUILD_DIR)
mkdir -p $@
cd $({{{pkg_name_upper}}}_BUILD_DIR) && DEB_ARCH=$(DEB_ARCH) $(SOURCE_DIR)/buildsystems/{{build_system}}/fetch_deps.sh
mustache "$(SOURCE_DIR)build_rules/`echo {{pkg_name_snake}}.yaml | tr '_' '-'`" $(SOURCE_DIR)buildsystems/{{build_system}}/debian-makefile-template > $({{{pkg_name_upper}}}_BUILD_DIR)/Makefile
{{/unpack}}
{{/clone_url}}
{{#get_assets}}
$({{{pkg_name_upper}}}_BUILD_DIR)/{{{file_name}}}: | $(dir $({{{pkg_name_upper}}}_BUILD_DIR)/{{{file_name}}})
wget -O $@ "{{{url}}}"
{{#signature}}
$({{{pkg_name_upper}}}_BUILD_DIR)/{{{file_name}}}.sig: | $(dir $({{{pkg_name_upper}}}_BUILD_DIR)/{{{file_name}}})
wget -O $@ "{{{signature}}}"
{{/signature}}
{{/get_assets}}
{{#shasums}}
$(BUILD_DIR)/{{{source_name}}}-$({{{pkg_name_upper}}}_VERSION)-shasums{{^detached_sig}}.asc{{/detached_sig}}: | $(BUILD_DIR)
wget -O $@ '{{{url}}}'
{{#detached_sig}}
$({{{pkg_name_upper}}}_SHASUMS_SIG): | $(BUILD_DIR)
wget -O $@ '{{{detached_sig}}}'
{{/detached_sig}}
{{/shasums}}
{{#copy_assets}}
$({{{pkg_name_upper}}}_BUILD_DIR)/{{{to}}}: $(SOURCE_DIR){{{from}}} $(BUILD_DIR)/verify-{{{source_name}}}.stamp | $(dir $({{{pkg_name_upper}}}_BUILD_DIR)/{{{to}}})
cp $< $@
{{/copy_assets}}
{{#dirs}}
$({{{pkg_name_upper}}}_BUILD_DIR)/{{{dir}}}/: $(BUILD_DIR)/verify-{{{source_name}}}.stamp | $(dir $({{{pkg_name_upper}}}_BUILD_DIR)/{{{to}}})
mkdir -p $@
{{/dirs}}
$({{{pkg_name_upper}}}_PACKAGES): $(BUILD_DIR)/packages-{{{source_name}}}.stamp
touch -c $@
{{#unpack}}
{{#shasums}}
$({{{pkg_name_upper}}}_FILTERED_SHASUMS): $({{{pkg_name_upper}}}_SHASUMS_SIG) {{#detached_sig}}$(BUILD_DIR)/{{{source_name}}}-$({{{pkg_name_upper}}}_VERSION)-shasums{{/detached_sig}} $(BUILD_DIR)/{{{fingerprint}}}$(KEY_INPUT_SUFFIX)
{{#detached_sig}}
gpgv --keyring $(BUILD_DIR)/{{{fingerprint}}}$(KEY_INPUT_SUFFIX) $< $(BUILD_DIR)/{{{source_name}}}-$({{{pkg_name_upper}}}_VERSION)-shasums
grep "{{{file_name}}}" $(BUILD_DIR)/{{{source_name}}}-$({{{pkg_name_upper}}}_VERSION)-shasums > $@
{{/detached_sig}}
{{^detached_sig}}
gpgv --keyring $(BUILD_DIR)/{{{fingerprint}}}$(KEY_INPUT_SUFFIX) -o - $< | grep "{{{file_name}}}" > $@
{{/detached_sig}}
{{/shasums}}
{{/unpack}}
$(BUILD_DIR)/verify-signature-{{{source_name}}}.stamp: {{#unpack}}$(BUILD_DIR)/{{{file_name}}}{{/unpack}}{{#clone_url}}$(BUILD_DIR)/fetch-{{{source_name}}}.stamp{{/clone_url}} $({{{pkg_name_upper}}}_FILTERED_SHASUMS){{#get_assets}}{{#signature}} $({{{pkg_name_upper}}}_BUILD_DIR)/{{{file_name}}}.sig $({{{pkg_name_upper}}}_BUILD_DIR)/{{{file_name}}} $(BUILD_DIR)/{{{fingerprint}}}$(KEY_INPUT_SUFFIX){{/signature}}{{/get_assets}}{{#verify_tag}} $(BUILD_DIR)/{{fingerprint}}-gnupg-home.stamp{{/verify_tag}}{{#verify_commit}} $(BUILD_DIR)/{{fingerprint}}-gnupg-home.stamp{{/verify_commit}}
{{#unpack}}
{{#shasums}}
cd $(BUILD_DIR) && sha256sum -c $({{{pkg_name_upper}}}_FILTERED_SHASUMS_FILENAME)
{{/shasums}}
{{/unpack}}
{{#get_assets}}
{{#signature}}
gpgv --keyring $(BUILD_DIR)/{{{fingerprint}}}$(KEY_INPUT_SUFFIX) $({{{pkg_name_upper}}}_BUILD_DIR)/{{{file_name}}}.sig $({{{pkg_name_upper}}}_BUILD_DIR)/{{{file_name}}}
{{/signature}}
{{/get_assets}}
{{#verify_tag}}
cd $({{{pkg_name_upper}}}_BUILD_DIR) && GNUPGHOME=$(BUILD_DIR)/{{fingerprint}}-gnupg-home git verify-tag "{{git_tag}}"
{{/verify_tag}}
{{#verify_commit}}
cd $({{{pkg_name_upper}}}_BUILD_DIR) && GNUPGHOME=$(BUILD_DIR)/{{fingerprint}}-gnupg-home git verify-commit "`git rev-list -n 1 "{{git_tag}}"`"
{{/verify_commit}}
touch $@
$(BUILD_DIR)/verify-pin-{{{source_name}}}.stamp: {{#unpack}}$(BUILD_DIR)/{{{file_name}}}{{/unpack}}{{#clone_url}}$(BUILD_DIR)/fetch-{{{source_name}}}.stamp{{/clone_url}}
{{#unpack}}
cd $(BUILD_DIR) && sha256sum -c $(SOURCE_DIR)/build_rules/{{{source_name}}}.pin
{{/unpack}}
{{#clone_url}}
test "`cat $(SOURCE_DIR)/build_rules/{{{source_name}}}.pin`" = "`cd "$({{{pkg_name_upper}}}_BUILD_DIR)" && git rev-parse HEAD`"
{{/clone_url}}
touch $@
{{#unpinned}}
$(BUILD_DIR)/verify-{{{source_name}}}.stamp: $(BUILD_DIR)/verify-signature-{{{source_name}}}.stamp
{{/unpinned}}
{{^unpinned}}
$(BUILD_DIR)/verify-{{{source_name}}}.stamp: $(BUILD_DIR)/verify-pin-{{{source_name}}}.stamp
{{/unpinned}}
{{#unpack}}
tar -C $(BUILD_DIR) -x{{#compression}}{{{compression}}}{{/compression}}{{^compression}}z{{/compression}}mf $(BUILD_DIR)/{{{file_name}}}
{{#rename}}
mv -T {{{rename}}} $({{{pkg_name_upper}}}_BUILD_DIR)
{{/rename}}
{{#remove}}
"$({{{pkg_name_upper}}}_BUILD_DIR)/{{{path}}}"
{{/remove}}
cd $({{{pkg_name_upper}}}_BUILD_DIR) && DEB_ARCH=$(DEB_ARCH) $(SOURCE_DIR)/buildsystems/{{build_system}}/fetch_deps.sh
mustache "$(SOURCE_DIR)build_rules/`echo {{pkg_name_snake}}.yaml | tr '_' '-'`" $(SOURCE_DIR)buildsystems/{{build_system}}/debian-makefile-template > $({{{pkg_name_upper}}}_BUILD_DIR)/Makefile
{{/unpack}}
{{#chmod}}
chmod {{perms}} $({{{pkg_name_upper}}}_BUILD_DIR)/{{file}}
{{/chmod}}
touch $@
{{#unpack}}
$({{{pkg_name_upper}}}_BUILD_DIR)/: $(BUILD_DIR)/verify-{{{source_name}}}.stamp
{{/unpack}}
update-pin-{{{source_name}}}: $(BUILD_DIR)/verify-signature-{{{source_name}}}.stamp
{{#unpack}}
cd $(BUILD_DIR) && sha256sum {{{file_name}}} > $(SOURCE_DIR)/build_rules/{{{source_name}}}.pin
{{/unpack}}
{{#clone_url}}
cd $({{{pkg_name_upper}}}_BUILD_DIR) && git rev-parse HEAD > $(SOURCE_DIR)/build_rules/{{{source_name}}}.pin
{{/clone_url}}
update-pin: update-pin-{{{source_name}}}
$(BUILD_DIR)/packages-{{{source_name}}}.stamp: $({{{pkg_name_upper}}}_ASSETS)
all: $(BUILD_DIR)/packages-{{{source_name}}}.stamp
fetch: $({{{pkg_name_upper}}}_FETCH_FILES)
build-dep: $(BUILD_DIR)/debcrafter-{{{source_name}}}.stamp
clean_{{{pkg_name_snake}}}:
rm -rf $({{{pkg_name_upper}}}_PACKAGES) $({{{pkg_name_upper}}}_EXTRA_FILES) $(BUILD_DIR)/packages-{{{source_name}}}.stamp