-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathpackaging.sh
174 lines (136 loc) · 4.31 KB
/
packaging.sh
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
171
172
173
174
#! /bin/bash
cat <<EOF
=================== Imposm Packaging Script ============================
This script creates binary packages for Imposm for Linux.
It installs and builds all dependencies, compiles the master
branch of this local repository and creates a .tar.gz with
the imposm3 binary and all 3rd party dependencies.
This script is made for Debian 10. The resulting binaries
should be compatible with all more recent Linux distribution.
'Vagrantfile' defines a working Debian VM that will call this script
during the provision phase. Please install Vagrant and Virtualbox first:
https://www.vagrantup.com/
To start the VM and the packaging:
$ vagrant up --provision
The resulting .tar.gz should appear in dist/
To build another package, e.g. after you commited new changes:
$ vagrant provision
or
$ vagrant ssh
% bash /vagrant/packaging.sh
You can specify a revision or branch by setting the REVISION
environment. REVISION defaults to the master branch:
$ REVISION=mybranch vagrant provision
To shutdown the VM:
$ vagrant halt
To remove the VM:
$ vagrant destroy
EOF
set -e
# set -x
REVISION=${REVISION:-master}
if [[ -z "$IMPOSM_BUILD_RELEASE" ]]; then
unset IMPOSM_BUILD_RELEASE
fi
BUILD_BASE=$HOME/imposm
PREFIX=$BUILD_BASE/local
SRC=$BUILD_BASE/src
export GOPATH=$BUILD_BASE/gopath
export PATH=$PATH:$BUILD_BASE/go/bin
export GOROOT=$BUILD_BASE/go
IMPOSM_SRC=$GOPATH/src/github.com/omniscale/imposm3
BUILD_TMP=$BUILD_BASE/imposm-build
GEOS_VERSION=3.12.2
GO_VERSION=1.22.4
LEVELDB_VERSION=1.23
export CGO_CFLAGS=-I$PREFIX/include
export CGO_LDFLAGS=-L$PREFIX/lib
export LD_LIBRARY_PATH=$PREFIX/lib
CURL="curl --silent --show-error --location"
mkdir -p $SRC
mkdir -p $PREFIX/lib
mkdir -p $PREFIX/include
mkdir -p $GOPATH
if ! grep --silent 'Debian GNU/Linux 10' /etc/issue; then
echo
echo "ERROR: This script only works for Debian 10.0 (Buster), see above."
exit 1
fi
if [ ! -e /usr/bin/unzip ]; then
echo "-> installing dependencies"
sudo apt-get update -y
sudo apt-get install -y build-essential unzip autoconf libtool git patchelf curl
fi
if [ ! -e $BUILD_BASE/go/bin/go ]; then
echo "-> installing go"
pushd $SRC
$CURL https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz -O
tar xzf go${GO_VERSION}.linux-amd64.tar.gz -C $BUILD_BASE/
popd
fi
if [[ ! -e $PREFIX/lib/libleveldb.so ]]; then
echo "-> installing leveldb"
pushd $SRC
git clone --recurse-submodules https://github.com/google/leveldb.git
pushd leveldb
git checkout $LEVELDB_VERSION
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLEVELDB_BUILD_TESTS=OFF -DLEVELDB_BUILD_BENCHMARKS=OFF .. && cmake --build .
cp -R ./liblevel* $PREFIX/lib/
cp -R ../include/leveldb $PREFIX/include/
popd
popd
fi
if [ ! -e $PREFIX/lib/libgeos.so.$GEOS_VERSION ]; then
echo "-> installing GEOS"
pushd $SRC
$CURL http://download.osgeo.org/geos/geos-$GEOS_VERSION.tar.bz2 -O
tar jxf geos-$GEOS_VERSION.tar.bz2
pushd geos-$GEOS_VERSION/
./configure --prefix=$PREFIX
make -j2
make install
popd
popd
fi
echo '-> fetching imposm'
mkdir -p $IMPOSM_SRC
git init $IMPOSM_SRC
pushd $IMPOSM_SRC
git config --add receive.denyCurrentBranch ignore
pushd /vagrant
git push --tags -f $IMPOSM_SRC
popd
git reset --hard
git checkout $REVISION
echo '-> compiling imposm'
make clean
make build
popd
echo '-> building imposm package'
rm -rf $BUILD_TMP
mkdir -p $BUILD_TMP
pushd $IMPOSM_SRC
cp imposm $BUILD_TMP
cp README.md $BUILD_TMP
cp example-mapping.json $BUILD_TMP/mapping.json
popd
mkdir -p $BUILD_TMP/lib
pushd $PREFIX/lib
cp libgeos_c.so $BUILD_TMP/lib
ln -s libgeos_c.so $BUILD_TMP/lib/libgeos_c.so.1
cp libgeos.so $BUILD_TMP/lib
ln -s libgeos.so $BUILD_TMP/lib/libgeos.so.$GEOS_VERSION
cp -R libleveldb.so* $BUILD_TMP/lib
popd
pushd $BUILD_TMP/lib
patchelf --set-rpath '$ORIGIN' libgeos_c.so
popd
pushd $BUILD_BASE
VERSION=`$BUILD_TMP/imposm version`-linux-x86-64
rm -rf imposm-$VERSION
mv imposm-build imposm-$VERSION
tar zcvf imposm-$VERSION.tar.gz imposm-$VERSION
mkdir -p /vagrant/dist
mv imposm-$VERSION.tar.gz /vagrant/dist/
popd