Package man-pages-uk: Specfile

%define LANG uk
%define locale uk_UA
%define ENC1 KOI8-U
%define ENC2 CP1251

%define origname man-pages-uk_UA.alfa
%define oldversion 0.1.1

Name: man-pages-%LANG
Version: 20030816
Release: alt2

Summary: Ukrainian man (manual) pages
License: distributable
Group: System/Internationalization

Url: http://www.linux.org.ua/cgi-bin/twiki/view/Projects/ManUk
Icon: books-%LANG.xpm

# NB: man-pages-uk comes in CP1251, other two in KOI8-U
# NB: man-pakes-uk_UA.alfa (20030507) seems to supercede
# both other sources generally, so it "just" steps over
Source0: %name-%oldversion.tar.bz2
Source1: %url/mount-2.11-n4.tar.gz
Source2: %url/%origname.tar.gz

Packager: Michael Shigorin <mike@altlinux.ru>

BuildArch: noarch

# Needed for /usr/share/man/uk/.charset file. See bug #9364 for
# details.
Requires: man >= 1.6e-alt1

Obsoletes: man-pages-%LANG-%ENC1, man-pages-%LANG-%ENC2

Summary(ru_RU.KOI8-R): \xf2\xd5\xcb\xcf\xd7\xcf\xc4\xd3\xd4\xd7\xc1 \xd0\xcf\xcc\xd8\xda\xcf\xd7\xc1\xd4\xc5\xcc\xd1 \xce\xc1 \xd5\xcb\xd2\xc1\xc9\xce\xd3\xcb\xcf\xcd \xd1\xda\xd9\xcb\xc5
Summary(uk_UA.KOI8-U): \xe4\xcf\xcb\xd5\xcd\xc5\xce\xd4\xc1æ\xd1 \xcb\xcf\xd2\xc9\xd3\xd4\xd5\xd7\xc1\xde\xc1 \xd5\xcb\xd2\xc1\xa7\xce\xd3\xd8\xcb\xcf\xc0 \xcd\xcf\xd7\xcf\xc0

%description
A small collection of man pages (reference material) from the Linux
Documentation Project (LDP), translated to Ukrainian.

%description -l ru_RU.KOI8-R
\xee\xc5\xc2\xcf\xcc\xd8\xdb\xc1\xd1 \xcb\xcf\xcc\xcc\xc5\xcb\xc3\xc9\xd1 \xd2\xd5\xcb\xcf\xd7\xcf\xc4\xd3\xd4\xd7 \xd0\xcf\xcc\xd8\xda\xcf\xd7\xc1\xd4\xc5\xcc\xd1 (\xd3\xd0\xd2\xc1\xd7\xcf\xde\xce\xd9\xca \xcd\xc1\xd4\xc5\xd2\xc9\xc1\xcc) \xc9\xda
Linux Documentation Project (LDP), \xd0\xc5\xd2\xc5\xd7\xc5ģ\xce\xce\xd9\xc8 \xce\xc1 \xd5\xcb\xd2\xc1\xc9\xce\xd3\xcb\xc9\xca \xd1\xda\xd9\xcb.

%description -l uk_UA.KOI8-U
\xee\xc5\xd7\xc5\xcc\xc9\xcb\xc1 \xcb\xcf\xcc\xc5\xcbæ\xd1 \xc4\xcf\xcb\xd5\xcd\xc5\xce\xd4\xc1æ\xa7 \xcb\xcf\xd2\xc9\xd3\xd4\xd5\xd7\xc1\xde\xc1 (man-\xd3\xd4\xcfҦ\xce\xcb\xc9) \xda Linux
Documentation Project (LDP), \xdd\xcf \xd0\xc5\xd2\xc5\xcb\xcc\xc1\xc4\xc5Φ \xd5\xcb\xd2\xc1\xa7\xce\xd3\xd8\xcb\xcf\xc0.

%prep
%setup -q -a1 -a2 -n %name-%oldversion

%install
mkdir -p %buildroot%_mandir/%LANG/man{1,2,3,4,5,6,7,8,9,n}
mkdir -p %buildroot%_cachedir/man/%LANG/cat{1,2,3,4,5,6,7,8,9,n}

# compression is better handled at brp-compress
find -name '*.gz' | xargs gunzip 2>/dev/null

# man-pages-uk-0.1.1 tarball contents
SECTIONS="1 5 8"
for i in $SECTIONS; do
  for f in man$i/*.[0-9n]; do
    iconv -f %ENC2 -t %ENC1 < "$f" > %buildroot%_mandir/%LANG/$f \
    || {
      echo "** $f: conversion failed"
      exit 1
    }
  done
done

# mount tarball
cp -av usr/share/man/uk_UA/man[0-9] %buildroot%_mandir/%LANG/

# man-pages-uk_UA.alfa tarball content (finally)
rm %origname/man9/ShouldBeDeleted.9
cp -av %origname/man[0-9n] %buildroot%_mandir/%LANG/

# fix subjectivisms more along the common taste
%__subst 's/\xec\xa6\xce\xc1\xcb\xd3/\xec\xa6\xce\xd5\xcb\xd3/g' %buildroot%_mandir/%LANG/*/*

echo >%buildroot%_cachedir/man/%LANG/whatis

%post -p /etc/cron.daily/makewhatis

%postun
if [ "$1" = 0 -a ! -d %_mandir/%LANG ]; then
	rm -rf %_cachedir/man/%LANG
fi

%files
%doc %origname/README %origname/TRANSLATORS
%_mandir/*

%attr(3775,root,man) %dir %_cachedir/man/%LANG
%attr(644,cacheman,man) %ghost %_cachedir/man/%LANG/whatis

%defattr(644,root,man,2775)
%_cachedir/man/%LANG/cat*

%changelog
* Wed Feb 06 2008 Slava Semushin <php-coder@altlinux.ru> 20030816-alt2
- NMU
- Don't supply /usr/share/man/uk/.charset file (part of fix for #9364)
- Exclude .chown.2.swp file from package
- Spec cleanup

* Sat Aug 16 2003 Michael Shigorin <mike@altlinux.ru> 20030816-alt1
- merged subpackages back to single package
  (see man-pages-ru-0.7-alt21)
- merged two more manpage tarballs from http://linux.org.ua
- base charset changed to KOI8-U (following the majority of sources)

* Mon Sep 30 2002 Michael Shigorin <mike@altlinux.ru> 0.1.1-alt1
- missing apt-cache(8) was added from fixed tarball

* Tue Sep 17 2002 Michael Shigorin <mike@altlinux.ru> 0.1-alt1
- initial release
- manpages from Andriy Dobrovol'skiy <dobr@altlinux.ru>
- based on man-pages-ru-0.7-alt20 spec by Sass <sass@altlinux.ru>
- ENC1<->ENC2 (source was in KOI8-R, uk is in CP1251)