|< 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 <email@example.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.
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.
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 >|