Advertisement
Guest User

Untitled

a guest
Apr 7th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.71 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Slackware build script for LibreOffice
  4.  
  5. # Copyright 2006,2007,2008,2009,2010 Robby Workman, Northport, Alabama, USA
  6. # Copyright 2010-2012 Niels Horn, Rio de Janeiro, RJ, Brazil
  7. # All rights reserved.
  8. #
  9. # Redistribution and use of this script, with or without modification, is
  10. # permitted provided that the following conditions are met:
  11. #
  12. # 1. Redistributions of this script must retain the above copyright
  13. # notice, this list of conditions and the following disclaimer.
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  16. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  17. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  18. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  21. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  22. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  23. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  24. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25.  
  26. # Modified by Niels Horn <niels.horn@gmail.com>
  27. # Revision date: 2012/12/27
  28.  
  29. PRGNAM=libreoffice
  30. VERSION=${VERSION:-"4.0.2"}
  31. BUILD=${BUILD:-1}
  32. TAG=${TAG:-_SBo}
  33.  
  34. # These variables seem to change with (almost) every release...
  35. SRCVERSION=$VERSION
  36. SRCSHORT=$(echo $VERSION | cut -f1-2 -d.) #"3.5"
  37.  
  38. if [ -z "$ARCH" ]; then
  39. case "$( uname -m )" in
  40. i?86) ARCH=i486 ;;
  41. arm*) ARCH=arm ;;
  42. *) ARCH=$( uname -m ) ;;
  43. esac
  44. fi
  45.  
  46. CWD=$(pwd)
  47. TMP=${TMP:-/tmp/SBo}
  48. PKG=$TMP/package-$PRGNAM
  49. OUTPUT=${OUTPUT:-/tmp}
  50.  
  51. # For now it seems upstream will have only one "base" program in 'en-US' and
  52. # LanguagePacks for all other languages.
  53. http://download.documentfoundation.org/libreoffice/stable/3.6.4/rpm/x86/LibO_3.6.4_Linux_x86_install-rpm_en-US.tar.gz
  54. LOLANG=${LOLANG:-en-GB}
  55. PKG_LANG=${LOLANG//-/_} # Leave this alone
  56.  
  57. # Until now all releases were without the JRE...
  58. WJRE=${WJRE:-no}
  59.  
  60. # If you want to disable java support by removing executable permissions
  61. # form LibreOffice's java loader (this will not affect other apps), set this
  62. # variable to "YES" Default is "NO"
  63. DISABLE_JAVA=${DISABLE_JAVA:-NO}
  64.  
  65. # Change source package name
  66. if [ "$ARCH" = "x86_64" ]; then
  67. SRCARCH="x86-64"
  68. PKGARCH="$ARCH"
  69. elif [ "$ARCH" = "arm" ]; then
  70. printf "\n$ARCH is unsupported for LibreOffice...\n\n"
  71. exit 1
  72. else
  73. SRCARCH="x86"
  74. PKGARCH="i586"
  75. fi
  76.  
  77. if [ $WJRE != no ]; then
  78. TARJRE="-wJRE"
  79. else
  80. TARJRE=""
  81. fi
  82.  
  83. # We have all the variables, construct the name of the tarball
  84. TARNAME="LibreOffice_${SRCVERSION}_Linux_${SRCARCH}_rpm${TARJRE}_${LOLANG}.tar.gz"
  85. if [ ! -r $TARNAME ]; then
  86. echo "$TARNAME not found"
  87. exit 1
  88. fi
  89.  
  90. # Ignore this - it's just to get the toplevel directory name of the
  91. # extracted tarball archive
  92. SOURCEDIR=$(tar tzf $CWD/$TARNAME 2>/dev/null | head -n 1 | tr -d \/)
  93. # If the above operation failed for some reason, unset SOURCEDIR so that
  94. # the "set -eu" below will cause us to bail out with an error
  95. [ -z $SOURCEDIR ] && unset SOURCEDIR
  96.  
  97. set -eu
  98.  
  99. rm -rf $PKG
  100. mkdir -p $TMP $PKG $OUTPUT
  101. rm -rf $TMP/$SOURCEDIR
  102.  
  103. # Extract tarball
  104. tar xvf $CWD/$TARNAME -C $TMP
  105.  
  106. # We'll remove this regardless of whether we're using the jre tarball...
  107. rm -rf $TMP/$SOURCEDIR/{JavaSetup.jar,installdata,setup}
  108. rm -rf $TMP/$SOURCEDIR/RPMS/{userland,jre-*-linux-*.rpm}
  109.  
  110. cd $TMP/$SOURCEDIR/RPMS/
  111.  
  112. # Yes, I know there is a Slackware integration file in the desktop-integration
  113. # directory, but it's worthless to us. I'd prefer to do things correctly.
  114. mv desktop-integration/libreoffice$SRCSHORT-freedesktop-menus-$SRCSHORT*.noarch.rpm .
  115.  
  116. # No, I don't want to update our packaged files after the fact
  117. rm -f *onlineupdate*.rpm # We don't want this
  118.  
  119. for FILE in *.rpm ; do rpm2cpio < $FILE | cpio -imdv ; done
  120. rm -rf desktop-integration *.rpm
  121. mv opt usr $PKG
  122. cd $PKG
  123.  
  124. # Kill a broken symlink
  125. rm -f $PKG/usr/share/applications/libreoffice3-startcenter.desktop
  126.  
  127. # Create symlinks in /usr/bin to actual binaries
  128. cd $PKG/usr/bin
  129. for FILE in \
  130. sbase scalc sdraw simpress smath soffice spadmin swriter unopkg ; do
  131. rm -f $FILE
  132. ln -sf ../../opt/libreoffice$SRCSHORT/program/$FILE $FILE ;
  133. done
  134. cd -
  135.  
  136. # Remove DejaVu and Liberation fonts - these are included in other packages
  137. rm -f opt/libreoffice/basis$SRCSHORT/share/fonts/truetype/{DejaVu,Liberation}*.ttf
  138.  
  139. # Fix Exec commands in the desktop files
  140. # See http://bugzilla.xfce.org/show_bug.cgi?id=2430
  141. cd $PKG/opt/libreoffice$SRCSHORT/share/xdg/
  142. for APP in base calc draw impress math writer; do
  143. sed -i "s%Exec=libreoffice -%Exec=/opt/libreoffice$SRCSHORT/program/s%" $APP.desktop ;
  144. done
  145. cd -
  146.  
  147. # Move docs to their expected locations
  148. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  149. cd $PKG/opt/libreoffice$SRCSHORT
  150. mv CREDITS* *LICENSE* readmes $PKG/usr/doc/$PRGNAM-$VERSION
  151. cd -
  152. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  153. # Include a script for those wanting to have OO.o + LibO installed together
  154. cp $CWD/open-libre-together.sh $PKG/usr/doc/$PRGNAM-$VERSION/
  155.  
  156. # Disable Java support if desired (see above)
  157. if [ "$DISABLE_JAVA" = "YES" ]; then
  158. chmod -x $PKG/opt/libreoffice$SRCSHORT/ure/bin/javaldx
  159. fi
  160.  
  161. mkdir -p $PKG/install
  162. cat $CWD/slack-desc > $PKG/install/slack-desc
  163. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  164.  
  165. # Fix ownership and permissions and make the package
  166. chown -R root:root .
  167. find . -type d -exec chmod 755 {} \;
  168. chmod -R u+rw,go+r-w,a-s .
  169. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-${VERSION}_${PKG_LANG}-$PKGARCH-$BUILD$TAG.${PKGTYPE:-tgz}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement