-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgen_file.sh
More file actions
executable file
·54 lines (42 loc) · 1.62 KB
/
gen_file.sh
File metadata and controls
executable file
·54 lines (42 loc) · 1.62 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
set -Eeuo pipefail
echo 'Set first argument to "addgit" if you want to add wkt files automatically'
# prepare destination
DIRNAME=`dirname $(readlink -f $0)`
mkdir -p $DIRNAME/dist
test "$(ls -A $DIRNAME/dist/)" && rm -r $DIRNAME/dist/*
# extract PROJ version from Dockerfile
PROJ_VERSION=`cat $DIRNAME/Dockerfile | sed -n 's/^FROM .*:\(.*\)$/\1/p'`
echo "PROJ_VERSION=$PROJ_VERSION"
# extract PYPROJ version from requirements.txt
PYPROJ_VERSION=`cat $DIRNAME/requirements.txt | sed -n 's/^pyproj==\(.*\)$/\1/p'`
echo "PYPROJ_VERSION=$PYPROJ_VERSION"
DOCKER_TAG="crs-explorer:$PROJ_VERSION"
# To build verbosely
# export BUILDKIT_PROGRESS=plain
# build container
docker build --pull --platform=linux/amd64 --build-arg PYPROJ_VERSION=$PYPROJ_VERSION --tag $DOCKER_TAG $DIRNAME
# execute container
docker run --user $(id -u):$(id -g) --rm -v "$DIRNAME/dist:/home/dist" $DOCKER_TAG
DEST=$DIRNAME/..
# copy to root location
cp $DIRNAME/dist/crslist.json $DEST
cp $DIRNAME/dist/metadata.txt $DEST
cp $DIRNAME/dist/sitemap.xml $DEST
for wkt in wkt1 wkt2 ; do
echo remove $wkt
if [ "${1-}" == "addgit" ] ; then
test "$(ls -A $DEST/$wkt/)" && git rm -r -q $DEST/$wkt
else
rm -r $DEST/$wkt
fi
cp -r $DIRNAME/dist/$wkt $DEST
if [ "${1-}" == "addgit" ] ; then
git add $DEST/$wkt
fi
done
INDEX=$DIRNAME/../index.html
sed -i -E "s/(<span id=\"proj_version\">).*?(<\/span>)/\1${PROJ_VERSION}\2/" $INDEX
if ! `grep value=\"${PROJ_VERSION}\" -q $INDEX` ; then
awk -v var="$PROJ_VERSION" '/<option value="latest">/{print; gsub(/latest/, var)}1' $INDEX > tmp.tmp && mv tmp.tmp $INDEX
fi