LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File tesseract-traineddata.spec.in of Package tesseract-traineddata (Project Documentation:Tools)

#
# spec file for package tesseract-traineddata
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

@DO_NOT_EDIT_COMMENT@

Name:           tesseract-traineddata
Version:        0
Release:        0
Summary:        Tesseract Traineddata for Various Languages
License:        @ALL_LICENSES@
Group:          Productivity/Graphics/Other
Url:            http://code.google.com/p/tesseract-ocr/
Source0:        README
# traineddata files
@SOURCES@
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
A commercial quality OCR engine originally developed at HP between 1985 and
1995. In 1995, this engine was among the top 3 evaluated by UNLV. It was
open-sourced by HP and UNLV in 2005. From 2007 it is developed by Google.

@METADATA@
%prep
%setup -cT
# Unpack sources
for archive in \
@SOURCES_UNPACK@  ; do
  archive_name=`basename $archive | sed -e "s|.zip$||" -e "s|.tar.gz$||" -e "s|.tar.bz2$||" -e "s|.gz$||"`
  mkdir $archive_name || exit 1;
  case $archive in
    *.zip)
      cd $archive_name; unzip $archive || exit 1; cd -
      ;;
    *.tar.gz)
      tar -xzf $archive -C $archive_name || exit 1;
      ;;
    *.tar.bz2)
      tar -xjf $archive -C $archive_name || exit 1;
      ;;
    *.gz)
      cd $archive_name; gunzip -c $archive > $archive_name || exit 1; cd -
      ;;
    *)
      echo "Error: Do not know how to uncompress $archive"
      exit 1;
      ;;
  esac
done
# Fix packages
@PREP_HACKS@#

%build

%install
install -pm 0755 -d %{buildroot}%{_datadir}/tessdata/
for lang_dir in * ; do
  test -d $lang_dir || continue
  # Initialize file list
  filelist=`mktemp /tmp/tesseract-traineddata-XXXXXX`
  echo "%%defattr(-,root,root,-)" > $filelist
  echo "%%dir %{_datadir}/tessdata/" >> $filelist
  # Find traineddata files
  for traineddata in `find $lang_dir -type f -and -name \*.traineddata | sort` ; do
    traineddata_base=$(basename $traineddata)
    # Add possible additional *cube* files
    cube=`echo $traineddata_base | sed -e "s|.traineddata$|.\\\*cube.\\\*|"`
    cubedata=`find $lang_dir -type f -and -name $cube | sort`

    # Install the data
    for f in $traineddata $cubedata ; do
      fname=$(basename $f)
      if test -f %{buildroot}%{_datadir}/tessdata/$fname ; then
        echo "Error: file already installed: $f"
        echo "       Probably is provided by two source tarballs"
        exit 1;
      fi
      install -pm 0644 $f %{buildroot}%{_datadir}/tessdata/
      echo %{_datadir}/tessdata/$fname >> $filelist
    done

    # Detect lang
    if test -n $traineddata_base ; then
      lang=`echo $traineddata_base | cut -d "." -f1`
    else
      echo "Error: No data found in $lang_dir"
      exit 1;
    fi
    short_lang="${lang}"
    # Workaround for packages which have more than one traineddata files
    if [ $lang = dan-frak ] ; then
      short_lang=dan
    fi
    if [ $lang = deu-frak ] ; then
      short_lang=deu
    fi
    if [ $lang = heb-ras ] || [ $lang = heb-seg ] ; then
      short_lang=heb-com
    fi
    if [ $lang = slk-frak ] ; then
      short_lang=slk
    fi

    # Detect long language name
    case "$short_lang" in
@LANG_NAME@            *) echo "Error: do not know language name for the $short_lang"
               exit 1
               ;;
    esac

    # Special hack for some langs
    case "$short_lang" in
@ENCODING@     esac

    # Install documentation
    for doc in `find $lang_dir -type f -printf "%%P\n" | grep -v -e ".traineddata$" -e "cube.*$"` ; do
      if ! test -f $lang_dir/$doc ; then
        echo "Error: is not a file: $lang_dir/$doc"
        exit 1;
      fi
      echo "%%doc $lang_dir/$doc" >>$filelist
    done
  done
  # Rename the file list according to the detected lang
  mv $filelist $short_lang.list
done

@FILES@
%changelog