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

Package Themis Core with BoringSSL #683

Merged
merged 10 commits into from
Jul 23, 2020
Merged

Conversation

ilammy
Copy link
Collaborator

@ilammy ilammy commented Jul 21, 2020

This PR teaches make deb, make deb_php, make rpm to build packages of Themis Core using embedded BoringSSL instead of system OpenSSL. This is useful in cases like #619, #657.

When ENGINE=boringssl is set, produced Themis Core packages will get a suffix:

  • libthemis-boringssl
  • libthemis-boringssl-dev or libthemis-boringssl-devel

This is an alternative flavor of Themis Core which includes embedded BoringSSL instead of depending on system OpenSSL.

The BoringSSL and OpenSSL flavors provide the same ABI and install the same files. As such, they are mutually exclusive and conflict with each other to prevent simultaneous installation.

Other packages (libthemispp-dev, libthemis-jni, libphpthemis) now depend on either OpenSSL or BoringSSL flavor. That is, any flavor can be installed to satisfy the dependency.

How to build new packages

In short, running

make deb ENGINE=boringssl

will build and package BoringSSL flavor of Themis. This will also compile and package other packages which are identical to the OpenSSL version.

It's better to build OpenSSL and BoringSSL flavors in separate build directories right now. The build system does not expect incremental rebuilds with different configuration.

Dependency summary

The dependencies are as follows:

  • libthemis
    • Depends: libsslX.Y (of any version)
    • Conflicts: libthemis-boringssl of any version (new!)
  • libthemis-boringssl (new!)
    • Depends: none
    • Conflicts: libthemis of any version
  • libthemis-dev
    • Depends: libssl-dev
    • Depends: libthemis of exactly the same version
    • Conflicts: libthemis-boringssl-dev of any version (new!)
  • libthemis-boringssl-dev (new!)
    • Depends: libthemis-boringssl of exactly the same version
    • Conflicts: libthemis-dev of any version
  • libthemispp-dev
    • Depends: libthemis-dev or libthemis-boringssl-dev of exactly the same version (changed)
  • libthemis-jni
    • Depends: libthemis or libthemis-boringssl of at least the same version (changed)
  • libphpthemis-php*
    • Depends: libthemis or libthemis-boringssl of at least the same version (new!)

Ditto for RPM, with s/dev/devel/g, etc.

Checklist

  • Change is covered by automated tests (not really, only Builtbot)
  • The coding guidelines are followed
  • Changelog is updated

This PR depends on the previous ones:

ilammy and others added 9 commits July 20, 2020 22:12
Strictly speaking, libthemis depends on the OpenSSL library, not the
"openssl" binary. The "openssl" package installs the entire binary
along with its man pages, etc. Instead, it is sufficient to depend
only on the library.

The library package is typically called "libssl1.1", with an ABI suffix.
The default OpenSSL library version differs between distros so we cannot
write it in Makefile, but we should depend on the OpenSSL library from
the particular distribution. If we were using debhelper, this would have
been resolved for us automagically, but we are using FPM. Therefore we
will use the dependencies of "libssl-dev" package as a proxy for the
current default OpenSSL library name. This should be good enough.
Similar to Debian/Ubuntu situation, the "openssl" package on RHEL/CentOS
installs the "openssl" binary. The package with libraries only is called
"openssl-libs", we should depend on that instead.

RPM packages typically do not include ABI infromation in the name,
though the distros here typically do not ship multiple ABIs of a library
either so it's fine.
If we are building Themis with embedded BoringSSL, produce packages with
"-boringssl" suffix in their names:

  - libthemis-boringssl
  - libthemis-boringssl-dev
  - libthemis-boringssl-devel

Note that this affects only Themis Core packages. Other packages do not
depend on the choice of the cryptographic backend and keep their names:

  - libthemispp-dev
  - libthemispp-devel
  - libthemis-jni
  - libphpthemis
If Themis Core package is built with embedded BoringSSL, it does not
depend on the system OpenSSL anymore. Do not include OpenSSL library and
development packages in dependencies of "libthemis-boringssl" and
"libthemis-boringssl-dev" packages.
Since both flavors of Themis Core install effectively the same files,
make them conflicting:

  - libthemis conflicts with libthemis-boringssl
  - libthemis-dev conflicts with libthemis-boringssl-dev

This prevents simultaneous installation.

The implementation is not the most beatiful one, but we need to make it
symmetric as either package conflicts with the other one.
Both OpenSSL and BoringSSL flavors of Themis Core provide the same ABI
and can be used interchangeably. Make sure that both can satisfy
dependencies of libthemispp, libthemis-jni, and libphpthemis packages.

Note, however, that libthemis-boringssl cannot be used with libthemis-dev
and vice versa.

Also note that in this case we need to keep the version specs in
parentheses because --depends value is directly substituted into DEB's
"Depends:" field. FPM will not add parthenses for us this time.
Previously PHPThemis did not include in its dependencies at all. Make
sure it depends on either OpenSSL or BoringSSL flavor of it, similar to
the "libthemis-jni" package.
@ilammy ilammy added core Themis Core written in C, its packages infrastructure Automated building and packaging C-BoringSSL Crypto provider: BoringSSL O-Linux 🐧 Operating system: Linux installation Installation of Themis core and wrapper packages labels Jul 21, 2020
endif
PHP_DEPENDENCIES += --depends "$(PACKAGE_NAME) (>= $(VERSION)+$(OS_CODENAME)) | $(OTHER_PACKAGE_NAME) (>= $(VERSION)+$(OS_CODENAME))"
Copy link
Contributor

Choose a reason for hiding this comment

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

magic 🧙‍♂️

@@ -604,23 +604,44 @@ endif
# Packaging Themis Core: Linux distributions
#

ifeq ($(ENGINE),boringssl)
ifeq ($(CRYPTO_ENGINE_LIB_PATH),)
PACKAGE_EMBEDDED_BORINGSSL := yes
Copy link
Contributor

Choose a reason for hiding this comment

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

so, if engine is boringssl, we'll pack boringssl as embedded library by default, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If ENGINE=boringssl and ENGINE_LIB_PATH is not set. That is, if the user has requested a build with BoringSSL from Themis submodule, not with some user-provided BoringSSL build from user-specified location.

Makefile Outdated
# If we were using native Debian packaging, dpkg-shlibdeps could supply us with
# accurate dependency information. However, we build packages manually, so we
# use dependencies of "libssl-dev" as a proxy. Typically this is "libssl1.1".
DEB_DEPENDENCIES += --depends $(shell apt-cache depends libssl-dev | grep 'Depends:' | cut -d: -f 2-)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
DEB_DEPENDENCIES += --depends $(shell apt-cache depends libssl-dev | grep 'Depends:' | cut -d: -f 2-)
DEB_DEPENDENCIES += --depends $(shell apt-cache depends libssl-dev | grep 'Depends:' | cut -d: -f 2- | tr -d ' ')

:)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It will be adjusted like this after #682 is merged 👌

@ilammy
Copy link
Collaborator Author

ilammy commented Jul 23, 2020

Dependencies have been merged, I've synced up this branch and resolved merge conflicts. If you want to make another review pass over the clean diff, this is the time. I'll merge it today if CI passes. (Let's hope GHA will work this time.)

@ilammy
Copy link
Collaborator Author

ilammy commented Jul 23, 2020

Well, GHA is stuck ¯\_(ツ)_/¯

@ilammy ilammy merged commit 8ae934c into cossacklabs:master Jul 23, 2020
@ilammy ilammy deleted the boringssl-package branch July 23, 2020 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-BoringSSL Crypto provider: BoringSSL core Themis Core written in C, its packages infrastructure Automated building and packaging installation Installation of Themis core and wrapper packages O-Linux 🐧 Operating system: Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants