Linux: Installing non-distribution programs using xstow manager

    Introduction


    Modern Linux distributions incorporate a lot of software. Problems with installing / uninstalling / updating such software have been resolved, one might say, perfectly. The package manager takes care of everything. Select the package you need, the package manager will install it. Need to be removed - the package manager will delete and clean everything carefully. But sometimes you want, or need to, install software that is not included in the distribution, or distributed in the source, or even in binaries. What to do in such cases?


    In the future, for definiteness, we assume that we use Linux, the Ubuntu distribution, or Debian.

    Installing a package from source


    Classical for free software distribution path, distribution in the source code. In this form, the program is an archive with the name of the form:

    name-version.tar.gz
    


    Installation of such software is performed by executing a set of simple commands:

    tar -xzvf name-version.tar.gz
    cd name-version
    ./configure
    make
    sudo make install
    


    Decryption of actions:

    StepCommandWhat is he doing
    1tar -xzvf name-version.tar.gzUnpacking the archive
    2cd name-versionGo to the directory received after unpacking
    3./configureConfiguring sources on our system
    4makeCompilation
    5sudo make installInstallation


    Problems


    Problem 1: Missing Required Libraries


    Very often, things do not go so smoothly, and in step 3, the configure command complains about something. And she usually complains about the lack of the necessary libraries, or library headers. We carefully consider the output that the configure command issued to the console and install the missing libraries and headers. The headers for Debian-like distributions, including Ubuntu, are in packages with the suffix -dev in the package name.

    Suppose we saw that configure complains about the library, we install it on the system:

    sudo apt-get install name
    


    Run configure again. Now complains about the headers of the same library. We install them:

    sudo apt-get install name-dev
    


    Well, finally, we installed everything we needed, compiled it, we work and enjoy it. It would seem happiness, here it is. But no, problem 2 looms:

    Problem 2: a mess in the system


    Suppose we installed one program from source, another, a third. And suddenly we needed to remove the first, or replace its version. And we, it turns out, do not know which files belong to this program and where they are. Some programs install their files in the / usr / local hierarchy , while others generally in / usr . In general, we do not know how to clean out files related to a package.

    Digression: The Linux File System Hierarchy Standard


    Linux has a standard for placing files on the system. Links are given in the section Literature . According to this standard, the files used by users, including users from other computers, should be stored in the / usr directory hierarchy . In the directory hierarchy / usr / local - files used by local users. Thus, we need to put our programs in the / usr / local hierarchy , while avoiding the mess.

    Xstow package manager


    The xstow package manager will help us do this. You can also use the stow manager, xstow is an advanced version. What is he doing? A very simple thing. We install our programs in the / usr / local / stow hierarchy , each program in its own directory, and then the xstow manager creates symbolic links to our files from the / usr / local hierarchy . Install xstow :

    sudo apt-get install xstow
    


    Now the sequence of operations when installing the package using the xstow manager.

    tar -xzvf name-version.tar.gz
    cd name-version
    ./configure --prefix = / usr / local / stow / name-version
    make
    sudo make install
    cd / usr / local / stow /
    sudo xstow name-version
    


    Decryption of actions:

    StepCommandWhat is he doing
    1tar -xzvf name-version.tar.gzUnpacking the archive
    2cd name-versionGo to the directory received after unpacking
    3./configure —prefix = / usr / local / stow / name-versionConfiguring the sources on our system so as to install in the specified directory
    4makeCompilation
    5sudo make installInstallation
    6cd / usr / local / stow /Go to the directory where the programs are
    7sudo xstow name-versionCreate symbolic links in the / usr / local hierarchy


    Command:

    sudo xstow -D name-version
    


    Removes symbolic links. After deleting the links, the directory with the program files located in / usr / local / stow / can be deleted.

    Conclusion


    Using the xstow package manager, you can not only maintain order in the system, you can have several versions of programs at the same time and quickly switch between them.

    Literature


    1. The standard Linux file system hierarchy (File System Hierarchy Standard)
    2. Filesystem Hierarchy Standard

    Also popular now: