Skip to content

Commit

Permalink
Keep backwards compatibility with source installations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ilammy committed Apr 4, 2019
1 parent f351b86 commit 71edd43
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,15 @@ define themisecho
@tput sgr0
endef

# default installation prefix
PREFIX ?= /usr/local
# Backwards compatibility with existing non-managed installations on Linux
DEFAULT_PREFIX := $(shell \
test -e /usr/include/themis/themis.h && \
! (dpkg --status libthemis | grep '^Status:.*installed' || \
rpm -q libthemis) >/dev/null 2>&1 \
&& echo "/usr" || echo "/usr/local")

# Default installation prefix
PREFIX ?= $(DEFAULT_PREFIX)

# default cryptographic engine
ENGINE ?= libressl
Expand Down

0 comments on commit 71edd43

Please sign in to comment.