Wednesday, February 23, 2022

[SOLVED] How to use environment variables in debian/install

Issue

How can I use environment variables inside the "install" file in the debian directory.

I want to do something like this :

Resources      $HOME/somefolder

However this is creating a folder called $HOME in the deb package and lintian is giving me a warning :

W: file-in-unusual-dir $HOME/somefolder


Solution

Debian packages install software system-wide. Also, only superuser can install packages, no ordinary user. A system typically has multiple users (my Desktop machine that has 2 user accounts for real world people, has a total of 38 different user accounts, most of them being system-users for specific programs (e.g. a webserver running as user www-data)

In this context ${HOME} doesn't make sense (whose home directory? root? a special pseudouser for your application? all users?).

Therefore, you should re-think how you install your package:

  • data that is valid for all users should go into /usr/share/<myapp> (for architecture independent data) or /usr/lib/<myapp> (for architecture dependent data).

  • per-user data should not be installed by the package at all! If it's absolutely necessary to have user-data installed prior to running your application (e.g. because the application will refuse to run without having user-data installed somewhere in ${HOME}), you should still put that data in a central place (/usr/share or /usr/lib) and either create a setup-script that each user has to run before starting the application for the first time and which will copy (or symlink) the contents from the central location to the user's ${HOME}. Alternatively, you could do a wrapper, that will check whether the data is there (and eventually copy/symlink it) before running the real program.

You might want to have a look at the FileSystemHierarchy and the Debian Policy.



Answered By - umläute
Answer Checked By - Mildred Charles (WPSolving Admin)