Installation of a package to a custom directory

6,510

A debian package needs to be compliant to the FHS, that clearly defines where to put data and where to install applications on any system. This clear structure makes administration easy and we all should stick to that.

In your case, when it comes to testing applications an installation to a custom directory may be desired. However there is no way to tell your package manager not to use the predefined file locations from an exisiting DEB package.

If you need an installation to another location you may need to compile your package from source, as you already pointed out. Alternatively, and if you need to use dpkg you will have to build your own private DEB where you can define other installation paths. If however the application relies on access to files located on a FHS-compliant path it may not run the way developers intended.

For installing testing versions of applications you may consider a chroot (or schroot) environment. The safest solution (though maybe overkill) for testing is installing applications in a virtual OS (e.g. through Virtual Box)

Share:
6,510

Related videos on Youtube

Jamess
Author by

Jamess

Updated on September 17, 2022

Comments

  • Jamess
    Jamess over 1 year

    Is there any option to install a package to my home directory (or /foo) instead of system wide ? I am looking for options using apt-get or dpkg. Something similar to --prefix in a source compile.

    What I am looking for co-existing of different versions of openJDK for testing purposes.

  • Jamess
    Jamess over 13 years
    Thanks. On further looking to 'man dpkg', I saw this and yet to evaluate. --instdir=dir Change default installation directory which refers to the directory where packages are to be installed. instdir is also the directory passed to chroot(2) before running package's installation scripts, which means that the scripts see instdir as a root directory. (Defaults to /).
  • Jamess
    Jamess over 13 years
    I tried to install an already existing package using this switch and I could not do it since the dpkg -i command detected my old package and warned me. Something like "Preparing to replace "foo" with foo.deb". So looks like source compile is the only way
  • Jamess
    Jamess over 13 years
    --instdir works and dumps the files to my directory. But this is not much useful in practise. This expects a chrooted environment. If I have a chrooted setup in this directory, I can use 'sudo chroot mydir' and use it.