How to create a .patch file?

Creating a patch file is a basic operation during the building of the packages. You seem to know how to do it. If so, this article lets you visualize a stage where I built the Omarine operating system. If you are a beginner, this article provides detailed instructions on how to create patch files and to patch code.

The Poppler package contains a PDF rendering library and command line tools that are used to manipulate PDF files. Version 0.71.0 of Poppler does not define the GBool data type and the gTrue, gFalse Boolean values. Therefore dependent packages that use old code such as Libreoffice 6.1.3.2 need to be patched.
First, you rename the libreoffice-6.1.3.2 directory to libreoffice-6.1.3.2.old:

mv libreoffice-6.1.3.2 libreoffice-6.1.3.2.old

Then create a replica directory libreoffice-6.1.3.2.new:

cp -r libreoffice-6.1.3.2.old libreoffice-6.1.3.2.new

The libreoffice-6.1.3.2.new/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx file needs to be modified by adding the definition for GBool, gTrue, gFalse, inserting them into line 23:

sed -i '23 i typedef bool GBool;\n#define gTrue true\n#define gFalse false\n' \
    libreoffice-6.1.3.2.new/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx

Now we create the libreoffice-6.1.3.2-poppler71-1.patch file:

diff -Naur libreoffice-6.1.3.2.old/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx \
    libreoffice-6.1.3.2.new/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx > libreoffice-6.1.3.2-poppler71-1.patch

The contents of the patch file are as follows:

--- libreoffice-6.1.3.2.old/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx 2018-10-30 02:55:29.000000000 +0700
+++ libreoffice-6.1.3.2.new/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx 2018-12-02 09:55:57.250834967 +0700
@@ -20,6 +20,10 @@
#ifndef INCLUDED_SDEXT_SOURCE_PDFIMPORT_XPDFWRAPPER_PDFIOUTDEV_GPL_HXX
#define INCLUDED_SDEXT_SOURCE_PDFIMPORT_XPDFWRAPPER_PDFIOUTDEV_GPL_HXX

+typedef bool GBool;
+#define gTrue true
+#define gFalse false
+
#include <sal/types.h>
#include <config_poppler.h>

Performing the patch
Patches can be applied to build package multiple times from the source code. You run the following command:

patch -Np1 -i ../libreoffice-6.1.3.2-poppler71-1.patch

Secret: Omarine 6.0 will be released tomorrow (03/Dec/2018).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.