How to install package in custom directory?

I was wondering how would I proceed if I need to install some software in a directory of my choice instead of where PKGBUILD will install it?

Reading the makepkg info it seems like there are 3 variables which can be configured:

  • PKGDEST — directory for storing resulting packages
  • SRCDEST — directory for storing source data (symbolic links will be placed to src/ if it points elsewhere)
  • SRCPKGDEST — directory for storing resulting source packages (built with makepkg -S)

Do I need to create a makepkg.conf file inside the cloned pakage repo with the above variables?

Upon examining the PKGBUILD file I see that there some symbolic links and also in some *.pc files paths are hard coded, e.g. /opt/somepackage which makes me wonder whether any of the above changes in makepkg.conf will even be respectd in the first place or I’ll end up with a mess?

Is there an standardised way to compile and install packages into a custom directory without affecting anything else on the system?

Hello,

The standard is offered by the way the package is already done either by upstream arch or manjaro.
From AUR you might get them installing in /opt/…

The custom path doesn’t quite make much sense, and modifying the package will lead you where you create your own repository …

I understand but in some cases I would like to install everything for instance in /tmp just to further examine the package but without affecting my system by installing in /opt or wherever the PKGBUILD has designated to install packages.

Why not simply extract the package. It is a tar file, usually compresd with zstd.

You can’t choose the folders in the install process. You need rebuild the package with your favorite path, if you don’t want the default.

1 Like

I have done that.

So there’s nothing equivalent to ?

  • ./configure --prefix
  • make
  • make install

Can you point me to a MWE?

Yes of course. You need the PKGBUILD file for the package you want to rebuild. Edit the build function. Depending on how the PKGBUILD is written, you might need to edit the install function too.

https://wiki.archlinux.org/index.php/Creating_packages
https://wiki.archlinux.org/index.php/Arch_Build_System
https://wiki.archlinux.org/index.php/PKGBUILD
and all other related Arch Wiki pages.

Yeah I was aware of this but as I said I’ll need to edit all other *.pc files where hardcoded links appear.
Of course I could simply do a grep and sed on that but there might be something more elegant like makepkg --prefix for instance?

Not that I am aware of something like this.

The problem with installing packages in non-standard directories is other packages won’t be able to find them. This may not matter for standalone packages, but eventually you’ll get into trouble creating a bad habit like that.

Install them normally and use firejail, perhaps.

From man pacman

   -r, --root <path>
       Specify an alternative installation root (default is /). This should not be used as a way to install software into /usr/local instead
       of /usr.  NOTE: If database path or log file are not specified on either the command line or in pacman.conf(5), their default location
       will be inside this root path.  NOTE: This option is not suitable for performing operations on a mounted guest system. See --sysroot
       instead.

Also I’m reving the xfce tag since the DE is not relevant to the question