# Where should manually built programs live?



## zirias@ (Dec 4, 2014)

Coming from Debian, I'm used to having /usr/local completely to myself, so if I ever build and install something manually (avoiding the hassle of creating a package, just to give something a try), I put it there .. usually applying some simple symlink-based package management nevertheless, but that's irrelevant.

Now on FreeBSD, this subtree "belongs" to the Ports. In fact, hier(7) doesn't say that, but claims it's _also used [..] for [..] ports_. So I conclude it's suggested to use /usr/local for manually built programs, too? Is this considered safe? Are there any alternatives people apply?


----------



## SirDice (Dec 4, 2014)

Ideally you'd create a port for your own application. That way there wouldn't be any risk. 

Porter's Handbook


----------



## zirias@ (Dec 4, 2014)

Zirias said:


> (avoiding the hassle of creating a package, just to give something a try)





SirDice said:


> Ideally you'd create a port for your own application.


Uhm ... yes. In fact, that's what I did. I consider packaging/porting roughly the same in this context -- so what about quick testing of some software?


----------



## Beeblebrox (Dec 4, 2014)

I used a linuxism to solve that problem. I created the folder /usr/local/opt/ and installed the software compiled from non-port sources with `# make install DESTDIR=`.

It's not that far of a leap though, when you consider that there are several ports which install into their own proprietary folders under /usr/local (java, llvm just to name two). This method also helps to keep track of non-port installs and if you ever decide you want a complete clean start all you have to do is delete whatever is below opt/*. I asked this issue on the mailing list once, and several developers answered that they themselves usually did not bother with port creation most of the time either.

You'll also need to add /usr/local/opt/bin and /usr/local/opt/sbin to your environment PATH.


----------



## kpa (Dec 4, 2014)

I use /opt as the PREFIX for my own scripts and other homebrewn software. I didn't want to mix them with /usr/local.


----------



## zirias@ (Dec 4, 2014)

Ok, so I'm not the only one, thanks for the replies! I think I'll prefer the second idea, maybe taking a little inspiration from FHS by using /etc/opt for SYSCONFDIR and /var/opt for LOCALSTATEDIR.


----------



## phoenix (Dec 4, 2014)

Zirias said:


> Ok, so I'm not the only one, thanks for the replies! I think I'll prefer the second idea, maybe taking a little inspiration from FHS by using /etc/opt for SYSCONFDIR and /var/opt for LOCALSTATEDIR.



You'd be better off following the FreeBSD filesystem layout instead of the Linux one.  IOW, /opt/etc.

Keep the sections separated:

/ and /etc are for the base OS (which includes /usr.
/usr/local and /usr/local/etc are for ports/packages managed by the FreeBSD project.
/opt and /opt/etc would be for your locally compiled/installed stuff.
Keeps things nice and symmetrical.    And everything can share /var as needed.


----------



## zirias@ (Dec 4, 2014)

FHS is not just Linux (any more), and I've never seen an /opt/etc in ANY standard, while /opt itself at least exists in FHS and its structure is described there. OTOH, /usr/local/etc is covered by FHS as well as hier(7) while both don't know something like /usr/etc.

I understand where you're coming from, but want to state *nix filesystems aren't "symmetrical" anyway. I guess it comes down to a _best practice_ approach in the end, maybe considering things like backup/restore issues.


----------



## xtaz (Dec 5, 2014)

Anything I build manually I personally put into a /usr/home/ home-directory. Either my own personal one, or one created specifically for whatever it is. I don't think it's a good idea to manually put anything into the normal FreeBSD file hierarchy. That way it can never collide with a buildworld, mergemaster, or any changes to the system that could affect that directory. Also I know where all the files are and can easily delete that directory without having to hunt around.


----------



## zirias@ (Dec 5, 2014)

xtaz said:


> I don't think it's a good idea to manually put anything into the normal FreeBSD file hierarchy.


Exactly my thoughts leading to this question! So, finding /usr/local "occupied" by ports, it seems everyone comes up with slightly different schemes for separating  well, ok ...


----------



## ShelLuser (Dec 5, 2014)

Just for clarification: /opt is a location which finds its origin on Unix platforms. I've used this a lot while I was still running Sun Solaris. Of course; there the situation was totally opposite; the system used /opt for 3third party programs (provided as extensions with the OS itself) which left me with /usr/local.

hier(7) doesn't mention /opt but that's only because it isn't part of the standard FreeBSD hierarchy. Which, in my opinion, makes it an ideal location for this. It's also easier to type than /usr/local


----------



## Beeblebrox (Dec 5, 2014)

ShelLuser said:


> It's also easier to type than /usr/local


My situation is, 
	
	



```
/opt -> /usr/local/opt
```


----------

