From ff5455881eed5d7750a804c090b8b02539fa4bf4 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Sun, 5 Nov 2023 20:50:33 +0100 Subject: [PATCH] chore(libreoffice): switch to unoconverter (#715) --- build/Dockerfile | 12 ++++----- pkg/modules/libreoffice/api/api.go | 8 +++--- pkg/modules/libreoffice/api/api_test.go | 6 ++--- .../libreoffice/api/libreoffice_test.go | 26 +++++++++---------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 3f257c8e..5adcec26 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -138,17 +138,17 @@ RUN \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN \ - # Install LibreOffice & unoconv. + # Install LibreOffice & unoconverter. echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list &&\ apt-get update -qq &&\ DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends -t bookworm-backports libreoffice &&\ - curl -Ls https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv -o /usr/bin/unoconv &&\ - chmod +x /usr/bin/unoconv &&\ - # unoconv will look for the Python binary, which has to be at version 3. + curl -Ls https://raw.githubusercontent.com/gotenberg/unoconverter/v0.0.1/unoconv -o /usr/bin/unoconverter &&\ + chmod +x /usr/bin/unoconverter &&\ + # unoconverter will look for the Python binary, which has to be at version 3. ln -s /usr/bin/python3 /usr/bin/python &&\ # Verify installations. libreoffice --version &&\ - unoconv --version &&\ + unoconverter --version &&\ # Cleanup. rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* @@ -181,7 +181,7 @@ COPY --from=binary-stage /home/gotenberg /usr/bin/ # Environment variables required by modules or else. ENV CHROMIUM_BIN_PATH /usr/bin/chromium ENV LIBREOFFICE_BIN_PATH /usr/lib/libreoffice/program/soffice.bin -ENV UNOCONV_BIN_PATH /usr/bin/unoconv +ENV UNOCONVERTER_BIN_PATH /usr/bin/unoconverter ENV PDFTK_BIN_PATH /usr/bin/pdftk ENV QPDF_BIN_PATH /usr/bin/qpdf diff --git a/pkg/modules/libreoffice/api/api.go b/pkg/modules/libreoffice/api/api.go index 415bc1f8..8e863355 100644 --- a/pkg/modules/libreoffice/api/api.go +++ b/pkg/modules/libreoffice/api/api.go @@ -30,7 +30,7 @@ var ( ErrMalformedPageRanges = errors.New("page ranges are malformed") ) -// Api is a module which provides an [Uno] to interact with LibreOffice. +// Api is a module which provides a [Uno] to interact with LibreOffice. type Api struct { autoStart bool args libreOfficeArguments @@ -115,9 +115,9 @@ func (a *Api) Provision(ctx *gotenberg.Context) error { return errors.New("LIBREOFFICE_BIN_PATH environment variable is not set") } - unoBinPath, ok := os.LookupEnv("UNOCONV_BIN_PATH") + unoBinPath, ok := os.LookupEnv("UNOCONVERTER_BIN_PATH") if !ok { - return errors.New("UNOCONV_BIN_PATH environment variable is not set") + return errors.New("UNOCONVERTER_BIN_PATH environment variable is not set") } a.args = libreOfficeArguments{ @@ -155,7 +155,7 @@ func (a *Api) Validate() error { _, statErr = os.Stat(a.args.unoBinPath) if os.IsNotExist(statErr) { - err = multierr.Append(err, fmt.Errorf("uno binary path does not exist: %w", statErr)) + err = multierr.Append(err, fmt.Errorf("unoconverter binary path does not exist: %w", statErr)) } return err diff --git a/pkg/modules/libreoffice/api/api_test.go b/pkg/modules/libreoffice/api/api_test.go index 7e126aee..aa220fb7 100644 --- a/pkg/modules/libreoffice/api/api_test.go +++ b/pkg/modules/libreoffice/api/api_test.go @@ -118,13 +118,13 @@ func TestApi_Validate(t *testing.T) { { scenario: "empty LibreOffice bin path", binPath: "", - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), expectError: true, }, { scenario: "LibreOffice bin path does not exist", binPath: "/foo", - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), expectError: true, }, { @@ -142,7 +142,7 @@ func TestApi_Validate(t *testing.T) { { scenario: "validate success", binPath: os.Getenv("CHROMIUM_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), expectError: false, }, } { diff --git a/pkg/modules/libreoffice/api/libreoffice_test.go b/pkg/modules/libreoffice/api/libreoffice_test.go index 67642cfb..4a205c99 100644 --- a/pkg/modules/libreoffice/api/libreoffice_test.go +++ b/pkg/modules/libreoffice/api/libreoffice_test.go @@ -26,7 +26,7 @@ func TestLibreOfficeProcess_Start(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -48,7 +48,7 @@ func TestLibreOfficeProcess_Start(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: "foo", - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -92,7 +92,7 @@ func TestLibreOfficeProcess_Stop(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -147,7 +147,7 @@ func TestLibreOfficeProcess_Healthy(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -254,7 +254,7 @@ func TestLibreOfficeProcess_pdf(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -284,7 +284,7 @@ func TestLibreOfficeProcess_pdf(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -312,7 +312,7 @@ func TestLibreOfficeProcess_pdf(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -340,7 +340,7 @@ func TestLibreOfficeProcess_pdf(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -369,7 +369,7 @@ func TestLibreOfficeProcess_pdf(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -398,7 +398,7 @@ func TestLibreOfficeProcess_pdf(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -427,7 +427,7 @@ func TestLibreOfficeProcess_pdf(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -456,7 +456,7 @@ func TestLibreOfficeProcess_pdf(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ), @@ -485,7 +485,7 @@ func TestLibreOfficeProcess_pdf(t *testing.T) { libreOffice: newLibreOfficeProcess( libreOfficeArguments{ binPath: os.Getenv("LIBREOFFICE_BIN_PATH"), - unoBinPath: os.Getenv("UNOCONV_BIN_PATH"), + unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"), startTimeout: 5 * time.Second, }, ),