tesseract.SlackBuild 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #!/bin/bash
  2. # Slackware build script for tesseract
  3. # Copyright 2009-2010 Pierre Cazenave <pwcazenave {at} gmail [dot] com>
  4. # Copyright 2013-2015 LukenShiro, Italy
  5. # Copyright 2019-2022 Logan Rathbone <poprocks@gmail.com>
  6. #
  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. # Pierre Cazenave 10/11/2007.
  26. # Updated 25/01/2009.
  27. # Updated 08/04/2009.
  28. # Updated 28/05/2009 for Slackware64.
  29. # Updated 08/09/2010 Fixed language packs logic (Thanks to Ed Rozenberg)
  30. # Thanks to S+*n_Pe*rm*n for a bug report from OCRopus.
  31. # Modified by Willy Sudiarto Raharjo <willysr@slackware-id.org>
  32. cd $(dirname $0) ; CWD=$(pwd)
  33. PRGNAM=tesseract
  34. VERSION=${VERSION:-5.0.1}
  35. BUILD=${BUILD:-1}
  36. TAG=${TAG:-_SBo}
  37. PKGTYPE=${PKGTYPE:-tgz}
  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. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  46. # the name of the created package would be, and then exit. This information
  47. # could be useful to other scripts.
  48. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  49. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  50. exit 0
  51. fi
  52. TMP=${TMP:-/tmp/SBo}
  53. PKG=$TMP/package-$PRGNAM
  54. OUTPUT=${OUTPUT:-/tmp}
  55. if [ "$ARCH" = "i486" ]; then
  56. SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  57. LIBDIRSUFFIX=""
  58. elif [ "$ARCH" = "i686" ]; then
  59. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  60. LIBDIRSUFFIX=""
  61. elif [ "$ARCH" = "x86_64" ]; then
  62. SLKCFLAGS="-O2 -fPIC"
  63. LIBDIRSUFFIX="64"
  64. else
  65. SLKCFLAGS="-O2"
  66. LIBDIRSUFFIX=""
  67. fi
  68. DOCFILES="AUTHORS CONTRIBUTING.md ChangeLog LICENSE README.md"
  69. # Language data files
  70. # replace this with the 3-character ISO 639-2 language code of the language(s)
  71. # you want to install: different language data files can coexist nicely.
  72. # Available languages are (in no particular order):
  73. # grc epo_alt eng ukr tur tha tgl tel tam swe swa srp sqi spa_old spa slv
  74. # slk ron por pol nor nld msa mlt mkd mal lit lav kor kan ita_old ita isl
  75. # ind chr hun hrv hin heb glg frm frk fra fin eus est equ epo enm ell due
  76. # dan ces cat bul ben bel aze ara afr jpn chi_sim chi_tra rus vie
  77. # see https://github.com/tesseract-ocr/tessdata/ for a list.
  78. LANGNAM=${LANGNAM:-"eng"}
  79. set -e
  80. rm -rf $TMP/$PRGNAM-$VERSION $PKG
  81. mkdir -p $TMP $PKG $OUTPUT
  82. cd $TMP
  83. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz || tar xvf $CWD/$VERSION.tar.gz
  84. cd $PRGNAM-$VERSION
  85. chown -R root:root .
  86. find -L . \
  87. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  88. -o -perm 511 \) -exec chmod 755 {} \; -o \
  89. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  90. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  91. ./autogen.sh
  92. CFLAGS="$SLKCFLAGS" \
  93. ./configure \
  94. --prefix=/usr \
  95. --libdir=/usr/lib${LIBDIRSUFFIX} \
  96. --sysconfdir=/etc \
  97. --localstatedir=/var \
  98. --mandir=/usr/man \
  99. --disable-static \
  100. --build=$ARCH-slackware-linux
  101. make
  102. make install DESTDIR=$PKG
  103. make training
  104. make training-install DESTDIR=$PKG
  105. # Install language name described above;
  106. # language files are not automatically installed.
  107. mkdir -p $PKG/usr/share/tessdata
  108. for LNG in $LANGNAM ; \
  109. do cp $CWD/$LNG.traineddata $PKG/usr/share/tessdata/ ; \
  110. done
  111. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  112. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  113. find $PKG/usr/man -type f -exec gzip -9 {} \;
  114. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  115. # Don't ship .la files:
  116. rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la
  117. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  118. cp -a $DOCFILES \
  119. $PKG/usr/doc/$PRGNAM-$VERSION
  120. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  121. find $PKG/usr/doc/$PRGNAM-$VERSION -type f -exec chmod 644 {} \;
  122. mkdir -p $PKG/install
  123. cat $CWD/slack-desc > $PKG/install/slack-desc
  124. cd $PKG
  125. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE