📜 ⬆️ ⬇️

I want to take and shoot, or an educational program about why you should not use make install

By writing this note, I was inspired by the fact that I was tired of making detailed comments on this topic in the comments to the articles, where as part of the instructions for building and configuring something for a specific distro, they propose to do a install install.
The bottom line is that this command in the form of “make install” or “sudo make install” cannot be used in modern distributions.

But the authors of the programs in the installation manuals write that you need to use this command, perhaps you will say. Yes, they write. But this only means that they do not know what kind of distribution kit you have, and whether it is a distribution kit at all, maybe you joined a sect and smoked about reading LFS and now decided to build their creation under your chthonic system. And make install is universal, though often the wrong way to do it.

Lyrical digression


As you know, for normal operation, most software must not only be compiled, but also correctly installed in the system. Programs expect to find the files they need in certain places, and these places in most * nix-systems are protected in the code at the compilation stage. In addition to this aspect, the main difference in the linux / freebsd / whatever installation process from that in Windows and MacOS is that the program does not just add a bunch of files to a separate directory in Program Files or / Applications, but “smears” itself across the entire file system. Libraries go to lib, executable files to bin, configs to etc, all sorts of data to var, and so on. If you suddenly need to update it, then all this must first be cleaned up somehow, since when using the new version, the remnants of the old files can lead to completely unpredictable consequences , often bad ones. The probability of this event is not so great, but you need it on the battle server?
')

So what?


So, if you did the installation directly through make install, then you most likely will not be able to uninstall or update the software. Moreover, installing a new version on top of the old one will most likely wipe your changes in configs . make install does exactly what it says - installs the files in the right places, ignoring the fact that something is already there. After this process, absolutely no information about what was put and where it was impossible to obtain in a digestible form. Sometimes, of course, the Makefile supports the uninstall action, but this is not so common, and it’s not a fact that it works correctly. In addition, it is strange to keep the unpacked source tree and build rules for uninstallation.

How to fight?


Since packages have the ability to sometimes be updated in distributions, they have invented such a thing as a package manager to solve this problem. When using it, the installation goes something like this:

  1. taken in a certain way formed archive
  2. information is extracted from it about what it is at all, what version, what it depends on, what conflicts with it, whether it is necessary to run some scripts to install / delete / configure, etc
  3. Perform direct installation steps.
  4. All data about where and what was delivered are added to the database of the package manager.


In this case, when upgrading, you can safely remove too much, and at the same time see if the files marked as configuration have changed in the system and ask what to do if their content is different in the new version. In addition, the package manager will not allow to overwrite the files of one package when installing another. In general, a lot of useful things he can do.

If you are unknowingly / lazy to make install install instructions, then files appear on the system that the package manager does not know about . With all that implies, if not enough of what has been listed before.

What to do?


You can, of course, configure the source tree so that the installation of everything and everything goes somewhere in / opt / mycoolapp /, and then, if necessary, remove it with your hands, but then a lot of unpleasant things can come out, starting with what the program expects load their libraries, and the loader about the directory where they lie knows nothing, ending with the fact that the author of the program can expect that for example, if he puts the file, say in $ prefix / share / xsessions /, then the display manager will pick it up. Not to mention the paths for pkgconfig and so on.

So it is necessary to collect the package.

I don’t have time to do this with ***, it’s better to do make install again, everything is simple and clear!


Calm, calm. He's tied to our feet. Everything is not so scary and difficult, as it seems at first glance.

checkinstall

This wonderful utility, being run instead of make install, will ask a few questions, after which it will assemble and install the package. Everything, at updating any problems with cleaning of old stuff you will not have.

Build a deb package manually

If you are not inclined to trust such automatics (which sometimes still mows down) or you want to make a couple of changes, but it’s still lazy to deal with the normal package building process, you can assemble the package with handles. I provide a way to build it for Debian-based systems, since it’s best known to them. It is not ideologically correct, but the output is a completely correct package without using additional entities. This is done as follows.
To begin with, we collect software with the parameters previously specified for configure or autogen.sh --prefix = / usr and --exec-prefix = / usr.
Next, make the installation in a temporary directory. We write:

fakeroot
make install DESTDIR=`pwd`/tempinstall

. , fakeroot-, . . , . fakeroot- , .
« » DEBIAN DEBIAN/conffiles , /etc:

cd tempinstall
mkdir DEBIAN
find etc | sed "s/^/\//" > DEBIAN/conffiles

DEBIAN/control :
Package: _
Version: 1.2.3
Architecture: amd64/i386/armel/all
Maintainer:    ,  ,    ,  dpkg  
Depends:       .
Priority: optional
Description:   - ,    


preinst, postinst, prerm postrm.

, dpkg -b tempinstall tempinstall.deb, dpkg -i , .

«» , , .



, , .

: checkinstall make install. .

Source: https://habr.com/ru/post/130868/


All Articles