From 199a7ba87951ca71d149068f306d47ccf94a4be4 Mon Sep 17 00:00:00 2001 From: Oliver Tonnhofer Date: Tue, 8 Mar 2016 14:23:37 +0100 Subject: [PATCH] add Vagrant-based packaging script --- Vagrantfile | 70 +++++++++++++++++++ packaging.sh | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 263 insertions(+) create mode 100644 Vagrantfile create mode 100644 packaging.sh diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..62a9900 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,70 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure(2) do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "puppetlabs/debian-6.0.10-64-nocm" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # 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" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + # vb.memory = "1024" + # end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies + # such as FTP and Heroku are also available. See the documentation at + # https://docs.vagrantup.com/v2/push/atlas.html for more information. + # config.push.define "atlas" do |push| + # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" + # end + + # Enable provisioning with a shell script. Additional provisioners such as + # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the + # documentation for more information about their specific syntax and use. + config.vm.provision "shell", inline: <<-SHELL + /bin/bash /vagrant/packaging.sh + SHELL +end diff --git a/packaging.sh b/packaging.sh new file mode 100644 index 0000000..9bcc0eb --- /dev/null +++ b/packaging.sh @@ -0,0 +1,193 @@ +#! /bin/bash + +cat < installing dependencies" + + # squeeze is EOL, use debian-archive + cat < installing go" + pushd $SRC + $CURL https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz -O + tar xzf go1.6.linux-amd64.tar.gz -C $BUILD_BASE/ + popd +fi + +if [ ! -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 $SRC +fi + +if [ ! -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 + popd + popd +fi + +if [ ! -e $PREFIX/lib/libgeos.so ]; 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 --all -f $IMPOSM_SRC + popd + + git reset --hard + git checkout build-refactor + + echo '-> compiling imposm' + make clean + make build +popd + + +echo '-> building imposm package' +rm -rf $BUILD_TMP +mkdir -p $BUILD_TMP +pushd $IMPOSM_SRC + cp imposm3 $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-$GEOS_VERSION.so + 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 +popd + +pushd $BUILD_TMP/lib + chrpath libgeos_c.so -r '${ORIGIN}' +popd + + +pushd $BUILD_BASE + VERSION=`$BUILD_TMP/imposm3 version`-linux-x86-64 + rm -rf imposm3-$VERSION + mv imposm-build imposm3-$VERSION + tar zcvf imposm3-$VERSION.tar.gz imposm3-$VERSION + mkdir -p /vagrant/dist + mv imposm3-$VERSION.tar.gz /vagrant/dist/ + echo "placed final package in: ./dist/imposm3-$VERSION.tar.gz" +popd