Hello community,

here is the log from the commit of package libreoffice-languagetool for 
openSUSE:Factory checked in at 2012-04-04 19:20:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libreoffice-languagetool (Old)
 and      /work/SRC/openSUSE:Factory/.libreoffice-languagetool.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libreoffice-languagetool", Maintainer is "[email protected]"

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/libreoffice-languagetool/libreoffice-languagetool.changes
        2011-09-23 02:10:27.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.libreoffice-languagetool.new/libreoffice-languagetool.changes
   2012-04-04 19:21:05.000000000 +0200
@@ -1,0 +2,10 @@
+Tue Apr  3 12:07:18 UTC 2012 - [email protected]
+
+- fix build with LO-3.5:
+    * basis directory does not longer exist
+    * use libreoffice instead of libreoffice-ure in BuildRequires
+- generate the whole spec file from a template and a data file
+- update license to follow spdx.org standard
+- spec file clean up
+
+-------------------------------------------------------------------

New:
----
  libreoffice-languagetool.spec.in

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libreoffice-languagetool.spec ++++++
++++ 960 lines (skipped)
++++ between 
/work/SRC/openSUSE:Factory/libreoffice-languagetool/libreoffice-languagetool.spec
++++ and 
/work/SRC/openSUSE:Factory/.libreoffice-languagetool.new/libreoffice-languagetool.spec

++++++ JLanguageTool-0.9.3-system-ooo-jars.diff ++++++
--- /var/tmp/diff_new_pack.hayGeZ/_old  2012-04-04 19:21:07.000000000 +0200
+++ /var/tmp/diff_new_pack.hayGeZ/_new  2012-04-04 19:21:07.000000000 +0200
@@ -9,7 +9,7 @@
 -ext.ooo.ridl.lib = ${ext.ooo.dir}/ridl.jar
 -ext.ooo.jurt.lib = ${ext.ooo.dir}/jurt.jar
 +ext.ooo.juh.lib = ${sys.ooo.dir}/ure/share/java/juh.jar
-+ext.ooo.unoil.lib = ${sys.ooo.dir}/basis-link/program/classes/unoil.jar
++ext.ooo.unoil.lib = ${sys.ooo.dir}/program/classes/unoil.jar
 +ext.ooo.ridl.lib = ${sys.ooo.dir}/ure/share/java/ridl.jar
 +ext.ooo.jurt.lib = ${sys.ooo.dir}/ure/share/java/jurt.jar
  

++++++ libreoffice-languagetool.spec.in ++++++
#
# spec file for package libreoffice-languagetool
#
# Copyright (c) 2012 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:           libreoffice-languagetool
Version:        1.4
Release:        0
#!BuildIgnore:  libreoffice
%define         ooo_prefix      %{_libdir}
%define         ooo_home        libreoffice
# ignore cs because of an unlclear license; also unsupported
# ignore sk unknown license; almost empty dictionary
# ignore uk (unsupported)
%define         langtool_langs  ca de en es fr gl it km pl nl ro ru sk sv
Summary:        Language Checker for LibreOffice
License:        @ALL_LICENSES@
Group:          Productivity/Office/Suite
Url:            http://www.languagetool.org/
# svn co https://languagetool.svn.sourceforge.net/svnroot/languagetool 
languagetool
# cd tags/V_1_4/JLanguageTool
# rm src/resource/cs/{*.dict,*.info}  because of unclear licese; also it is not 
longer supported (only a bachelor's thesis)
# rm src/resource/uk/{*.dict,*.info}  because of unclear licese
# rm src/resource/ml/{*.dict,*.info}  because of unclear licese
# rm -rf libs/ooo
#    + we use these jars from our libreoffice packages
# FIXME: wanted to remove libs/commons-logging-1.1.1.jar but it was not 
available on SLED11
#        it is small file (60kB) => it is not worth doing special hacks for 
SLED11 and other distros
# NOTE: jakarta-regexp-1.4.jar uses the Apache License, v2.0, see 
http://archive.apache.org/dist/jakarta/regexp/jakarta-regexp-1.4.tar.gz
Source0:        JLanguageTool-%{version}.tar.bz2
# helper files to generate the spec file
Source100:      libreoffice-languagetool.spec.in
Source101:      lo-languagetool-data
Source102:      lo-languagetool-gen-spec
# PATCH-FIX-OPENSUSE ignore dictionaries that are not installed; it allows to 
package them separately
Patch0:         JLanguageTool-1.4-package-dicts-separately.diff
# PATCH-FIX-OPENSUSE use the system libreoffice jars
Patch1:         JLanguageTool-0.9.3-system-ooo-jars.diff
# do not use the broken help; unopkg complained about it when registering 
extensions
# FIXME: the right fix is to compile the help and produce the .db_, .ht_, and 
other files
Patch2:         JLanguageTool-1.4-no-broken-help.diff
BuildRequires:  ant
BuildRequires:  java-devel
BuildRequires:  libreoffice >= 3.5
BuildRequires:  unzip
# dependencies for post install scripts
%if 0%{?suse_version} > 01120
Requires(post):   coreutils
Requires(post):   grep
Requires(post):   libreoffice >= 3.5
Requires(postun): coreutils
Requires(postun): grep
Requires(postun): libreoffice >= 3.5
%endif
%if 0%{?suse_version} && 0%{?suse_version} <= 01120
PreReq:         coreutils
PreReq:         grep
PreReq:         libreoffice >= 3.5
%endif
Requires:       jre >= 1.6
Requires:       libreoffice >= 3.5
# the Czech stuff newer worked; the package was created by mistake
Obsoletes:      OpenOffice_org-LanguageTool-cs < 0.9.9
# compat stuff
Provides:       OpenOffice_org-LanguageTool = %{version}
Obsoletes:      OpenOffice_org-LanguageTool <= %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
This package provides the language checker extension for
LibreOffice. It allows to detect errors that a simple spell checker
cannot detect, e.g. mixing up there/their, no/now etc. It can also
detect some grammar mistakes. It does not include spell checking.

The language checker uses special dictionaries that are provided by the
libreoffice-languagetool-<lang> packages.

@METADATA@
%prep
%setup -q -n JLanguageTool-%{version}
%patch0
%patch1
%patch2
cp libs/README libs/README-libs.txt

%build
ant -Dsys.ooo.dir=%{_libdir}/%ooo_home dist

%install
# skip the check for java bytecode version; it uses some jar files prebuilt 
with JRE-1.6
# can't be complied with JDK-1.5; the dependency on JRE-1.5 is solved at runtime
export NO_BRP_CHECK_BYTECODE_VERSION="true"
# main package
oxt=$(pwd)/dist/LanguageTool-%{version}.oxt
mkdir -p 
%{buildroot}%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}
cd %{buildroot}%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}
unzip "$oxt"
cd - >/dev/null 2>&1
# dictionaries
for lang in %langtool_langs ; do
    # dir
    mkdir -p %{buildroot}%{_datadir}/%ooo_home/ure/lib/resource/$lang
    echo "%dir %{_datadir}/%ooo_home" >files-langtool-$lang.txt
    echo "%dir %{_datadir}/%ooo_home/ure" >>files-langtool-$lang.txt
    echo "%dir %{_datadir}/%ooo_home/ure/lib" >>files-langtool-$lang.txt
    echo "%dir %{_datadir}/%ooo_home/ure/lib/resource" 
>>files-langtool-$lang.txt
    echo "%dir %{_datadir}/%ooo_home/ure/lib/resource/$lang" 
>>files-langtool-$lang.txt
    # files
    for file in src/resource/$lang/{*.dict,*.info} ; do
        filename=${file#src/resource/$lang/}
        cp $file 
%{buildroot}%{_datadir}/%ooo_home/ure/lib/resource/$lang/$filename
        echo "%{_datadir}/%ooo_home/ure/lib/resource/$lang/$filename" 
>>files-langtool-$lang.txt
    done
    cp files-langtool-$lang.txt %{buildroot}%{_datadir}/%ooo_home
    echo "%{_datadir}/%ooo_home/files-langtool-$lang.txt" 
>>files-langtool-$lang.txt
    # common README.txt
    echo "%doc README.txt" >>files-langtool-$lang.txt
done
# we need to create architecture dependent symlinks even for the main package
# create file list for link-to-ooo-home script
find 
%{buildroot}%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}/ 
-type d \
     -printf "%%%%dir 
%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}/%%P\n" \
     >files-langtool.txt
find 
%{buildroot}%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}/ 
-type f \
     -printf 
"%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}/%%P\n" \
     >>files-langtool.txt
cp files-langtool.txt %{buildroot}%{_datadir}/%ooo_home
echo "%{_datadir}/%ooo_home/files-langtool.txt" >>files-langtool.txt

%clean
rm -rf %{buildroot}

%files -f files-langtool.txt
%defattr(-,root,root)
%doc CHANGES.txt COPYING.txt README.txt libs/*.txt libs/build/junit-license.txt
%dir %{_datadir}/%ooo_home
%dir %{_datadir}/%ooo_home/share
%dir %{_datadir}/%ooo_home/share/extensions

%pre
if test -f %{_datadir}/ooo3/share/extension/install/LanguageTool-*.oxt ; then
    # unregister the extension that was added by OOo-LanguageTool and LO 
packages
    if unopkg list --shared | grep -q "org.openoffice.languagetool.oxt" ; then
        unopkg remove --shared org.openoffice.languagetool.oxt || true;
    fi
    # explain errors if extension that was added by OOo-LanguageTool and OOo 
packages
    echo
    echo "WARNING: Please ignore the following error about the extension:"
    echo "WARNING:     org.openoffice.languagetool.oxt"
    echo "WARNING: It is printed by the old OpenOffice_org package. The 
extension cannot"
    echo "WARNING: be unregistered from the OOo cache because unopkg tool 
already"
    echo "WARNING: works with the LO cache. The LO installation will be 
correct!"
    echo
fi
# the initial libreoffice packages symlinked the whole directory a wrong way 
(bnc#677354)
home_path="%ooo_home/share/extensions/languagetool-%{version}"
for link in "/usr/lib/$home_path" "/usr/lib64/$home_path" ; do
    test -L "$link" && rm "$link" || true
done

%post
# link to the directory where the extenisons is automatically detected
%{_datadir}/%ooo_home/link-to-ooo-home %{_datadir}/%ooo_home/files-langtool.txt 
|| true

%posttrans
# update UNO cache for bundled extensions
%{_sbindir}/unopkg-sync-bundled || true

%preun
test "$1" = "0" && cp %{_datadir}/%ooo_home/files-langtool.txt 
%{_datadir}/%ooo_home/files-langtool.txt.postun || true

%postun
test "$1" = "0" && %{_datadir}/%ooo_home/link-to-ooo-home --unlink 
%{_datadir}/%ooo_home/files-langtool.txt.postun || true
rm -f %{_datadir}/%ooo_home/files-langtool.txt.postun 2>/dev/null
# update UNO cache for bundled extensions
%{_sbindir}/unopkg-sync-bundled || true

@INSTALL_SCRIPTS@
@FILES@
%changelog
++++++ lo-languagetool-data ++++++
--- /var/tmp/diff_new_pack.hayGeZ/_old  2012-04-04 19:21:07.000000000 +0200
+++ /var/tmp/diff_new_pack.hayGeZ/_new  2012-04-04 19:21:07.000000000 +0200
@@ -1,53 +1,50 @@
 %lang ca Catalan 0
-%license GPL
+%license GPL-3.0
 %files %doc src/resource/ca/README
 
 %lang de German 0
-%license CCA-SA3.0
+%license CC-BY-SA-3.0
 %files %doc src/resource/de/{errors.txt,tagset.txt}
 
 %lang en English 0
-%license BSD3c, BSD4c, Public Domain, Freeware
+%license BSD-3-Clause, BSD-4-Clause, SUSE-Public-Domain
 %files %doc 
src/resource/en/{12dicts-readme.html,agid-readme.txt,errors.txt,pos-readme.txt}
 
 %lang gl Galician 0
-%license GPL
+%license GPL-3.0
 %files %doc src/resource/gl/{LICENSE,README,README.cvs}
 
 %lang fr French 0
-%license GPLv2.0, LGPLv2.1, MPLv1.1
+%license GPL-2.0, LGPL-2.1, MPL-1.1
 %files %doc src/resource/fr/README_lexique.txt
 
 %lang it Italian 0
-%license CCA-SA2.0, LGPL
+%license CC-BY-SA-2.0, LGPL-2.0+
 %files %doc src/resource/it/readme-morph-it.txt
 
 %lang km Khmer 0
-%license BSD, CCA-SA3.0
+%license BSD-2-Clause, CC-BY-SA-3.0
 %files %doc src/resource/km/README.txt
 
 %lang nl Dutch 0
-%license LGPL
+%license LGPL-2.1+
 
 %lang pl Polish 0
-%license LGPL
+%license LGPL-3.0
 
 %lang ro Romanian 0
-%license LGPL
+%license LGPL-3.0
 
 %lang ru Russian 0
-%license LGPL
-
-%lang sv Swedish 0
-%license LGPL
+%license LGPL-3.0
 
 %lang sk Slovak 0
-%license LGPL
+%license LGPL-3.0
 %files %doc src/resource/sk/README
 
 %lang es Spanish 0
-%license GPL
+%license GPL-3.0
 %files %doc src/resource/es/{README,README.cvs}
 
 %lang sv Swedish 0
-%license LGPL
+%license LGPL-2.1+

++++++ lo-languagetool-gen-spec ++++++
--- /var/tmp/diff_new_pack.hayGeZ/_old  2012-04-04 19:21:07.000000000 +0200
+++ /var/tmp/diff_new_pack.hayGeZ/_new  2012-04-04 19:21:07.000000000 +0200
@@ -3,39 +3,58 @@
 # This script changes the definite article of ProductName
 
 use strict;
+use File::Copy;
 
-sub init_lang_data($$$$)
+my $args = join ' ',  @ARGV;
+# FIXME: we need a global variable to pass the data to the sort function
+my $pdata_sort = undef;
+
+
+
+sub init_locale_data($$$$)
 {
-    my ($datap, $curLang, $long_name, $level) = @_;
+    my ($pdata, $locale, $long_name, $level) = @_;
     
-    $datap->{$curLang}{'long_name'} = $long_name;
-    $datap->{$curLang}{'level'} = $level;
-    $datap->{$curLang}{'locale'} = "$curLang";
-    $datap->{$curLang}{'locale'} =~ s/-/_/g;
-    $datap->{$curLang}{'package'} = ();
+    % {$pdata->{'dict'}{$locale}} = ();
+    my $pld = \% {$pdata->{'dict'}{$locale}};
     
-    return $curLang;
+    $pld->{'long_name'} = $long_name;
+    $pld->{'level'} = $level;
+    $pld->{'pack_suffix'} = "$locale";
+    $pld->{'pack_suffix'} =~ s/_/-/g;
+    
+    return $pld;
 }    
 
+sub add_locale_data_list($$$$)
+{
+    my ($pdata, $pld, $tag, $value) = @_;
+
+    foreach my $item ( split(/,\s*/, $value) ) {
+       @ {$pld->{$tag}} = () unless (defined $pld->{$tag});
+       push @ {$pld->{$tag}}, $item;
+       $pdata->{'license'}{"$item"} = 1 if ( $tag eq 'license' );
+    }
+}
+
 sub read_data($$)
 {
-    my ($data_file, $datap) = @_;
-    my $curLang;
+    my ($pdata, $data_file) = @_;
+    # pointer to locale data
+    my $pld = undef;
     
     open DATA , "< $data_file" or die "Can't open '$data_file'\n";
 
     while( my $line = <DATA>){
        chomp $line;
        if ( $line =~ m/^\s*\%lang\s+([\w-]+)\s+(\w+)\s+(\d+)\s*$/ ) {
-           $curLang = init_lang_data($datap, "$1", "$2", "$3");
+           $pld = init_locale_data($pdata, "$1", "$2", "$3");
        } elsif ( $line =~ m/^\s*\%lang\s+([\w-]+)\s+\"([\w\s]+)\"\s+(\d+)\s*$/ 
) {
-           $curLang = init_lang_data($datap, "$1", "$2", "$3");
-       } elsif ( $line =~ /^\s*\%package\s+(.*)$/ ) {
-           push @ {$datap->{$curLang}{'package'}}, "$1";
+           $pld = init_locale_data($pdata, "$1", "$2", "$3");
        } elsif ( $line =~ /^\s*\%license\s+(.*)$/ ) {
-           $datap->{$curLang}{'license'} = "$1";
+           add_locale_data_list($pdata, $pld, 'license', "$1");
        } elsif ( $line =~ /^\s*\%files\s+(.*)$/ ) {
-           push @ {$datap->{$curLang}{'files'}}, "$1";
+           push @ {$pld->{'files'}}, "$1";
        } elsif ( $line =~ /^\s*$/ ) {
            # ignore empty line
        } else {
@@ -45,188 +64,231 @@
     close(DATA);
 }
 
-sub write_generated_section_start()
-{
-    print "########################################################\n";
-    print "# Start of a section generated by lo-languagetool-gen-spec\n";
-    print "# Do not edit!\n";
-    print "########################################################\n";
-    print "\n";
-}
 
-sub write_generated_section_end()
+##############################
+# simple sections
+
+sub write_do_not_edit_section($)
 {
-    print "######################################################\n";
-    print "# End of a section generated by lo-languagetool-gen-spec\n";
-    print "######################################################\n";
-    print "\n";
+    my $out = 
"###################################################################\n" .
+              "## DO NOT EDIT THIS SPEC FILE\n" .
+              "## Generated by:\n" .
+              "## perl lo-languagetool-gen-spec $args\n" .
+              
"###################################################################";
+    return $out;
 }
 
-sub write_section_comment($)
+sub write_all_licenses_section($)
 {
-    my ($section_name) = @_;
+    my ($pdata) = @_;
 
-    print "#\n";
-    print "# $section_name\n";
-    print "#\n";
-    print "\n";
+    my @licenses = sort (keys %{$pdata->{'license'}});
+    my $out = join " and ", @licenses;
 
+    return $out;
 }
 
-sub write_level_begin($$)
+
+##############################
+# all langs sections
+
+sub write_metadata_section($$)
 {
-    my ($curLevel, $newLevel) = @_;
+    my ($pdata, $locale) = @_;
+    my $pld = \% {$pdata->{'dict'}{$locale}};
+    my $out = "";
 
-    if ($curLevel != $newLevel) {
-       print "%endif\n"                                if ($curLevel > 0);
-       print "%if %test_build_langs >= $newLevel\n"    if ($newLevel > 0);
-       print "\n";
+    unless (defined $pld->{'license'}) {
+       die "Error: License is not defined for the locale: $locale\n";
     }
 
-    return $newLevel;
-}
+    $out .= "%package -n libreoffice-languagetool-$pld->{'pack_suffix'}\n";
+    $out .= "Summary:        $pld->{'long_name'} Dictionary for LibreOffice 
Language Tool\n";
+    $out .= "License:        " . join (" and ", @{$pld->{'license'}}) . "\n";
+    $out .= "Group:          Productivity/Office/Dictionary\n";
+    $out .= "%if 0%{?suse_version} > 01120\n";
+    $out .= "Requires(post):   coreutils\n";
+    $out .= "Requires(post):   grep\n";
+    $out .= "Requires(post):   libreoffice >= 3.5\n";
+    $out .= "Requires(postun): coreutils\n";
+    $out .= "Requires(postun): grep\n";
+    $out .= "Requires(postun): libreoffice >= 3.5\n";
+    $out .= "%endif\n";
+    $out .= "%if 0%{?suse_version} && 0%{?suse_version} <= 01120\n";
+    $out .= "PreReq:         coreutils\n";
+    $out .= "PreReq:         grep\n";
+    $out .= "PreReq:         libreoffice >= 3.5\n";
+    $out .= "%endif\n";
+    $out .= "Requires:       libreoffice-languagetool = %{version}\n";
+    $out .= "Provides:       locale(libreoffice-languagetool:$locale)\n";
+    $out .= "# compat stuff\n";
+    $out .= "Provides:       OpenOffice_org-LanguageTool-$pld->{'pack_suffix'} 
= %{version}\n";
+    $out .= "Obsoletes:      OpenOffice_org-LanguageTool-$pld->{'pack_suffix'} 
<= %{version}\n";
+
+    $out .= "\n";
+
+    $out .= "%description -n libreoffice-languagetool-$pld->{'pack_suffix'}\n";
+    $out .= "The $pld->{'long_name'} dictionary that can be used to check 
grammar and other more\n";
+    $out .= "complex mistakes using the LibreOffice language tool 
extension.\n";
+    $out .= "\n";
+
+    return $out;
+}
+
+sub write_install_scripts_section($$)
+{
+    my ($pdata, $locale) = @_;
+    my $pld = \% {$pdata->{'dict'}{$locale}};
+    my $out = "";
+
+    $out .= "# $locale\n";
+    $out .= "%posttrans -n libreoffice-languagetool-$pld->{'pack_suffix'}\n";
+    $out .= "%{_datadir}/%ooo_home/link-to-ooo-home 
%{_datadir}/%ooo_home/files-langtool-$locale.txt || true\n";
+    $out .= "\n";
+    $out .= "%preun -n libreoffice-languagetool-$pld->{'pack_suffix'}\n";
+    $out .= "test \"\$1\" = \"0\" && cp 
%{_datadir}/%ooo_home/files-langtool-$locale.txt 
%{_datadir}/%ooo_home/files-langtool-$locale.txt.postun || true\n";
+    $out .= "\n";
+    $out .= "%postun -n libreoffice-languagetool-$pld->{'pack_suffix'}\n";
+    $out .= "test \"\$1\" = \"0\" && %{_datadir}/%ooo_home/link-to-ooo-home 
--unlink %{_datadir}/%ooo_home/files-langtool-$locale.txt.postun || true\n";
+    $out .= "rm -f %{_datadir}/%ooo_home/files-langtool-$locale.txt.postun 
2>/dev/null\n";
+    $out .= "\n";
+
+    return $out;
+}
+
+sub write_files_section($$)
+{
+    my ($pdata, $locale) = @_;
+    my $pld = \% {$pdata->{'dict'}{$locale}};
+    my $out = "";
 
-sub write_level_end($)
-{
-    my ($curLevel) = @_;
+    $out .= "%files -f files-langtool-$locale.txt -n 
libreoffice-languagetool-$pld->{'pack_suffix'}\n";
+    $out .= "%defattr(-,root,root)\n";
 
-    if ($curLevel > 0) {
-       print "%endif\n";
-       print "\n";
+    foreach  my $line (@{$pld->{'files'}}) {
+        $out .= "$line\n";
     }
 
-    return 0;
+    $out .= "\n";
+
+    return $out;
 }
 
-sub write_langtool_package_section($$)
-{
-    my ($datap, $curLang) = @_;
+########################################################
+# universal writing functions
 
-    return if ("$curLang" eq "en-US"); # we do not have the l10n-en-US package
-    
-    unless (defined $datap->{$curLang}{'license'}) {
-       die "Error: License is not defined for the language: $curLang";
-    }
+sub sort_dictionaries()
+{
+    # sort the dictionaries by the package name
+    $pdata_sort->{'dict'}{$a}->{'pack_suffix'} cmp 
$pdata_sort->{'dict'}{$b}->{'pack_suffix'};
+}
 
-    print "%package -n libreoffice-languagetool-$curLang\n";
-    print "License:        $datap->{$curLang}{'license'}\n";
-    print "Summary:        $datap->{$curLang}{'long_name'} Dictionary for 
LibreOffice Language Tool\n";
-    print "Group:          Productivity/Office/Dictionary\n";
-    print "Provides:       
locale(libreoffice-languagetool:$datap->{$curLang}{'locale'})\n";
-    print "PreReq:         libreoffice-ure >= 2.99\n";
-    print "Requires:       libreoffice-languagetool = %version\n";
-    print "# compat stuff\n";
-    print "Provides:       OpenOffice_org-LanguageTool-$curLang = %version\n";
-    print "Obsoletes:      OpenOffice_org-LanguageTool-$curLang <= %version\n";
+# the text is repeated for each locale
+# it is used on all distributions
+sub write_locale_sections($$)
+{
+    my ($pdata, $write_section) = @_;
+    my $out = "";
 
-    foreach  my $line (@{$datap->{$curLang}{'package'}}) {
-        print "$line\n";
+    $pdata_sort = $pdata;
+    foreach my $locale (sort sort_dictionaries keys %{$pdata->{'dict'}}) {
+       $out .= & {$write_section} ($pdata, $locale);
     }
-
-    print "\n";
-
-    print "%description -n libreoffice-languagetool-$curLang\n";
-    print "The $datap->{$curLang}{'long_name'} dictionary that can be used to 
check grammar and other more\n";
-    print "complex mistakes using the LibreOffice language tool extension.\n";
-    print "\n";
-    print "\n";
-    print "\n";
+    return $out;
 }
 
-sub write_langtool_scripts_section($$)
+# the text is not repeated for each locale
+sub write_simple_section($$)
 {
-    my ($datap, $curLang) = @_;
+    my ($pdata, $write_section) = @_;
 
-    print "# $curLang\n";
-    print "%posttrans -n libreoffice-languagetool-$curLang\n";
-    print "%_datadir/%ooo_home/link-to-ooo-home 
%_datadir/%ooo_home/files-langtool-$datap->{$curLang}{'locale'}.txt || true\n";
-    print "\n";
-    print "%preun -n libreoffice-languagetool-$curLang\n";
-    print "test \"\$1\" = \"0\" && cp 
%_datadir/%ooo_home/files-langtool-$datap->{$curLang}{'locale'}.txt 
%_datadir/%ooo_home/files-langtool-$datap->{$curLang}{'locale'}.txt.postun || 
true\n";
-    print "\n";
-    print "%postun -n libreoffice-languagetool-$curLang\n";
-    print "test \"\$1\" = \"0\" && %_datadir/%ooo_home/link-to-ooo-home 
--unlink 
%_datadir/%ooo_home/files-langtool-$datap->{$curLang}{'locale'}.txt.postun || 
true\n";
-    print "rm -f 
%_datadir/%ooo_home/files-langtool-$datap->{$curLang}{'locale'}.txt.postun 
2>/dev/null\n"
+    return & {$write_section} ($pdata);
 }
 
-sub write_langtool_files_section($$)
+sub write_spec($$)
 {
-    my ($datap, $curLang) = @_;
+    my ($pdata, $spec_template) = @_;
 
-    print "%files -f files-langtool-$datap->{$curLang}{'locale'}.txt -n 
libreoffice-languagetool-$curLang\n";
-    print "%defattr(-,root,root)\n";
+    my $all_licenses = write_simple_section ($pdata, 
\&write_all_licenses_section);
+    my $do_not_edit = write_simple_section ($pdata, 
\&write_do_not_edit_section);
+    my $metadata = write_locale_sections ($pdata, \&write_metadata_section);
+    my $install_scripts = write_locale_sections ($pdata, 
\&write_install_scripts_section);
+    my $files = write_locale_sections ($pdata, \&write_files_section);
 
-    foreach  my $line (@{$datap->{$curLang}{'files'}}) {
-        print "$line\n";
-    }
+    my $spec = $spec_template;
+    $spec =~ s/.in$//;
 
-    print "\n";
-}
+    print "Generating $spec...\n";
 
-sub write_langtool_section($$$)
-{
-    my ($datap, $write_single_lang_section, $section_name) = @_;
-    my $curLevel = 0;
+    open TEMPLATE , "< $spec_template" or die "Can't open '$spec_template'\n";
+    open SPEC , "> $spec" or die "Can't open '$spec for writing'\n";
 
-    write_section_comment($section_name);
-    
-    foreach my $curLang (sort keys %{$datap}) {
-       $curLevel = write_level_begin($curLevel, $datap->{$curLang}{'level'});
-       & {$write_single_lang_section} ($datap, $curLang);
+    while( my $line = <TEMPLATE>) {
+       $line =~ s/\@ALL_LICENSES\@/$all_licenses/;
+       $line =~ s/\@DO_NOT_EDIT_COMMENT\@/$do_not_edit/;
+       $line =~ s/\@METADATA\@/$metadata/;
+       $line =~ s/\@INSTALL_SCRIPTS\@/$install_scripts/;
+       $line =~ s/\@FILES\@/$files/;
+
+       print SPEC $line;
     }
 
-    $curLevel = write_level_end($curLevel);
+    close(TEMPLATE);
+    close(SPEC);
 }
 
+############################################################
+# main stuff
+############################################################
+
 sub usage()
 {
-    print "This tool generates pieces of the LanguageTool spec\n\n" .
+    print "This tool generates the LanguageTool spec file\n\n" .
 
           "Usage:\n".
-         "\tlo-langtool-gen-spec [--help] data_file...\n\n" .
-       
-         "Options:\n" .
-         "\t--help: prints this help\n" .
-         "\tdata_file: input file\n";
+         "\tlo-langtool-gen-spec [--help] spec_template.in data_file\n\n";
 }
 
 
-# info about localizations
-# it is a hash, the key is the lang id, e.g. "en-US", the value is:
-#        a hash, keys introduce perl-like structure items:
-#            'long_name'               ... string, long name of the language, 
e.g. "American"
-#            'level'                   ... integer, level in whih it should 
get build, e.g. '1'
-#                                          it is the level in the rpm spec to 
do a reduced build
-#            'locale'                  ... string, it is actually the lang id 
with undersore instead of dash,
-#                                          e.g. "en_US"
-#            'package'                 ... array of strings that should be 
added to the %package section for
-#                                           the given language
-#            'license'                 ... string, defines the license of the 
package
-#            'files'                   ... array of strings that should be 
added to the %files section for
-#                                           the given language
+# info about data structure
+# it is a hash, keys introduce perl-like structure items:
+#      'dict'          ... hash; key is the primary locale for the given 
dictioanry, e.g. "en_US"
+#                          the value is hash that store an information about 
ech dictionary using
+#                          tags; the known tags are:
+#            'long_name'       hash(*) of string; long name of the language, 
e.g. "American"
+#            'level'           hash(*) of integer; level in whih it should get 
build, e.g. '1'
+#                                         it is the level in the rpm spec to 
do a reduced build
+#            'pack_suffix'     hash(*) of string; like the locale but used 
hash instead of underscore, e.g en-us
+#            'license'         hash(*) of array of strings; defines the 
license of the package
+#            'files'           hash(*) of array of strings; libes that should 
be added to the %files section
+#      'license'       ... hash; key is the license used for a dictionary, 
e.g. LGPLv2; it is used to generate
+#                              licenses for the source package
+
+#
+# hash(*) of ...   - key is the condition under which the tag is defined; it 
is usually used to define a special tag
+#                   for another distro; the key 'default' defines tags for the 
default distro, ...
 my %data;
-my $l10n = 1;
-my $help = 1;
-
+my $spec_template;
+my $data_file;
 
 for my $arg (@ARGV) {
     if ($arg eq '--help' || $arg eq '-h') {
        usage;
        exit 0;
     } else {
-       if (-f $arg) {
-           read_data($arg, \%data);
+       -f $arg || die "Error: The file does not exist: $arg\n";
+       if (! defined $spec_template) {
+           $spec_template = $arg;
+       } elsif (! defined $data_file) {
+           $data_file = $arg;
        } else {
-           die "File does not exist: $arg\n";
+           die "Error: Too many arguments!\n";
        }
     }
 }
 
-write_generated_section_start();
-write_langtool_section(\%data, \&write_langtool_package_section, "langtool 
dictionaries");
-write_generated_section_end();
-
-write_generated_section_start();
-write_langtool_section(\%data, \&write_langtool_scripts_section, "langtool 
dictionaries");
-write_langtool_section(\%data, \&write_langtool_files_section, "langtool 
dictionaries");
-write_generated_section_end();
+die "Error: Spec file template is not defined, try --help" unless (defined 
$spec_template);
+die "Error: Data file is not defined, try --help" unless (defined $data_file);
+
+read_data(\%data, $data_file);
+write_spec(\%data, $spec_template);

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to