Skip to content

Instantly share code, notes, and snippets.

@hbrunn
Last active November 10, 2020 05:16
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save hbrunn/6f4a007a6ff7f75c0f8b to your computer and use it in GitHub Desktop.
Save hbrunn/6f4a007a6ff7f75c0f8b to your computer and use it in GitHub Desktop.
This is an instruction how to rebuild libreoffice on ubuntu trusty to use python-uno for python 2.7
# we need some fixes from 14.10
sudo add-apt-repository --enable-source ppa:libreoffice/libreoffice-4-3
# fetch this repository
sudo apt-get update
# update your libreoffice installation
sudo apt-get install libreoffice
# get all build dependencies for libreoffice
sudo apt-get build-dep libreoffice
# that strangely enough doesn't come with the above
sudo apt-get install gcj-jdk python-dev
# get the actual source code
cd /tmp
apt-get source libreoffice
# the folder name is versioned
cd libreoffice*
# we want to have python2
sed -ie 's/^\(ENABLE_PYTHON2=\)n$/\1y/' debian/rules
# and we add the package description to the control file (this is from the debian package)
echo "
Package: python-uno
Provides: \${python:Provides}
XB-Python-Version: \${python:Versions}
Section: oldlibs
Priority: extra
Architecture: alpha amd64 armel armhf hppa i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc powerpcspe ppc64 s390 s390x sparc
Enhances: libreoffice
Depends: libreoffice-core (= \${binary:Version}),
\${misc:Depends},
\${python:Depends},
\${shlibs:Depends}
Breaks: libreoffice-common (<< 1:3.5~), libreoffice-core (<< 1:3.5~)
Conflicts: python3-uno, python3.3-uno
Description: Python-UNO bridge (support for old python 2)
The Python-UNO bridge allows use of the standard LibreOffice API
with the Python scripting language. It additionally allows
others to develop UNO components in Python, thus Python UNO components
may be run within the LibreOffice process and can be called from C++
or the built in StarBasic scripting language.
.
This package is for compatibility with applications/libraries not ported
to python 3 yet. Prefer python3-uno over this.
Homepage: http://udk.openoffice.org/python/python-bridge.html" >> debian/control
# do the build
dpkg-buildpackage -us -uc
# have coffee. a lot of it
# install updated metapackage and the script provider so as not to depend on python3-uno any more
sudo dpkg --install ../libreoffice_*.deb ../libreoffice-script-provider-python*.deb
# remove python3-uno
sudo apt-get remove python3-uno
# and finally install the package we want
sudo dpkg --install ../python-uno*.deb
@XaRz
Copy link

XaRz commented Sep 30, 2014

I was tryng these several times on my ubuntu 14.04 and the build fails. Perhaps is a space problem though because this beast consumes 10Gb of my vm and Iwas recieving disk space warnings.

On the other hand, I'm wondering if it's the way to go, only to suport aeroo reports. Perhaps I must desist and try the new qweb reports..I'll think about it.

@kurtcoke
Copy link

I think you probably need to mark those packages to not be updated by apt-get/aptitude.

These are the packages that I thought should be held back (not updated) during update/upgrade.

$ echo libreoffice-common hold | sudo dpkg --set-selections
$ echo libreoffice-core hold | sudo dpkg --set-selections
$ echo python-uno hold | sudo dpkg --set-selections
 

$ sudo apt-mark hold python-uno
$ sudo apt-mark hold libreoffice-common
$ sudo apt-mark hold libreoffice-core

@JurassicPork
Copy link

hello,
to execute the script, you need at least 35 Gb of free disk space.
Time to execute the script > 5 hours ( quadcore 2.5 ghz)

to use libreoffice with aeroo / openerp :
need to add /usr/lib/libreoffice/program to Pythonpath to resolve No module named pyuno
in /usr/bin/openerp-server file add :
import sys
sys.path.append('/usr/lib/libreoffice/program')

but now i have this big problem :
No module named com.sun.star.lang
seems to be an environment problem with python-uno python 2.7
when i use python-uno , in writer Tools>Macros>Organize>Python>Libreoffice macros
i can't see the sample macros (for example HelloWorld)
when i use python3-uno i see sample macros and i can execute them.

@n-epifanov
Copy link

n-epifanov commented Feb 27, 2018

PPA used in this script doesn't exist anymore and another PPA with LibreOffice 4.4 fails to build.
Here is an up-to-date script https://gist.github.com/nicktime/364a80ad0e083948b9f873640e50fe89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment