15.5. Creating DarwinPorts Packages

 < Day Day Up > 

15.4. Creating Fink Packages

You can create your own Fink packages by identifying a source archive and creating a .info file in your /sw/fink/dists/local/main/finkinfo directory.

15.4.1. Creating and Publishing the Tarball

The Fink package system needs a tarball that can be downloaded with the curl utility. To illustrate how to create a Fink package, let's use the hellow-1.0 program (see "Using PackageMaker" earlier in this chapter). In this case, you can use the makefile shown in Example 15-4, which is a little simpler than the one used in Example 15-3.

Example 15-4. Makefile for hellow
 all:         cc -o hellow hellow.c 

Before you proceed, you should create a tarball named hellow-1.0.tar.gz with the following contents, and move it to the /Users/Shared/hellow/src directory:

     hellow-1.0/     hellow-1.0/hellow.1     hellow-1.0/hellow.c     hellow-1.0/Makefile 

The curl utility can download this file with the following URL: file:///Users/Shared/hellow/src/hellow-1.0.tar.gz. (You can host your own files on a public web server or FTP server, or, as in this example, on the local file system with a file: URL.)

15.4.2. Creating the .info File

Next, create a .info file to tell Fink where to download the package from and how to install it. Fink uses this information to download, extract, and compile the source code, and then to generate and install a Debian package (.deb file). This file must be in /sw/fink/dists/local/main/finkinfo, so you'll need superuser privileges to create it (use the sudo utility to temporarily gain these privileges). Example 15-5 shows /sw/fink/dists/local/main/finkinfo/hellow-1.0.info.

Example 15-5. The hellow-1.0 info file
 Package: hellow Version: 1.0 Revision: 1 Source: file:///Users/Shared/hellow/src/%n-%v.tar.gz Source-MD5: 4ca04528f976641d458f65591da7985c CompileScript: make InstallScript: mkdir -p %i/bin  cp %n %i/bin  mkdir -p %i/share/man/man1  cp %n.1 %i/share/man/man1/%n.1 Description: Hello, World program DescDetail: << Prints a friendly greeting to you and your friends. << License: Public Domain Maintainer: Brian Jepson <bjepson@oreilly.com> 

The hellow-1.0.info file includes several entries, described in the following list. See the Fink Packaging Manual at http://fink.sourceforge.net/doc/packaging/ for more details.


Package

The name of the package.


Version

The package version.


Revision

The package revision number.


Source

The URL of the source distribution. You can use percent expansion in the name. (In this example, %n is the name of the package and %v is the package version.) See the Fink Packaging Manual for more percent expansions.


Source-MD5

The MD5 sum for the file, as calculated by the md5sum binary (/sw/bin/md5sum) that comes with Fink. You may need to replace the MD5 sum in the hellow-1.0.info file if it's different than what's shown in Example 15-5.


CompileScript

The command (or commands) needed to compile the source package. The command(s) may span multiple lines, but must begin after the colon.


InstallScript

The command (or commands) that install the compiled package. The command(s) may span multiple lines, but must begin after the colon.


Description

A short description of the package.


DescDetail

A longer description of the package, enclosed with << >>.


License

The license used by the package. See the Fink Packaging Manual for information on available licenses.


Maintainer

The name and email address of the maintainer.

15.4.3. Installing the Package

To install hellow, use the command sudo fink install hellow. This command downloads the source to a working directory, and then extracts, compiles, and packages it, generating the file /sw/fink/dists/local/main/binary-darwin-powerpc/hellow_1.0-1_darwin-powerpc.deb.

If /sw/etc/fink.conf has the entry MirrorOrder: MasterFirst (the default), it will try to find the .tar.gz file on the server designated as Mirror-master. Since it is unlikely that hellow-1.0.tar.gz is hosted on that server, it will fail, and you'll be presented with several options, including "Retry using original source URL," which means to download the file from the location specified in hellow-1.0.info. You could avoid this by changing the MirrorOrder to MasterLast, but we do not recommend changing the default behavior of Fink, since it could have unpredictable results down the road.


After Fink creates this file, it installs it using dpkg. After you've installed hellow, you can view its manpage and run the hellow command:

     $ man hellow     HELLOW(1)         BSD General Commands Manual         HELLOW(1)     NAME          hellow - Greeting generator     DESCRIPTION          This command prints a friendly greeting.     Mac OS                    April 29, 2005                    Mac OS     $ hellow     Hello, world! 

This example shows only a portion of Fink's capabilities. For example, Fink can be used to download and apply patches to a source distribution. For more information, see the Fink Packaging Manual (http://fink.sourceforge.net/doc/packaging/index.php), which contains detailed instructions on how to build and contribute a .deb package to the Fink distribution.

     < Day Day Up > 


    Mac OS X Tiger for Unix Geeks
    Mac OS X Tiger for Unix Geeks
    ISBN: 0596009127
    EAN: 2147483647
    Year: 2006
    Pages: 176

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net