OSGeo4W Packaging

This page describes techniques used for preparing OSGeo4W packages.

= General =

OSGeo4W packages are each bzip2 compressed .tar files intended to be unpacked in the OSGeo4W root directory. They come with setup.hint files designed to describe dependencies and a package description.

= Installed Directory Layout =


 * /apache: the Apache web server
 * /apache/htdocs: The web document directory. Web applications should only include a .pkg file in this directory, see the "Web Application Package Guidelines" section below for more information.
 * /apps: Directory for applications that need their own directory tree, and don't fit conveniently into /bin, /lib, etc. Each app appearing here should have a subdirectory with a name closely related to the name of the package.
 * /bin: most .exe and .dll files intended to be in the user path. The apache alias '/cgi-bin/' also points to this /bin directory.
 * /etc/ini: .bat files to be called from OSGEO4W_ROOT/osgeo4w.bat - usually these contain SET statements for required environment variables.
 * /etc/postinstall: per package post-install scripts
 * /etc/setup: used by cygwin setup to keep track of installed packages.
 * /http.d: apache configuration files, one per package. See the "Web Application Package Guidelines" section below for more information.
 * /include: include files required for building additional packages and executables.
 * /lib: static and stub libraries required for building additional packages and executables.
 * /share: static support data files.
 * /src: When available source packages should unpack here with a directory name matching the package name.
 * /tmp - directory to store temporary files (non-web-accessible)
 * /tmp/ms_tmp/ directory to store temporary web-accessible files
 * /var: currently used by Cygwin setup.exe

= Package Directory Layout =

OSGeo4W packages are generally structured like packages for Cygwin as described at http://cygwin.com/setup.html.

Packages prepared for OSGeo4W are currently uploaded to:

buildbot.osgeo.org:/osgeo/download/osgeo4w/release/

This tree can be reviewed at: http://download.osgeo.org/osgeo4w/release

Each package directory should have a single setup.hint file, and one or more versions of that package as a .tar.bz2 file. These should normally have names like gdal-1.5.0-1.tar.bz2 where "1.5.0" is the version of GDAL that was packaged, and "-1" indicates the version of the packaging attempt. The directory can also contain corresponding source snapshots named like gdal-1.5.0-1-src.tar.bz2. Note that the basename should exactly match the directory in which the package is found. So the "gdal" directory has gdal- - .tar.bz2 package files.

Sometimes a single project is packaged as several packages. In this case component packages are normally created as subdirectories of the primary directory. So, for instance the Oracle 10g driver for GDAL is kept in the release/gdal/gdal-oracle10g directory and packaged as gdal-oracle10g-1.5.0-1.tar.bz2.

= Web Application Package Guidelines =

Here are some important guidelines:

application must be installed in a subdirectory of the /osgeo4w/apps/ directory, preferably with a meaningful name (in lowercase). directory is automatically scanned by Apache when it starts. The following is an alias example for an application named 'foobar':
 * the /osgeo4w/apps/ directory exists to hold applications. Your
 * the Apache alias "/ms_tmp/" exists to access temporary web-accessible files, which points to the directory /osgeo4w/tmp/ms_tmp/
 * the Apache alias "/cgi-bin/" points to the /osgeo4w/bin/ folder. e.g. mapserv.exe lives in the /bin folder.
 * the /osgeo4w/httpd.d/ directory exists to hold Apache Alias Files. This

Alias /foobar/ @osgeo4w@/apps/foobar/htdocs/ AllowOverride None Options Indexes FollowSymLinks Multiviews Order allow,deny Allow from all

The name of the file is very important. Apache will only load files that match the following pattern:

httpd_*.conf

Normally, you would replace * with your application name. In the above example, the application would use httpd_foobar.conf in the /OSGEO4W/httpd.d/ directory. This would allow the user to connect to http://localhost/foobar/ to access the application.


 * All web applications should include a small .pkg file in the /osgeo4w/apache/htdocs/ folder so that a link to the application is displayed on the OSGeo4W index page (localhost). This 'Index Package File' provides a small HTML snippet that is automatically included in the OSGeo4W index page.  This HTML snippet should provide a brief description of your application and provide links to access the aliases you have provided via the Apache Alias File.  The Index Package File follows a strict naming convention:

packagename.pkg.html

Only files that end in .pkg.html will be included in the index page. Here is an example of a .pkg file (named 'foobar.pkg.html):

Foobar Application Foobar demo

= setup.hint =

Each package directory has a setup.hint file which normally contains the short and long description for the package, and the list of other packages on which it depends. Note that there is normally only one setup.hint file for a package even if several versions of the package exist. A normal setup.hint file might look like::

sdesc: "The Libgeotiff library, commandline tools and supporting tables." ldesc: "The Libgeotiff library, commandline tools and supporting tables. Used for manipulating GeoTIFF files." category: Libs Commands requires: msvcrt libtiff

This indicates the short and long description for the package, the list of categories it will appear in for the installer user interface, and the package it requires.

= Post-Install Actions =

Packages may take post-install actions by including a .bat file in the /etc/postinstall directory as part of the package. The filename should be named etc/postinstall/ .bat. The bat file will be run with the environment variables OSGEO4W_HOME and OSGEO4W_HOME_MSYS defined, and with OSGEO4W_HOME/bin already in the path. One very common thing to do in postinstall actions is to insert/update configuration files to include the installed path to the OSGeo4W tree. This is normally done with a postinstall file that looks like::

textreplace -sf bin/gdal-config.tmpl -df bin/gdal-config \ -map @osgeo4w@ "%OSGEO4W_ROOT%" \ -map @osgeo4w_msys@ "%OSGEO4W_ROOT_MSYS%"

This runs the bin/textreplace program (part of the msvcrt package) with source file bin/gdal-config.tmpl and destination file bin/gdal-config and replaces occurances of @osgeo4w@ with the value of the OSGEO4W_ROOT environment variable, and @osgeo4w_msys@ with the value of the OSGEO4W_ROOT_MSYS environment variable. The pattern of processing a file from a .tmpl version is sufficiently common that textreplace supports this short form for the same action:

textreplace -std -t bin/gdal-config

This applies the "standard" conversions to file bin/gdal-config.tmpl and puts the results in bin/gdal-config

Another postinstall task that packages might do is to create shortcuts that will be available to launch a certain command. As its is the case for the textreplace executable, there is an utility binary xxmklink.exe that is available in the installer (part of the msvcrt package). By typing xxmklink, you can see all the options supported by this utility. Here are some examples on how it can be used in a post install file::

mkdir "%ALLUSERSPROFILE%\start menu\Programs\OSGeo4W" mkdir "%ALLUSERSPROFILE%\start menu\Programs\OSGeo4W\Apache" xxmklink "%ALLUSERSPROFILE%\start menu\Programs\OSGeo4W\Apache\OSGEO4W-Apache-Install.lnk" \ %OSGEO4W_ROOT%\Apache\bin\httpd.exe " -k install -n \"Apache OSGEO4W Web Server\"" Using icons: xxmklink "%ALLUSERSPROFILE%\start menu\Programs\OSGeo4W\ttt.lnk" cmd.exe "". "my_desc" 1 \ "%OSGEO4W_ROOT%\OSGeo4W.ico"

The postinstall scripts can run any DOS command or installed binary with desired arguments.

= Shell Initialization =

Some packages need to set particular environment variables. For the OSGeo4W command shell this can be accomplished by adding an initialization file in etc/ini. A typical example looks like::

SET GDAL_DATA=%OSGEO4W_ROOT%\share\gdal

These scripts are run in random order by %OSGEO4W_ROOT%\OSGeo4W.bat when establishing the environment for the OSGeo4W shell. The OSGEO4W_ROOt environment variable will always be set on the way in.

= Setup.ini =

The Cygwin Setup.exe actually downloads the setup.ini file with a list of all packages each time it is run. This file should be recreated on the server by running the script /osgeo/download/osgeo4w/regen.sh (normally as user frankw) each time packages are uploaded.