2022-10-27 10:45:25 +00:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
|
|
|
VERSION ?= "$(shell git describe --tags --match "v*" --dirty --always --abbrev=8 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")"
|
2023-01-12 14:19:27 +00:00
|
|
|
FROST ?= frostfs-cli
|
2022-10-27 10:45:25 +00:00
|
|
|
|
2022-10-27 13:50:54 +00:00
|
|
|
.PHONY: all clean version help unlocode debpackage
|
2022-10-27 10:45:25 +00:00
|
|
|
|
|
|
|
DIRS = in tmp
|
|
|
|
|
|
|
|
space := $(subst ,, )
|
|
|
|
|
2022-10-27 13:50:54 +00:00
|
|
|
# .deb package versioning
|
|
|
|
OS_RELEASE = $(shell lsb_release -cs)
|
|
|
|
PKG_VERSION ?= $(shell echo $(VERSION) | sed "s/^v//" | \
|
2022-10-27 19:54:31 +00:00
|
|
|
sed -E "s/(.*)-(g[a-fA-F0-9]{6,8})(.*)/\1\3~\2/" | \
|
|
|
|
sed "s/-/~/")-${OS_RELEASE}
|
2022-10-27 13:50:54 +00:00
|
|
|
|
2022-10-27 10:45:25 +00:00
|
|
|
all: $(DIRS) locode_db
|
|
|
|
|
|
|
|
$(DIRS):
|
2022-10-27 19:54:31 +00:00
|
|
|
@echo "⇒ Ensure dir: $@"
|
|
|
|
@mkdir -p $@
|
2022-10-27 10:45:25 +00:00
|
|
|
|
|
|
|
in/airports.dat:
|
|
|
|
wget -c https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat -O in/airports.dat
|
|
|
|
|
|
|
|
in/countries.dat:
|
|
|
|
wget -c https://raw.githubusercontent.com/jpatokal/openflights/master/data/countries.dat -O in/countries.dat
|
|
|
|
|
|
|
|
in/continents.geojson: $(DIRS)
|
|
|
|
zcat continents.geojson.gz > in/continents.geojson
|
|
|
|
|
|
|
|
unlocode:
|
2023-01-12 14:14:36 +00:00
|
|
|
wget -c https://service.unece.org/trade/locode/loc222csv.zip -O tmp/loc222csv.zip
|
|
|
|
unzip -u tmp/loc222csv.zip -d in/
|
2022-10-27 10:45:25 +00:00
|
|
|
|
|
|
|
locode_db: unlocode in/continents.geojson in/airports.dat in/countries.dat
|
2022-12-22 13:28:24 +00:00
|
|
|
$(FROST) util locode generate \
|
2022-10-27 10:45:25 +00:00
|
|
|
--airports in/airports.dat \
|
|
|
|
--continents in/continents.geojson \
|
|
|
|
--countries in/countries.dat \
|
2023-01-12 14:14:36 +00:00
|
|
|
--in in/2022-2\ UNLOCODE\ CodeListPart1.csv,in/2022-2\ UNLOCODE\ CodeListPart2.csv,in/2022-2\ UNLOCODE\ CodeListPart3.csv \
|
|
|
|
--subdiv in/2022-2\ SubdivisionCodes.csv \
|
2022-10-27 10:45:25 +00:00
|
|
|
--out locode_db
|
2022-10-27 19:54:31 +00:00
|
|
|
chmod 644 locode_db
|
2022-10-27 10:45:25 +00:00
|
|
|
|
|
|
|
# Print version
|
|
|
|
version:
|
|
|
|
@echo $(VERSION)
|
|
|
|
|
|
|
|
# Show this help prompt
|
|
|
|
help:
|
|
|
|
@echo ' Usage:'
|
|
|
|
@echo ''
|
|
|
|
@echo ' make <target>'
|
|
|
|
@echo ''
|
|
|
|
@echo ' Targets:'
|
|
|
|
@echo ''
|
|
|
|
@awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort -u
|
|
|
|
|
|
|
|
# Clean up
|
|
|
|
clean:
|
|
|
|
rm -f in/*
|
|
|
|
rm -f tmp/*
|
|
|
|
rm -f locode_db
|
2022-10-27 13:50:54 +00:00
|
|
|
|
|
|
|
# Package for Debian
|
|
|
|
debpackage:
|
2022-12-22 13:28:24 +00:00
|
|
|
dch --package frostfs-locode-db \
|
2022-10-27 19:54:31 +00:00
|
|
|
--controlmaint \
|
|
|
|
--newversion $(PKG_VERSION) \
|
|
|
|
--force-bad-version \
|
|
|
|
--distribution $(OS_RELEASE) \
|
|
|
|
"Please see CHANGELOG.md for code changes for $(VERSION)"
|
2022-10-27 13:50:54 +00:00
|
|
|
dpkg-buildpackage --no-sign -b
|
|
|
|
|
|
|
|
debclean:
|
2022-10-27 19:54:31 +00:00
|
|
|
dh clean
|