# opt/ vs /usr/local/opt



## BeOurGuest (Mar 18, 2020)

I recently learned that not all BSD distros have a default /opt/ path as Linux does. Notably FreeBSD. Which was news to me because the original BSD distro I was playing with did.  Reading the documentation it would appear that FreeBSD recommends /usr/local/.   For my purposes, I was using /opt/ *foo* originally. But for distribution purposes, I can see the logic in using /usr/local/opt *foo* in the future.

A few keynotes.  The distribution has its own libraries (you could technically run tar xjf *foo*.tar.bz2 on your desktop and it would work there). It also has the option to self-update. Which means whatever path used it would using chmod 757.

Where do you recommend such distribution would be preferred for FreeBSD?

/opt/ *foo*
/usr/local/opt *foo*


----------



## VladiBG (Mar 18, 2020)

hier
					






					www.freebsd.org


----------



## SirDice (Mar 18, 2020)

If this is only for your own systems then it really doesn't matter and /opt/ would work just fine. 

If this is for a new port you're going to submit then neither works. Although some ports install as /usr/local/${portname} (see sysutils/logstash6 for example) but that's an exception, most ports use /usr/local/bin, /usr/local/lib, etc. 



BeOurGuest said:


> It also has the option to self-update.


For a real port this would be a no-no.


----------



## BeOurGuest (Mar 18, 2020)

VladiBG said:


> hier
> 
> 
> 
> ...


I know. I read the documentation.  But I also outline my details above and why I would inquire.


----------



## BeOurGuest (Mar 18, 2020)

SirDice said:


> If this is only for your own systems then it really doesn't matter and /opt/ would work just fine.
> 
> If this is for a new port you're going to submit then neither works. Although some ports install as /usr/local/${portname} (see sysutils/logstash6 for example).



Can you explain further?  If by port you mean to inquire will this be using a repo via the package manager, no.


----------



## shkhln (Mar 18, 2020)

Can you restate the question without the word "distribution"? Nobody has any idea what you are talking about.


----------



## BeOurGuest (Mar 18, 2020)

shkhln said:


> Can you restate the question without the word "distribution"? Nobody has any idea what you are talking about.


A software release of which the admin will choose to install and will self-update as necessary


----------



## SirDice (Mar 18, 2020)

BeOurGuest said:


> Can you explain further? If by port you mean to inquire will this be using a repo via the package manager, no.


I mean a proper submitted port in /usr/ports (all packages in the repositories are built from this).

FreeBSD Porter's Handbook


----------



## shkhln (Mar 18, 2020)

BeOurGuest said:


> A software release of which the admin will choose to install and will self-update as necessary



That's impressively opaque. Are we talking about packages or self-updatable applications (Steam, Chrome, etc)?


----------



## BeOurGuest (Mar 18, 2020)

SirDice said:


> I mean a proper submitted port in /usr/ports (all packages in the repositories are built from this).


Not using repo and application will be backward compatible between Linux and BSD... ie... Not looking to make a separate release.


----------



## BeOurGuest (Mar 18, 2020)

shkhln said:


> That's impressively opaque. Are we talking about packages or self-updatable applications (Steam, Chrome, etc)?


Self-updatable application.


----------



## usdmatt (Mar 18, 2020)

> Not using repo and application will be backward compatible between Linux and BSD... ie... Not looking to make a separate release.



So it's basically a private self-contained application that you are deploying without using pkg.

It really makes no difference, although I would go for /usr/local/opt to at least maintain some of the fundamental hierarchy of FreeBSD. The "root" directories are for the system, third party stuff should be under /usr/local/.

If you're using /opt on Linux, and it will simplify things to just use the same path, then I don't really see a problem doing that either tbh.


----------



## BeOurGuest (Mar 18, 2020)

usdmatt said:


> So it's basically a private self-contained application that you are deploying without using pkg.


YES. I am sorry if I have not been clear on that. I wrongfully assumed when I said it would not be using the package manager (or repo) that folks would know this is what I meant.


----------



## shkhln (Mar 18, 2020)

Packages are allowed to create arbitrary directories under _/usr/local_ as long as they don't clash with each other, therefore _/usr/local/opt_ is definitely not recommended. Self-updating software usually lives in the user's home directory.


----------



## BeOurGuest (Mar 18, 2020)

shkhln said:


> Packages are allowed to create arbitrary directories under _/usr/local_ as long as they don't clash with each other, therefore _/usr/local/opt_ is definitely not recommended.


The application will support multi-user involvement. But we also do not want it clashing. Exactly what makes /usr/local/opt foo a bad choice?  Originally /opt/ foo was considered since it should be more independent.


----------



## BeOurGuest (Mar 18, 2020)

usdmatt said:


> If you're using /opt on Linux, and it will simplify things to just use the same path, then I don't really see a problem doing that either tbh.


That likely may be the outcome.


----------



## SirDice (Mar 18, 2020)

BeOurGuest said:


> I wrongfully assumed when I said it would not be using the package manager (or repo) that folks would know this is what I meant.


You wrongfully assumed everything is based on packages 

With FreeBSD all third-party software starts with a port. All package repositories for all versions and architectures are built from those ports.


----------



## BeOurGuest (Mar 18, 2020)

SirDice said:


> You wrongfully assumed everything is based on packages
> 
> With FreeBSD all third-party software starts with a port. All package repositories for all versions and architectures are built from those ports.


The distribution will be you download a sh bash file. Run the bash it downloads the tar, it extracts to install path, it creates user shortcuts. DONE.


----------



## shkhln (Mar 18, 2020)

BeOurGuest said:


> The application will support multi-user involvement.



Honestly, that's just weird. The point of multi-user environment is isolation and you are proposing a scheme where the application can be updated* from any user account on the machine. There is no way to do this "properly".

* or, rather, replaced by an arbitrary executable


----------



## BeOurGuest (Mar 18, 2020)

shkhln said:


> Honestly, that's just weird. The point of multi-user environment is isolation and you are proposing a scheme where the application can be updated from any user account on the machine. There is no way to do this "properly".


Thanks for your opinion.


usdmatt said:


> If you're using /opt on Linux, and it will simplify things to just use the same path, then I don't really see a problem doing that either tbh.




I think* usdmatt *was right.  /opt/ foo Which is where we assumed. But wanted to double-check.


----------

