| 1 | このページは describes techniques used for preparing OSGeo4W packages. |
| 2 | [[TOC]] |
| 3 | = General = |
| 4 | |
| 5 | 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. |
| 6 | |
| 7 | == Package Directory Layout == |
| 8 | |
| 9 | The installed OSGeo4W directory tree is described in DirectoryLayout. |
| 10 | |
| 11 | OSGeo4W packages are generally structured like packages for Cygwin as described at http://cygwin.com/setup.html . |
| 12 | |
| 13 | Packages prepared for OSGeo4W are currently uploaded to: |
| 14 | |
| 15 | upload.osgeo.org:/osgeo/download/osgeo4w/release/<package> |
| 16 | |
| 17 | This tree can be reviewed at: http://download.osgeo.org/osgeo4w/release |
| 18 | |
| 19 | 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-<version>-<revision>.tar.bz2 package files. |
| 20 | |
| 21 | 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. |
| 22 | |
| 23 | '''Note:''' Please use `tar` & `bzip2` from osgeo4w's msys (%OSGEO4W_ROOT%\apps\msys\bin). Don't use 7zip as setup.exe can't understand the archives it creates, and there is mixed success with gnuwin32 bzip2 and cygwin bzip2. Linux tar/bzip2 has no reported problems. (see ticket #101) |
| 24 | |
| 25 | == Web Application Package Guidelines == |
| 26 | |
| 27 | Here are some important guidelines: |
| 28 | |
| 29 | * the /osgeo4w/apps/ directory exists to hold applications. Your application must be installed in a subdirectory of the /osgeo4w/apps/ directory, preferably with a meaningful name (in lowercase). |
| 30 | * the Apache alias "/ms_tmp/" exists to access temporary web-accessible files, which points to the directory /osgeo4w/tmp/ms_tmp/ |
| 31 | * the Apache alias "/cgi-bin/" points to the /osgeo4w/bin/ folder. e.g. mapserv.exe lives in the /bin folder. |
| 32 | * the /osgeo4w/httpd.d/ directory exists to hold Apache Alias Files. This directory is automatically scanned by Apache when it starts. The following is an alias example for an application named 'foobar': |
| 33 | |
| 34 | {{{ |
| 35 | Alias /foobar/ @osgeo4w@/apps/foobar/htdocs/ |
| 36 | AllowOverride None |
| 37 | Options Indexes FollowSymLinks Multiviews |
| 38 | Order allow,deny |
| 39 | Allow from all |
| 40 | }}} |
| 41 | |
| 42 | The name of the file is very important. Apache will only load files that match the following pattern: |
| 43 | {{{ |
| 44 | httpd_*.conf |
| 45 | }}} |
| 46 | 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/ |
| 47 | to access the application. |
| 48 | |
| 49 | * 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: |
| 50 | {{{ |
| 51 | packagename.pkg.html |
| 52 | }}} |
| 53 | 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): |
| 54 | {{{ |
| 55 | <pre><h3>Foobar Application</h3> |
| 56 | <blockquote><p><a href="/foobar/">Foobar demo</a></p></pre> |
| 57 | }}} |
| 58 | == setup.hint == |
| 59 | |
| 60 | 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:: |
| 61 | {{{ |
| 62 | sdesc: "The Libgeotiff library, commandline tools and supporting tables." |
| 63 | ldesc: "The Libgeotiff library, commandline tools and supporting tables. |
| 64 | Used for manipulating GeoTIFF files." |
| 65 | category: Libs Commands |
| 66 | requires: msvcrt libtiff |
| 67 | }}} |
| 68 | 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. |
| 69 | |
| 70 | |
| 71 | == Post-Install Actions == |
| 72 | |
| 73 | 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/<package>.bat. The bat file will be run with the environment variables OSGEO4W_STARTMENU, OSGEO4W_HOME and OSGEO4W_HOME_MSYS defined, and with OSGEO4W_HOME/bin already in the path. |
| 74 | |
| 75 | 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, and here are 2 examples:: |
| 76 | |
| 77 | === !TextReplace Example !#1 === |
| 78 | |
| 79 | * hardcoded paths exist in the /httpd.d/httpd_gmap.conf file of the gmap package: |
| 80 | {{{ |
| 81 | Alias /gmap/ "C:/mypath/apps/gmap/htdocs/" |
| 82 | <Directory "C:/mypath/apps/gmap/htdocs/"> |
| 83 | AllowOverride None |
| 84 | Options Indexes FollowSymLinks Multiviews |
| 85 | Order allow,deny |
| 86 | Allow from all |
| 87 | </Directory> |
| 88 | }}} |
| 89 | * the first step is to replace the hardcoded path in the file with the ''@osgeo4w@'' variable, in your favourite text editor. For example the above file would then look like: |
| 90 | {{{ |
| 91 | Alias /gmap/ "@osgeo4w@/apps/gmap/htdocs/" |
| 92 | <Directory "@osgeo4w@/apps/gmap/htdocs/"> |
| 93 | AllowOverride None |
| 94 | Options Indexes FollowSymLinks Multiviews |
| 95 | Order allow,deny |
| 96 | Allow from all |
| 97 | </Directory> |
| 98 | }}} |
| 99 | * the second step is to create a postinstall script named gmap.bat (that lives at /etc/postinstall/ of the gmap package) to replace that variable with the actual user's install path: |
| 100 | {{{ |
| 101 | textreplace -sf httpd.d/httpd_gmap.conf -df httpd.d/httpd_gmap.conf -map @osgeo4w@ %OSGEO4W_ROOT% |
| 102 | }}} |
| 103 | |
| 104 | === !TextReplace Example !#2 === |
| 105 | |
| 106 | {{{ |
| 107 | textreplace -sf bin/gdal-config.tmpl -df bin/gdal-config \ |
| 108 | -map @osgeo4w@ "%OSGEO4W_ROOT%" \ |
| 109 | -map @osgeo4w_msys@ "%OSGEO4W_ROOT_MSYS%" |
| 110 | }}} |
| 111 | Both examples use the bin/textreplace program (part of the msvcrt package). The second example uses it 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: |
| 112 | {{{ |
| 113 | textreplace -std -t bin/gdal-config |
| 114 | }}} |
| 115 | This applies the "standard" conversions to file bin/gdal-config.tmpl and puts the results in bin/gdal-config |
| 116 | |
| 117 | == Creating Shortcuts == |
| 118 | |
| 119 | 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: |
| 120 | {{{ |
| 121 | mkdir "%OSGEO4W_STARTMENU%" |
| 122 | mkdir "%OSGEO4W_STARTMENU%\Apache" |
| 123 | xxmklink "%OSGEO4W_STARTMENU%\Apache\OSGEO4W-Apache-Install.lnk" |
| 124 | %OSGEO4W_ROOT%\Apache\bin\httpd.exe " -k install -n \"Apache OSGEO4W Web Server\"" |
| 125 | }}} |
| 126 | Using icons: |
| 127 | {{{ |
| 128 | xxmklink "%OSGEO4W_STARTMENU%\ttt.lnk" cmd.exe "" . "my_desc" 1 "%OSGEO4W_ROOT%\OSGeo4W.ico" |
| 129 | }}} |
| 130 | A Desktop icon: |
| 131 | {{{ |
| 132 | xxmklink "%ALLUSERSPROFILE%\Desktop\OpenEV.lnk" "%OSGEO4W_ROOT%\bin\openev.bat" |
| 133 | " " \ "OSGeo4W OpenEV" 1 "%OSGEO4W_ROOT%\apps\openev\icon.ico" |
| 134 | }}} |
| 135 | |
| 136 | The postinstall scripts can run any DOS command or installed binary with desired arguments. |
| 137 | |
| 138 | = Shell Initialization = |
| 139 | |
| 140 | Some packages need to set particular environment variables. For the OSGeo4W command shell this can be |
| 141 | accomplished by adding an initialization file in etc/ini. A typical example looks like:: |
| 142 | {{{ |
| 143 | SET GDAL_DATA=%OSGEO4W_ROOT%\share\gdal |
| 144 | }}} |
| 145 | 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. |
| 146 | |
| 147 | = Application batch file template = |
| 148 | Sample of how to start an application with standard environment set. Replace `foo.exe` with your application executable and save as `foobar.bz2:bin/foo.bat.tmpl`. [#Post-InstallActions Post-Install] will set the proper OSGEO4W_ROOT. |
| 149 | {{{ |
| 150 | @echo off |
| 151 | SET OSGEO4W_ROOT=@osgeo4w@ |
| 152 | call "%OSGEO4W_ROOT%\bin\o4w_env.bat" |
| 153 | start "Foo window title" /B "%OSGEO4W_ROOT%\bin\foo.exe" %* |
| 154 | @echo on |
| 155 | }}} |
| 156 | |
| 157 | == Setup.ini == |
| 158 | |
| 159 | The Cygwin Setup.exe actually downloads the [http://download.osgeo.org/osgeo4w/setup.ini 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 invoking `osgeo4w-regen.sh` on the web each time packages are uploaded. This produces a test version of the file (http://download.osgeo.org/osgeo4w/setup_test.ini), which can be used with the setup program by passing the -t commandline option. Once this has been tested, using the link `osgeo4w-promote.sh` to copy this file to setup.ini, making it live for regular users. |
| 160 | |
| 161 | * Generate test setup: `http://upload.osgeo.org/cgi-bin/osgeo4w-regen.sh` |
| 162 | * Verify package version numbers (top of PackageListing) |
| 163 | * Test by passing -t to setup program ([http://download.osgeo.org/osgeo4w/osgeo-setup_test-ini.bat osgeo-setup_test-ini.bat]) |
| 164 | * Promote test setup to live: `http://upload.osgeo.org/cgi-bin/osgeo4w-promote.sh` |
| 165 | |
| 166 | == Documenting == |
| 167 | |
| 168 | Please ensure that you prepare a wiki page linked off [wiki:PackageListing] with info on your package. It should include a pointer back to the upstream project, the name of the packager (a link to a page with contact info on the packager), and special notes on where things are placed within OSGeo4W. |
| 169 | |
| 170 | [wiki:WikiStart 戻る] |