From 83270949e0764c3f011bcb876960542c9128f50e Mon Sep 17 00:00:00 2001 From: Stanislav Bogatyrev Date: Thu, 27 Oct 2022 13:45:25 +0300 Subject: [PATCH] Add Makefile Signed-off-by: Stanislav Bogatyrev --- .gitignore | 3 +++ Makefile | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 12 ++++++++++- VERSION | 1 + 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 VERSION diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de9e96a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +tmp/ +in/ +locode_db \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..19f7c80 --- /dev/null +++ b/Makefile @@ -0,0 +1,58 @@ +#!/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")" +NEOFSCLI ?= neofs-cli + +.PHONY: all clean version help unlocode + +DIRS = in tmp + +space := $(subst ,, ) + +all: $(DIRS) locode_db + +$(DIRS): + @echo "⇒ Ensure dir: $@" + @mkdir -p $@ + +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: + wget -c https://service.unece.org/trade/locode/loc221csv.zip -O tmp/loc221csv.zip + unzip -u tmp/loc221csv.zip -d in/ + +locode_db: unlocode in/continents.geojson in/airports.dat in/countries.dat + $(NEOFSCLI) util locode generate \ + --airports in/airports.dat \ + --continents in/continents.geojson \ + --countries in/countries.dat \ + --in in/2022-1\ UNLOCODE\ CodeListPart1.csv,in/2022-1\ UNLOCODE\ CodeListPart2.csv,in/2022-1\ UNLOCODE\ CodeListPart3.csv \ + --subdiv in/2022-1\ SubdivisionCodes.csv \ + --out locode_db + +# Print version +version: + @echo $(VERSION) + +# Show this help prompt +help: + @echo ' Usage:' + @echo '' + @echo ' make ' + @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 diff --git a/README.md b/README.md index ba1d4ac..4cae58c 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,17 @@ more in [NeoFS Specification](https://github.com/nspcc-dev/neofs-spec). - [OpenFlight Countries](https://raw.githubusercontent.com/jpatokal/openflights/master/data/countries.dat) database -## Run +## Quick start + +Just run `make` to generate `locode_db` file for use with NeoFS InnerRing nodes. + +``` shell +$ make +... +--out locode_db +``` + +## Building First unzip file with GeoJSON continents from this repository. ``` diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..22c08f7 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v0.2.1