File icu.spec of Package icu.7191

#
# spec file for package icu
#
# Copyright (c) 2018 SUSE LINUX 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/
#


Name:           icu
%define lname	libicu52_1
Version:        52.1
Release:        0
%define aversion 52_1
Summary:        International Components for Unicode
License:        MIT
Group:          Development/Libraries/C and C++
Url:            http://icu-project.org/

#DL-URL:	http://download.icu-project.org/files/icu4c/%version/icu4c-%aversion-src.tgz
Source:         icu4c-%aversion-src.tar.xz
Source2:        icu4c-%aversion-docs.tar.xz
Source3:        sanitize_docs.sh
Patch1:         icu-rpmlint.diff
Patch2:         icu-remove-datetime.patch
Patch3:         icu-versioning.diff
Patch4:         icu-fix-install-mode-files.diff
Patch5:         icu-fix-tests-depending-on-date.patch
# PATCH-FIX-UPSTREAM bnc#917129 ticket:11371 icu-CVE-2014-9654.patch pwieczorkiewicz@suse.com -- Improved checking of regular expression pattern size limits.
Patch6:         icu-CVE-2014-9654.patch
# PATCH-FIX-UPSTREAM bnc#929629 ticket:11451 icu-CVE-2014-8146.patch fezhang@suse.com -- Add overflow fix.
Patch7:         icu-CVE-2014-8146.patch
# PATCH-FIX-UPSTREAM bnc#929629 ticket:11451 icu-CVE-2014-8147.patch fezhang@suse.com -- Fix potential overflow issue.
Patch8:         icu-CVE-2014-8147.patch
# PATCH-FIX-UPSTREAM icu-CVE-2016-6293-2017-7867-2017-7868-2017-14952-2017-15422-2017-17484.patch
# bnc#990636 CVE-2016-6293 bnc#1034674 CVE-2017-7868 bnc#1034678 CVE-2017-7867 bnc#1067203 CVE-2017-14952 bnc#1072193 CVE-2017-17484 bnc#1077999 CVE-2017-15422 
# qzhao@suse.com -- Porting upstream security fixes.
Patch9:         icu-CVE-2016-6293-2017-7867-2017-7868-2017-14952-2017-15422-2017-17484.patch
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  pkg-config
BuildRequires:  xz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
ICU is a set of C and C++ libraries that provides robust and
full-featured Unicode and locale support. The library provides calendar
support, conversions for many character sets, language sensitive
collation, date and time formatting, support for many locales, message
catalogs and resources, message formatting, normalization, number and
currency formatting, time zone support, transliteration, and word,
line, and sentence breaking, etc.

This subpackage contains the runtime programs for interacting with ICU.

%package -n %lname
Summary:        International Components for Unicode
Group:          System/Libraries
%ifarch ppc64
# bug437293
Obsoletes:      libicu-64bit
%endif
Requires:       timezone
Obsoletes:      icu-i18ndata
# Following O/P added in timeframe for 12.2
Provides:       libicu = %version-%release
Obsoletes:      libicu < %version-%release
Requires:       libicu%aversion-data

%description -n %lname
ICU is a set of C and C++ libraries that provides robust and
full-featured Unicode support. This package contains the runtime
libraries for ICU which include precompiled locale data.

%package -n libicu%aversion-data
Summary:        International Components for Unicode
Group:          System/Libraries

%description -n libicu%aversion-data
ICU is a set of C and C++ libraries that provides robust and
full-featured Unicode support. This package contains the runtime
libraries for ICU which include precompiled locale data.

This subpackage contains the precompiled ICU databases that contain
most of the locale-specific information.

%package -n libicu-devel
Summary:        International Components for Unicode (development files)
Group:          Development/Libraries/C and C++
%ifarch ppc64
# bug437293
Obsoletes:      libicu-devel-64bit
%endif
Requires:       %lname = %version

%description -n libicu-devel
ICU is a C++ and C library that provides robust and full-featured
Unicode support. This package contains the development files for ICU.

%package -n libicu-doc
Summary:        International Components for Unicode  (html documentation)
Group:          Development/Libraries/C and C++

%description -n libicu-doc
ICU is a C++ and C library that provides robust and full-featured
Unicode support. This package contains the html documentation.

%package data
Summary:        International Components for Unicode (Sources for the Data in ICU)
Group:          System/Libraries
Requires:       %lname >= %version

%description data
ICU is a C++ and C library that provides robust and full-featured
Unicode support. This package contains the source files for the data
found in the "icu" package.

This data describes the Unicode data (normative and informative) and
also all the table-based converters provided in the ICU distribution.

This package contains uncompiled source data.

%prep
%setup -qn icu -a2
%patch -P 1 -P 2 -P 3 -P 4 -p1 -P 5 -p1 -P 6 -P 7 -P 8
%patch9 -p1

%build
cd source
export CXXFLAGS="%optflags -DICU_DATA_DIR=\\\"/usr/share/icu/%version/\\\""
export CFLAGS="$CXXFLAGS"
%configure --disable-static --enable-shared --disable-samples \
	--with-data-packaging=archive
make %{?_smp_mflags}

%install
b="%buildroot"
mkdir -p "$b/%_docdir/%name"
cp -a html "$b/%_docdir/%name/"
cp -a license.html readme.html "$b/%_docdir/%name/"

find . -name CVS -type d -exec rm -Rf "{}" "+"
cd source

make install DESTDIR="$b";

#
# ICU's "pkgdata" utility is really fragile, so icu-versioning.diff
# does as few as possible, but that means we need some additional
# cleanup in the spec file now.
#
pushd "$b/%_libdir/"
for i in *.so.[0-9]*; do
	echo "Looking at $i"
	if [ "${i##*.so.}" != "%version" ]; then
		rm -fv "$i"
		continue
	fi
	# Because U_ICU_VERSION_SHORT is "51_2" and not "51.2",
	# create some symlinks.
	ln -s "$i" "${i%%%version}%aversion"
done
popd

# /usr/lib/rpm/elfdeps requires +x bit and not all had it at one point
chmod a+rx "$b/%_libdir"/lib*.so.*

# install uncompiled source data:
mkdir -p "$b/%_datadir/icu/%version/unidata"
install -m 644 data/unidata/*.txt "$b/%_datadir/icu/%version/unidata"
ln -s unidata/UnicodeData.txt "$b/%_datadir/icu/%version/"

rm "$b/%_datadir/icu/%version/license.html"
rm "$b/%_datadir/icu/%version/install-sh"

%fdupes %buildroot/%_prefix

%check
#ln source/data/in/icudt51l.dat source/data/in/icudt%{version}l.dat
cd source
%if !0%{?qemu_user_space_build:1}
# Checks disabled in qemu because of races happening when we emulate
# multi-threaded programs, and some check tests atomic instructions in
# multi-threaded icu invocations
ICU_DATA="%buildroot/%_datadir/icu/%version" make check VERBOSE=1
%endif

# This should be run by whatever owns /usr/lib64/icu -
# the (main) package in this case
%post
if test -d "%_libdir/icu"; then
	current=$(cd "%_libdir/icu/"; find [0-9]* -maxdepth 1 -type d -printf '%f\n' |
		sort -V | tail -n1);
	if test -n "$current"; then
		rm -f "%_libdir/icu/current";
		ln -sv "$current" "%_libdir/icu/current";
	fi;
fi;

%postun
if test -d "%_libdir/icu"; then
	current=$(cd "%_libdir/icu/"; find [0-9]* -maxdepth 1 -type d -printf '%f\n' |
		sort -V | tail -n1);
	if test -n "$current"; then
		rm -f "%_libdir/icu/current";
		ln -sv "$current" "%_libdir/icu/current";
	fi;
fi;

%post   -n %lname -p /sbin/ldconfig
%postun -n %lname -p /sbin/ldconfig

%files
%defattr(-,root,root)
%dir %_libdir/icu
%dir %_libdir/icu/%version
%_libdir/icu/current
%_bindir/derb
%_bindir/gen*
%_bindir/icuinfo
%_bindir/makeconv
%_bindir/pkgdata
%_bindir/uconv
%_sbindir/*
%_mandir/man*/*
%dir %_docdir/%name/
%_docdir/%name/license.html
%_docdir/%name/readme.html

%files -n %lname
%defattr(-, root, root)
%_libdir/libicu*.so.*

%files -n libicu%aversion-data
%defattr(-,root,root)
%dir %_datadir/icu
%dir %_datadir/icu/%version
%ifarch %sparc mips hppa ppc ppc64 s390 s390x
%_datadir/icu/%version/icudt52b.dat
%else
%_datadir/icu/%version/icudt52l.dat
%endif

%files -n libicu-devel
%defattr(-, root, root)
%_libdir/libicu*.so
%_includedir/unicode/
%_includedir/layout/
%dir %_libdir/icu/
%dir %_libdir/icu/%version/
%_libdir/icu/%version/Makefile.inc
%_libdir/icu/%version/pkgdata.inc
%_libdir/icu/Makefile.inc
%_libdir/icu/pkgdata.inc
%_libdir/pkgconfig/icu-*.pc
%_bindir/icu-config
%dir %_datadir/icu/
%dir %_datadir/icu/%version/
%_datadir/icu/%version/mkinstalldirs
%_datadir/icu/%version/config/

%files -n libicu-doc
%defattr(-,root,root)
%dir %_docdir/%name/
%_docdir/%name/html/

%files data
%defattr(-, root, root)
%dir %_datadir/icu/
%dir %_datadir/icu/%version/
%_datadir/icu/%version/unidata/
%_datadir/icu/%version/UnicodeData.txt

%changelog