# Irrationality in port build system



## freemason (Oct 12, 2012)

I want to *build port as user but install as root* (and you all know, that *we can't install port as user*).
Then, why do we have build environment-variable option for this called INSTALL_AS_USER but not BUILD_AS_USER? Anyway, we can't install as user!

Another trouble is that when you build (as user) port which has dependencies, they are tried to be installed as user at build time (which is absurd), and don't do switch to root credentials to install, so it fails and you must go to their directories and do 
`#  make install`
recursively for each dependency at installation of which you are stuck in building main port.
That is very annoying and irrational!

Will it be fixed some day? Is there any hope?


----------



## freemason (Oct 13, 2012)

Why I am posting this:

All goes well if INSTALL_AS_USER is not set, but when I do`$ make config`on arbitrary port, it shows 

```
===>  Switching to root credentials to create /home/ports/CONFIG/firefox
Password:
```
despite the fact that /home/ports and all subdirs are fully owned and writable by user!

Otherwise, if INSTALL_AS_USER is set to something (x, YES, etc.) then I can configure ports as user but there will be no switching to root credentials during their installation and problems which I describe in the first post arise.

Thanks.


----------



## freemason (Oct 17, 2012)

Seems solved...But I politely ask some willing and helpful guy to test it if he can!

To fix this you need to replace INSTALL_AS_USER with (for example) BUILD_AS_USER in the $PORTSDIR/Mk/bsd.port.mk file as following:
line 6103:
	
	



```
.if ${UID} != 0 && !defined(BUILD_AS_USER)
```
line 6140:
	
	



```
if [ ${UID} != 0 -a "${BUILD_AS_USER}" != "" ]; then \
```
line 6241:
	
	



```
if [ ${UID} != 0 -a "${BUILD_AS_USER}" != "" ]; then \
```
, then add 
	
	



```
BUILD_AS_USER=
```
 to /etc/make.conf.

And this seems giving you ability to fully build ports as user (without switching to root credentials for writing configs!) and install them as root.

Thanks go to *port-build system maintainers/developers* if and only if they fix this of course!


----------



## UNIXgod (Oct 17, 2012)

For some reason I though you where trying to install as a user into a user dir; not for root.

What is the goal if your just removing root privilages to ports?


----------



## freemason (Oct 17, 2012)

Oh, my third eye...

The goal was to enable full building of ports as user (in user-customized dirs), still leaving installation running as root (I don't know what is the point in installing as user, but why compile as root?) to default system dirs.
And then make package and clean as user.

Whole point was - it wasn't possible to write configs in user-writable dirs when building ports as user.


----------



## UNIXgod (Oct 17, 2012)

How about a build server... You could even use a jail for that.


----------



## freemason (Oct 18, 2012)

Build server is probably a good idea.

But I also think that scripts must do their work properly.


----------

