summaryrefslogtreecommitdiffstats
path: root/php-symfony-icu.spec
blob: 157ef8c78bf9aae8c3b4653b6e9e5d9edb51229c (plain)
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
#
# RPM spec file for php-symfony-icu
#
# Copyright (c) 2013-2014 Shawn Iwinski <shawn.iwinski@gmail.com>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     symfony
%global github_name      Icu
%global github_version   1.2.1
%global github_commit    98e197da54df1f966dd5e8a4992135703569c987

%global composer_vendor  symfony
%global composer_project icu

# "php": ">=5.3.3"
%global php_min_ver          5.3.3
# "symfony/intl": "~2.3" (composer.json)
%global symfony_intl_min_ver 2.3
%global symfony_intl_max_ver 3.0
# "lib-ICU": ">=4.4" (composer.json)
%global libicu_min_ver       4.4

%global symfony_dir          %{_datadir}/php/Symfony

# Tests are only run with rpmbuild --with tests to avoid circular dependency
%global with_tests           %{?_with_tests:1}%{!?_with_tests:0}

Name:           php-%{composer_vendor}-%{composer_project}
Version:        %{github_version}
Release:        3%{dist}
Summary:        Symfony Icu Component

Group:          Development/Libraries
License:        MIT
URL:            https://github.com/%{github_owner}/%{github_name}
Source0:        %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch:      noarch
%if %{with_tests}
# For tests
# always ok BuildRequires:  libicu >= %{libicu_min_ver}
BuildRequires:  php(language)    >= %{php_min_ver}
BuildRequires:  php-symfony-intl >= %{symfony_intl_min_ver}
BuildRequires:  php-symfony-intl <  %{symfony_intl_max_ver}
# For tests: phpcompatinfo (computed from version 1.2.1)
Requires:       php-ctype
Requires:       php-intl
%endif

# always ok Requires:       libicu  >= %{libicu_min_ver}
Requires:       php(language)    >= %{php_min_ver}
# phpcompatinfo (computed from version 1.2.1)
Requires:       php-ctype
Requires:       php-intl

# Composer
Provides:       php-composer(%{composer_vendor}/%{composer_project}) = %{version}

# Disabled to prevent circular dependency
#Requires:       php-symfony-intl >= %%{symfony_intl_min_ver}
#Requires:       php-symfony-intl <  %%{symfony_intl_max_ver}
# Ensure conflicting versions are not installed
Conflicts:      php-symfony-intl <  %{symfony_intl_min_ver}
Conflicts:      php-symfony-intl >= %{symfony_intl_max_ver}
# Rename
Obsoletes:      php-symfony2-Icu < %{version}-%{release}
Provides:       php-symfony2-Icu = %{version}-%{release}


%description
Contains data of the ICU library.

You should not directly use this component. Use it through the API of the
Symfony Intl component instead.

NOTE: This package requires the Symfony Intl package (>= %{symfony_intl_min_ver}, < %{symfony_intl_max_ver})
      but does not explicitly require it to prevent a circular dependency.


%prep
%setup -qn %{github_name}-%{github_commit}


%build
# Empty build section, nothing required


%install
mkdir -p %{buildroot}%{symfony_dir}/Component/Icu
cp -rp *.php Resources Tests %{buildroot}%{symfony_dir}/Component/Icu/

# Lang files
for res_file in \
    %{buildroot}%{symfony_dir}/Component/Icu/Resources/data/*/*.res
do
    res_file_lang=$(basename $res_file | sed 's#\(_.*\)*\.res##')
    if [ "root" != "$res_file_lang" ] && \
       [ "supplementaldata" != "$res_file_lang" ]
    then
        echo "%lang($res_file_lang) $res_file"
    else
        echo "$res_file"
    fi
done > %{name}.lang
sed -i "s#%{buildroot}##" %{name}.lang


%check
%if %{with_tests}
# Create tests' autoloader
mkdir vendor
( cat <<'AUTOLOADER'
<?php
spl_autoload_register(function ($class) {
    $src = str_replace('\\', '/', $class).'.php';
    @include_once $src;
});
AUTOLOADER
) > vendor/autoload.php

# Create PHPUnit config w/ colors turned off
sed 's/colors="true"/colors="false"/' phpunit.xml.dist > phpunit.xml

%{_bindir}/phpunit \
    --include-path %{buildroot}%{_datadir}/php \
    --exclude-group tty,benchmark \
    -d date.timezone="UTC"
%else
: Tests skipped, missing '--with tests' option
%endif


%files -f %{name}.lang
%defattr(-,root,root,-)
%doc LICENSE *.md composer.json
%doc Resources/data/*.txt

%dir %{symfony_dir}
%dir %{symfony_dir}/Component
%dir %{symfony_dir}/Component/Icu
     %{symfony_dir}/Component/Icu/*.php
%dir %{symfony_dir}/Component/Icu/Resources
%dir %{symfony_dir}/Component/Icu/Resources/data
%dir %{symfony_dir}/Component/Icu/Resources/data/curr
%dir %{symfony_dir}/Component/Icu/Resources/data/lang
%dir %{symfony_dir}/Component/Icu/Resources/data/locales
%dir %{symfony_dir}/Component/Icu/Resources/data/region
%exclude %{symfony_dir}/Component/Icu/Resources/data/*.txt
%exclude %{symfony_dir}/Component/Icu/Tests


%changelog
* Thu Jun 12 2014 Remi Collet <remi@fedoraproject.org> 1.2.1-3
- backport rawhide changes (composer)

* Wed Jun 11 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.2.1-3
- Added php-composer(%%{composer_vendor}/%%{composer_project}) virtual provide

* Tue Apr 29 2014 Remi Collet <remi@fedoraproject.org> 1.2.1-1
- update to 1.2.0 (backport)

* Mon Apr 28 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.2.1-1
- Updated to 1.2.1 (BZ #1078756)

* Wed Nov 27 2013 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.2.0-1
- Updated to 1.2.0

* Sat Nov 23 2013 Remi Collet <remi@fedoraproject.org> 1.2.0-2
- update to 1.2.0 and backport stuff

* Mon Nov 18 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 1.1.0-2
- Renamed from "php-symfony2-icu" to "php-symfony-icu"
- Direct libicu dependency instead of using pkgconfig
- Added tests (only run with rpmbuild --with tests)
- Dependency "php-symfony2-intl" => "php-symfony-intl"

* Mon Nov 18 2013 Remi Collet <remi@fedoraproject.org> 1.2.0-2
- update to 1.2.0 and backport stuff

* Sun Nov 17 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 1.1.0-1
- Initial package