Fink & Apple's X11

      / How To...? /

This section is made mostly of answers given by the Fink developers to common problems at the fink-users mailing list.



Contents

What's installed?
Checking your PATH
Starting XFree86
Checking what you installed with fink
Checking one package
When you install a package, save a log
CVS by default
Fink verbose output
Launch X app. from your Terminal.app
Launch Aqua app from xterm or terminal
ls color
Installing from source (How long should it take?)
To move the /sw tree to a different location
Proxy and airport
curl: Server does not grok PORT
Cut and Paste from X11 to Aqua
Removing fink, XFree86 + XDarwin.app
Checking libraries
How to purge the /sw/src/ directory
If you are really short of espace in your HD
Lonely 'little white square'
To search for symbols
Broken sudoers
'New Users' and the 'passwd' package
dselect wont start
Useful Commands
How to pause a Fink installation
To copy the /sw directory to a network computer
'fink list' truncates package names
Curl fails to download a package
To pipe the whole X session to a log file
error: "dyld: xinit can't open library"





What's installed?

What OS version? ('sw_vers')
What version of make? ('make -v')
What Fink version? ('fink -V')
What version of the dev tools? ('gcc -v')





Checking your PATH

If you wrote "source /sw/bin/init.csh" somewhere in your .login or .cshrc file, that should have added both /sw/bin and /sw/sbin to your path automatically, as well as setting environment variables that various Fink programs need.





Starting XFree86

There are basically two ways to start XFree86 under Mac OS X:

1-XDarwin.app
Double-clicking the XDarwin.app in your Applications folder.

Then, a dialog will appear where you can choose between full screen and rootless mode. In XDarwin Preferences, you can set XDarwin to always use the mode of your choice and disable the startup dialog.

2-Terminal.app
From the terminal.app you can type either:

startx -- -fullscreen
or
startx -- -rootless





Checking what you installed with fink

fink list --help

to get all the list options

fink list   -will list all packages

The first column always displays:

     not installed
 i   latest version is installed
(i)  installed, but a new version is available

fink list -i

-will list all installed packages

You can also run:

fink list | grep -e '^ i'

Or you can check by archive section, for example:

fink list -i --section=graphics

will give you a list of all graphics packages installed.

List of Packages by archive section:
base
Core packages
crypto
Cryptographic software (subject to national regulations)
database
SQL database software
devel
Software for software development
editors
Text editors
games
Games and other fun stuff
gnome
The GNOME desktop environment (version 1.4)
graphics
Graphics applications and libraries
kde
K Desktop Environment (version 3.0)
languages
Programming languages (compilers, interpreters)
libs
General purpose libraries
libs/perlmods
Perl libraries
net
Network-related applications and libraries
sci
Scientific applications
shells
Shells a.k.a. command line interpreters
sound
Audio software
text
Text-processing software
utils
Utilities that don't fit elsewhere
web
Web-related software
x11
General X11 packages - toolkits and utilities
x11-system
X Window System core packages
x11-wm
Window managers for the X Window System





Checking one package

To check about only one package, run:

fink list 'packagename'

To get a description on that package, you can run:

fink info 'packagename'
or
fink describe 'packagename'





When you install a package, save a log

When you install a package save a log of the build.
You can do that like this:

fink install packagename | tee ~/Desktop/packagename.log

Afterwards, if things are going wrong, you can look through the log and see what happened.





CVS by default

If you have an appropriate version of the Developers Tools (December 2002 for OS 10.2) installed, that will give you cvs by default.

Even though fink will let you install a CVS package from the binary distribution, you won't be able to run 'fink selfupdate' without the Dev Tools.





Fink verbose output

The nice thing about Fink is that for example, you can just type:

% fink install gtk+

and it will figure out what dependencies are involved, ask if you would like to install them too, then after you say 'Yes' it'll download everything. For each package, it will unpack it, apply any needed patches, auto-configure, compile, test, and install into a .deb file which gets installed for you by dpkg.

If you go into /sw/etc/fink.conf and turn on

verbose output,

you can watch each of these steps and get a clear idea of what Fink is doing, so that you understand it better and can do it yourself if necessary.

The plus side is that you learn a lot and can keep up to date with all of this software. The down side is that, compared to binary installs, it's a slow process -- but it can be much more reliable in many cases.





Launch X app. from your Terminal.app

To enable entering XWindows commands in the Terminal.app "when XWindows is running" write at the beginning of your ~/.cshrc file:

setenv DISPLAY :0.0

So, if you type 'gimp' in Terminal.app the corresponding X11 binary will open in XWindows.

You could set the XDarwin.app to start up when you login in the Login Panel of the System Preferences and then add to your ~/.cshrc file:

if (! $?DISPLAY) then
setenv DISPLAY :0.0
endif


This will set DISPLAY automatically in every shell. It doesn't override the current value when DISPLAY is already set, though. his way you can still run X11 applications remotely or through ssh with X11 tunneling.





Launch Aqua app from an xterm or terminal.app

Use "open", as in:

[1]
% open SomeDocument.rtf
% open ~/Sites/index.html

[2]
% open /Applications/TextEdit.app
% open /Applications/Internet\ Explorer.app

[3]
% open -a /Applications/Internet\ Explorer.app ~/Sites/index.html
% open -a /Applications/TextEdit.app index.html

[1]
opens the document, using the application handler assigned to
that document type by the system.

[2]
opens an application.

[3]
opens a document, but forcing it to be opened in the application given with the -a switch instead of whatever the default handler might be.





ls color

Install the fileutils package. Then you can do:

ls --color=auto

to get colored ls output.

You can write in your ~/.cshrc file some aliases like this:

alias l     'ls -Ahl --color=always'

alias lh    'ls -Al --color=always'

alias ls    'ls -A --color=always'





Installing from source: (How long should it take?)

Question
"I ran the fink install like suggested, but I've been waiting for a freaking long time for it to compile (like 5+ hours). Should it take this long?"

Answer
It's normal. Depending on what kind of computer you're running (an old iMac, or the latest G4, etc) and what you're installing, this can be done in a matter of minutes or it can take well over a day. Depends on the number & the kinds of packages: generally, mozilla, nautilus, evolution, kde and gnome all take a long time, while others are very fast.

Installing binaries is faster, but if you install from source you have the advantage to usually get newer software, and if you can leave it working overnight, then it shouldn't bother you so much.





To move the /sw tree to a different location

cd /
tar -zcvf /Volumes/b2/fink.tgz sw
cd /Volumes/foo
tar -zxvf fink.tgz

then symlink /Volumes/foo/sw to /sw:

ln -s /Volumes/foo/sw /sw

You can also have the "sw" directory moved to another partition, and share it between two systems, via symlinks works fine.

Make sure you do the "move" correct, that is, either with "sudo mv" (you must be root to move this, hence the sudo), or with dito - don't use "cp -r" as it will "flatten" symlinks.





Proxy and airport

Set the proxies to none and specify passive ftp in the fink.conf file.





curl: Server does not grok PORT

Problem:
curl: (30) Server does not grok PORT, try without it!
### curl failed, exit code 30
Downloading the file "bzip2-1.0.2.tar.gz" failed.

Answer:
This error frequently shows up when you don't have passive FTP enabled. Rerun 'fink configure' and enable passive FTP (answer y when prompted) or edit /sw/etc/fink.conf and add this line:

ProxyPassiveFTP: true





Cut and Paste from X11 to Aqua

Copy and Paste generally works between the Aqua and X11 environments.

To transfer text from Aqua to X11:

use Cmd-C in Aqua

then bring the destination window to the front

and use the middle mouse button to paste.

To transfer text from X11 to Aqua:

simply select the text with the mouse in X11

then use Cmd-V in Aqua to paste it.

If you're running XDarwin and blackbox in rootless mode:

just selecting text in an x client (certainly in an xterm or eterm) puts the text in the Cut buffer. Then you can paste the text into another X client by using:

command-click

and you can paste the text into an aqua window by using:

command-v

(or the paste command in the aqua edit menu).

This also works if you cut in fullscreen mode

then switch to the aqua desktop, and then paste into BBEdit or similar.

And it works the other way around:

you can cut in aqua

switch to XDarwin

and paste in an x client using command-click.

Install the program autocutsel; it automatically synchronizes the two main cut buffers. To run it, add the following line to your .xinitrc:

autocutsel &

Make sure it's before the line that exec's the window manager and never returns! Don't just add it at the end, it won't be executed.





Removing Fink, XFree86 + XDarwin.app

First, if you have installed the package passwd or g77 then run:

sudo dpkg --force-depends --remove passwd g77

Then do the following:

Almost all files installed by Fink are in /sw (or wherever you chose to install it). Thus in order to get rid of Fink, you enter this command:

sudo rm -rf /sw

And all your installation will be gone. Then you can reinstall, by hand or using Fink again, if you wish.

If you also want to remove XFree86, additionally enter this:

sudo rm -rf /usr/X11R6 /etc/X11 /Applications/XDarwin.app

This will delete your XFree86 installation as well as the XDarwin application.

You will want to remove the line

source /sw/bin/init.csh

that you added to your .cshrc file.

To do this, type "pico ~/.cshrc". Navigate to the "source /sw/bin/init.csh" line and type control-K to remove it.

Then type control-O, return, control-X to exit.

Also check your dotfiles, just open them up & edit accordingly.





Checking libraries

% dpkg -L gdk-pixbuf-shlibs | grep xlib
/sw/lib/libgdk_pixbuf_xlib.2.0.0.dylib
/sw/lib/libgdk_pixbuf_xlib.2.dylib





How to purge the /sw/src/ directory

You can remove stuff from /sw/src, especially any subdirectories of it. The easiest way to do this is to use emacs in dired mode. You can use OSX's /usr/bin/emacs:

sudo /usr/bin/emacs /sw/src

It goes into dired mode automatically. You go down the list of files and directories, you flag the files you want to get rid of by hitting "d" and the directories hitting "m". After the selection, you hit "x" to delete the files and "!" then "rm -rf" to delete the directories.





If you are really short of espace in your HD


You could delete everything from /sw/src.

If you really need to wipe *all* source files, you can just do:

sudo rm -rf /sw/src/*

But, you should keep in mind that if you do that, you will have to redownload all sources if you ever need to rebuild the package in question.

Also, the first time you run fink selfupdate-cvs

a fink.old directory

is created just in case something goes wrong during the update.

You can safely delete the whole 'fink.old' directory

once you've verified that fink works after the selfupdate-cvs.

Also check:

/sw/fink/dists/unstable/main/binary-darwin-powerpc/base

you might have:

apt-dev_0.5.4-7_darwin-powerpc.deb
apt-dev_0.5.4-8_darwin-powerpc.deb
................
fink_0.11.1-10_darwin-powerpc.deb
fink_0.11.1-1_darwin-powerpc.deb
fink_0.11.2-1_darwin-powerpc.deb
................
ncurses_5.2-8_darwin-powerpc.deb
ncurses_5.2-9_darwin-powerpc.deb


You should be safe to remove the older of the duplicates. However, fink isn't doing this automatically, for various reasons, one being that you might want to go back to an older version of a given package.

If you only use apt-get to obtain your .deb files (i.e. the binary distro) and want to delete the old deb files via Fink:

sudo apt-get autoclean

With fink package manager version 0.10.0, we have the command:

fink cleanup

to do the cleaning job. It cleans up the old .deb files.





Lonely 'little white square'

Question:
Does anyone else have a little white square in the bottom right of their screen when they have XDarwin at the forefront?

Answer:
It is autocutsel that produces the little square. I have no idea why. But it disappeares if you kill autocutsel, and it will came back as soon as you restart it.





To search for symbols

To search for symbols use nm :

nm /sw/lib/libgdk-1.2.0.dylib | grep Grab
      U _XGrabKeyboard
      U _XGrabPointer
      U _XGrabServer
      U _XGrabServer

"U" from nm, means "undefined".





Broken sudoers

Problem:
localhost:~] momo% sudo apt-get update
sudo: /etc/sudoers is mode 0775, should be 0440
[localhost:~] momo% can not write to queue directory
/var/spool/clientmqueue/ (RunAsGid=25, required=80): Permission denied


Answer:
Reboot holding down cmd-S.

When you get to a prompt, do :

fsck -y
mount -uw /
chmod 0440 /etc/sudoers
exit






'New Users' and the 'passwd' package

"If you install a package which has a dependency on the 'passwd' package, then you will be installing 'passwd' which is a sort of general purpose package that sets up a couple of extra users on your system in the event that you someday decide to install packages that require these extra users. This installation is actually a security "feature". All unix processes have to run as one user or another. System processes generally run as the user root, but for a process such as MySQL to run as root would be a big security breach, so it creates a user with no privledges to run under. This user also becomes the owner of any files that the process needs to have write access to, adding another layer of security. In theory you could have a single generic user account that all of these processes run under (some Linux systems use 'nobody') but this could get messy so it customary to have different accounts such as mail, news, apache, mysql, etc."

When you install 'passwd' this will come up:

Existing entries with these names or numbers will be overwritten or otherwise affected by this. On the other hand, some Fink packages will not work unless these entries are in the NetInfo database. You can make adjustments to the files /sw/etc/passwd-fink and /sw/etc/group-fink now (from another window), then say yes here. Or you can say no here and add the users and groups manually (e.g. on your central NetInfo server). If you don't know what all of this is about, just say yes. Do you want to continue? [Y/n]

So then, I you accept the installation of the new users, existing entries with these names or numbers will be overwritten or otherwise affected by this. But, it also says you can make adjustments before installation in /sw/etc/passwd-fink or in the /sw/etc/group-fink. You can edit those files to suit your needs. If you decide not to install the new users, and the need arise later for one of them, you can install it manually.





dselect wont start

Question:
"After upgrading fink with "sudo fink selfupdate", dselect wont start with the message":

% dselect
Error opening terminal: vt100.

Answer:
I read that someone with the same problem was advised to try solve it by rebuilding ncurses.





Useful Commands

To clean your cvs:

cd /sw/fink and then run:

sudo find . -name 'CVS' -type d -exec rm -rf {} \;

When you run now 'fink selfupdate-cvs' it will prompt you for your settings again.


To find package dependencies:

find /sw/fink/dists/ -name \*.info | xargs grep Depends | grep packagename | more


If you do decide to wipe Fink and reinstall it:

The following command will create a list of all your installed packages in a file named "installed" in your home directory.

dpkg --get-selections |egrep "\binstall" | awk '{print $1}' | xargs > ~/installed


Then, after you reinstalled Fink, you can just do:

fink install < ~/installed


To find out which packages depend on 'daemonic' run:

grep Depends -r /sw/fink/dists/ | grep daemonic


or more to the point:

fink list -i |awk '{print $2}' |grep -v about |xargs dpkg -s |grep daemonic


Gives you the X11 version without running the X server:
(Thanks to Martin Costabel)

grep "Version.*XFree86" /usr/X11R6/man/man7/X.7 | cut -d " " -f 5


Using the sh -c command to get system info:
(check man sh)

sh -c ". /sw/bin/init.sh; /usr/bin/env"


A utility for displaying information about an X server:
(check man xdpyinfo)

% xdpyinfo





How to pause a Fink installation

When you install a large package it can take up to several hours to compile it. If you want to do some other work in the meantime, the compilation in the background sometimes slows down the work which can be annoying. Is it possible to pause a compilation for a while and then after the other work is done to resume it. If you started the installation manually in Terminal.app, you can just press:

Ctrl+Z

while you're in the Terminal.app window that "contains" the compilation process. The process will be stopped and put to sleep in the background. You can then go and do the other work, and when you're ready to continue just return to the Terminal.app window where you stopped the process and type:

'fg' (without quotes). fg = foreground

If you are not sure whether you have stopped jobs in a given Terminal.app window, just type:

'jobs'

and you will get a list of jobs that you have put in the background. If there are several of them they will be marked with a number. Type for instance:

'fg 2' to continue with job 2.

You could also say:

'bg 2' to continue job 2 in the background.

You are then free to type other commands on the shell prompt while the job runs in the background. Note that the background job will still send all output to the screen as if it were in the foreground. This can interfere with the output of another command that you have started in the meantime, or even with the command that you're typing right now. The interference is actually harmless - it will not affect how another command is executed, nor will the output mix with anything that you type. If you're not sure about this, just fool around with harmless commands such as "find" that generate lots of output.

If you find yourself in a situation where a "runaway" background job is wildly polluting your window with output and it seems you're helpless, just try the following:

- blindly type 'fg x' (where x is the number of the runaway job)

- now you have the job in the foreground and you can just type:

Ctrl+Z to put it to sleep, or Ctrl+C to abort it.

If you'd like to start a job in the background from the first moment, just type your command as normal and then append an & (ampersand) to the very end of the command.

If you started the installation with FinkCommander:

Just find the pid of the fink process by:

'ps aux | grep fink' or something

then 'kill -STOP thePid'

which is similar to Ctrl+Z.

And when you want to continue it:

'kill -CONT thePid'

which is similar to 'fg'.





To copy the /sw directory to a network computer

If you want to copy the /sw directory to a networked computer from the command line, you could do it with rsync over ssh:

sudo rsync -az -e ssh /sw othermachine:/

There are some caveats:
Some packages need to run postinstall scripts. Some are installing stuff outside /sw (the xfree packages, of course; also g77; and anything that uses daemonic, most notably openssh). And if your /sw is not /sw but for example a symlink, the real path may be hardcoded somewhere if you are not careful.

So you may expect some more or less subtle breakage. Nothing that can't be repaired, usually by a "fink reinstall" or else "fink rebuild", but be warned.





'fink list' truncates package names

If when you run "fink list" it truncates package names you can use fink list --width option.

You can run:

fink list --width 120 xfree

or

fink list -w120 xfree





curl fails to download a package

Problem:
curl: (28) Connection aborted
### execution of curl failed, exit code 28

Downloading the file "blabla-0.6.1.tar.gz" failed

If curl can't get the file, the problem is almost always with the resource being unavailable (dead or changed link, server down, etc)

Try first:
1) See what URL curl is using to get the file.
2) Use a web browser (or ftp client) at that URL to download the file.
3) Move ('sudo mv') the downloaded file to /sw/src.
4) 'fink install' the package.

If still fails:
Do a 'google' search to find the file elsewhere (exactly the same name), then download it with your browser and put it in your source directory, either /sw/src or the alternative directory you specified during fink's configure phase:

1) Google search for file.
2) Download file with your browser.
3) Move ('sudo mv') the downloaded file to /sw/src.
4) 'fink install' the package.

Or:
cd /sw/src
sudo wget http://alternate.source.for/package.tgz
sudo fink install package



If you would like to add an extra source or specify another source for the download of a fink package, the .info file for the package has a 'Source:' line in it.

For example, in the qt package case:

Source: ftp://ftp.trolltech.com/qt/source/qt-x11-free-%v.tar.bz2

You can modify that line to make it work as you want.





To pipe the whole X session to a log file

To pipe the whole X session to a log file for later autopsies, do a:

startx |& tee ~/startx.log

then log in & immediately try to get back out.

If you can get to that log file (remotely, or from another machine, or even from an xterm while X is running) you might be able to see something that explains where the problem is coming from.





error: "dyld: xinit can't open library"

If you get one of the following errors when you try to start XFree86:

dyld: xinit can't open library: /usr/X11R6/lib/libXmuu.1.dylib
or
dyld: xinit can't open library: /usr/X11R6/lib/libXext.6.dylib

you are missing a file that is supposed to be installed by the

xfree86-rootless-(threaded)-shlibs package

You should reinstall it.

From source:

fink reinstall xfree86-rootless-shlibs
or
fink reinstall xfree86-rootless-threaded-shlibs
(if you are using the threaded XFree86 packages)

From binaries:

sudo apt-get install --reinstall xfree86-rootless-shlibs








astronaut / Make Contact /
drop me a line at:       sao1@mac.com

MacOS X,    Fink,    X11,    Unix    ...and other related things