<commit_before>#!/bin/sh
# Copyright (c) 2009 by <NAME>, and the Open Source Geospatial Foundation
# Licensed under the GNU LGPL v.2.1.
# 
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 2.1 of the License,
# or any later version.  This library is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY, without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details, either
# in the "LGPL-2.1.txt" file distributed with this software or at
# web page "http://www.fsf.org/licenses/lgpl.html".
#
#
# script to install GpsDrive
#    written by H.Bowman <hamish_b  yahoo com>
#    GpsDrive homepage: http://www.gpsdrive.de
#


# live disc's username is "user"
USER_NAME="user"
USER_HOME="/home/$USER_NAME"

TMP_DIR=/tmp/build_gpsdrive
BUILD_DIR=`pwd`


#### install program ####

## packaged version (2.10pre4) is long out of date, so we build 2.11svn manually.
BUILD_LATEST=0

# base packages
if [ "$BUILD_LATEST" -eq 0 ] ; then
   # install very old pre-packaged version
   #PACKAGES="gpsd gpsd-clients python-gps gpsdrive"
   PACKAGES="gpsd gpsd-clients python-gps"
else
   # important pre-req
   PACKAGES="gpsd gpsd-clients python-gps"
fi

# add some useful Recommends
PACKAGES="$PACKAGES espeak gdal-bin gpsbabel graphicsmagick-imagemagick-compat \
   postgresql-8.4-postgis python-mapnik speech-dispatcher"

apt-get --assume-yes install  $PACKAGES

if [ $? -ne 0 ] ; then
   echo "An error occurred installing packages. Aborting install."
   exit 1
fi

# highly useful
apt-get --assume-yes install sqlite3 sqlitebrowser



#######################
## use prebuilt debs

if [ $BUILD_LATEST -eq 0 ] ; then
  if [ ! -d "$TMP_DIR" ] ; then
    mkdir "$TMP_DIR"
  fi
  cd "$TMP_DIR"

  URL="http://download.osgeo.org/livedvd/data/gpsdrive/precise"
  MAIN_FILE=gpsdrive_2.11_i386.deb
  EXTRA_FILES="
    gpsdrive-friendsd_2.11_i386.deb
    gpsdrive-utils_2.11_i386.deb
    openstreetmap-map-icons-classic.small_25996_all.deb
    openstreetmap-map-icons-square.big_25996_all.deb
    openstreetmap-map-icons-square.small_25996_all.deb
    openstreetmap-map-icons_25996_all.deb"

  wget -c --progress=dot:mega "$URL/$MAIN_FILE"
  for FILE in $EXTRA_FILES ; do
     wget -c -nv "$URL/$FILE"
  done

  dpkg -i openstreetmap-map-icons*.deb
  gdebi --non-interactive --quiet gpsdrive-friendsd_2.11_i386.deb
  gdebi --non-interactive --quiet gpsdrive-utils_2.11_i386.deb
  gdebi --non-interactive --quiet gpsdrive_2.11_i386.deb

fi



#######################
## build latest release
if [ $BUILD_LATEST -eq 1 ] ; then
  VERSION="2.11svn"

  if [ ! -d "$TMP_DIR" ] ; then
    mkdir "$TMP_DIR"
  fi
  cd "$TMP_DIR"

  ## FIXME (use better home once known/officially released)
  ##  wget -c --progress=dot:mega "http://www.gpsdrive.de/packages/gpsdrive-$VERSION.tar.gz"
  FILE=gpsdrive_2.11svn2556.tar.gz
  wget --progress=dot:mega -O "$FILE" \
     "http://sites.google.com/site/hamishbowman/${FILE}?attredirects=0"

  #tar xzf gpsdrive-$VERSION.tar.gz
  #if [ $? -eq 0 ] ; then
  #  \rm gpsdrive-$VERSION.tar.gz
  #fi

  #cd gpsdrive-$VERSION

  # FIXME
  mkdir gpsdrive-2.11svn
  cd gpsdrive-2.11svn
  tar xzf "../$FILE"


  ## --- apply any patches here ---

  # fix package dependencies
  PATCHES="gpsdrive_blue_mapnik"

  for PATCH in $PATCHES ; do
     patch -p0 < "$BUILD_DIR/../app-conf/gpsdrive/$PATCH.patch"
  done

  if [ $? -ne 0 ] ; then
     echo "An error occurred patching package. Aborting install."
     exit 1
  fi

  # local database name is "osm_local_smerc"
  sed -i -e 's/"gis"/"osm_local_smerc"/' src/database.c

  # installed mapnik version is 0.7
  sed -i -e 's+/usr/lib/mapnik/0.5+/usr/lib/mapnik/0.7+' src/gpsdrive_config.c


# no longer needed? better to use `sed -i` for this anyway..
if [ 0 -eq 1 ] ; then
  cat << EOF > "gpsdrive_fix_icon.patch"
--- data/gpsdrive.desktop.ORIG  2009-08-31 01:42:39.000000000 +1200
+++ data/gpsdrive.desktop       2009-08-31 01:43:19.000000000 +1200
@@ -3,7 +3,7 @@
 Comment=GPS Navigation. You need to setup Gpsd manually
 Comment[de]=GPS Navigationsprogramm
 Exec=gpsdrive
-Icon=gpsicon
+Icon=/usr/share/gpsdrive/pixmaps/gpsicon.png
 Terminal=false
 Type=Application
 Categories=Graphics;Network;Geography;
EOF
   patch -p0 < "gpsdrive_fix_icon.patch"
fi


  #apply debian/ubuntu-lucid-32 patches to sync package deps for Lucid
  sed -i -e 's/Build with old libgps version (<2.90)" ON)/Build with old libgps version (<2.90)" OFF)/' \
      DefineOptions.cmake


  if [ $? -ne 0 ] ; then
     echo "An error occurred patching package. Aborting install."
     exit 1
  fi


  # use latest libboost, mapnik, postgis packages
  sed -i -e 's/libboost-\(.*\)1\.3[0-9]\.[0-9]/libboost-\11.42.0/' \
         -e 's/mapnik0\.[3-6]/mapnik0.7/' \
         -e 's/postgresql-8\.[2-3]-postgis/postgresql-8.4-postgis/' \
     debian/control


  ### install any missing build-dep packages

  # kludge to make sure these make it in there
  apt-get --assume-yes install libboost-dev libboost-filesystem-dev \
                               libboost-serialization-dev libmapnik-dev

  # explicitly install these so they aren't removed in a later autoclean
  apt-get --assume-yes install  libgeos-3.2.2 libxml-simple-perl \
    libboost-serialization1.42.0 libboost-date-time1.42.0

  # any of these too?
  #  libgssrpc4
  #  libodbcinstq1c2
  #  libpcrecpp0
  #  libpthread-stubs0
  #  libtiffxx0c2<commit_msg>no-op it; pkg is not ready yet. various updates anyway<commit_after>#!/bin/sh
# Copyright (c) 2009 by <NAME>, and the Open Source Geospatial Foundation
# Licensed under the GNU LGPL v.2.1.
# 
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 2.1 of the License,
# or any later version.  This library is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY, without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details, either
# in the "LGPL-2.1.txt" file distributed with this software or at
# web page "http://www.fsf.org/licenses/lgpl.html".
#
#
# script to install GpsDrive
#    written by H.Bowman <hamish_b  yahoo com>
#    GpsDrive homepage: http://www.gpsdrive.de
#




echo "The GpsDrive package is not yet ready for Ubuntu 12.04"
exit 0





# live disc's username is "user"
USER_NAME="user"
USER_HOME="/home/$USER_NAME"

TMP_DIR=/tmp/build_gpsdrive
BUILD_DIR=`pwd`


#### install program ####

## packaged version (2.10pre4) is long out of date, so we build 2.11svn manually.
BUILD_LATEST=0

# base packages
if [ "$BUILD_LATEST" -eq 0 ] ; then
   # install very old pre-packaged version
   #PACKAGES="gpsd gpsd-clients python-gps gpsdrive"
   PACKAGES="gpsd gpsd-clients python-gps"
else
   # important pre-req
   PACKAGES="gpsd gpsd-clients python-gps"
fi

# add some useful Recommends
PACKAGES="$PACKAGES espeak gdal-bin gpsbabel \
   graphicsmagick-imagemagick-compat \
   postgresql-9.1-postgis python-mapnik2 \
   speech-dispatcher"

apt-get --assume-yes install  $PACKAGES

if [ $? -ne 0 ] ; then
   echo "An error occurred installing packages. Aborting install."
   exit 1
fi

# highly useful
apt-get --assume-yes install sqlite3 sqlitebrowser



#######################
## use prebuilt debs

if [ $BUILD_LATEST -eq 0 ] ; then
  if [ ! -d "$TMP_DIR" ] ; then
    mkdir "$TMP_DIR"
  fi
  cd "$TMP_DIR"

  URL="http://download.osgeo.org/livedvd/data/gpsdrive/precise"
  MAIN_FILE=gpsdrive_2.11_i386.deb
  EXTRA_FILES="
    gpsdrive-friendsd_2.11_i386.deb
    gpsdrive-utils_2.11_i386.deb
    openstreetmap-map-icons-classic.small_25996_all.deb
    openstreetmap-map-icons-square.big_25996_all.deb
    openstreetmap-map-icons-square.small_25996_all.deb
    openstreetmap-map-icons_25996_all.deb"

  wget -c --progress=dot:mega "$URL/$MAIN_FILE"
  for FILE in $EXTRA_FILES ; do
     wget -c -nv "$URL/$FILE"
  done

  dpkg -i openstreetmap-map-icons*.deb
  gdebi --non-interactive --quiet gpsdrive-friendsd_2.11_i386.deb
  gdebi --non-interactive --quiet gpsdrive-utils_2.11_i386.deb
  gdebi --non-interactive --quiet gpsdrive_2.11_i386.deb

fi



#######################
## build latest release
if [ $BUILD_LATEST -eq 1 ] ; then
  VERSION="2.11svn"

  if [ ! -d "$TMP_DIR" ] ; then
    mkdir "$TMP_DIR"
  fi
  cd "$TMP_DIR"

  ## FIXME (use better home once known/officially released)
  ##  wget -c --progress=dot:mega "http://www.gpsdrive.de/packages/gpsdrive-$VERSION.tar.gz"
  FILE=gpsdrive_2.11svn2556.tar.gz
  wget --progress=dot:mega -O "$FILE" \
     "http://sites.google.com/site/hamishbowman/${FILE}?attredirects=0"

  #tar xzf gpsdrive-$VERSION.tar.gz
  #if [ $? -eq 0 ] ; then
  #  \rm gpsdrive-$VERSION.tar.gz
  #fi

  #cd gpsdrive-$VERSION

  # FIXME
  mkdir gpsdrive-2.11svn
  cd gpsdrive-2.11svn
  tar xzf "../$FILE"


  ## --- apply any patches here ---

  # fix package dependencies
  PATCHES="gpsdrive_blue_mapnik"

  for PATCH in $PATCHES ; do
     patch -p0 < "$BUILD_DIR/../app-conf/gpsdrive/$PATCH.patch"
  done

  if [ $? -ne 0 ] ; then
     echo "An error occurred patching package. Aborting install."
     exit 1
  fi

  # local database name is "osm_local_smerc"
  sed -i -e 's/"gis"/"osm_local_smerc"/' src/database.c

  # installed mapnik version is 2.0
  MAPNIK_VER=2.0
  sed -i -e "s+/usr/lib/mapnik/0.5+/usr/lib/mapnik/$MAPNIK_VER+" src/gpsdrive_config.c
  sed -i -e 's+^      mapnik$+      mapnik2+' cmake/Modules/FindMapnik.cmake


# no longer needed? better to use `sed -i` for this anyway..
if [ 0 -eq 1 ] ; then
  cat << EOF > "gpsdrive_fix_icon.patch"
--- data/gpsdrive.desktop.ORIG  2009-08-31 01:42:39.000000000 +1200
+++ data/gpsdrive.desktop       2009-08-31 01:43:19.000000000 +1200
@@ -3,7 +3,7 @@
 Comment=GPS Navigation. You need to setup Gpsd manually
 Comment[de]=GPS Navigationsprogramm
 Exec=gpsdrive
-Icon=gpsicon
+Icon=/usr/share/gpsdrive/pixmaps/gpsicon.png
 Terminal=false
 Type=Application
 Categories=Graphics;Network;Geography;
EOF
   patch -p0 < "gpsdrive_fix_icon.patch"
fi


  #apply debian/ubuntu-lucid-32 patches to sync package deps for Lucid
  sed -i -e 's/Build with old libgps version (<2.90)" ON)/Build with old libgps version (<2.90)" OFF)/' \
      DefineOptions.cmake


  if [ $? -ne 0 ] ; then
     echo "An error occurred patching package. Aborting install."
     exit 1
  fi


  # use latest libboost, mapnik, postgis packages
  BOOST_VER=1.46.0
  PGIS_VER=9.1
  sed -i -e "s/libboost-\(.*\)1\.3[0-9]\.[0-9]/libboost-\1$BOOST_VER/" \
         -e 's/mapnik0\.[3-6]/mapnik2-2.0/' \
	 -e 's/libmapnik-dev/libmapnik2-dev/' \
         -e "s/postgresql-8\.[2-3]-postgis/postgresql-$PGIS_VER-postgis/" \
     debian/control

  ### install any missing build-dep packages

  # kludge to make sure these make it in there
  apt-get --assume-yes install libboost1.46-dev libboost-filesystem1.46-dev \
                               libboost-serialization1.46-dev libmapnik-dev

  # explicitly install these so they aren't removed in a later autoclean
  apt-get --assume-yes install  libgeos-3.2.2 libxml-simple-perl \
    libboost-serialization1.46.0 libboost-date-time1.46.0

  # any of these too?
  #  libgssrpc4
  #  libodbcinstq1c2
  #  libpcrecpp0
  #  libpthread-stubs0
  #  libtiffxx0c2
{'fraction_non_alphanumeric': 0.12901266701370814, 'fraction_numerical': 0.03956272774596564, 'mean_word_length': 3.2115454877603216, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '81182', 'n_tokens_mistral': 4663, 'n_tokens_neox': 4224, 'n_words': 1091}