libreoffice.SlackBuild 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #!/bin/bash
  2. # Slackware build script for LibreOffice
  3. # Copyright 2006.2007.2008,2009,2010 Robby Workman, Northport, Alabama, USA
  4. # Copyright 2010-2014 Niels Horn, Rio de Janeiro, RJ, Brazil
  5. # Copyright 2014-2022 Willy Sudiarto Raharjo <willysr@slackbuilds.org>
  6. # All rights reserved.
  7. #
  8. # Redistribution and use of this script, with or without modification, is
  9. # permitted provided that the following conditions are met:
  10. #
  11. # 1. Redistributions of this script must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. #
  14. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  15. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  17. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  20. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  22. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  23. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. cd $(dirname $0) ; CWD=$(pwd)
  25. PRGNAM=libreoffice
  26. VERSION=${VERSION:-"7.3.2"}
  27. BUILD=${BUILD:-1}
  28. TAG=${TAG:-_SBo}
  29. PKGTYPE=${PKGTYPE:-tgz}
  30. # These variables seem to change with (almost) every release...
  31. SRCVERSION=$VERSION
  32. SRCSHORT=$(echo $VERSION | cut -f1-2 -d.)
  33. if [ -z "$ARCH" ]; then
  34. case "$( uname -m )" in
  35. i?86) ARCH=i586 ;;
  36. arm*) ARCH=arm ;;
  37. *) ARCH=$( uname -m ) ;;
  38. esac
  39. fi
  40. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  41. # the name of the created package would be, and then exit. This information
  42. # could be useful to other scripts.
  43. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  44. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  45. exit 0
  46. fi
  47. TMP=${TMP:-/tmp/SBo}
  48. PKG=$TMP/package-$PRGNAM
  49. OUTPUT=${OUTPUT:-/tmp}
  50. # Until now all releases were without the JRE...
  51. WJRE=${WJRE:-no}
  52. # If you want to disable java support by removing executable permissions
  53. # form LibreOffice's java loader (this will not affect other apps), set this
  54. # variable to "YES" Default is "NO"
  55. DISABLE_JAVA=${DISABLE_JAVA:-NO}
  56. # Change source package name
  57. if [ "$ARCH" = "x86_64" ]; then
  58. SRCARCH="x86-64"
  59. PKGARCH="$ARCH"
  60. elif [ "$ARCH" = "arm" ]; then
  61. printf "\n$ARCH is unsupported for LibreOffice...\n\n"
  62. exit 1
  63. else
  64. SRCARCH="x86"
  65. PKGARCH="i586"
  66. fi
  67. if [ $WJRE != no ]; then
  68. TARJRE="-wJRE"
  69. else
  70. TARJRE=""
  71. fi
  72. # We have all the variables, construct the name of the tarball
  73. TARNAME="LibreOffice_${SRCVERSION}_Linux_${SRCARCH}_rpm${TARJRE}.tar.gz"
  74. if [ ! -r $TARNAME ]; then
  75. echo "$TARNAME not found"
  76. exit 1
  77. fi
  78. # Ignore this - it's just to get the toplevel directory name of the
  79. # extracted tarball archive
  80. SOURCEDIR=$(tar tzf $CWD/$TARNAME 2>/dev/null | head -n 1 | tr -d \/)
  81. # If the above operation failed for some reason, unset SOURCEDIR so that
  82. # the "set -eu" below will cause us to bail out with an error
  83. [ -z $SOURCEDIR ] && unset SOURCEDIR
  84. set -eu
  85. rm -rf $PKG
  86. mkdir -p $TMP $PKG $OUTPUT
  87. rm -rf $TMP/$SOURCEDIR
  88. # Extract tarball
  89. tar xvf $CWD/$TARNAME -C $TMP
  90. # We'll remove this regardless of whether we're using the jre tarball...
  91. rm -rf $TMP/$SOURCEDIR/{JavaSetup.jar,installdata,setup}
  92. rm -rf $TMP/$SOURCEDIR/RPMS/{userland,jre-*-linux-*.rpm}
  93. cd $TMP/$SOURCEDIR/RPMS/
  94. # No, I don't want to update our packaged files after the fact
  95. rm -f *onlineupdate*.rpm # We don't want this
  96. for FILE in *.rpm ; do rpm2cpio < $FILE | cpio -imdv ; done
  97. rm -rf desktop-integration *.rpm
  98. mv opt usr $PKG
  99. cd $PKG
  100. # Kill a broken symlink
  101. rm -f $PKG/usr/share/applications/libreoffice3-startcenter.desktop
  102. # Create symlinks in /usr/bin to actual binaries
  103. cd $PKG/usr/bin
  104. for FILE in \
  105. sbase scalc sdraw simpress smath soffice swriter unopkg ; do
  106. rm -f $FILE
  107. ln -sf ../../opt/libreoffice$SRCSHORT/program/$FILE $FILE ;
  108. done
  109. # The symlinks below are required to (directly) open documents
  110. # supported by libreoffice with Xfe file manager.
  111. ln -sf ../../opt/libreoffice$SRCSHORT/program/sbase lobase
  112. ln -sf ../../opt/libreoffice$SRCSHORT/program/scalc localc
  113. ln -sf ../../opt/libreoffice$SRCSHORT/program/sdraw lodraw
  114. ln -sf ../../opt/libreoffice$SRCSHORT/program/simpress loimpress
  115. ln -sf ../../opt/libreoffice$SRCSHORT/program/smath lomath
  116. ln -sf ../../opt/libreoffice$SRCSHORT/program/swriter lowriter
  117. cd -
  118. # the .desktop files installed in /opt/libreoffice<VER>/share/xdg and
  119. # symlinks to that files in /usr/share/applications have version number
  120. # in their name (ex libreoffice6.1-writer.desktop) which force user to
  121. # re-create/update any link/reference (ex: on KDE/XFCE desktop, in fluxbox
  122. # menu file, in wmalauncher configuration file,...) to that files on each
  123. # libreoffice version number increment.
  124. #
  125. # To avoid that, the code below deletes the "versioned" symlinks
  126. # and creates news without version number in their names.
  127. #
  128. cd $PKG/usr/share/applications
  129. for APP in base calc draw impress math startcenter writer xsltfilter ; do
  130. rm -f $PRGNAM$SRCSHORT-$APP.desktop
  131. ln -sf ../../../opt/libreoffice$SRCSHORT/share/xdg/$APP.desktop $PRGNAM-$APP.desktop
  132. done
  133. cd -
  134. # Remove DejaVu and Liberation fonts - these are included in other packages
  135. rm -f opt/libreoffice$SRCSHORT/share/fonts/truetype/{DejaVu,Liberation}*.ttf
  136. # Fix Exec commands in the desktop files
  137. # See http://bugzilla.xfce.org/show_bug.cgi?id=2430
  138. cd $PKG/opt/libreoffice$SRCSHORT/share/xdg/
  139. for APP in base calc draw impress math writer; do
  140. sed -i "s%Exec=libreoffice -%Exec=/opt/libreoffice$SRCSHORT/program/s%" $APP.desktop ;
  141. done
  142. cd -
  143. # Move docs to their expected locations
  144. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  145. cd $PKG/opt/libreoffice$SRCSHORT
  146. mv CREDITS* *LICENSE* readmes $PKG/usr/doc/$PRGNAM-$VERSION
  147. cd -
  148. # Remove executable flag from some docs
  149. cd $PKG/usr/doc/$PRGNAM-$VERSION
  150. find . -type f -exec chmod -x {} \;
  151. cd -
  152. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  153. # Disable Java support if desired (see above)
  154. if [ "$DISABLE_JAVA" = "YES" ]; then
  155. chmod -x $PKG/opt/libreoffice$SRCSHORT/program/javaldx
  156. fi
  157. # Add libreoffice.sh to set SAL_USE_VCLPLUGIN=gtk
  158. mkdir -p $PKG/etc/profile.d/
  159. install -m755 $CWD/libreoffice.sh $PKG/etc/profile.d/
  160. mkdir -p $PKG/install
  161. cat $CWD/slack-desc > $PKG/install/slack-desc
  162. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  163. # Fix ownership and permissions and make the package
  164. chown -R root:root .
  165. find . -type d -exec chmod 755 {} \;
  166. find -L . \
  167. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  168. -o -perm 511 \) -exec chmod 755 {} \; -o \
  169. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  170. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  171. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  172. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  173. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$PKGARCH-$BUILD$TAG.$PKGTYPE