Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "/usr/local" as default prefix for "make install" #448

Merged
merged 5 commits into from Apr 10, 2019

Conversation

ilammy
Copy link
Collaborator

@ilammy ilammy commented Apr 3, 2019

Conventional filesystem standards imply that /usr prefix should be used only by system package managers. Custom installations should go to /usr/local by default. However, on Linux machines make install installs to /usr, messing with package manager installations. Let's install to /usr/local/ everywhere.

However, we should keep /usr prefix for packaging, therefore override the default for deb and rpm targets.

Convential filesystem standards imply that "/usr" prefix should be
used only by system package managers. Custom installations should go
to /usr/local by default.

However, we *should* keep "/usr" prefix for packaging, therefore
override the default for "deb" and "rpm" targets.
@ilammy ilammy added the installation Installation of Themis core and wrapper packages label Apr 3, 2019
@vixentael
Copy link
Contributor

How this will affect current users that have Themis installed in /usr?

@ilammy
Copy link
Collaborator Author

ilammy commented Apr 3, 2019

Good question...

Assuming these are users that install from source code, I can see make uninstall breaking if they wish to use newer version to uninstall the previous one. The users will have to explicitly set PREFIX=/usr to uninstall the previous version from correct path.

Similarly, if Themis 0.11 is installed to /usr (by current default) then installing Themis 0.12 to /usr/local will not overwrite the previous install (as it is now). Instead, Themis 0.12 will be installed alongside Themis 0.11. Usually /usr/local takes precedence over /usr, so effectively Themis 0.12 should be used. But that depends on the software, and it may break in case of misconfiguration. In particular, Themis libraries do not have versions embedded into them so the software can load a wrong library.

Overall, I feel that we will have to ask those users who install from source to cleanly uninstall previous version of Themis using previous source code, and then install an upgrade using the new source code.

Alternatively, I think we could detect whether Themis is already installed to /usr and not managed by package manager. If so then we keep using the old prefix, otherwise default to /usr/local (unless the user explicitly sets something). Together with that we could urge users to switch to the new default and eventually drop the special case.

All previous installation of Themis from source on Linux used "/usr"
prefix. This means that installing a newer version into "/usr/local"
will result in two completely unmanaged side-by-side installations of
Themis. It is brittle and can cause all sorts of trouble, both when
building software and when loading shared libraries.

Add a shim for backwards compatibility for Linux. If we detect that
there is already a "make install" installation of Themis in /usr then
we keep using the old "/usr" prefix by default. Otherwise we use the new
"/usr/local" prefix. If the user has explicitly specified the prefix
then we go with that value regardless of the installation status.

It's kinda tricky to detect source-based installation. We do as follows:

 1. Check for the main header file <themis/themis.h>

    It is always installed by "make install", and it may be installed by
    Themis package (DEB or RPM).

    If there is no such file then Themis is not installed to "/usr",
    we can simply use the new prefix.

 2. Otherwise, check DEB and RPM packages

    If there is "libthemis" package installed then Themis installation
    is managed by the system's package manager. We should not use "/usr"
    prefix to avoid overwriting system installation, use "/usr/local".

In this way we prefer "/usr/local" prefix if possible, avoid overwriting
installations by package managers, and keep using the old "/usr" prefix
if the user had Themis installed there before.

macOS has always used "/usr/local" prefix so we can just keep using the
default there.
@ilammy
Copy link
Collaborator Author

ilammy commented Apr 4, 2019

@vixentael I've pushed a commit that implements the backwards compatibility behavior described in the previous commit.

With that, on systems that do not have Themis installed (yet) we'll be using the new /usr/local prefix. However, if the system already has Themis manually installed to /usr (not by the package manager) then we'll keep using /usr. If the user explicitly specifies the prefix then we'll be using that instead.

@ilammy ilammy requested a review from Lagovas April 4, 2019 10:43
@shadinua
Copy link
Contributor

shadinua commented Apr 4, 2019

I'd avoid to set path automatically. How about next behaviour:

  • if we detected themis installed in path differ from /usr/local, but included into ldconfig, then stop with special error code (differ than default ones);
  • add environment variable, for example THEMIS_ALLOW_MULTIPLE_INSTALLS that allows to install even when previous installation detected.

@ilammy
Copy link
Collaborator Author

ilammy commented Apr 8, 2019

@shadinua, well, that's a reasonable approach as well. Though, I feel that installing a local version to /usr/local in parallel with system version in /usr will be quite often used by developers for local testing, so I don't think that we should make it more annoying. We can't account for all the conflicts that are possible by multiple installations.

Ideally, I'd avoid doing all this guesswork altogether (as it's bound to fail for someone, human perversion has no limits). If you install Themis from source then well, do manage your versions yourself if you insist on not using any sort of package manager.

It's better for our users to know where do we install files to and
where do we remove them from during uninstallation. Let's print the
PREFIX value for "make install" and "make uninstall" targets.
@ilammy
Copy link
Collaborator Author

ilammy commented Apr 8, 2019

I've added one more convenience for the users: now we print the installation prefix so the users know where Themis has been installed to or removed from.

Now, what should we do about multiple installations and upgrades?

  1. Decline this PR. Keep installation paths as is.

    Pro: users can continue being blissfully ignorant of where they install stuff.
    Con: sudo make install on a system with installed packages overwrites the packages.

  2. Accept current PR. Prefer /usr/local, unless there is an existing installation in /usr.

    Pro: users can still be somewhat ignorant.
    Pro: we won't overwrite package manager installations anymore.
    Con: complicates installation, endorses bad behavior.

  3. Revert guesswork, follow @shadinua. Deny multiple installations, unless asked to.

    Pro: not taking chances, fail early if we detect a conflict.
    Pro: still allows multiple installs if needed.
    Con: complicates installation, has to be documented.

  4. Revert guesswork. Just install to /usr/local from now on.

    Pro: dead simple.
    Con: previous installation to /usr has to be manually removed.

  5. Any other options out there?

@vixentael?

As for paths, I believe that we'd run into conflicts either way if we ever going to fix the mismatch on CentOS (libraries should go to /usr/lib64, not /usr/lib). For that we will have to ask the users to cleanly remove their previous installation of Themis and install the new version from scratch. That gives us freedom to change the new installation path however we like.

@shadinua
Copy link
Contributor

shadinua commented Apr 8, 2019

Though, I feel that installing a local version to /usr/local in parallel with system version in /usr will be quite often used by developers for local testing, so I don't think that we should make it more annoying.

By default /usr/local/lib is included to ldconfig search paths of most distributives. Thus in case when we have different versions of library that installed simultaneously in /usr/lib and /usr/local/lib, it will change behaviour anyway. I wouldn't like to think that installing the new version of the library for development purposes while we changing behaviour of whole system is the right way. Isn't it better to put the library in the project folder?

Ideally, I'd avoid doing all this guesswork altogether ...

I completely agree. That is why I'd suggest to choose one of standard, predictable and simple variants to solve this issue.

@ilammy
Copy link
Collaborator Author

ilammy commented Apr 8, 2019

Isn't it better to put the library in the project folder?

This is involves much more hassle than make install. You have to get Themis to your project directory, setup all lookup paths in your project, etc. I don't really imagine people using make install for that. I'd personally would just copy binaries out of build directory if I don't want to keep Themis installed in my system.

By default /usr/local/lib is included to ldconfig search paths of most distributives. Thus in case when we have different versions of library that installed simultaneously in /usr/lib and /usr/local/lib, it will change behaviour anyway.

Yeah, that's exactly the point. Imagine you're using PyThemis and there's some bug in the core library. Your core library is installed from package repositories. However, you are able to grab the latest source code, sudo make install it, check whether the bug is fixed for you (without having to fiddle with Python library lookup), and then sudo make uninstall everything back. And the system-managed installation of Themis is kept intact.

@ilammy
Copy link
Collaborator Author

ilammy commented Apr 8, 2019

Another common approach is system-wide installation to /opt, when you do make install PREFIX=/opt/themis-0.11 and configure multiple projects to use the same installation. I believe we should allow such installations without any additional required flags and variables, regardless of whatever is or is not installed in /usr and /usr/local.

I think that we can keep it simple by installing to specified prefix if it is explicitly requested by the user. If they request it, they have their reasons and did their homework.

@shadinua
Copy link
Contributor

shadinua commented Apr 9, 2019

Yeah, that's exactly the point. Imagine you're using PyThemis and there's some bug in the core library. Your core library is installed from package repositories. ...

There are too many cases. For some of them, this is an advantage. For some — a disadvantage. These libraries can be installed not only on the developers' machines, where changing in the behaviour of the whole system is normal.

In the proposed variant, parallel installation of the library using make install is absolutely possible. Howeve, in my opinion, for responsible libraries, such as Themis, it is better to be sure that the user is consciously doing this.

@shadinua
Copy link
Contributor

shadinua commented Apr 9, 2019

Well. I'll not insist on that behaviour. I'd prefer to have Makefile without any extended logic inside.

Let's choose variant #4. But we have to implement CentOS detection to set correct paths.

@vixentael
Copy link
Contributor

Let's choose variant #4. But we have to implement CentOS detection to set correct paths.

With this option I would feel better if we notify user that installation path was changed. For example, if we detect that Themis is already installed in /usr, we can write a warning log message after successful installation ~ "Multiple Themis installation found. If you didn't do it intentionally consider removing old versions."

Changing default installation path from /usr to /usr/local is more or
less safe on Linux as the compilers and linker-loaders *usually* check
/usr/local before /usr. Therefore after "sudo make install" the software
will (probably) be using the new version of Themis. However, the old
installation may still remain there in "/usr" and this may cause issues
with non-standard configurations.

Check if there are multiple installations of Themis and print a warning
for the users, suggesting to keep only one installation in their system.
@ilammy
Copy link
Collaborator Author

ilammy commented Apr 9, 2019

@shadinua @vixentael I have reverted the 'AI-commit' and added a simple check with a warning if we detect Themis in both /usr and /usr/local simultaneously, suggesting to remove the (presumed) old installation from /usr and keep installations by make install in /usr/local.

Copy link
Contributor

@shadinua shadinua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link
Contributor

@vixentael vixentael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks very user friendly and cool!

@ilammy ilammy merged commit c266872 into master Apr 10, 2019
@ilammy ilammy deleted the ilammy/default-prefix branch April 10, 2019 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation Installation of Themis core and wrapper packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants