Advertisement
Guest User

Untitled

a guest
Apr 7th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 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:-"3.6.4"}
  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. LOLANG=${LOLANG:-en-US}
  54. PKG_LANG=${LOLANG//-/_} # Leave this alone
  55.  
  56. # Until now all releases were without the JRE...
  57. WJRE=${WJRE:-no}
  58.  
  59. # If you want to disable java support by removing executable permissions
  60. # form LibreOffice's java loader (this will not affect other apps), set this
  61. # variable to "YES" Default is "NO"
  62. DISABLE_JAVA=${DISABLE_JAVA:-NO}
  63.  
  64. # Change source package name
  65. if [ "$ARCH" = "x86_64" ]; then
  66. SRCARCH="x86-64"
  67. PKGARCH="$ARCH"
  68. elif [ "$ARCH" = "arm" ]; then
  69. printf "\n$ARCH is unsupported for LibreOffice...\n\n"
  70. exit 1
  71. else
  72. SRCARCH="x86"
  73. PKGARCH="i586"
  74. fi
  75.  
  76. if [ $WJRE != no ]; then
  77. TARJRE="-wJRE"
  78. else
  79. TARJRE=""
  80. fi
  81.  
  82. # We have all the variables, construct the name of the tarball
  83. TARNAME="LibO_${SRCVERSION}_Linux_${SRCARCH}_install-rpm${TARJRE}_${LOLANG}.tar.gz"
  84. if [ ! -r $TARNAME ]; then
  85. echo "$TARNAME not found"
  86. exit 1
  87. fi
  88.  
  89. # Ignore this - it's just to get the toplevel directory name of the
  90. # extracted tarball archive
  91. SOURCEDIR=$(tar tzf $CWD/$TARNAME 2>/dev/null | head -n 1 | tr -d \/)
  92. # If the above operation failed for some reason, unset SOURCEDIR so that
  93. # the "set -eu" below will cause us to bail out with an error
  94. [ -z $SOURCEDIR ] && unset SOURCEDIR
  95.  
  96. set -eu
  97.  
  98. rm -rf $PKG
  99. mkdir -p $TMP $PKG $OUTPUT
  100. rm -rf $TMP/$SOURCEDIR
  101.  
  102. # Extract tarball
  103. tar xvf $CWD/$TARNAME -C $TMP
  104.  
  105. # We'll remove this regardless of whether we're using the jre tarball...
  106. rm -rf $TMP/$SOURCEDIR/{JavaSetup.jar,installdata,setup}
  107. rm -rf $TMP/$SOURCEDIR/RPMS/{userland,jre-*-linux-*.rpm}
  108.  
  109. cd $TMP/$SOURCEDIR/RPMS/
  110.  
  111. # Yes, I know there is a Slackware integration file in the desktop-integration
  112. # directory, but it's worthless to us. I'd prefer to do things correctly.
  113. mv desktop-integration/libreoffice$SRCSHORT-freedesktop-menus-$SRCSHORT*.noarch.rpm .
  114.  
  115. # No, I don't want to update our packaged files after the fact
  116. rm -f *onlineupdate*.rpm # We don't want this
  117.  
  118. for FILE in *.rpm ; do rpm2cpio < $FILE | cpio -imdv ; done
  119. rm -rf desktop-integration *.rpm
  120. mv opt usr $PKG
  121. cd $PKG
  122.  
  123. # Kill a broken symlink
  124. rm -f $PKG/usr/share/applications/libreoffice3-startcenter.desktop
  125.  
  126. # Create symlinks in /usr/bin to actual binaries
  127. cd $PKG/usr/bin
  128. for FILE in \
  129. sbase scalc sdraw simpress smath soffice spadmin swriter unopkg ; do
  130. rm -f $FILE
  131. ln -sf ../../opt/libreoffice$SRCSHORT/program/$FILE $FILE ;
  132. done
  133. cd -
  134.  
  135. # Remove DejaVu and Liberation fonts - these are included in other packages
  136. rm -f opt/libreoffice/basis$SRCSHORT/share/fonts/truetype/{DejaVu,Liberation}*.ttf
  137.  
  138. # Fix Exec commands in the desktop files
  139. # See http://bugzilla.xfce.org/show_bug.cgi?id=2430
  140. cd $PKG/opt/libreoffice$SRCSHORT/share/xdg/
  141. for APP in base calc draw impress math writer; do
  142. sed -i "s%Exec=libreoffice -%Exec=/opt/libreoffice$SRCSHORT/program/s%" $APP.desktop ;
  143. done
  144. cd -
  145.  
  146. # Move docs to their expected locations
  147. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  148. cd $PKG/opt/libreoffice$SRCSHORT
  149. mv CREDITS* *LICENSE* readmes $PKG/usr/doc/$PRGNAM-$VERSION
  150. cd -
  151. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  152. # Include a script for those wanting to have OO.o + LibO installed together
  153. cp $CWD/open-libre-together.sh $PKG/usr/doc/$PRGNAM-$VERSION/
  154.  
  155. # Disable Java support if desired (see above)
  156. if [ "$DISABLE_JAVA" = "YES" ]; then
  157. chmod -x $PKG/opt/libreoffice$SRCSHORT/ure/bin/javaldx
  158. fi
  159.  
  160. mkdir -p $PKG/install
  161. cat $CWD/slack-desc > $PKG/install/slack-desc
  162. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  163.  
  164. # Fix ownership and permissions and make the package
  165. chown -R root:root .
  166. find . -type d -exec chmod 755 {} \;
  167. chmod -R u+rw,go+r-w,a-s .
  168. /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