4

I am using multiple tools developed by the suckless people which are not configured via a config file but via their source code (in this case C) and then simply installed through make install. So I am maintaining my own repos (need continuous changes) of these programs. The question is where should i put these repos? Directorys like /usr or /usr/local/share are for reference purpose. Is it /opt, /srv or should i just collect them somewhere in my home directory?

xel
  • 263
  • Also: https://unix.stackexchange.com/questions/56394/where-should-i-keep-the-source-files-of-the-compiled-applications – Kusalananda Aug 23 '18 at 14:15
  • Also: https://unix.stackexchange.com/questions/30/where-should-i-put-software-i-compile-myself – Kusalananda Aug 23 '18 at 14:15
  • apparently i didn't make it clear enough that these projects need need constant editing/recompiling. i read these answers before posting and they more or less suggest to use /usr/src. the FHS however says "only for reference purposes." – xel Aug 23 '18 at 14:28
  • you should put it wherever makes you happy or most practical, there is no requirement, keeping thing simple and explicit is usually best. If it wasn't for how you worded your question i would not have commented; may i suggest /usr/local/bendover/ haha – ron Aug 23 '18 at 15:52

2 Answers2

8

If you’re installing the software in /usr/local, I would use /usr/local/src — that’s the local variant of /usr/src, of which the FHS says

Source code may be placed in this subdirectory, only for reference purposes.

with a footnote adding that

Generally, source should not be built within this hierarchy.

It’s your system though so in my opinion /usr/local/src is fair game.

What is the "/usr/local/src" folder meant for? has more on the topic; read this answer in particular.

The general idea is to do your work in your home directory, but ensure that the source code to anything installed in /usr/local be at least copied for reference in /usr/local/src, so that local binaries can be rebuilt without needing a specific user’s home directory.

Stephen Kitt
  • 434,908
  • So you're saying, since it is my system i can ignore the " ... source should not be built within this hierarchy" ? – xel Aug 23 '18 at 14:23
  • Right, /usr/local is really your domain; it’s helpful to use it in a way which matches the equivalents in /usr, but you don’t have to. Where things get a bit complicated if you try to work inside /usr/local/src is that you shouldn’t build software as root, only become root to install it; one way to deal with that is to make /usr/local/src owned by a src group, setgid, and add yourself to that group (Debian used to configure systems in that way). – Stephen Kitt Aug 23 '18 at 14:31
  • Ok thanks I think this solves my problem. I guess the question should've been "what is a proper workflow/setup" – xel Aug 23 '18 at 14:47
  • @protolyse It's up to you. If several people are working against the same repository, it makes most sense for them to have private clones of it in their home directories somewhere. – Kusalananda Aug 23 '18 at 15:41
1

I consulted the Linux manual, specifically the page about filesystem hierarchy (man hier)

/usr/local/src
          Source code for locally installed software.
[...]

/usr/src
          Source files for different parts of the system, included with
          some packages for reference purposes.  Don't work here with
          your own projects, as files below /usr should be read-only
          except when installing software (optional).

/usr/src/linux
          This was the traditional place for the kernel source.  Some
          distributions put here the source for the default kernel they
          ship.  You should probably use another directory when building
          your own kernel.
loa_in_
  • 398
  • 1
  • 9