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.
To demonstrate how to create a package, we'll create a short C program and its associated manpage. Example 6-1 shows hellow.c and Example 6-2 shows its manpage, hellow.1.
/* * hellow.c - Prints a friendly greeting. */ #include <stdio.h> int main( ) { printf("Hello, world!\n"); return 0; }
.\" Copyright (c) 2002, O'Reilly & Associates, Inc. .\" .Dd April 15, 2002 .Dt HELLOW 1 .Os Mac OS X .Sh NAME .Nm hellow .Nd Greeting generator .Sh DESCRIPTION This command prints a friendly greeting.
The Fink package system needs a tarball that can be downloaded with the curl utility, so you should put these two files into a directory, such as hellow-1.0. Then, create a tarball containing these files and that top-level directory, and put it somewhere where you can get it. In this example, the tarball is created and moved to the local Shared folder:
[localhost:~/src] bjepson% tar cvfz hellow-1.0.tar.gz hellow-1.0/ hellow-1.0/ hellow-1.0/hellow.1 hellow-1.0/hellow.c hellow-1.0/Makefile [localhost:~/src] bjepson% cp hellow-1.0.tar.gz /Users/Shared
The curl utility can download this file with the following URL: file:///Users/Shared/hellow-1.0.tar.gz. (We could also have put the file on a public web server or FTP server.)
Next, you need a .info file to tell Fink where to download the package and how to install it. Fink can use this information to download, extract, and compile the source code, and then generate and install a Debian package (.deb file). To create the file in /sw/fink/dists/local/main/finkinfo, you'll need superuser privileges (use the sudo utility to temporarily gain these privileges). Example 6-3 shows hellow-1.0.info.
Package: hellow
Version: 1.0
Revision: 1
Source: file:///Users/Shared/%n-%v.tar.gz
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 protected]>
The hellow-1.0.info file includes several entries, described in the following list. See the Fink Packaging Manual on http://fink.sourceforge.net/doc/packaging/ for more details.
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) System General Commands Manual HELLOW(1) NAME hellow - Greeting generator DESCRIPTION This command prints a friendly greeting. Mac OS April 15, 2002 Mac OS % hellow Hello, world!
This example shows only a portion of Fink's capabilities. For example, Fink can download and apply patches to a source distribution. For more information, see the Fink Packaging Manual, which contains detailed instructions on how to build and contribute a .deb package to the Fink distribution.
Copyright © 2003 O'Reilly & Associates. All rights reserved.