Some users have been asking how to reinstall Fink. This might be necessary when there isn’t an upgrade path — for instance, there’s no upgrade path from 32-bit Fink to 64-bit Fink, or when trying to replicate a Fink installation from one architecture (e.g. PowerPC, 32-bit Intel) to another (e.g. 64-bit Intel). This text explains how to save the list of installed packages and their configuration files in order to conveniently reinstall them on a clean Fink installation. Bear in mind that packages in one platform may not be available on another. For example, some packages are only available for PowerPC, and 64-bit Fink has (at the moment) fewer packages than on 32-bit Intel, 32-bit Fink.
Note: if you’re not sure how to execute the commands listed below on a terminal window, contact someone that’s more familiar with Unix and shells.
Preamble: Understanding virtual packages
Virtual packages are placeholders for packages or features that are present on your system but haven’t necessarily been installed by Fink itself. Some of them are system virtual packages, representing files that are shipped with the system (e.g. system-java, system-perl), whilst others may represent files installed by either Fink (e.g. pdftex) or the user (e.g. growl). Some of these virtual packages do not actually refer to files on your system. For example, the 64bit-cpu virtual package is just an indication that the system has a 64-bit processor. At any rate, virtual packages are managed by Fink and you can’t run commands fink install or fink remove on them.
Listing installed packages
Fink provides a handy command to list installed packages:
fink list --installed
fink list -i
for short. This command outputs a human-readable list of packages that are considered to be installed on your system, including packages you’ve installed yourself, their dependencies, and virtual packages. The following command trims virtual packages off this list:
fink list -i | grep -v " p " | grep -v "\["
We may use the -t flag and the cut command to get a nice list of installed packages that doesn’t include virtual packages:
fink list -it | grep -v " p " | grep -v "\[" \ | cut -f2
In order to save this list to a file (e.g. instpkgs.txt) for further reference, use the command
fink list -it | grep -v " p " | grep -v "\[" \ | cut -f2 > instpkgs.txt
Saving configuration files
If you’re planning on removing your entire /sw folder then you should consider saving your configuration files. Fink’s configuration file is /sw/etc/fink.conf. Packages may also place configuration files under /sw, usually under but not limited to /sw/etc (on my system there are package configuration files under /sw/etc, sw/lib, and /sw/var).
The following command lists the configuration files of every package in instpkgs.txt as created in the previous section, saving the list in conffiles.txt:
cat instpkgs.txt | xargs fink dumpinfo -fconffiles \ | sed "s/^conffiles: //;s/^[ \t]*//" | tr " " "\n" \ | sort | uniq > conffiles.txt
Browse through this list and backup the configuration files you want to keep (don’t forget to write their original location down). Some of them don’t need to be backed up (e.g. /sw/etc/passwd-fink). If you want to know which package installed a certain configuration file (e.g. /sw/etc/pkgconffile.conf), run the following command:
dpkg -S /sw/etc/pkgconffile.conf
Please note that if you’re changing from a 32-bit Fink installation to a 64-bit Fink installation then it is possible that old configuration files won’t work on the new installation. As this is particular to each package there’s no general solution for it. If you’re changing from one OS X version to another, or from 32-bit Fink to 64-bit Fink, it is also possible that your old fink.conf won’t work on the new installation, especially the Distribution and SelfUpdateTrees entries. You’re better off using your old fink.conf as a guide when answering the questions asked by Fink during installation/bootstrapping or when running the
If you’ve created local packages under /sw/fink/dists/local, don’t forget to backup them up. You probably won’t need to keep the binaries so it should be safe to keep only the package descriptions and patches; those are usually under /sw/fink/dists/local/main/finkinfo.
Every file installed by Fink is under the /sw folder, so running the following command will wipe out your Fink installation:
sudo rm -rf /sw
Well, not exactly. Fink also places convenient shortcuts under /Applications/Fink for packages that are application bundles (those special folders whose name end with .app). If you use the fink remove command to remove a package that provides an application bundle then the equivalent shortcut is removed. However, if you simply remove the /sw folder, the shortcuts won’t get removed, so you might want to do that yourself.
Depending on how you’ve installed Fink or if you’ve run the pathsetup shell script, you might have a line resembling
test -r /sw/bin/init.sh && . /sw/bin/init.sh
in your $HOME/.profile shell initialisation script (or the equivalent command/file for csh, tcsh). The line above can be left there if you’re planning on reinstalling Fink. It is also harmless to leave if there if Fink is not installed.
Follow the installation instructions on Fink’s Web site. Recall that at the moment there is no binary installer for OS X 10.6, Snow Leopard, so you need to use the source installation from version 0.29.9 or higher.
Reinstalling the packages
You may use the instpkgs.txt created in the Listing installed packages section. The following shell script reads that file, line by line, and runs Fink’s installation command on each package:
cat instpkgs.txt | while read pkg do fink install $pkg done
Note that if you’re using sudo then this shell script will ask your password every now and then. You might want to save the whole script to a file (e.g. reinstall.sh) and run it with sudo (e.g. sudo ./reinstall.sh).
As some of the packages in instpkgs.txt are dependencies of other packages it is quite probable that you’ll get some No packages to install warnings which may safely be ignored — they mean that the command above is trying to install a package that’s already been installed. If a package is not available on your new installation, you’ll get Failed: no package found for specification errors.
You may also want to restore the configuration files you’ve saved. Remember that if you’ve changed from one platform to another there might be differences in the configuration files. Whenever possible, use the application itself to enter the configuration, using the old (backed up) configuration file as a guide.
If you’ve backed up your local packages, restore them to /sw/fink/dists/local and run
so that Fink becomes (once again) aware of them.