Subject: CheckSymlink to adjust symlinks breaks my x11-links
To: None <tech-pkg@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 11/26/2002 22:34:35
I was having a problem where some x11 packages using buildlink2 wouldn't
configure because missing -lX11.

After learning more about the buildlink2, I saw that the config.log
message was only partially applicable, but I saw the .buildlink/.wrapper
log showed that the directory with my libX11 was included.

So then I looked at it. It was a symlink to ../../../ three-levels above
-- which didn't exist!

Then I looked at the share/x11-links and all the links also pointed to
files that didn't exist.

For example, on this broken system:

 lrwxrwxrwx    1 root     root           27 Nov 26 21:59
 /usr/share/x11-links/lib/libX11.a -> ../../../X11R6/lib/libX11.a

(Note that my LOCALBASE is /usr.)

But on a good system:

 lrwxr-xr-x  1 root  wheel  23 May  8  2002
 /usr/pkg/share/x11-links/lib/libX11.a -> /usr/X11R6/lib/libX11.a

So I tried to reinstall pkgtools/x11-links again. I noticed:

  Full pathname symlink ... is target of ... - adjusting to ...

For example:
 ===> Registering installation for x11-links-0.8
 ...
 Full pathname symlink `/usr/X11R6/lib/libX11.a' is target of
 `/usr/share/x11-links/lib/libX11.a' - adjusting to
 `../../../X11R6/lib/libX11.a'

This was done via CheckSymlink() in pkg_install (pkg_install/create/pl.c).

So during an install (FORCE_PKG_REGISTER) of x11-links I aborted it (via
ctrl-c) right after it created the symlinks but before the full pathname
symlink was changed. So it was like:

 lrwxrwxrwx    1 root     root           27 Nov 26 21:59
 /usr/share/x11-links/lib/libX11.a -> ../../../X11R6/lib/libX11.a

Then my x11 building (for gtk and imlib) worked. The .buildlink/lib/
directory was correct with full pathnames instead of ../../../ to
non-existent files.

I see how this pkg_install code makes this change, but I am unclear why it
is needed. Can anyone explain the purpose of this CheckSymlink()?

At least by forcing my x11-links shadow directory to have full-pathnames
(which causes my buildlinks to be correct), I can continue to
successfully build x11 packages.

Any suggestions on how to properly fix this so it will work correctly when
installing it the first time?

Should I patch pkg_install/create/pl.c so if cwd is /usr then ignore?

   Jeremy C. Reed
   http://bsd.reedmedia.net/