Build libreoffice for slackware 202102

From Studiosg
Revision as of 12:08, 21 March 2022 by Wikiuser (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Welcome to Simone Giustetti's wiki pages.


Languages: English - Italiano


How-to Build a Recent Version of LibreOffice for Slackware Linux

Not so long ago I wrote a page about building working LibreOffice packages for Slackware current, the development version of the famous Linux distribution, for the ARM architecture. Maintaining packages for a development release is a lot like hitting a moving target. A lot of the included packages are updated daily thus introducing new dependencies and issues arising from library version mismatch. I myself discovered with a certain disappointment that many programs, including LibreOffice, had stopped working after a particularly large update of the operating system. Noticing the problem, I tried to rebuild everything only to find that the scripts described in the mentioned article no longer worked. After some unsuccessful attempts, I resolved to start from scratch upgrading to LibreOffice 7.0.3.1. In the following article I'll detail the procedure, provide some hits and all of the corrections made to produce working packages of LibreOffice 7.0.3.1 for SlackwareArm 14.2 current.

Development Environment

I used a Raspberry Pi 4 model with 4 Giga Bytes of RAM memory which runs Slackware Linux Arm 14.2 current. Before I start, I'd like to point out that I'm still using a SlackwareArm release dating back to Christmas 2020. No serious operating system update was installed after that because a glibc version update has been in the air for some time. The Glibc libraries are a fundamental part of the system and it is very likely that, following the upgrade, the vast majority of installed programs will stop working and a massive rebuild, touching more or less the whole system, will be required afterwards. Not having much time to spare, I chose to postpone any update to when the distribution will be stable anew.

Prerequisites

For a full list of prerequisites I'll suggest reading the previous article of the series. The provided information is still valid. I'm going to write about OpenJDK, previously used release 8 does not match with LibreOffice 7.0, and other differences instead.

LibFreehand

I again built a stand alone package for the LibFreehand library that enables support for Freehand save files. The libreoffice-7.0.3.1-srcs.tar.xz archive includes a version of the library matching the one in libreoffice-6.4.1.2-srcs.tar.xz, that proved to be a source of errors and problems in the past. I preferred to play it safe and build a stand alone package following the same procedure described in the LibreOffice 6.4 related web page.

OpenJDK

OpenJDK is a Software Development Kit for the Java programming language, needed to write new programs and applications. LibreOffice includes many Java libraries, to connect to database servers and more. LibreOffice cannot be successfully built unless a recent working JDK is installed on the operating system. I had previously installed an OpenJDK 8 package provided by the Sarpi project. The very same package turned out to be outdated for LibreOffice 7.0 and I was in need of a newer release. I installed an OpenJDK 11 package provided by the AdoptOpenJDK project web site. Newer versions exist already, but release 11 offers long term support that guarantees a certain degree of stability. The mentioned web site provides both a 32 bit (arm32) and 64 bit (aarch64) version. The required version is the 32 bit one because Slackware Arm does not provide support for any 64 bit platform yet.

Alternatively you could build your own version of OpenJDK from scratch. That is no easy task requiring a lot of time and effort, therefore I suggest using the pre-built packages, at least initially.

RedLand

RedLand is a library of software functions written in C programming language LibreOffice leans on. I used the version included in the additional source code archive. All of the LibreOffice required libraries are included in the libreoffice-7.0.3.1-srcs.tar.xz archive file.

Remove Any Installed LibreOffice Release

Installed versions of LibreOffice should always be removed before you start building a new one, otherwise errors will raise when the script detects the presence of old system programs and settings. After you remove previously installed versions, please clean some leftover environment variables running commands:

   unset UNO_PATH
   unset URE_BOOTSTRAP

or executing a log out followed by a new authentication to reload the environment, or again rebooting your Linux box.

Patch no-check-if-root

Packages are usually built by user root in Slackware Linux unlike other distributions. LibreOffice developers prefer to avoid building by root and provide a check to prevent the source code from being compiled by a high privileged user such as the administrator. To work around the problem, the www.slackbuilds.org project includes the no-check-if-root.diff file which removes all checks allowing the SlackBuild script to work. The patch included in the slackbuilds.org compressed archive file works well with LibreOffice 6.4, but requires editing to work with 7.0.3.1. An updated patch menat for release 7.0.3.1 of the source code follows:

   --- Makefile.orig    2018-02-07 22:18:13.161535968 +1000
   +++ Makefile 2018-02-07 22:17:41.560533422 +1000
   @@ -9,7 +9,7 @@
    
    gb_Top_MODULE_CHECK_TARGETS := slowcheck unitcheck subsequentcheck perfcheck uicheck screenshot
    
   -.PHONY : check-if-root bootstrap gbuild build build-non-l10n-only build-l10n-only check clean clean-build clean-host test-install distclean distro-pack-install docs download etags fetch get-submodules id install install-gdb-printers install-strip tags debugrun help showmodules translations packageinfo internal.clean $(gb_Top_MODULE_CHECK_TARGETS)
   +.PHONY : bootstrap gbuild build build-non-l10n-only build-l10n-only check clean clean-build clean-host test-install distclean distro-pack-install docs download etags fetch get-submodules id install install-gdb-printers install-strip tags debugrun help showmodules translations packageinfo internal.clean $(gb_Top_MODULE_CHECK_TARGETS)
    
    MAKECMDGOALS?=all
    build_goal:=$(if $(filter build check,$(MAKECMDGOALS)),all)\
   @@ -268,7 +268,7 @@
    #
    # Bootstrap
    #
   -bootstrap: check-if-root compilerplugins
   +bootstrap: compilerplugins
    
    #
    # Build

The file no-check-if-root.diff included in the archive should be replaced with a new one, bearing the same name, but containing the above lines.

For your convenience I share a link to the updated patch. Download and unzip it, move it in the directory where the SlackBuild script LibreOffice.SlackBuild is located overwriting the existing no-check-if-root.diff file.

To check for the patch archive consistency and ensure its safety, please confront its checksum values with the following ones:

   md5: 8d2ebf2aad015833692a2091a5310a30
   SHA512: be3cb2d237b1991e978186c1dcab837887b5ff31c1ee8a98c14d652a673ac764fc5efff83726ddf459a245bc205951f9d7bf8717e6268c9b36da59a9fb042796

Build Script

The LibreOffice build script] requires some updates to work. Please follow the instructions of my previous article to apply them. Moreover yuo need to add some lines of code specifically for gcc 10.

   # GCC10 requirements (Tx alienBOB)
   # From http://cgit.ponce.cc/slackbuilds/commit/?h=LibreOffice
   sed -i external/libcdr/ExternalProject_libcdr.mk \
      -e '/configure /i \\t\t&& sed -i "s/TRUE/true/g" src/lib/libcdr_utils.cpp \\'
   sed -i external/libebook/ExternalProject_libebook.mk \
      -e '/configure /i \\t\t&& sed -i "s/TRUE/true/g" src/lib/EBOOKCharsetConverter.cpp \\'
   sed -i i18npool/source/calendar/calendar_gregorian.cxx -e 's/TRUE/true/'

The issue was discussed by both Alien Bob, in his blog, and members of the www.slacky.it forum. My thanks to both for the tip.

For your commodity I share a link to the whole updated SlackBuild file]. Download and unzip it, then replace the one provided by www.slackbuilds.org in their archive.

Download it with wget:

   '''wget''' http://www.giustetti.net/resource/slackbuild/libreoffice-6.4.1.2/LibreOffice.SlackBuild.gz

Check the integrity of the downloaded archive against its checksum values:

   md5: 296dd03a782f0cafc2d366554186a35c
   SHA512: 65af0d178abe33642c785886a631098b97c204a6a4deec101b4c7dd3f9e0b18e45d24451b320a6d1676459e4bab0e6ab8338097b2545baa95375e475b185644b

Unzip it with command:

   gunzip ./LibreOffice.SlackBuild.gz

Assign it execution permissions

   chmod u+x ./LibreOffice.SlackBuild

Overwrite the original script and start building:

   sh ./LibreOffice.SlackBuild

Please do not ask the original script author for help regarding my updated version.

.desktop Files

Files with the .desktop extension are used to register installed programs in menus of graphical user interface like Gnome, KDE, TDE or XFCE. The LibreOffice suite includes a multitude of applications with a wide range of functionality: writer, a word processor, calc, a spreadsheet software, draw, a vector drawing software and so on. Menu entries are very helpful to start a program without having to run it through the command line. The build script I provide saves the .desktop files into the /opt directory along the libraries, the executable files, and many other resources, but GUIs search for them in the /usr directory meaning the related menu entries do not appear in any panel. You can correct this minor nuisance in one of three ways:

  1. Copy the files, move them or link them in directory /usr/share/applications.
  2. Rebuild LibreOffice setting /usr instead of /opt as its root directory.
  3. Modify the SlackBuild script adding the commands required to move .desktop files in the proper directory while building the package.

The former require users to manually delete files or links when uninstalling LibreOffice, to avoid leaving dead files through the file system. The second option is enforced by the majority of Linux distributions and causes a single directory to be cluttered by a multitude of programs, libraries, applications and so on. The latter is probably the best one, at least in my opinion. When files are properly arranged in a package, they can be manages easily recurring to the package managers and users do not risk the issues afflicting the first of the three solutions proposed when uninstalling packages.

My sincere thanks to Mr. Ananda Murthy for pointing this out.


CONCLUSIONS

This article delves once more about building a recent version of LibreOffice on a Raspberry Pi 4. Recent Slackware Arm updates caused old versions of the software to fail and required installing a newer one. All the updates made to the original script and patch are included, as well as instructions required to successfully execute the task. Moreover I included copies of the updated SlackBuild script and patch.


For any feedback, questions, errors and such, please e-mail me at studiosg [at] giustetti [dot] net


External links





Languages: English - Italiano