Пакет ispell-ru-lebedev: Specfile

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
%define ispelldir	%_libdir/ispell
%define aspelldir	%_libdir/aspell
%define myspelldir	%_datadir/myspell
%define ispell_version	3.2.06
%define aspell_version	0.60.0

Name: ispell-ru-lebedev
Version: 0.99g5
Release: alt15

Summary: Russian ispell dictionary, KOI8-R, "io" and "ie" spelling allowed
Summary(ru_RU.UTF-8): Словарь русского языка для ispell, KOI8-R, разрешена замена "ё" на "е"
Summary(be_BY.UTF-8): Слоўнік рускае мовы для ispell, KOI8-R, дазволена зьмена "ё" на "е"
# aspell is also GPL-2.0-only, see LICENSE.phonet
License: BSD-3-Clause
Group: Text tools
URL: http://scon155.phys.msu.su/~swan/orthography.html

# Note: ispell and aspell hash files are architecture-dependent.
# Do not put BuildArch: noarch here.

# ftp://scon155.phys.msu.su/pub/russian/ispell/rus-ispell-%version.tar.gz
Source: rus-ispell-%version.tar
# http://www.inp.nsk.su/~grozin/aspell/
Source2: rus-ispell-aspellfiles-0.3.tar
Source10: addition.words

Patch1:	rus-ispell-0.99g1-alt-no-substandard-language.patch
Patch3:	ispell-ru-lebedev-affix_flags.patch

Requires: %name-common
Requires: ispell >= %ispell_version
Provides: ispell-dictionary, ispell-ru = %version
Obsoletes: irussian, ispell-rus, ispell-russian, rispell, ispell-ru

# Automatically added by buildreq on Sun Nov 28 2010
BuildRequires: i2myspell vim-console

BuildRequires: ispell >= %ispell_version
BuildRequires: aspell >= %aspell_version
BuildRequires: vim-devel >= 4:7.0

# The real ispell is required - not the aspell-provided emulation.
BuildConflicts:	aspell-ispell

# no need for provides like /usr/lib64/aspell/ru.multi = 40 (alt#39256)
AutoProv: yes,noalternatives

%package common
Summary: Russian ispell/aspell/hunspell/vim dictionaries common files
Group: Text tools
BuildArch: noarch
Conflicts: %name < %EVR
Conflicts: %name-cp1251 < %EVR
Conflicts: %name-ie < %EVR
Conflicts: %name-ie-cp1251 < %EVR
Conflicts: %name-io < %EVR
Conflicts: %name-io-cp1251 < %EVR
Conflicts: aspell-ru-lebedev < %EVR
Conflicts: hunspell-ru-lebedev < %EVR
Conflicts: hunspell-ru-lebedev-ie < %EVR
Conflicts: hunspell-ru-lebedev-io < %EVR
Conflicts: vim-spell-ru-lebedev < %EVR
Conflicts: vim-spell-ru-lebedev-ie < %EVR
Conflicts: vim-spell-ru-lebedev-io < %EVR

%package cp1251
Summary: Russian ispell dictionary, CP1251, "io" and "ie" spelling allowed
Summary(ru_RU.UTF-8): Словарь русского языка для ispell, CP1251, разрешена замена "ё" на "е"
Summary(be_BY.UTF-8): Слоўнік рускае мовы для ispell, CP1251, дазволена зьмена "ё" на "е"
Group: Text tools
Requires: %name-common
Requires: ispell >= %ispell_version
Provides: ispell-dictionary, ispell-ru-cp1251 = %version
Obsoletes: irussian, ispell-rus, ispell-russian, rispell, ispell-ru-cp1251

%package -n aspell-ru-lebedev
Summary: Russian dictionary for GNU Aspell
Summary(ru_RU.UTF-8): Словарь русского языка для GNU Aspell
Summary(be_BY.UTF-8): Слоўнік рускае мовы для GNU Aspell
License: BSD-3-Clause and GPL-2.0-only
Group: Text tools
Requires: %name-common
Requires: aspell >= %aspell_version
Provides: aspell-dictionary, aspell-ru = %version
Provides: aspell-ru-lebedev-common = %version-%release
Obsoletes: aspell-ru, aspell-ru-lebedev-ie, aspell-ru-lebedev-io
Obsoletes: aspell-ru-lebedev-common
Obsoletes: aspell-ru-lebedev-common-ie, aspell-ru-lebedev-common-io

%package -n hunspell-ru-lebedev
Summary: Russian dictionary for myspell/hunspell, "io" and "ie" spelling allowed
Summary(ru_RU.UTF-8): Словарь русского языка для myspell/hunspell, разрешена замена "ё" на "е"
Group: Text tools
BuildArch: noarch
Requires: %name-common
Provides: hunspell-ru
Obsoletes: hunspell-ru

%package -n hunspell-ru-lebedev-ie
Summary: Russian dictionary for myspell/hunspell, only "ie" spelling allowed
Summary(ru_RU.UTF-8): Словарь русского языка для myspell/hunspell без поддержки буквы "ё"
Group: Text tools
BuildArch: noarch
Requires: %name-common
Provides: hunspell-ru

%package -n hunspell-ru-lebedev-io
Summary: Russian dictionary for myspell/hunspell, "io" required
Summary(ru_RU.UTF-8): Словарь русского языка для myspell/hunspell с обязательным употреблением буквы "ё"
Group: Text tools
BuildArch: noarch
Requires: %name-common
Provides: hunspell-ru

%package -n vim-spell-ru-lebedev
Summary: Russian dictionary for vim, "io" and "ie" spelling allowed
Summary(ru_RU.UTF-8): Словарь русского языка для vim, разрешена замена "ё" на "е"
Group: Text tools
BuildArch: noarch
Requires: %name-common
Provides: vim-spell-ru
Obsoletes: vim-spell-ru

%package -n vim-spell-ru-lebedev-ie
Summary: Russian dictionary for vim, only 'ie' spelling allowed
Summary(ru_RU.UTF-8): Словарь русского языка для vim без поддержки буквы "ё"
Group: Text tools
BuildArch: noarch
Requires: %name-common

%package -n vim-spell-ru-lebedev-io
Summary: Russian dictionary for vim, "io" required
Summary(ru_RU.UTF-8): Словарь русского языка для vim с обязательным употреблением буквы "ё"
Group: Text tools
BuildArch: noarch
Requires: %name-common

%package ie
Summary: Russian ispell dictionary, KOI8-R, only "ie" spelling allowed
Summary(ru_RU.UTF-8): Словарь русского языка для ispell, KOI8-R, без поддержки буквы "ё"
Summary(be_BY.UTF-8): Слоўнік рускае мовы для ispell, KOI8-R, бяз літары "ё"
Group: Text tools
Requires: %name-common
Requires: ispell >= %ispell_version
Provides: ispell-dictionary, ispell-ru = %version
Obsoletes: irussian, ispell-rus, ispell-russian, rispell, ispell-ru

%package ie-cp1251
Summary: Russian ispell dictionary, CP1251, only "ie" spelling allowed
Summary(ru_RU.UTF-8): Словарь русского языка для ispell, CP1251, без поддержки буквы "ё"
Summary(be_BY.UTF-8): Слоўнік рускае мовы для ispell, CP1251, бяз літары "ё"
Group: Text tools
Requires: %name-common
Requires: ispell >= %ispell_version
Provides: ispell-dictionary, ispell-ru-cp1251 = %version
Obsoletes: irussian, ispell-rus, ispell-russian, rispell, ispell-ru-cp1251

%package io
Summary: Russian ispell dictionary, KOI8-R, "io" required
Summary(ru_RU.UTF-8): Словарь русского языка для ispell, KOI8-R, обязательное употребление буквы 'ё'
Summary(be_BY.UTF-8): Слоўнік рускае мовы для ispell, KOI8-R, абавязковае выкарыстаньне літары 'ё'
Group: Text tools
Requires: %name-common
Requires: ispell >= %ispell_version
Provides: ispell-dictionary, ispell-ru = %version
Obsoletes: irussian, ispell-rus, ispell-russian, rispell, ispell-ru

%package io-cp1251
Summary: Russian ispell dictionary, CP1251, 'io' required
Summary(ru_RU.UTF-8): Словарь русского языка для ispell, CP1251, обязательное употребление 'ё'
Summary(be_BY.UTF-8): Слоўнік рускае мовы для ispell, CP1251, абавязковае выкарыстаньне літары 'ё'
Group: Text tools
Requires: %name-common
Requires: ispell >= %ispell_version
Provides: ispell-dictionary
Provides: ispell-ru-cp1251 = %version
Obsoletes: irussian, ispell-rus, ispell-russian, rispell, ispell-ru-cp1251


%description
Russian dictionary for ispell in KOI8-R encoding, based on original
Dr. Alexander Lebedev dictionary with a little additions.

This variant allows spellings with and without the "io" letter.

Dictionary is installed under the name "russian-lebedev",
default one with the name "russian" is selected
using alternatives subsystem.

%description -l ru_RU.UTF-8
Словарь русского языка для ispell в кодировке KOI8-R. Основан
на оригинальной версии проф. Александра Лебедева с небольшими
добавлениями.

Допускает замену буквы "ё" на "е" (выборочное употребление
буквы "ё").

Устанавливается под именем "russian-lebedev". Словарь по умолчанию
с именем "russian" выбирается при помощи подсистемы альтернатив.

%description common
This package contains files common among all Russian
ispell/aspell/hunspell/vim dictionaries.

%description cp1251
Russian dictionary for ispell in CP1251 encoding, based on original
Dr. Alexander Lebedev dictionary with a little additions.

This variant allows spellings with and without the "io" letter.

Dictionary is installed under the name "russianw-lebedev",
default one with the name "russianw" is selected
using alternatives subsystem.

%description cp1251 -l ru_RU.UTF-8
Словарь русского языка для ispell в кодировке CP1251. Основан
на оригинальной версии проф. Александра Лебедева с небольшими
добавлениями.

Допускает замену буквы "ё" на "е" (выборочное употребление
буквы "ё").

Устанавливается под именем "russianw-lebedev". Словарь по умолчанию
с именем "russianw" выбирается при помощи подсистемы альтернатив.


%description -n aspell-ru-lebedev
Russian dictionary for use with GNU Aspell, based on original Ispell
dictionary by Dr. Alexander Lebedev with a little additions.

There are three spelling variants available:

 - "ru-lebedev" - allows spellings with and without the "io" letter;
 - "ru-lebedev-io" - requires strict use of the "io" letter;
 - "ru-lebedev-ie" - does not support the "io" letter.

You can select the default Russian dictionary for GNU Aspell
(with the name "ru") using the alternatives subsystem.

%description -n aspell-ru-lebedev -l ru_RU.UTF-8
Словарь русского языка для GNU Aspell. Основан на оригинальной версии
словаря для Ispell проф. Александра Лебедева с небольшими добавлениями.

Доступны три варианта словаря:

 - "ru-lebedev" - допускает замену буквы "ё" на "е" (выборочное
   употребление буквы "ё");
 - "ru-lebedev-io" - требует обязательного использования буквы "ё";
 - "ru-lebedev-ie" - не поддерживает букву "ё".

Выбор словаря русского языка по умолчанию  именем "ru")
осуществляется с помощью механизма альтернатив.


%description  -n hunspell-ru-lebedev
Russian dictionary for myspell/hunspell, based on original Ispell
dictionary by Dr. Alexander Lebedev with a little additions.

Used in OpenOffice, LibreOffice, Mozilla Firefox, Thunderbird
and others.

This variant allows spellings with and without the "io" letter.

This dictionary is installed under the name "ru_RU-lebedev".
Default Russian hunspell dictionary ("ru_RU") is selected
using alternatives.

%description  -n hunspell-ru-lebedev -l ru_RU.UTF-8
Словарь русского языка для myspell/hunspell. Основан на оригинальной
версии словаря для Ispell проф. Александра Лебедева с небольшими
добавлениями.

Используется в OpenOffice, LibreOffice, Mozilla Firefox,
Thunderbird и др.

Допускает замену буквы "ё" на "е" (выборочное употребление
буквы "ё").

Устанавливается под именем "ru_RU-lebedev". Словарь hunspell
по умолчанию ("ru_RU") выбирается с помощью механизма альтернатив.


%description  -n hunspell-ru-lebedev-io
Russian dictionary for myspell/hunspell, based on original Ispell
dictionary by Dr. Alexander Lebedev with a little additions.

Used in OpenOffice, LibreOffice, Mozilla Firefox, Thunderbird
and others.

This variant requires strict use of the "io" letter.

This dictionary is installed under the name "ru_RU-lebedev-io".
Default Russian hunspell dictionary ("ru_RU") is selected
using alternatives.

%description  -n hunspell-ru-lebedev-io -l ru_RU.UTF-8
Словарь русского языка для myspell/hunspell. Основан на оригинальной
версии словаря для Ispell проф. Александра Лебедева с небольшими
добавлениями.

Используется в OpenOffice, LibreOffice, Mozilla Firefox,
Thunderbird и др.

Требует обязательного использования буквы "ё".

Устанавливается под именем "ru_RU-lebedev-io". Словарь hunspell
по умолчанию ("ru_RU") выбирается с помощью механизма альтернатив.


%description  -n hunspell-ru-lebedev-ie
Russian dictionary for myspell/hunspell, based on original Ispell
dictionary by Dr. Alexander Lebedev with a little additions.

Used in OpenOffice, LibreOffice, Mozilla Firefox, Thunderbird
and others.

This variant does not support the "io" letter.

This dictionary is installed under the name "ru_RU-lebedev-ie".
Default Russian hunspell dictionary ("ru_RU") is selected
using alternatives.

%description  -n hunspell-ru-lebedev-ie -l ru_RU.UTF-8
Словарь русского языка для myspell/hunspell. Основан на оригинальной
версии словаря для Ispell проф. Александра Лебедева с небольшими
добавлениями.

Используется в OpenOffice, LibreOffice, Mozilla Firefox,
Thunderbird и др.

Этот вариант словаря не поддерживает букву "ё".

Устанавливается под именем "ru_RU-lebedev-ie". Словарь hunspell
по умолчанию ("ru_RU") выбирается с помощью механизма альтернатив.


%description  -n vim-spell-ru-lebedev
Russian dictionary for vim spellchecking feature, based on original
Ispell dictionary by Dr. Alexander Lebedev with a little additions.

This variant allows spellings with and without the "io" letter.

Accessible in vim under the name "ru-lebedev", so you can call it
with the following vim command:

:setlocal spell spelllang=ru-lebedev

%description  -n vim-spell-ru-lebedev-io
Russian dictionary for vim spellchecking feature, based on original
Ispell dictionary by Dr. Alexander Lebedev with a little additions.

This variant requires strict use of the "io" letter.

Accessible in vim under the name "ru-lebedev-io", so you can call it
with the following vim command:

:setlocal spell spelllang=ru-lebedev-io

%description  -n vim-spell-ru-lebedev-ie
Russian dictionary for vim spellchecking feature, based on original
Ispell dictionary by Dr. Alexander Lebedev with a little additions.

This variant does not support the "io" letter.

Accessible in vim under the name "ru-lebedev-ie", so you can call it
with the following vim command:

:setlocal spell spelllang=ru-lebedev-ie


%description ie
Russian dictionary for ispell in KOI8-R encoding, based on original
Dr. Alexander Lebedev dictionary with a little additions.

This variant does not support the "io" letter.

Dictionary is installed under the name "russian-lebedev-ie",
default one with the name "russian" is selected
using alternatives subsystem.

%description ie -l ru_RU.UTF-8
Словарь русского языка для ispell в кодировке KOI8-R. Основан
на оригинальной версии проф. Александра Лебедева с небольшими
добавлениями.

Этот вариант словаря не поддерживает букву "ё".

Устанавливается под именем "russian-lebedev-ie". Словарь по умолчанию
с именем "russian" выбирается при помощи подсистемы альтернатив.


%description ie-cp1251
Russian dictionary for ispell in CP1251 encoding, based on original
Dr. Alexander Lebedev dictionary with a little additions.

This variant does not support the "io" letter.

Dictionary is installed under the name "russianw-lebedev-ie",
default one with the name "russianw" is selected
using alternatives subsystem.

%description ie-cp1251 -l ru_RU.UTF-8
Словарь русского языка для ispell в кодировке CP1251. Основан
на оригинальной версии проф. Александра Лебедева с небольшими
добавлениями.

Этот вариант словаря не поддерживает букву "ё".

Устанавливается под именем "russianw-lebedev-ie". Словарь по умолчанию
с именем "russianw" выбирается при помощи подсистемы альтернатив.


%description io
Russian dictionary for ispell in KOI8-R encoding, based on original
Dr. Alexander Lebedev dictionary with a little additions.

This variant requires strict use of the "io" letter.

Dictionary is installed under the name "russian-lebedev-io",
default one with the name "russian" is selected
using alternatives subsystem.

%description io -l ru_RU.UTF-8
Словарь русского языка для ispell в кодировке KOI8-R. Основан
на оригинальной версии проф. Александра Лебедева с небольшими
добавлениями.

Этот вариант словаря требует обязательного использования буквы "ё".

Устанавливается под именем "russian-lebedev-io". Словарь по умолчанию
с именем "russian" выбирается при помощи подсистемы альтернатив.


%description io-cp1251
Russian dictionary for ispell in CP1251 encoding, based on original
Dr. Alexander Lebedev dictionary with a little additions.

This variant requires strict use of the "io" letter.

Dictionary is installed under the name "russianw-lebedev-io",
default one with the name "russianw" is selected
using alternatives subsystem.

%description io-cp1251 -l ru_RU.UTF-8
Словарь русского языка для ispell в кодировке CP1251. Основан
на оригинальной версии проф. Александра Лебедева с небольшими
добавлениями.

Этот вариант словаря требует обязательного использования буквы "ё".

Устанавливается под именем "russianw-lebedev-io". Словарь по умолчанию
с именем "russianw" выбирается при помощи подсистемы альтернатив.


%prep
%setup -q -c -a 2
cat %SOURCE10 | iconv -f=utf-8 -t=koi8-r > addition.koi
%patch1 -p1
%patch3 -p1

iconv -fkoi8r -tutf8 <README.koi >README.ru

%build

# BuildIspellEncoding <spelling> <encoding> <encoding-suffix>
BuildIspellEncoding()
{
	DICT="base.koi abbrev.koi computer.koi for_name.koi geography.koi \
		science.koi addition.koi"
		# rare.koi

	FileSuffix "$1"

	case $1 in
	"ie" )
		cat $DICT | sed "/^\(#\|$\)/d" | tr '\243\263' '\305\345' | ./sortkoi8 | uniq |
			./trans koi $2 > russian$3-lebedev$suffix.dict
		cat russian.aff.koi | sed -e "s/^\#e//;s/^\#$2/wordchars/" | \
			./trans koi $2 > russian$3-lebedev$suffix.aff
	;;
	"io" )
		cat $DICT | sed "/^\(#\|$\)/d" | ./sortkoi8 | uniq |
			./trans koi $2 > russian$3-lebedev$suffix.dict
		cat russian.aff.koi | sed -e "s/^\#y//;s/^\#$2/wordchars/" | \
			./trans koi $2 > russian$3-lebedev$suffix.aff
	;;
	* )
		cat russian-lebedev-ie.dict russian-lebedev-io.dict | ./sortkoi8 | uniq |
			./trans koi $2 > russian$3-lebedev.dict
		cat russian.aff.koi | sed -e "s/^\#e//;s/^\#y//;s/^\#$2/wordchars/" | \
			./trans koi $2 > russian$3-lebedev.aff
	;;
	esac

	buildhash ./russian$3-lebedev$suffix.dict ./russian$3-lebedev$suffix.aff \
		russian$3-lebedev$suffix.hash

}

# BuildWordList <spelling>
BuildWordList()
{
	ispell -d ./russian-lebedev-$1.hash -e < russian-lebedev-$1.dict | \
		tr ' ' '\n' | grep -v '^$' | \
		sort -u > "$1.list"
}

# BuildAspellHash <part>
BuildAspellHash()
{
	aspell --lang=ru-lebedev create master ./ru-lebedev-"$1"-only.rws \
		< ru-lebedev-"$1"-only.list
}

# BuildSpelling <spelling>
BuildSpelling()
{
	BuildIspellEncoding "$1" "win" "w"
	BuildIspellEncoding "$1" "koi" ""
	if [ -n "$1" ] ; then
		BuildWordList "$1"
	fi
}

MakeHunspell()
{
	FileSuffix "$1"

	# ALPHABET contains 3rd, 4th and 5th parameters for i2myspell
	# 3rd: alphabet uppercase
	# 4th: alphabet lowercase
	# 5th: all letters in frequency order, taken from original Dr. Lebedev's
	# dictionary for myspell
	ALPHABET="АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"
	ALPHABET="$ALPHABET абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
	ALPHABET="$ALPHABET оаитенрсвйлпкьыяудмзшбчгщюжцёхфэъАВСМКГПТЕИЛФНДОЭРЗЮЯБХЖШЦУЧЬЫЪЩЙЁ"

	# In case of "ie-only" remove "io" from the alphabet
	[ "$1" == "ie" ] && ALPHABET=`echo $ALPHABET | sed -e 's/ё//g;s/Ё//g'`

	# Convert alphabet to koi8-r
	ALPHABET=`echo $ALPHABET | iconv -fUTF-8 -tkoi8-r`

	i2myspell ./russian-lebedev$suffix.hash UTF-8 $ALPHABET | \
		iconv -fkoi8-r -tUTF-8 > ru_RU-lebedev$suffix.aff
	
	# The myspell dictionary is the same as ispell one.
	# The only difference -- words count in the first line.
	cat russian-lebedev$suffix.dict | wc -l > ru_RU-lebedev$suffix.dic
	cat russian-lebedev$suffix.dict | iconv -fkoi8-r -tUTF-8 >> ru_RU-lebedev$suffix.dic
}

MakeVimspell()
{
	FileSuffix "$1"

	# To bild vimspell dictionaries, we need a slightly changed
	# MySpell's affix file, so make a copy
	for ext in dic aff; do
		cp ru_RU-lebedev$suffix.$ext ru_RU-lebedev$suffix.vim.$ext
	done

	# In order to build suggestions feature, vim mkspell requires
	# additional information in SOFOFROM and SOFOTO fields.
	# Next data was proposed and upstreamed by Alexey I. Froloff (raorn@)
	SOFOINFO="\
FOL абвгдеёжзийклмнопрстуфхцчшщьыъэюя\n\
LOW абвгдеёжзийклмнопрстуфхцчшщьыъэюя\n\
UPP АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ\n\
SOFOFROM абвгдеёжзийклмнопрстуфхцчшщьыъэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ\n\
SOFOTO   ебвгдеежзейклннепрстефхцчшшье'еееЕБВГДЕЕЖЗЕЙКЛННЕПРСТЕФХЦЧШШЬЕ'ЕЕЕ\n\
"
	sed -i "0,/^$/s/^$/$SOFOINFO/" ru_RU-lebedev$suffix.vim.aff

	LANG="ru_RU.UTF-8" vim-console -E -X -N -n -i NONE -u NONE -U NONE \
		-c "mkspell! ru-lebedev$suffix ru_RU-lebedev$suffix.vim" -c q
}

FileSuffix()
{
	if [ -n "$1" ] ; then
		suffix="-$1"
	else
		suffix=""
	fi
}

BuildSpelling "ie"
BuildSpelling "io"
# Note: "combined" run must be last, it uses files from previous ones
BuildSpelling ""

# Now we have ie.list and io.list.
# We want to create a combined dictionary which will allow spellings
# either with 'io' or without it.

# For aspell we build three partial dictionaries and combine them
# with .multi files.
comm -12 ie.list io.list | ./sortkoi8 > ru-lebedev-common-only.list
comm -13 ie.list io.list | ./sortkoi8 > ru-lebedev-io-only.list
comm -23 ie.list io.list | ./sortkoi8 > ru-lebedev-ie-only.list
BuildAspellHash common
BuildAspellHash io
BuildAspellHash ie

MakeHunspell "ie"
MakeHunspell "io"
MakeHunspell ""

MakeVimspell "ie"
MakeVimspell "io"
MakeVimspell ""

%install
install -d %buildroot%ispelldir
install -d %buildroot%aspelldir
install -d %buildroot%_datadir/aspell
install -d %buildroot%myspelldir
install -d %buildroot%vim_spell_dir

# Install vimspell dictionary and suggestions files
for spelling in "" "-ie" "-io" ; do
	install -p -m 644 ru-lebedev$spelling.utf-8.{spl,sug} \
		%buildroot%vim_spell_dir
done
for s in spl sug; do
	ln -s ru-lebedev.utf-8.$s %buildroot%vim_spell_dir/ru.utf-8.$s
done

# Install myspell/hunspell dictionary and affix files
for spelling in "" "-ie" "-io" ; do
	install -p -m 644 ru_RU-lebedev$spelling.{aff,dic} \
		%buildroot%myspelldir
done

# Install ispell hash and affix files
for spelling in "" "-ie" "-io" ; do
	install -p -m 644 russian{,w}-lebedev$spelling.{aff,hash} \
		%buildroot%ispelldir
done

# install aspell

# aspell language data files
install -p -m 644 ru-lebedev.dat %buildroot%_datadir/aspell
install -p -m 644 ru-lebedev_phonet.dat %buildroot%_datadir/aspell

# aspell hash files
for i in common ie io ; do
	install -p -m 644 ru-lebedev-"$i"-only.rws \
		%buildroot%aspelldir
done

# aspell .multi and .alias files
for spelling in "" "-ie" "-io" ; do
	install -p -m 644 ru-lebedev$spelling.multi russian-lebedev$spelling.alias \
		%buildroot%aspelldir
done


# install alternatives
install -d %buildroot%_altdir

# ispell and  myspell/hunspell alternatives
for spelling in "" "-ie" "-io" ; do
	case "$spelling" in
		"-io"	) weight=40 ;;
		"-ie"	) weight=10 ;;
		*	) weight=50 ;;
	esac

	# ispell koi8-r
	cat > %buildroot%_altdir/%name$spelling << EOF
%ispelldir/russian.hash	%ispelldir/russian-lebedev$spelling.hash	$weight
%ispelldir/russian.aff	%ispelldir/russian-lebedev$spelling.aff	%ispelldir/russian-lebedev$spelling.hash
EOF

	# ispell cp1251
	cat > %buildroot%_altdir/%name$spelling-cp1251 << EOF
%ispelldir/russianw.hash	%ispelldir/russianw-lebedev$spelling.hash	$weight
%ispelldir/russianw.aff	%ispelldir/russianw-lebedev$spelling.aff	%ispelldir/russianw-lebedev$spelling.hash
EOF

	# myspell/hunspell
	cat > %buildroot%_altdir/hunspell-ru-lebedev$spelling << EOF
%myspelldir/ru_RU.dic	%myspelldir/ru_RU-lebedev$spelling.dic	$weight
%myspelldir/ru_RU.aff	%myspelldir/ru_RU-lebedev$spelling.aff	%myspelldir/ru_RU-lebedev$spelling.dic
%myspelldir/ru.dic	%myspelldir/ru_RU.dic	1000
%myspelldir/ru.aff	%myspelldir/ru_RU.aff	1000
EOF

done

# aspell alternatives
cat > %buildroot%_altdir/aspell-ru-lebedev << EOF
%aspelldir/ru.multi	%aspelldir/ru-lebedev.multi	50
%aspelldir/russian.alias	%aspelldir/russian-lebedev.alias	%aspelldir/ru-lebedev.multi
%aspelldir/ru.multi	%aspelldir/ru-lebedev-io.multi	40
%aspelldir/russian.alias	%aspelldir/russian-lebedev-io.alias	%aspelldir/ru-lebedev-io.multi
%aspelldir/ru.multi	%aspelldir/ru-lebedev-ie.multi	10
%aspelldir/russian.alias	%aspelldir/russian-lebedev-ie.alias	%aspelldir/ru-lebedev-ie.multi
EOF
cat > %buildroot%_altdir/aspell-ru-lebedev-dat << EOF
/usr/share/aspell/ru.dat	/usr/share/aspell/ru-lebedev.dat	50
/usr/share/aspell/ru_phonet.dat	/usr/share/aspell/ru-lebedev_phonet.dat	/usr/share/aspell/ru-lebedev.dat
EOF

mkdir -p %buildroot%_docdir/%name
install -pm644 LICENSE LICENSE.phonet README README.ru \
	%buildroot%_docdir/%name/
for d in aspell-ru-lebedev hunspell-ru-lebedev{,-i{e,o}} \
	vim-spell-ru-lebedev{,-i{e,o}}; do
	ln -s %name %buildroot%_docdir/$d
done


%files common
%dir %_docdir/%name
%_docdir/%name/LICENSE
%_docdir/%name/README
%_docdir/%name/README.ru

%files
%_altdir/%name
%ispelldir/russian-lebedev.*

%files cp1251
%_altdir/%name-cp1251
%ispelldir/russianw-lebedev.*

%files -n aspell-ru-lebedev
%dir %_docdir/%name
%_docdir/%name/LICENSE.phonet
%_docdir/aspell-ru-lebedev
%_altdir/aspell-ru-lebedev
%aspelldir/*
%_datadir/aspell/*
%_altdir/aspell-ru-lebedev-dat

%files -n hunspell-ru-lebedev
%_docdir/hunspell-ru-lebedev
%_altdir/hunspell-ru-lebedev
%myspelldir/ru_RU-lebedev.*

%files -n hunspell-ru-lebedev-ie
%_docdir/hunspell-ru-lebedev-ie
%_altdir/hunspell-ru-lebedev-ie
%myspelldir/ru_RU-lebedev-ie.*

%files -n hunspell-ru-lebedev-io
%_docdir/hunspell-ru-lebedev-io
%_altdir/hunspell-ru-lebedev-io
%myspelldir/ru_RU-lebedev-io.*

%files -n vim-spell-ru-lebedev
%_docdir/vim-spell-ru-lebedev
%vim_spell_dir/ru-lebedev.*
%vim_spell_dir/ru.*

%files -n vim-spell-ru-lebedev-ie
%_docdir/vim-spell-ru-lebedev-ie
%vim_spell_dir/ru-lebedev-ie.*

%files -n vim-spell-ru-lebedev-io
%_docdir/vim-spell-ru-lebedev-io
%vim_spell_dir/ru-lebedev-io.*

%files ie
%_altdir/%name-ie
%ispelldir/russian-lebedev-ie.*

%files ie-cp1251
%_altdir/%name-ie-cp1251
%ispelldir/russianw-lebedev-ie.*

%files io
%_altdir/%name-io
%ispelldir/russian-lebedev-io.*

%files io-cp1251
%_altdir/%name-io-cp1251
%ispelldir/russianw-lebedev-io.*


%changelog
* Wed Nov 11 2020 Igor Vlasenko <viy@altlinux.ru> 0.99g5-alt15
- AutoProv: yes,noalternatives against multiple auto provides (closes: #39256)

* Sat Jun 01 2019 Igor Vlasenko <viy@altlinux.ru> 0.99g5-alt14
- added alternatives for %_datadir/aspell/ru.dat(+_phonetic)
- (closes: #36827)

* Wed Jan 16 2019 Dmitry V. Levin <ldv@altlinux.org> 0.99g5-alt13
- Added an auxiliary subpackage for better intersubpackage dependencies.
- vim-spell-ru-lebedev: turned into a full replacement of vim-spell-ru.
- Removed redundant PreReqs on alternatives.
- Fixed license tags.

* Sat Jul 20 2013 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt12.1
- fix alternatives issue (ALT #28364)

* Thu Jul 18 2013 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt12
- a few more words
- hunspell-ru-lebedev obsoletes hunspell-ru
- hunspell: ru-alternative in addition to ru_RU-alternative (closes: #28364)

* Mon Apr 22 2013 Repocop Q. A. Robot <repocop@altlinux.org> 0.99g5-alt11.qa1
- NMU (by repocop). See http://www.altlinux.org/Tools/Repocop
- applied repocop fixes:
  * altlinux-policy-rpm-group-should-be-text-tools for aspell-ru-lebedev
  * altlinux-policy-rpm-group-should-be-text-tools for hunspell-ru-lebedev-ie
  * altlinux-policy-rpm-group-should-be-text-tools for hunspell-ru-lebedev-io
  * altlinux-policy-rpm-group-should-be-text-tools for hunspell-ru-lebedev
  * altlinux-policy-rpm-group-should-be-text-tools for ispell-ru-lebedev
  * altlinux-policy-rpm-group-should-be-text-tools for ispell-ru-lebedev-io-cp1251
  * altlinux-policy-rpm-group-should-be-text-tools for ispell-ru-lebedev-ie
  * altlinux-policy-rpm-group-should-be-text-tools for ispell-ru-lebedev-cp1251
  * altlinux-policy-rpm-group-should-be-text-tools for ispell-ru-lebedev-io
  * altlinux-policy-rpm-group-should-be-text-tools for ispell-ru-lebedev-ie-cp1251

* Sun Feb 26 2012 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt11
- a few more words

* Fri Jan  7 2011 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt10
- build vimspell dictionaries from the same source. New subpackages:
  + vim-spell-ru-lebedev
  + vim-spell-ru-lebedev-io
  + vim-spell-ru-lebedev-ie
- descriptions corrected to satisfy the license term: "Modified versions
  must be clearly marked as such". Byelorussian descriptions removed
  from specfile, sorry...
- a few more words

* Tue Jun  1 2010 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt9
- a few more words

* Fri Feb 26 2010 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt8
- myspell/hunspell: fixed affix rules with cutted suffixes
  (rebuild with fixed i2myspell convertor)
- myspelldir and aspelldir macros in spec
- a few more words

* Wed Feb 24 2010 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt7
- myspell alternatives grouped back, slave-master conflict was settled
- a few more words

* Wed Feb 24 2010 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt6
- myspell alternatives ungouped to avoid slave-master conflict
  with other myspell dictionaries in repository
- a few more words

* Tue Feb 23 2010 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt5
- build dictionaries in myspell/hunspell format too
- a few more words
- alternatives weights slightly changed
- spec cleanup

* Fri Feb 19 2010 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt4
- corrected the build of combined hashes for ispell
- a few more words

* Tue Jan 12 2010 Sergey Kurakin <kurakin@altlinux.org> 0.99g5-alt3
- added extra dictionary addition.koi

* Thu Mar 12 2009 Igor Vlasenko <viy@altlinux.ru> 0.99g5-alt2
- support for alternatives 0.4

* Tue Sep 09 2008 Igor Vlasenko <viy@altlinux.ru> 0.99g5-alt1
- new version 0.99g5.

* Wed Mar 28 2007 Sergey Vlasov <vsu@altlinux.ru> 0.99g4-alt1
- Version 0.99g4.

* Wed Oct 11 2006 Sergey Vlasov <vsu@altlinux.ru> 0.99g3-alt2
- Fix %%_libdir paths in alternative definitions on x86_64 (#10110).
- Switch to uncompressed original tarballs in src.rpm.

* Tue Jun 27 2006 Sergey Vlasov <vsu@altlinux.ru> 0.99g3-alt1
- Version 0.99g3.
- Removed all %%__* macro abuse from spec.

* Sat Jan 28 2006 Sergey Vlasov <vsu@altlinux.ru> 0.99g1-alt1
- Version 0.99g1.
- Added alt-no-substandard-language patch: remove words which
  should not be present in a dictionary used for spellchecking (#8531).

* Sun Jun 12 2005 Sergey Vlasov <vsu@altlinux.ru> 0.99f9-alt1
- Version 0.99f9.
- Converted alternatives config files to new format (0.2.0).
- Updated BuildRequires.

* Thu Jul 29 2004 Sergey Vlasov <vsu@altlinux.ru> 0.99f7-alt1
- Version 0.99f7.
- Fixed aspell version dependencies.

* Thu Jul 29 2004 Vital Khilko <vk@altlinux.ru> 0.99f6-alt2
- NMU to fix #4441 and rebuild for new aspell-0.60
- fixed package descriptions
- added belarusian translation of descriptions

* Sun Nov 23 2003 Sergey Vlasov <vsu@altlinux.ru> 0.99f6-alt1
- Version 0.99f6.
- Updated for new aspell (no more pspell, different dictionary names).
- Updated BuildRequires.
- Spec file cleanup.
- Added Russian descriptions.
- Always build the aspell dictionary (no more --without aspell).

* Tue May 06 2003 Stanislav Ievlev <inger@altlinux.ru> 0.99f2-alt1.1
- move to new alternatives scheme

* Fri Oct 18 2002 Sergey Vlasov <vsu@altlinux.ru> 0.99f2-alt1
- Version 0.99f2.
- Updated URLs.

* Tue Apr 02 2002 Sergey Vlasov <vsu@altlinux.ru> 0.99e9-alt1
- Version 0.99e9.
- Added aspell phonetic rules file from Andrey Grozin.
- Combined all aspell dictionaries into one package.
- Fixed bugs in %%preun scripts (alternatives were lost
  after upgrading).
- Lots of %%triggerpostun to clean up after my %%preun bugs
  in the previous version :-(

* Sun Dec 02 2001 Sergey Vlasov <vsu@altlinux.ru> 0.99e5-alt1
- First spec