UNDER CONSTRUCTION - UNDER CONSTRUCTION - UNDER CONSTRUCTION - UNDER CONSTRUCTION 

PREFACE:
	There are configuration files included in the dir where this document
	 resides. Use them, that's why they're there. But I know, since some of
	 you like to go against the grain, at least one of you is going to try
	 building a package from an install that differs from mine.

	If you choose to go down that dark road, then bear in mind that there
	 are ways to do this right, and there are ways to do this wrong....
	 Make sure that you mind where you decide to install the bin and lib.
	 If you specify a target outside of the trunk, and don't, let's say,
	 write the same dir somewhere else, then the package won't work. 

	Make sure when putting together a dir hierarchy for a package, that you
	 create something sime to what you specifed during compile. If you
	 change "--bindir" then create a dir in the package that corresponds to
	 that. The trunk doesn't necessarily have to be in the same place as it
	 is on the build system.

-------------------------------------------------------------------------------
		    Installing ISSM to create a deb package:
-------------------------------------------------------------------------------

1.	Install mpich from the ubuntu repositories:

		> sudo apt-get install mpich2 (or something similar)

		Check to make sure that it installs the "-dev" libs
			if not:
			 > sudo apt-get install libmpich-dev (or something similar)
			Otherwise you won't get "/usr/lib/mpich2"

		You can use "apt-cache search" to find a package's full name

2a.	Compile petsc and metis (preferred versions: 3.2 and 4.0, respectively):

		Make sure that petsc's installer file is pointing to the
		 correct mpich dir

			You should use "/usr/lib/mpich2" (or something similar)

		As of now, it is preferable to use the separate mpich package
		 because the infrastructure of the mpich package under petsc
		 is having issues with being packaged

		Also make sure that you mind the target of the installation.
			Right now /usr/share/petsc and /usr/share/metis are the
			 best options suffixed by version numbers

2b.	Install dependencies from the ubuntu repositories

		Use apt-get install to install:
			triangle-bin, libtriangle-dev, python2.7-dev, 
			 python-scipy, python-netcdf4, netcdf-bin, python-nose, 
			 libnetcdfc++4, hdf5-tools

		REMEMBER: that this tutorial assumes you are creating the
		 python interface
			
3.	Be sure to patch the system triangle.h file

		> sudo patch /usr/include/triangle.h $ISSM_DIR/externalpackages/triangle/triangle.h.patch
			the header may also be called "libtriangle.h"

		Just like always, this will move the original to 
		 "triangle.h.old" incase you need to revert

4.	Compile ISSM

		> autoreconf -iv && configs/config-*-packaging.sh && make && sudo -E make install

-------------------------------------------------------------------------------
		          Creating an issm.deb package
-------------------------------------------------------------------------------
	THIS ASSUMES YOU ARE USING THE CONFIG FILE SUPPLIED HERE.
	IF YOU ARE DOING AN ALTERNATE CONFIG, MAKE SURE THE DIR
	HIERARCHY IS PROPERLY REFLECTED BY THE BINDIR AND LIBDIR!

1.	Make a directory to work from (the dir dpkg-deb will build)
		Anywhere will do, but using a ~/tmp dir works best

		> mkdir issmpkgdir
		> cd issmpkgdir

2.	Create the dir hierarchy:

		> mkdir -p usr/{bin,lib,share/issm-trunk} etc/issm DEBIAN

		This is will create:
		issmpkgdir/
		|_ usr/
		|  |_ bin/
		|  |_ lib/
		|  |_ share/
		|     |_issm-trunk/ - this is the trunk
		|_ etc/
		|  |_ issm/ - this is where issmrc and other conf files go
		|_DEBIAN/ - where control files and install scripts go

		As stated, if you change "--bindir" or "--libdir" in the config
		 file, then make sure that you create matching dirs in this
		 step, or vice-versa.

3.	Copy the contents of the package over:

		> sudo cp -r /usr/bin/issm usr/bin
		> sudo cp -r /usr/lib/issm usr/lib
		> cp -r $ISSM_DIR/* usr/share/issm-trunk

		When you copy the trunk over, this your opportunity to weed out
		 anything you don't want included in the build.
		Again, the config file installs the bin and lib files to a dir
		 that's separate from the rest of the bin and lib files. If you
		 change "--bindir" or "--libdir", make sure you install them to
		 a subdirectory of your target to keep things neat or else 
		 you'll have to pick them out, one-by-one to complete this step.

4.	Write your control file. A template is provided, that is the bare minimum to
		 create the package 

		You will NEED the following dependencies:
		mpich2, petsc3.2-issm, metis4.0-issm, triangle-bin, libtriangle-dev, 
		 python2.7-dev, python-scipy, python-netcdf4, netcdf-bin, python-nose, 
		 libnetcdfc++4, hdf5-tools

5.	Create any install/uninstall scripts needed (preinst, postinst, prerm, postrm)
		There are already some templates provided for you.

		Make sure you address the issue of any user created content. By
		 default, apt-get won't remove anything that wasn't created by
		 the installer, even if you use purge. Put this in a rm script.

6.	Build the package:

		> dpkg-deb --build <workingDir> <nameOfPackage>

UNDER CONSTRUCTION - UNDER CONSTRUCTION - UNDER CONSTRUCTION - UNDER CONSTRUCTION 
