Skip to content

Bundling LibreOffice

probonopd edited this page Jun 5, 2017 · 17 revisions

This is the script I use to bundle LibreOffice (and OpenOffice).

VERSION=$(wget http://www.openoffice.org/download/globalvars.js -O - | grep -e "DL.VERSION" | head -n 1 | cut -d '"' -f 2)
./doit.sh http://downloads.sourceforge.net/project/openofficeorg.mirror/${VERSION}/binaries/en-US/Apache_OpenOffice_${VERSION}_Linux_x86-64_install-deb_en-US.tar.gz

VERSION=$(wget "http://www.libreoffice.org/download/libreoffice-fresh/" -O - | grep -o -e "/dl/src/.*/all/" | cut -d "/" -f 4 | head -n 1)
./doit.sh http://download.documentfoundation.org/libreoffice/stable/${VERSION}/deb/x86_64/LibreOffice_${VERSION}_Linux_x86-64_deb.tar.gz
#!/bin/bash -x

set +e

OOODOWNLOADLINK="$1"

if [ "x$OOODOWNLOADLINK" ==  "x" ] ; then
  echo "Usage: $0 http://downloads.sourceforge.net/project/openofficeorg.mirror/4.1.0/binaries/en-US/Apache_OpenOffice_4.1.0_Linux_x86-64_install-deb_en-US.tar.gz"
  exit 1
fi

# if [ -e ./ooo ] ; then
  # echo "./ooo exists; exiting"
  # exit 1
# fi

mkdir -p ./ooo/ooo.AppDir
cd ./ooo

wget --timestamping -c "$OOODOWNLOADLINK"

tar xfvz *.tar.gz
# rm *.tar.gz

cd ooo.AppDir/

find ../ -name *.deb -exec dpkg -x \{\} . \;

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

find -name *startcenter.png -path *hicolor*48x48* -exec cp \{\} . \;

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

# sed -i -e 's|/opt|../opt|g' ./usr/bin/$BINARY
cd usr/bin/
rm ./$BINARY
find ../../opt -name soffice -path *program* -exec ln -s \{\} ./$BINARY \;
cd ../../

# (64-bit)
wget -c "https://downloads.sourceforge.net/project/portable/64bit/AppRun"
# or (32-bit)
wget -c "https://downloads.sourceforge.net/project/portable/AppRun"

chmod a+x ./AppRun

# Try to run ./AppRun

cd ..

wget -c "https://github.com/AppImage/AppImageKit/releases/download/9/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 -n ./ooo.AppDir/

Daily builds

To bundle daily LibreOffice builds (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
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"

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

wget -c "$OOODOWNLOADLINK"

tar xfvz ./*.tar.gz

cd $APP.AppDir/ || exit

# Do not hardcode the version in the path
mv ./opt/libreofficedev* ./opt/libreofficedev

find ../ -name "*.deb" -exec dpkg -x \{\} . \;

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 ..

# TODO: Integrate Update Information for AppImageUpdate binary delta updates

wget -c "https://github.com/AppImage/AppImageKit/releases/download/9/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 ""