Browse Source

add experimental Vagrantfile, see https://grasswiki.osgeo.org/wiki/Vagrant

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67765 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 years ago
parent
commit
6477b44a7c
2 changed files with 163 additions and 0 deletions
  1. 106 0
      Vagrantfile
  2. 57 0
      tools/vagrant/grass.sh

+ 106 - 0
Vagrantfile

@@ -0,0 +1,106 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+### Inspired by https://svn.osgeo.org/gdal/trunk/gdal/Vagrantfile
+
+require 'socket'
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+  
+  vm_ram = ENV['VAGRANT_VM_RAM'] || 1024
+  vm_cpu = ENV['VAGRANT_VM_CPU'] || 2
+  
+  config.vm.box = "precise64"
+  
+  config.vm.hostname = "grass-gis-vagrant"
+  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
+  config.vm.define "grass-gis-vagrant" do |host|
+    
+    config.vm.network :forwarded_port, guest: 80, host: 8080
+    
+    host.vm.provider :virtualbox do |vb|
+      vb.customize ["modifyvm", :id, "--memory", vm_ram]
+      vb.customize ["modifyvm", :id, "--cpus", vm_cpu]
+      vb.customize ["modifyvm", :id, "--ioapic", "on"]
+      vb.name = "grass-gis-vagrant"
+    end  
+
+    config.ssh.forward_agent = true
+    config.ssh.forward_x11 = true
+    
+    ppaRepos = [
+      "ppa:ubuntugis/ubuntugis-unstable"
+    ]
+    
+    packageList = [
+      "autoconf2.13",
+      "autotools-dev",
+      "make",
+      "g++",
+      "gettext",
+      "flex",
+      "bison",
+      "lesstif2-dev",
+      "libcairo2-dev",
+      "libfftw3-dev",
+      "libfreetype6-dev",
+      "libgdal-dev",
+      "libgeos-dev",
+      "libglu1-mesa-dev",
+      "libjpeg-dev",
+      "libpng-dev",
+      "libtiff-dev",
+      "libmysqlclient-dev",
+      "libncurses5-dev",
+      "libpq-dev",
+      "libproj-dev",
+      "proj-bin",
+      "libreadline-dev",
+      "libsqlite3-dev",
+      "libwxgtk2.8-dev",
+      "libxmu-dev",
+      "python",
+      "python-wxgtk2.8",
+      "python-dev",
+      "python-numpy",
+      "python-ply",
+      #    "python-pil",
+      "libnetcdf-dev",
+      "netcdf-bin",
+      "libblas-dev",
+      "liblapack-dev",
+      "unixodbc-dev",
+      "zlib1g-dev"
+      #    "liblas",
+      #    "liblas-c-dev"
+    ]
+    
+    unless File.exists?(".no_apt_cache")
+      cache_dir = "apt-cache/#{config.vm.box}"
+      FileUtils.mkdir_p(cache_dir) unless Dir.exists?(cache_dir)
+      host.vm.synced_folder cache_dir, "/var/cache/apt/archives"
+    end
+    
+    if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/grass-gis-vagrant/*/id").empty?
+      pkg_cmd = "sed -i 's#deb http://us.archive.ubuntu.com/ubuntu/#deb mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list; "
+      
+      pkg_cmd << "apt-get update -qq; apt-get install -q -y python-software-properties; "
+      
+      if ppaRepos.length > 0
+	ppaRepos.each { |repo| pkg_cmd << "add-apt-repository -y " << repo << " ; " }
+	pkg_cmd << "apt-get update -qq; "
+      end
+      
+      # install packages we need we need
+      pkg_cmd << "apt-get install -q -y " + packageList.join(" ") << " ; "
+      host.vm.provision :shell, :inline => pkg_cmd
+      scripts = [
+        "grass.sh",
+      ];
+      scripts.each { |script| host.vm.provision :shell, :privileged => false, :path => "tools/vagrant/" << script }
+    end
+  end
+end

+ 57 - 0
tools/vagrant/grass.sh

@@ -0,0 +1,57 @@
+#!/bin/sh
+
+### inspired by https://svn.osgeo.org/gdal/trunk/gdal/scripts/vagrant/gdal.sh
+
+# abort install if any errors occur and enable tracing
+set -o errexit
+set -o xtrace
+
+NUMTHREADS=2
+if [[ -f /sys/devices/system/cpu/online ]]; then
+	# Calculates 1.5 times physical threads
+	NUMTHREADS=$(( ( $(cut -f 2 -d '-' /sys/devices/system/cpu/online) + 1 ) * 15 / 10  ))
+fi
+#NUMTHREADS=1 # disable MP
+export NUMTHREADS
+
+cd /vagrant
+
+if [ -f "include/Make/Platform.make" ] ; then
+    make cleandistdirs
+    make distclean
+fi
+./configure \
+    --bindir=/usr/bin \
+    --srcdir=/vagrant \
+    --prefix=/usr/lib \
+    --enable-socket \
+    --enable-shared \
+    --with-postgres \
+    --with-mysql \
+    --with-cxx \
+    --with-x \
+    --with-gdal \
+    --with-geos \
+    --with-freetype \
+    --with-motif \
+    --with-readline \
+    --with-nls \
+    --with-odbc \
+    --with-netcdf \
+    --with-blas \
+    --with-lapack \
+    --with-sqlite \
+    --enable-largefile \
+    --with-freetype-includes=/usr/include/freetype2 \
+    --with-postgres-includes=`pg_config --includedir` \
+    --with-mysql-includes=`mysql_config --include | sed -e 's/-I//'` \
+    --with-proj-share=/usr/share/proj \
+    --with-wxwidgets=/usr/bin/wx-config \
+    --with-python \
+    --with-cairo
+# --with-liblas=/usr/bin/liblas-config \
+
+make -j $NUMTHREADS
+
+sudo make install
+sudo ldconfig