Skip to content

Commit

Permalink
fix for old-stable debian packaging + add workaround to replace unoconv
Browse files Browse the repository at this point in the history
  • Loading branch information
neowutran committed May 2, 2020
1 parent 5b8b11f commit c30ec96
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
2 changes: 1 addition & 1 deletion archlinux/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ arch=(x86_64)
pkgdesc=$(grep "Summary:" ./rpm_spec/qpdf-converter.spec.in | sed 's/Summary://' | xargs)
url=$(git remote get-url origin)
license=(GPL)
depends=(unoconv graphicsmagick zenity poppler python-nautilus)
depends=(libreoffice graphicsmagick zenity poppler python-nautilus file net-tools)

build() {
ln -s "$srcdir"/../ "$srcdir/src"
Expand Down
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
6 changes: 4 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ Source: qubes-pdf-converter
Section: admin
Priority: optional
Maintainer: Jason Mehring <[email protected]>
Build-Depends: pandoc, debhelper-compat (= 10)
Build-Depends: pandoc, debhelper (>= 9)
# For the futures version of debian, delete the "compat" file, and add the line below in "Build-Depends"
# debhelper-compat (= 12)
Standards-Version: 4.5.0
Homepage: https://github.com/QubesOS/qubes-app-linux-pdf-converter

Package: qubes-pdf-converter
Section: admin
Architecture: any
Depends: poppler-utils, unoconv, graphicsmagick, python-nautilus, ${misc:Depends}
Depends: poppler-utils, net-tools, file, libreoffice, graphicsmagick, python-nautilus, ${misc:Depends}
Description: The Qubes service for converting untrusted PDF files into trusted ones
45 changes: 42 additions & 3 deletions qpdf-convert-server
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,51 @@ application/pdf)
done
;;
*)
# Start libreoffice server
libreoffice --accept='socket,host=localhost,port=2202;urp;' --norestore --nologo --nodefault >/dev/null 2>/dev/null &
listener_notready=1

# Wait until libreoffice server is started
while [ $listener_notready -ne 0 ];
do
sleep 1
netstat -anop 2> /dev/null | grep '127.0.0.1:2202' | grep LISTEN >/dev/null 2>/dev/null
listener_notready=$?
done

# Remove password from file using libreoffice API
while [ $PASSWORD_SUCCESS -eq 0 ] ; do
unoconv --password="$PASSWORD" -o "$INPUT_FILE""unoconv" "$INPUT_FILE" >&2
python3 -c '
import os
import uno
from com.sun.star.beans import PropertyValue
import sys
src="file://'"$INPUT_FILE"'"
dst="file://'"$INPUT_FILE.nopassword"'"
password="'"$PASSWORD"'"
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
ctx = resolver.resolve("uno:socket,host=localhost,port=2202;urp;StarOffice.ComponentContext")
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
hidden_property = PropertyValue()
hidden_property.Name = "Hidden"
hidden_property.Value = True
password_property = PropertyValue()
password_property.Name = "Password"
password_property.Value = password
document = desktop.loadComponentFromURL(src, "_blank", 0, (password_property, hidden_property,))
document.storeAsURL(dst, ())' >&2
ERROR_CODE=$?
read_password $(( ERROR_CODE != 5 && ERROR_CODE != 6 ))
read_password $(( ERROR_CODE == 0 ))
done
mv "$INPUT_FILE""unoconv.pdf" "$INPUT_FILE"
libreoffice --convert-to pdf "$INPUT_FILE.nopassword" --outdir /tmp/ >&2
mv "$INPUT_FILE"".pdf" "$INPUT_FILE"
;;
esac
# now, let's convert it into a simple representation,
Expand Down
2 changes: 1 addition & 1 deletion rpm_spec/qpdf-converter.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ URL: https://github.com/QubesOS/qubes-app-linux-pdf-converter

BuildRequires: pandoc

Requires: poppler-utils GraphicsMagick unoconv
Requires: poppler-utils GraphicsMagick libreoffice file net-tools
Requires: nautilus-python

Source0: %{name}-%{version}.tar.gz
Expand Down

0 comments on commit c30ec96

Please sign in to comment.