Skip to content

Commit

Permalink
dev: update build script; default to leveldb 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
olt committed Apr 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 33e15ac commit 7104d7d
Showing 6 changed files with 32 additions and 80 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ GOLDFLAGS=-ldflags '-r $${ORIGIN}/lib $(VERSION_LDFLAGS)'

GO:=go

ifdef LEVELDB_POST_121
GOTAGS=-tags="ldbpost121"
ifdef LEVELDB_PRE_121
GOTAGS=-tags="ldbpre121"
endif

BUILD_DATE=$(shell date +%Y%m%d)
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ GEOS >=3.2 is recommended, since it became much more robust when handling invali


[libleveldb]: https://github.com/google/leveldb/
[libgeos]: http://trac.osgeo.org/geos/
[libgeos]: https://libgeos.org/

#### Compile

@@ -137,9 +137,8 @@ See also `packaging.sh` for instructions on how to build binary packages for Lin

#### LevelDB

For better performance you can either use [HyperLevelDB][libhyperleveldb] as an in-place replacement for libleveldb or you can use LevelDB >1.21. You need to build Imposm with ``go build -tags="ldbpost121"`` or ``LEVELDB_POST_121=1 make build`` to enable optimizations available with LevelDB 1.21 and higher.
For better performance you should use LevelDB >1.21. You can still build with support for 1.21 with ``go build -tags="ldbpre121"`` or ``LEVELDB_PRE_121=1 make build``.

[libhyperleveldb]: https://github.com/rescrv/HyperLevelDB

Usage
-----
4 changes: 2 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ Vagrant.configure(2) do |config|

# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "debian/jessie64"
config.vm.box = "generic/debian10"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
@@ -37,7 +37,7 @@ Vagrant.configure(2) do |config|
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
config.vm.synced_folder "./", "/vagrant"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
2 changes: 1 addition & 1 deletion cache/ldb_post_121.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build ldbpost121
//go:build !ldbpre121

package cache

2 changes: 1 addition & 1 deletion cache/ldb_pre_121.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !ldbpost121
//go:build ldbpre121

package cache

95 changes: 24 additions & 71 deletions packaging.sh
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ 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 8. The resulting binaries
are compatible with Ubuntu 14.04, SLES 12, Fedora 21.
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:
@@ -57,10 +57,9 @@ export GOROOT=$BUILD_BASE/go
IMPOSM_SRC=$GOPATH/src/github.com/omniscale/imposm3
BUILD_TMP=$BUILD_BASE/imposm-build

GEOS_VERSION=3.6.2

# If set, build with HyperLevelDB instead of LevelDB
#WITH_HYPERLEVELDB=1
GEOS_VERSION=3.12.1
GO_VERSION=1.21.6
LEVELDB_VERSION=1.23

export CGO_CFLAGS=-I$PREFIX/include
export CGO_LDFLAGS=-L$PREFIX/lib
@@ -74,78 +73,42 @@ mkdir -p $PREFIX/include
mkdir -p $GOPATH


if ! grep --silent 'Debian GNU/Linux 8' /etc/issue; then
if ! grep --silent 'Debian GNU/Linux 10' /etc/issue; then
echo
echo "ERROR: This script only works for Debian 8.0 (Jessie), see above."
echo "ERROR: This script only works for Debian 10.0 (Buster), see above."
exit 1
fi

if [ ! -e /usr/bin/git ]; then
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 chrpath curl
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://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz -O
tar xzf go1.9.2.linux-amd64.tar.gz -C $BUILD_BASE/
$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 [[ -z "$WITH_HYPERLEVELDB" && ! -e $PREFIX/lib/libleveldb.so ]]; then
if [[ ! -e $PREFIX/lib/libleveldb.so ]]; then
echo "-> installing leveldb"
pushd $SRC
$CURL https://github.com/google/leveldb/archive/master.zip -L -O
unzip master.zip
pushd leveldb-master
make -j4
cp -R out-shared/liblevel* $PREFIX/lib/
cp -R include/leveldb $PREFIX/include/
popd
popd
fi

if [[ -n "$WITH_HYPERLEVELDB" && ! -e $PREFIX/lib/libhyperleveldb.so ]]; then
echo "-> installing hyperleveldb"
pushd $SRC
$CURL https://github.com/rescrv/HyperLevelDB/archive/master.zip -O
unzip master.zip
pushd HyperLevelDB-master
autoreconf -i
./configure --prefix=$PREFIX
make -j4
make install
popd
popd
fi

if [[ -n "$WITH_HYPERLEVELDB" && ! -e $PREFIX/include/leveldb ]]; then
echo "-> linking hyperleveldb as leveldb"
pushd $PREFIX/lib
for s in 'a', 'la', 'so'; do
ln -sf libhyperleveldb.$s libleveldb.$s
done
popd
ln -s $PREFIX/include/hyperleveldb $PREFIX/include/leveldb
fi

if [ ! -e $PREFIX/lib/libprotobuf.so ]; then
echo "-> installing protobuf"
pushd $SRC
$CURL https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.bz2 -O
tar jxf protobuf-2.6.1.tar.bz2
pushd protobuf-2.6.1/
./configure --prefix=$PREFIX
make -j2
make install
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-$GEOS_VERSION.so ]; then
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
@@ -174,11 +137,7 @@ pushd $IMPOSM_SRC

echo '-> compiling imposm'
make clean
if [[ -n "$WITH_HYPERLEVELDB" ]]; then
make build
else
LEVELDB_POST_121=1 make build
fi
LEVELDB_POST_121=1 make build
popd


@@ -196,18 +155,12 @@ 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-$GEOS_VERSION.so
if [ -n "$WITH_HYPERLEVELDB" ]; then
cp libhyperleveldb.so $BUILD_TMP/lib
ln -s libhyperleveldb.so $BUILD_TMP/lib/libhyperleveldb.so.0
ln -s libhyperleveldb.so $BUILD_TMP/lib/libleveldb.so.1
else
cp -R libleveldb.so* $BUILD_TMP/lib
fi
ln -s libgeos.so $BUILD_TMP/lib/libgeos.so.$GEOS_VERSION
cp -R libleveldb.so* $BUILD_TMP/lib
popd

pushd $BUILD_TMP/lib
chrpath libgeos_c.so -r '${ORIGIN}'
patchelf --set-rpath '$ORIGIN' libgeos_c.so
popd


0 comments on commit 7104d7d

Please sign in to comment.