envs: Add LD_LIBRARY_PATH and PKG_CONFIG_PATH

I use ~/local for compiling packages without root. It emulates
/usr/local, basically. So sometimes it might have .pc files etc in
corresponding pkgconfig/ in there or .so files in corresponding lib/.

I do this because I almost always don't have root, because I work on
tildes primarily (tilde.cafe to be specific) so yeah. If a package is
written in go or similar where building would be easy, the basic
workflow is this:

    cd ~/local/src
    git clone git@example.com:user/repo
    cd repo
    make PREFIX="$HOME/local" install

If all goes well the binary would be available at ~/local/bin.

For apt packages there is a higher chance of build failing and most of
them need other dependencies (plus some other historical reasons idk) so
I don't use ~/local/src[1], here's the general workflow:

    cd ~/Downloads
    apt source pkgname
    cd pkgname
    ls -A
    less INSTALL
    ./configure --prefix=~/local
    make PREFIX=~/local
    make install PREFIX=~/local

And most likely it would complain about some package not found in the
configure step, in which case I woukd repeat the steps for that package.

Eventually (if I hadn't given up yet), the binary would be sitting in
~/local/bin nicely.

Sometimes the package needs a lot of dependencies, in that case it may
take up a shit ton of disk space, so I would pack it in a .tar.gz so it
can be saved for future use.

For meson projects:

    cd ~/local/src
    git clone git@example.com:user/repo
    ls -A
    meson setup build
    meson compile -C build
    meson install -C build --destdir ~/local
    rsync ~/local/usr/local/ ~/local/ -avr
    rsync ~/local/usr/ ~/local/ -avr && rm -rf ~/local/usr

I don't use meson often so I'm unaware of a way to easily specify
PREFIX, if any.

So that's my life of getting stuff installed without root. Thanks for
coming to my ted talk. One day I'll probably copy this entire commit msg
and make it into a blog post.
This commit is contained in:
Hedy Li 2021-09-29 11:36:27 +08:00
parent 25a8ad7b7c
commit b068d6aec8
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
1 changed files with 5 additions and 0 deletions

View File

@ -27,3 +27,8 @@ export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_USER_CONFIG_DIR="$XDG_CONFIG_HOME"
# Paths
export LD_LIBRARY_PATH="$HOME/local/lib/x86_64-linux-gnu/:$HOME/local/lib"
export PKG_CONFIG_PATH="$HOME/local/lib/x86_64-linux-gnu/pkgconfig:$HOME/local/lib/pkgconfig"