Skip to content

Bundling LibreOffice

probonopd edited this page Feb 24, 2018 · 17 revisions

Note that LibreOffice now provides official AppImage downloads at https://www.libreoffice.org/download/appimage/

This is the script I use to bundle LibreOffice (and OpenOffice): https://github.com/AppImage/AppImages/blob/master/recipes/libreoffice/Recipe

Please note that this page is outdated, as LibreOffice provides official AppImages now at https://www.libreoffice.org/download/appimage/.

Daily builds

To bundle daily LibreOffice builds with all languages (this also sets a private settings directory for each build):

#!/bin/bash -x

# Generate daily LibreOffice AppImage
# by Simon Peter
# Released under the Mozilla Public License Version 2.0
# http://www.libreoffice.org/about-us/licenses/

set +e

APP=LibreOfficeDev

# Determine version
DLD=$(wget -q "http://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@70-TDF/current/" -O - | grep -o -e ">mas.*Linux_x86-64_deb.tar.gz" | cut -d ">" -f 2)
OOODOWNLOADLINK='http://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@70-TDF/current/'${DLD}
VERSION1=$(echo "$DLD" | cut -d "_" -f 4)
VERSION2=$(echo "$DLD" | cut -d "_" -f 2)
export VERSION="${VERSION1}.${VERSION2}"
echo "$VERSION"
FILES=$(wget -q "http://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@70-TDF/current/" -O - | grep -e ".*_deb.*gz" | cut -d '"' -f 6 | grep -v sdk)

# Get all download URLs
for FILE in $FILES ; do
  URLS="$URLS http://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@70-TDF/current/$FILE"
done
echo $URLS

if [ -e ./$APP/$APP.AppDir ] ; then
  rm -rf ./$APP/$APP.AppDir || true
fi
mkdir -p ./$APP/$APP.AppDir
cd ./$APP || exit

wget -c $URLS

find . -name "*.tar.gz" -exec tar xfvz {} \;

cd $APP.AppDir/ || exit

DEBS=$(find ../ -name "*.deb")
for DEB in $DEBS; do
  ar p "$DEB" data.tar.gz | tar zx
done

# Do not hardcode the version in the path
mv $(readlink -f "./opt/libreofficedev*") ./opt/libreofficedev


find . -name startcenter.desktop -exec cp \{\} . \;

# No, dear LibreOffice developers, "Name=LibreOffice 5.x"
# is not a good .desktop file entry. There should be a SoftwareVersion=
# entry in the Desktop Entry Specification, but there isn't
sed -i -e 's|Name=.*|Name=LibreOfficeDev|g' startcenter.desktop

find . -name "*startcenter.png" -path "*hicolor*256x256*" -exec cp \{\} . \;

BINARY=$(cat ./*.desktop | grep "Exec=" | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 1)

mkdir -p usr/bin/
cd usr/bin/ || exit
rm ./"$BINARY"
find ../../opt -name soffice -path "*program*" -exec ln -s \{\} ./"$BINARY" \;
cd ../../ || exit

# Dear LibreOffice devs, please (also) put an AppStream file
# into usr/share/appdata/ that describes LibreOffice as a whole
# (e.g., usr/share/appdata/libreofficedev5.4-startcenter.appdata.xml)
# as AppImages need one clear entry point rather than multiple ones
# Thanks!

# For testing purposes, use different versions of LibreOffice
# for testing of any bugs, thus edit the file bootstraprc
# to generate a clean user folder for each daily version, e.g.,
# UserInstallation=$SYSUSERCONFIG/libreofficedev/5.4.0.0.alpha0.05.59.04
sed -i -e 's|^UserInstallation=.*|UserInstallation=$SYSUSERCONFIG/libreofficedev/'$VERSION'|g' ./opt/libreoffice*/program/bootstraprc

ln -s ./opt/libreofficedev/program/soffice ./AppRun

cd ..

sudo find *.AppDir/ -type f -executable -or -name *.so* -exec strip {} \;

# TODO: Integrate Update Information for AppImageUpdate binary delta updates

wget -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod a+x appimagetool-x86_64.AppImage
# --comp xz to get a smaller but somewhat slower-launching AppImage
./appimagetool-x86_64.AppImage ./LibreOfficeDev.AppDir -n -u 'zsync|http://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@70-TDF/current/LibreOfficeDev-daily-x86_64.AppImage.zsync'
mv LibreOfficeDev-*.AppImage.zsync LibreOfficeDev-daily-x86_64.AppImage.zsync

echo ""
echo "PLEASE NOTE:"
echo ""
echo "For binary delta updates to work, you need to copy the"
echo "zsync file to the following URL:"
echo "http://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@70-TDF/current/LibreOfficeDev-daily-x86_64.AppImage.zsync"
echo "Put the AppImage into the same directory, without renaming it."
echo "Then you should be able to run AppImageUpdate and only download"
echo "the few MB that have changed from build to build."
echo ""

References

Clone this wiki locally