Subject: installing xmkmf packages as non-root
To: None <tech-pkg@netbsd.org>
From: Georg Schwarz <georg.schwarz@freenet.de>
List: tech-pkg
Date: 12/04/2005 20:37:43
I've just bootstrapped a clean copy on pkgsrc on Darwin using
--ignore-user-check.
My mk.conf thus has UNPRIVILEGED=yes.
Next I built x11/xearth and tried to install it. I get:

===> Installing for xearth-1.1nb2
install -c -o root -g wheel   xearth /Users/schwarz/pkg/bin/xearth
install: /Users/schwarz/pkg/bin/xearth: chown/chgrp: Operation not
permitted
*** Error code 71

Stop.

I appears that inspite of UNPRIVILEGED=yes pkgsrc tries to install
things as root.
The reason seems to be
 INSTALLFLAGS = -c -o root -g wheel
in makefile creatred by xmkmf.
It looks like we need a mechanism to have  INSTALLFLAGS set to -c only.
I suspect that this is not a Darwin-specific issue. 

For Darwin at least, /usr/X11R6/lib/X11/config/darwin.cf has

#define InstallFlags -c -o root -g wheel

I copied that file to ${LOCALBASE}/lib/X11/config and editied that copy
to hold only

#define InstallFlags -c

This makes things work.
The best way I think is to have the #define InstallFlags enclosed by
#ifndef InstallFlags #endif, and define InstallFlags elsewhere if needed
(any ideas where?).
This example also shows that at least on some platforms the system
specific xmkmf .cf file needs to be edited. Luckily pkgtools/xpkgwedge
provides a nice mechanism for such alternative files that take priority.
With IRIX basically the same issue exists (so far this is worked around
by patching the original files during bootstrap, which is not really
nice).
Do you think it makes sense to have such copying and manipulation
performed (for systems that need it) in the framework of
pkgtools/xpkgwedge?
The necessary code could be added to the do-install section there?

-- 
Georg Schwarz    http://home.pages.de/~schwarz/
 georg.schwarz@freenet.de  +49 178 8545053