Tag Archives: deb

Finding files in Fink

Let’s see some methods to find files and their packages in Fink.

Using find

find is a command that is provided by most, if not all, Unix-based systems, including Mac OS X. Let’s say you want to find a file named zipfile.py in your Fink installation. On my system,

$ find /sw -name zipfile.py
/sw/lib/python2.5/zipfile.py
/sw/lib/python2.6/zipfile.py

You can be more specific if you’re sure that a file resides in a certain directory, e.g.

$ find /sw/lib -name libgutils\*dylib
/sw/lib/fontforge/libgutils.1.0.3.dylib
/sw/lib/fontforge/libgutils.1.dylib
/sw/lib/fontforge/libgutils.dylib

In the command above I also used \* to indicate that I was interested in any file whose name starts with libgutils and ends with dylib.

Furthermore, depending on your configuration, you may use locate or mdfind for this purpose.

Using dpkg

Fink uses a fork of Debian’s dpkg tool for binary package management. Here are some useful dpkg commands.

If you want to find out which package installed a given file, use dpkg -S. For example,

$ dpkg -S zipfile.py
python26: /sw/lib/python2.6/zipfile.pyc
python26: /sw/lib/python2.6/zipfile.pyo
python26: /sw/lib/python2.6/test/test_zipfile.pyc
python26: /sw/lib/python2.6/test/test_zipfile.pyo
python25: /sw/lib/python2.5/zipfile.py
python25: /sw/lib/python2.5/zipfile.pyc
python25: /sw/lib/python2.5/zipfile.pyo
python25: /sw/lib/python2.5/test/test_zipfile.pyc
python25: /sw/lib/python2.5/test/test_zipfile.pyo
python26: /sw/lib/python2.6/test/test_zipfile.py
python25: /sw/lib/python2.5/test/test_zipfile.py
python26: /sw/lib/python2.6/zipfile.py

Specifying an absolute path will limit the results:

$ dpkg -S /sw/lib/python2.6/zipfile.py
python26: /sw/lib/python2.6/zipfile.py

If you want to list the files installed by a given package (e.g. the di package), use dpkg -L:

$ dpkg -L di
/.
/sw
/sw/bin
/sw/bin/di
/sw/bin/mi
/sw/share
/sw/share/doc
/sw/share/doc/di
/sw/share/doc/di/MANIFEST
/sw/share/doc/di/README
/sw/share/man
/sw/share/man/man1
/sw/share/man/man1/di.1

The grep command can be useful to filter the results: to list only the binaries (programs) installed under /sw/bin,

$ dpkg -L di | grep ^/sw/bin
/sw/bin
/sw/bin/di
/sw/bin/mi

If you have a binary package (i.e., a .deb file that was either built on your machine or obtained via a binary distribution), you need to use dpkg -c instead:

$ dpkg -c /sw/fink/debs/bibclean_2.11.4-2_darwin-i386.deb
drwxr-xr-x root/admin        0 2009-09-16 09:04 ./
drwxr-xr-x root/admin        0 2009-09-16 09:04 ./sw/
drwxr-xr-x root/admin        0 2009-09-16 09:04 ./sw/bin/
-rwxr-xr-x root/admin   112564 2009-09-16 09:04 ./sw/bin/bibclean
drwxr-xr-x root/admin        0 2009-09-16 09:04 ./sw/share/
drwxr-xr-x root/admin        0 2009-09-16 09:04 ./sw/share/doc/
drwxr-xr-x root/admin        0 2009-09-16 09:04 ./sw/share/doc/bibclean/
-rw-r--r-- root/admin    26550 2009-09-16 09:04 ./sw/share/doc/bibclean/README
-rw-r--r-- root/admin     2932 2009-09-16 09:04 ./sw/share/doc/bibclean/bibclean.copyright
-rw-r--r-- root/admin    48768 2009-09-16 09:04 ./sw/share/doc/bibclean/bibclean.pdf
-rw-r--r-- root/admin    76512 2009-09-16 09:04 ./sw/share/doc/bibclean/bibclean.ps
-rw-r--r-- root/admin    55226 2009-09-16 09:04 ./sw/share/doc/bibclean/bibclean.txt
drwxr-xr-x root/admin        0 2009-09-16 09:04 ./sw/share/man/
drwxr-xr-x root/admin        0 2009-09-16 09:04 ./sw/share/man/man1/
-rw-r--r-- root/admin    42974 2009-09-16 09:04 ./sw/share/man/man1/bibclean.1

The directory/folder /sw/fink/debs contains convenient symbolic links to the actual .deb files created when packages were built on your machine. On the other hand, .deb files obtained via binary distributions are located under /sw/var/cache/apt/archives.

Build process flowchart

Here’s an overview of Fink’s build process and its five phases. The build process always refers to one package description or, if the description has variants, to one of those variants. If a package description (or one variant) yields different packages (e.g. the php5.info package description yields the php5, php5-cgi, php5-cli, … packages) then all of these packages, called split-offs, are built in the same run of the build process.

Build process flowchart

Build process flowchart

Assuming that all the necessary source files are located under /sw/src or FetchAltDir (fink.conf), they are unpacked, patched if needed, and compiled under the build directory. Files are ‘installed’ under the install directory, a temporary directory used by the following phase, Build, to create one or more (split-off) .deb package files based on the contents of the install directory.

The fink command has two options that let you inspect the contents of the build and install directories: -k or –keep-build-dir will keep the build directory after the build process ends, and -K or –keep-root-dir will keep the install (root) directory after the build process ends.

There are equivalent configuration options that can be used in fink.conf: KeepBuildDir and KeepRootDir. Be careful, though: keeping every build and install directory can fill your hard disk quickly!

Package installation flowchart

Here’s an overview of what Fink needs to do in order to install a new package. A bindist (binary distribution) refers to both the .deb packages available on your local system as well as remote packages (either from Fink or from unofficial bindists).

Package installation flowchart

Package installation flowchart

As explained in a previous post, the source code is only necessary to build .deb packages, which in turn are only necessary to install files on your system. Ultimately, only the files that the package installed under /sw are needed in order to run it. However, keeping the .deb files available helps with subsequent installations and updates.

Cleaning Fink up: packages

The last post dealt with removing files (sources and .debs) that Fink might not need any longer. What about packages?

Word of advice: Some of the commands below should be run with care. If you’re not sure about what they do and how they should be used then you might want not to run them at all.

The basics: fink remove

The basic command for removing packages is fink remove:

fink remove packagename

Unless that package is necessary by other package(s), every file installed by that package will be removed. Well, actually that’s not precise. The remove command will keep configuration files, which is a nice idea in case you want to install that package again. If you want to remove both the package and its configuration files, run:

fink purge packagename

Some packages can’t be removed this way because other packages depend on it. Fink will warn you if that’s the case and tell you how to proceed if you want to recursively remove that package.

Packages containing developer files

Fink packages can roughly be categorized into user applications, utilities, shared libraries, and developer files. Users normally install applications, which in turn might need utilities or shared libraries to function properly (the so-called dependencies). If  a package needs to be compiled/built by Fink, then it will often need one of more developer files (usually header files) which are part of BuildDependsOnly (BDO) packages. After the compilation/build ends, these packages containing developer files may be removed – Fink will install them again if needs be.

BDO packages tend to be quite small so the effort of removing them might not be worth it.

If you want to list all the BDO packages installed by Fink, save the following shell script in a file (e.g. bdolist.sh):

#!/bin/sh
fink list -it | cut -f2 | \
xargs fink dumpinfo -fbuilddependsonly -p "%n" | \
while read line
do
  firstfield=`echo $line | cut -d: -f1`
  secondfield=`echo $line | cut -d: -f2`
  if [ "$firstfield" == "%n" -a \
    "$previousline" == "builddependsonly: true" ]
  then
    echo $secondfield
  fi
  previousline="$line"
done

Flag the file as being executable and run it:

chmod +x bdolist.sh
./bdolist.sh

If you want to remove all the BDO packages listed by the script, run the  following command:

./bdolist.sh | xargs fink remove

Deb management packages

In general, deb management programs besides the APT and dpkg management systems should work on Fink. They need to be installed by the fink install command and, as they are not part of Fink core, Fink cannot vouch for (or support) them.

Deborphan lists packages (libraries and BDO packages mostly) that have no other packages depending on them. Run

deborphan

in order to get a list of such packages. If you want to remove them, run

deborphan | xargs fink remove

Debfoster, when run in interactive mode, asks the user for which packages should be kept on the system, assisting with the removal of packages (especially libraries and BDO packages) that are no longer necessary.

Cleaning Fink up: files

So you’ve installed Fink, played around with its selection of packages, installing and removing several of them, and now you feel like cleaning it up. There are a few things to consider. Be sure to read the highlighted text, and be careful when running the commands listed below.

Introduction

When Fink installs a package it needs one or more .deb files, which contain the individual files that are to be installed on the system. These .deb files can be obtained via a binary distribution or built from source. In the latter, Fink downloads source files (usually .zip, .tar.gz, .tar.bz2 files), compiles the package from source, and creates one or more .deb files. After a package has been built its source files can be removed; after a package has been installed its .deb files can be removed. They won’t be needed again unless you need to (re)build or (re)install that particular version of the package.

The fink cleanup command

Fink provides a cleanup command that can be used to remove source and .deb files that are obsolete, i.e., they are neither present in your current distribution (e.g. the package has been removed from Fink or it has been updated to a newer version) nor installed. Run the following command on a terminal window.

fink cleanup

Note that this command will keep source and .deb files of packages that are currently installed, as well as source and .deb files of packages that are not installed but are up-to-date. In summary, fink cleanup only removes files that won’t be necessary if you decide to (re)install a package.

Removing source files

In a standard Fink installation source files are downloaded into the folder /sw/src. If you want to get a listing of the files under that folder, sorted by size, run the following command on a terminal window.

ls -hklsS /sw/src

In order to zero that folder out, run the following command on a terminal window.

sudo rm -rf /sw/src/*

The only disadvantage of removing source files is that if Fink needs them then it’ll download them again.

Removing .deb files

There are two main folders where .deb packages are kept. Packages that are built from source files are placed under /sw/fink/dists; the specific folder depends on the tree and the section the package belongs to, and your system’s processor. For example, a .deb file of a package that is in the unstable/main tree, belongs to the graphics section, and was built on an Intel system is placed under /sw/fink/dists/ustable/main/binary-darwin-i386/graphics. If you want to list every .deb file built by Fink, run the following command on a terminal window.

find -L /sw/fink/dists -name \*.deb

In order to remove all of them, run the following commands on a terminal window.

sudo find -L /sw/fink/dists -name \*.deb -exec rm {} \;
fink scanpackages

If Fink needs to (re)install a package and it can’t find a suitable .deb file then it’ll build it from source. Building a package may take considerable time.

If you are using binary distributions, Fink will, whenever possible, download prebuilt .deb packages instead of building them from source. They are placed under the folder /sw/var/cache/apt/archives, and you may remove them by running the following command on a terminal window.

sudo rm /sw/var/cache/apt/archives/*.deb
fink scanpackages

If Fink needs to (re)install a package and it can’t find a .deb file then it’ll try to download it from a binary distribution, and some .deb files are quite big. If that .deb file is not available on a binary distribution, then Fink will build it from source, and building packages may take considerable time.

Another reason to keep your .deb files around is that that during a build, fink may need to swap packages containing headers, the so-called BuildDependsOnly packages, in order to build against different versions of libraries. If it discovers that there isn’t a .deb corresponding to a currently installed package, of identical version and revision, that is going to be swapped out, then it will stop and complain about the lack of a .deb file.