Stefano on August 30th, 2008

In order to create your package, you have to:

  1. have a relocatable application, or write your application so to take advantage of the Chestnut Package Manager concept
  2. put executables, resources and other stuff into a properly named .chestnut directory (as of version 2.2.0 .package is deprecated but still working)
  3. write a manifest file
  4. That’s it! You can deploy your package.

5.1 Relocatable application

The application does not have to be dependent at compile time on a specific hardcoded path to get its static resources (eg. stuff like icons, template documents, default configuration files etc). To get the current package location you can get the environment variable CN_ROOT_DIR. Chestnut sets this variable before running the package to the current absolute path of the package directory, so when this variable is set, you can conclude that the application is running in a packaged environment. If the package is moved somewhere else, the value will be the proper one for the new location.

Applications that do not access other files, like applications getting input from stdin, or that require the file to access through a command line argument are relocatable.

What about libraries? if your application is using system libraries, the dynamic linker will do the job no matter where the application is. If the application is using private libraries stored into the package, and some environment variable must be exported to make them accessible, you can write a wrapper script that first export these variables, and then runs the application.

5.2 Putting Executables and Resources in the package

The package must have a standardized name, otherwise it will not be recognized as a package. The standard is “name-major.minor.patchlevel.chestnut”, eg. foo-1.2.5.chestnut. The Executables and Resources directories are standard, but you are by no means obliged to use them to make your executables and resources visible to Chestnut. You can create your own directories, and specify the Path type “package_relative” in the manifest.xml file.

However, using the standard packages is preferred. You are free to use other directories (for example, I used Libraries/architecture/language to store private libraries, eg. Libraries/Linux-i686/perl/) until a preferred standardized naming arises from de-facto usage.

Remember that, for an executable to run successfully, the platform string as specified in the package must match the result of the command “uname” and “uname -m”, separated by a single dash. Also, remember that the noarch fallback, if present, will be used if no platform specific executable is found.

5.3 Writing a manifest file

To write a manifest file, you can grab the hello-1.1.0.chestnut manifest as a template. Remember that you can leave out the Meta section, if you don’t want to specify documentation and/or default entry point.

Also, remember that you can skip the specification of the Interpreter, if the program is compiled, or if you want to execute it as a script with the shabang (#!). In this case, make sure that the program has executable permission (chmod +x), otherwise it will not be considered a valid Executable entry.

5.4 Deployment

Recursively copy or move the .chestnut directory into one of the Package repository as defined by CN_PACKAGE_SEARCH_PATH. Invoking cnls should show your package. If not, check accurately the manifest, 90% of the time the problem resides there. Better debugging, and a tool to create and deploy packages will be target for future releases.

Leave a Reply