Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.2:Update
OpenOffice_org-LanguageTool
ooo-LanguageTool-gen-spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ooo-LanguageTool-gen-spec of Package OpenOffice_org-LanguageTool
#!/usr/bin/perl -w # This script changes the definite article of ProductName use strict; sub init_lang_data($$$$) { my ($datap, $curLang, $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'} = (); return $curLang; } sub read_data($$) { my ($data_file, $datap) = @_; my $curLang; 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"); } 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"; } elsif ( $line =~ /^\s*\%files\s+(.*)$/ ) { push @ {$datap->{$curLang}{'files'}}, "$1"; } elsif ( $line =~ /^\s*$/ ) { # ignore empty line } else { die "Synrax error in $data_file, line $.\n"; } } close(DATA); } sub write_generated_section_start() { print "########################################################\n"; print "# Start of a section generated by ooo-langtool-gen-spec\n"; print "# Do not edit!\n"; print "########################################################\n"; print "\n"; } sub write_generated_section_end() { print "######################################################\n"; print "# End of a section generated by ooo-langtool-gen-spec\n"; print "######################################################\n"; print "\n"; } sub write_section_comment($) { my ($section_name) = @_; print "#\n"; print "# $section_name\n"; print "#\n"; print "\n"; } sub write_level_begin($$) { my ($curLevel, $newLevel) = @_; if ($curLevel != $newLevel) { print "%endif\n" if ($curLevel > 0); print "%if %test_build_langs >= $newLevel\n" if ($newLevel > 0); print "\n"; } return $newLevel; } sub write_level_end($) { my ($curLevel) = @_; if ($curLevel > 0) { print "%endif\n"; print "\n"; } return 0; } sub write_langtool_package_section($$) { my ($datap, $curLang) = @_; return if ("$curLang" eq "en-US"); # we do not have the l10n-en-US package print "%package -n OpenOffice_org-LanguageTool-$curLang\n"; print "License: LGPL v2.0 or later\n"; print "Summary: $datap->{$curLang}{'long_name'} Dictionary for OpenOffice.org Language Tool\n"; print "Group: Productivity/Office/Dictionary\n"; print "Provides: locale(OpenOffice_org-LanguageTool:$datap->{$curLang}{'locale'})\n"; print "PreReq: OpenOffice_org-ure >= 2.99\n"; print "Requires: OpenOffice_org-LanguageTool\n"; foreach my $line (@{$datap->{$curLang}{'package'}}) { print "$line\n"; } print "\n"; print "%description -n OpenOffice_org-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 OpenOffice.org language tool extension.\n"; print "\n"; print "\n"; print "\n"; } sub write_langtool_scripts_section($$) { my ($datap, $curLang) = @_; print "# $curLang\n"; print "%posttrans -n OpenOffice_org-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 OpenOffice_org-LanguageTool-$curLang\n"; print "test \"\$1\" = \"0\" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-$datap->{$curLang}{'locale'}.txt || true\n"; } sub write_langtool_files_section($$) { my ($datap, $curLang) = @_; print "%files -f files-langtool-$datap->{$curLang}{'locale'}.txt -n OpenOffice_org-LanguageTool-$curLang\n"; print "%defattr(-,root,root)\n"; foreach my $line (@{$datap->{$curLang}{'files'}}) { print "$line\n"; } print "\n"; } sub write_langtool_section($$$) { my ($datap, $write_single_lang_section, $section_name) = @_; my $curLevel = 0; 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); } $curLevel = write_level_end($curLevel); } sub usage() { print "This tool generates pieces of the LanguageTool spec\n\n" . "Usage:\n". "\tooo-langtool-gen-spec [--help] data_file...\n\n" . "Options:\n" . "\t--help: prints this help\n" . "\tdata_file: input file\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 # 'files' ... array of strings that should be added to the %files section for # the given language my %data; my $l10n = 1; my $help = 1; for my $arg (@ARGV) { if ($arg eq '--help' || $arg eq '-h') { usage; exit 0; } else { if (-f $arg) { read_data($arg, \%data); } else { die "File does not exist: $arg\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();
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor