You are not logged in.
I have some "library" files I source in many different bash scripts.
I want to make a package (for my personal use), and my question is, if the correct location for these files is
/usr/lib/mybashlib/?
(PS: How does one format 'inline monospaced text' in BBCode? [c]{text}[/c] did not work for me.)
Offline
Since it's "your" lib, yeah why not, since they are technically not libs but other bash/data files potentially a subdir in /usr/share might be more applicable but as long as you don't have a conflict with other packages it probably doesn't strictly matter
PS: You can't do inline tags.
Offline
Would you, personally, put them under /usr/share/mybashlib/ ?
Thank you, btw.
And another (stupid) question: How are naming conflicts of packages resolved? Does the first one, that claims a name win? And how/where can someone check if a name is already in use? (Is https://archlinux.org/packages/ the definite authority, even for stuff not yet available as an Arch package?)
Last edited by anick (2022-07-28 18:19:28)
Offline
If it is for your personal use, I would put it in ~/.local/bin and ensure that is in your PATH.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
I now think, that I shouldn't have said, that it's only for "personal use".
I really want to know the "correct location" these files belong in (like if it would be a public package, intended for many to install).
Last edited by anick (2022-07-28 18:22:47)
Offline
mkinitcpio has its sources in /usr/lib/initcpio/ makepkg has its stuff in /usr/share/makepkg/ bash has /usr/share/bash-completion/ zsh has /usr/share/zsh/functions …
There's no "correct" but for the most part it seems /usr/share is preferred over /usr/lib but it also really doesn't matter - what matters is that you have a collision-free path, so /usr/share/myscript/foo.sh is bad - /usr/lib/anicksbashtricks/bar.sh is better.
Offline
How are naming conflicts of packages resolved?
They aren't really. But that's why you use something like /usr/share/${pkgname}. As long as no other package has the same name as yours, then no other package should use that path. And package name conflicts are avoided pretty much by first come first serve as a duplicate name really can't be added to the repo or aur (and an aur package that duplicated a repo name should be quickly removed / deleted). I suspect there are cases where package maintainers were asked to rename their package if they had a small project that took the same name as a well-known and established project which was later going to be added to the repos. And any good programmer should make a genuine effort to not name their project the same thing as a different existing project.
But aside from paths including pkgname, there are file conflicts even between some repo packages. This is mostly avoided by giving files like actual shared libraries appropriate names. On occasion some newbie programmer will think something as minimal as "libm.so" was suitable for their niche project - but this will not last long: you've got to be a glibc-level badass to have the stones to claim a name like that.
Last edited by Trilby (2022-07-28 19:18:45)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
A subdirectory under /usr/share or ~/.local/share (or whatever $XDG_DATA_HOME points to) is usually a good place for miscellaneous files related to a specific program or use.
You can also use relative paths if you want to keep everything together in a single directory without hard-coding a full path to the files that you want to source.
Example directory structure
example/
├── lib
│ ├── bar.sh
│ └── foo.sh
└── scripts
└── test.shtest.sh
#!/usr/bin/env bash
set -euo pipefail
this_script=$(readlink -f "${BASH_SOURCE[0]}")
root_dir=${this_script%/*/*}
source "$root_dir"/lib/{foo,bar}.shThen you can put the example directory wherever you want and just add the scripts subdirectory to PATH.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
About this "libm.so" thing: Is it allowed that different packages have files under the same path? I mean something like that: packageA has /usr/lib/x/a and packageB has /usr/lib/x/b ?
Offline
About this "libm.so" thing: Is it allowed that different packages have files under the same path? I mean something like that: packageA has /usr/lib/x/a and packageB has /usr/lib/x/b ?
If the packages are related in some non-trivial way, i.e. they're both part of some project "x", then yes. If they have nothing to do with each other then they shouldn't be in the same subdirectory. Name collisions occur and there may be some cases in which 2 unrelated packages could co-exist that way, but it's confusing and bad practice.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Not sure how non-trivial that is but otherwise there would be the execption of modules/plugins, eg.
pacman -Qo /usr/lib/securitywhich also has real™ libraries inside and the projects dropping them there are not related to each other - other than providing plugins for "stuff".
Maybe be more specific about your intentions?
Offline
> Maybe be more specific about your intentions?
Hmm. My intentions? I don't know, TBH. I put some general stuff I always repeated when writing bash scripts into some files and I'm genuinely wondering where to put them, because neither the FHS, nor the people over at unix.stackexchange.com (https://unix.stackexchange.com/question … es-sourced) seem to have an answer for that. That's why and that's all.
But now I know, thanks to you. /usr/share/<aname>/ seems to be the answer you're suggesting.
I should have asked this question here first, but I wanted a more distro-agnostic answer (- which did not work out, because some stackexchange mod tagged my question with 'arch-linux' (and altered its wording, too). But the question I asked was "Where to put files intended to be 'sourced' by bash scripts?").
Last edited by anick (2022-07-28 20:48:38)
Offline