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

Adding FreeBSD support for server version #353

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

Teetoow
Copy link

@Teetoow Teetoow commented Jul 19, 2021

These patches added FreeBSD support for server version of DocumentServer.
Applying these patches won't break non FreeBSD users since there are os specific conditions everywhere (excepted for the patching mechanism but as explained in its commit it won't do anything if patches/ or patches/ is not present which is the case by default).

Please note that the FreeBSD version needs specific packages installed before using it as explained in the header of the tools/freebsd/automate.py file.
The node10 version installed have to be installed with the "--shared" option enabled in order to use its V8 version.

Also add patches/ directory check in order to easily apply custom patches to
OnlyOffice sources. By default this directory does not exists.
not written for FreeBSD. In order to get chromium compiling under
FreeBSD a specific set of compilation tool has to be used (see
https://wiki.freebsd.org/Chromium)
repositories. This is particulary useful when compiling code on an
unsupported platform. Patches are stored in patches/<platform/
directory.

Moreover skip the 3rd party compilation under FreeBSD since OnlyOffice
depends on v8 which needs specific compilation tools under FreeBSD
(native v8 compilation tools are not written for FreeBSD. Thus under
FreeBSD we use node10 available in the FreeBSD port compiled with the
"shared" option.  In that way libnode.so is used in order to get the v8
code).
Since v8 library is got from FreeBSD ports, we also want to use the
native ICU library, boost library, openssl library etc.
Moreover it lets the sysadmin getting the latest security patches for
these libraries and avoid security holes (without recompiling
onlyoffice).
/usr/bin. When npm-pkg is installed it is installed in /usr/local/bin.
In that way by specifying the full path under FreeBSD it lets the python
script accessing npm pkg rather that the FreeBSD package manager.
Before calling this script:
  - be sure that "git" (or "git-lite"), "sudo" and # "python27" are installed:
    # pkg install git-lite sudo python27
  - /usr/bin/python is a symlink to /usr/local/bin/python2.7:
    # ln -s /usr/local/bin/python2.7 /usr/bin/python
  - CC and CXX environment variables are respectively set to clang and clang++
    # export CC=clang
    # export CXX=clang++

Last but not least only "server" module has been checked to compile
under FreeBSD. That's why only this module is currently accepted.
apply it. Currently it only supports linux patch but it is easy to add
the windows solution too. It does nothing if the patches/ or the
patches/<os> directories don't exist. It could be useful to easily apply
patches before compiling them.
Since some patches are applied (at least in build_server.py) it could also be
interested in creating a function with an argument "prefix" in order to
apply patches before compiling and after compiling in a such way.
Since it changes nothing if directories are not present it would be very
intested in adding this code.
In that way it would be easier to add FreeBSD (and other OSes) support.
library updates which removes very old functions declared as obsolete
since many years (Node10 is very old..).
There is no more problems with node12.
Please note that node12 is now obsolete and no more maintained. It could
then bring security issues especially for servers...). Since the code is
not working under node14 or node16 it would be interested in working on
the code to use them.
In that case we are sure that we are using the latest version with
latest security patches applied. Moreover these libraries will be
updated with the system updates. Then we will be sure we will get the
latest security fixes!
ABI.  In order to compile some node modules on very old FreeBSD version
some macros have to be passed to the compiler.
Unfortunately the test used to check which FreeBSD version is installed
on the host is quite poor since it is based on a text string which
corresponds to the LLVM version.
With FreeBSD version greater or equal to FreeBSD 12, LLVM major version
is greater or equal to 10. Then the string comparison between "4.0" and
the current LLVM version "10.xx" gives wrong result and unsupported
MACROS are applied during compilation whereas it should not be applied.

On "newer" version of node (at least since node12) this test has been
removed. However since the current version of DocumentServer does not
compiles with node12 or greater (due to the use of V8 code which is no
more available in the V8 version contained in node12 and greater) we
need to patch the common.gypi file which is cached during npm install
process.
Once node_gyp files are cached other calls to npm install use the cached
version. So patching the cache files will work during the compilation
process.

To summarize this part of the code is only useful because
documentserver version use VERY VERY VERY VERY old V8 version. Once
DocumentServer will be able to use newer V8 version this hack will be
removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant