-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmerge.mk
More file actions
executable file
·36 lines (28 loc) · 1.42 KB
/
merge.mk
File metadata and controls
executable file
·36 lines (28 loc) · 1.42 KB
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
#!/usr/bin/make -f
# Builds changeset augmented diffs from stage-data/split-adiffs/*/ and writes
# them to bucket-data/*.adiff. Skips any output changeset that already exists
# and is newer than any of its constituent inputs.
.PHONY: all
.ONESHELL:
.SECONDEXPANSION:
MAKEDIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
# all: metadatas changesets
all: changesets
changesets: $(shell find stage-data/split-adiffs/ -mindepth 1 -type d -printf 'stage-data/changesets/%P.adiff.md5\n')
# bucket-data/changesets/%.adiff: $$(wildcard stage-data/split-adiffs/%/*)
stage-data/changesets/%.adiff.md5: $$(wildcard stage-data/split-adiffs/%/*)
tmpfile=$$(mktemp)
merge_adiffs.py $^ | xmlstarlet format > $$tmpfile
if [ -s $$tmpfile ]; then
# merge_adiffs.py can fail if it is given no input files or if one or more
# of its input files are not found. Either of these can happen if the input
# split-adiffs/*/ directory is deleted by gc.sh while Make is running this
# script. So we only move the adiff file into bucket-data and update the
# stamp file if the merged output file is nonempty (-s).
md5sum < $$tmpfile > $@
gzip -c < $$tmpfile > $$tmpfile.gz
mv $$tmpfile.gz bucket-data/changesets/$*.adiff && rm $$tmpfile
fi
metadatas: $(shell find stage-data/split-adiffs/ -mindepth 1 -type d -printf '%p/metadata.xml\n')
stage-data/split-adiffs/%/metadata.xml:
curl -sL https://api.openstreetmap.org/api/0.6/changeset/$* -o $@