Imported Upstream version 15.0.0
[platform/upstream/libzypp.git] / libzypp.spec.cmake
1 #
2 # spec file for package libzypp
3 #
4 # Copyright (c) 2005-2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
5 #
6 # All modifications and additions to the file contributed by third parties
7 # remain the property of their copyright owners, unless otherwise agreed
8 # upon. The license for this file, and modifications and additions to the
9 # file, is the same license as for the pristine package itself (unless the
10 # license for the pristine package is not an Open Source License, in which
11 # case the license is the MIT License). An "Open Source License" is a
12 # license that conforms to the Open Source Definition (Version 1.9)
13 # published by the Open Source Initiative.
14
15 # Please submit bugfixes or comments via http://bugs.opensuse.org/
16 #
17
18
19 %define force_gcc_46 0
20
21 Name:           @PACKAGE@
22 Version:        @VERSION@
23 Release:        0
24 License:        GPL-2.0+
25 Url:            git://gitorious.org/opensuse/libzypp.git
26 Summary:        Package, Patch, Pattern, and Product Management
27 Group:          System/Packages
28 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
29 Source:         %{name}-%{version}.tar.bz2
30 Source1:        %{name}-rpmlintrc
31 Provides:       yast2-packagemanager
32 Obsoletes:      yast2-packagemanager
33
34 # Features we provide (update doc/autoinclude/FeatureTest.doc):
35 Provides:       libzypp(plugin) = 0
36 Provides:       libzypp(plugin:appdata) = 0
37 Provides:       libzypp(plugin:commit) = 1
38 Provides:       libzypp(plugin:services) = 0
39 Provides:       libzypp(plugin:system) = 0
40 Provides:       libzypp(plugin:urlresolver) = 0
41 Provides:       libzypp(repovarexpand) = 0
42
43 %if 0%{?suse_version}
44 Recommends:     logrotate
45 # lsof is used for 'zypper ps':
46 Recommends:     lsof
47 %endif
48 BuildRequires:  cmake
49 BuildRequires:  openssl-devel
50 %if 0%{?suse_version} >= 1130 || 0%{?fedora_version} >= 16
51 BuildRequires:  libudev-devel
52 %else
53 BuildRequires:  hal-devel
54 %endif
55 BuildRequires:  boost-devel
56 BuildRequires:  dejagnu
57 BuildRequires:  doxygen
58 %if 0%{?force_gcc_46}
59 BuildRequires:  gcc46
60 BuildRequires:  gcc46-c++
61 %else
62 BuildRequires:  gcc-c++ >= 4.6
63 %endif
64 BuildRequires:  gettext-devel
65 BuildRequires:  graphviz
66 BuildRequires:  graphviz-gnome
67 BuildRequires:  libxml2-devel
68 %if 0%{?suse_version} != 1110
69 # No libproxy on SLES
70 BuildRequires:  libproxy-devel
71 %endif
72
73 %if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
74 BuildRequires:  pkgconfig
75 %else
76 BuildRequires:  pkg-config
77 %endif
78
79 BuildRequires:  libsolv-devel >= 0.6.7
80 %if 0%{?suse_version} >= 1100
81 BuildRequires:  libsolv-tools
82 %requires_eq    libsolv-tools
83 %else
84 Requires:       libsolv-tools
85 %endif
86
87 # required for testsuite, webrick
88 BuildRequires:  ruby
89
90 %if 0%{?suse_version}
91 BuildRequires:  libexpat-devel
92 %else
93 BuildRequires:  expat-devel
94 %endif
95
96 Requires:       rpm
97
98 %if 0%{?suse_version}
99 BuildRequires:  rpm-devel
100 %endif
101
102 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
103 BuildRequires:  glib2-devel
104 BuildRequires:  popt-devel
105 BuildRequires:  rpm-devel
106 %endif
107
108 %if 0%{?mandriva_version}
109 BuildRequires:  glib2-devel
110 BuildRequires:  librpm-devel
111 %endif
112
113 %if 0%{?suse_version}
114 Requires:       gpg2
115 %else
116 Requires:       gnupg2
117 %endif
118
119 %define min_curl_version 7.19.4
120 %if 0%{?suse_version}
121 %if 0%{?suse_version} >= 1100
122 # Code11+
123 BuildRequires:  libcurl-devel >= %{min_curl_version}
124 Requires:       libcurl4   >= %{min_curl_version}
125 %else
126 # Code10
127 BuildRequires:  curl-devel
128 %endif
129 %else
130 # Other distros (Fedora)
131 BuildRequires:  libcurl-devel >= %{min_curl_version}
132 Requires:       libcurl   >= %{min_curl_version}
133 %endif
134
135 %description
136 Package, Patch, Pattern, and Product Management
137
138 %package devel
139 Summary:        Package, Patch, Pattern, and Product Management - developers files
140 Group:          Development/Libraries/C and C++
141 Provides:       yast2-packagemanager-devel
142 Obsoletes:      yast2-packagemanager-devel
143 Requires:       boost-devel
144 Requires:       bzip2
145 Requires:       glibc-devel
146 Requires:       libstdc++-devel
147 Requires:       libxml2-devel
148 Requires:       libzypp = %{version}
149 Requires:       openssl-devel
150 Requires:       popt-devel
151 Requires:       rpm-devel
152 Requires:       zlib-devel
153 %if 0%{?suse_version} >= 1130 || 0%{?fedora_version} >= 16
154 Requires:       libudev-devel
155 %else
156 Requires:       hal-devel
157 %endif
158 Requires:       cmake
159 %if 0%{?suse_version}
160 %if 0%{?suse_version} >= 1100
161 # Code11+
162 Requires:       libcurl-devel >= %{min_curl_version}
163 %else
164 # Code10
165 Requires:       curl-devel
166 %endif
167 %else
168 # Other distros (Fedora)
169 Requires:       libcurl-devel >= %{min_curl_version}
170 %endif
171 %if 0%{?suse_version} >= 1100
172 %requires_ge    libsolv-devel
173 %else
174 Requires:       libsolv-devel
175 %endif
176
177 %description devel
178 Package, Patch, Pattern, and Product Management - developers files
179
180 %package devel-doc
181 Summary:        Package, Patch, Pattern, and Product Management - developers files
182 Group:          Documentation/HTML
183
184 %description devel-doc
185 Package, Patch, Pattern, and Product Management - developers files
186
187 %prep
188 %setup -q
189
190 %build
191 mkdir build
192 cd build
193 %if 0%{?force_gcc_46}
194 export CC=gcc-4.6
195 export CXX=g++-4.6
196 %endif
197 export CFLAGS="$RPM_OPT_FLAGS"
198 export CXXFLAGS="$RPM_OPT_FLAGS"
199 unset TRANSLATION_SET
200 unset EXTRA_CMAKE_OPTIONS
201 # Same codebase, but SLES may use it's own translation set.
202 #     suse_version
203 #       1110            SLES11
204 #       1315            SLES12
205 %if 0%{?suse_version} == 1110 || 0%{?suse_version} == 1315
206 if [ -f ../po/sle-zypp-po.tar.bz ]; then
207   export TRANSLATION_SET=sle-zypp
208 fi
209 %endif
210 # No libproxy on SLE11
211 %if 0%{?suse_version} == 1110
212 export EXTRA_CMAKE_OPTIONS="-DDISABLE_LIBPROXY=ON"
213 %endif
214
215 cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
216       -DDOC_INSTALL_DIR=%{_docdir} \
217       -DLIB=%{_lib} \
218       -DCMAKE_BUILD_TYPE=Release \
219       -DCMAKE_SKIP_RPATH=1 \
220       -DUSE_TRANSLATION_SET=${TRANSLATION_SET:-zypp} \
221       ${EXTRA_CMAKE_OPTIONS} \
222       ..
223 make %{?_smp_mflags} VERBOSE=1
224 make -C doc/autodoc %{?_smp_mflags}
225 make -C po %{?_smp_mflags} translations
226
227 %if 0%{?run_testsuite}
228   make -C tests %{?_smp_mflags}
229   pushd tests
230   LD_LIBRARY_PATH=$PWD/../zypp:$LD_LIBRARY_PATH ctest .
231   popd
232 %endif
233
234 #make check
235
236 %install
237 rm -rf "$RPM_BUILD_ROOT"
238 cd build
239 make install DESTDIR=$RPM_BUILD_ROOT
240 make -C doc/autodoc install DESTDIR=$RPM_BUILD_ROOT
241 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
242 ln -s %{_sysconfdir}/yum.repos.d $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
243 %else
244 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
245 %endif
246 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/services.d
247 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/vendors.d
248 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/multiversion.d
249 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp
250 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins
251 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/appdata
252 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/commit
253 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/services
254 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/system
255 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/urlresolver
256 mkdir -p $RPM_BUILD_ROOT%{_var}/lib/zypp
257 mkdir -p $RPM_BUILD_ROOT%{_var}/log/zypp
258 mkdir -p $RPM_BUILD_ROOT%{_var}/cache/zypp
259
260 make -C po install DESTDIR=$RPM_BUILD_ROOT
261 # Create filelist with translations
262 cd ..
263 %{find_lang} zypp
264
265 %post
266 /sbin/ldconfig
267 if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi
268
269 # convert old lock file to new
270 # TODO make this a separate file?
271 # TODO run the sript only when updating form pre-11.0 libzypp versions
272 LOCKSFILE=%{_sysconfdir}/zypp/locks
273 OLDLOCKSFILE=%{_sysconfdir}/zypp/locks.old
274
275 is_old(){
276   # if no such file, exit with false (1 in bash)
277   test -f ${LOCKSFILE} || return 1
278   TEMP_FILE=`mktemp`
279   cat ${LOCKSFILE} | sed '/^\#.*/ d;/.*:.*/d;/^[^[a-zA-Z\*?.0-9]*$/d' > ${TEMP_FILE}
280   if [ -s ${TEMP_FILE} ]
281   then
282     RES=0
283   else
284     RES=1
285   fi
286   rm -f ${TEMP_FILE}
287   return ${RES}
288 }
289
290 append_new_lock(){
291   case "$#" in
292     1 )
293   echo "
294 solvable_name: $1
295 match_type: glob
296 " >> ${LOCKSFILE}
297 ;;
298     2 ) #TODO version
299   echo "
300 solvable_name: $1
301 match_type: glob
302 version: $2
303 " >> ${LOCKSFILE}
304 ;;
305     3 ) #TODO version
306   echo "
307 solvable_name: $1
308 match_type: glob
309 version: $2 $3
310 " >> ${LOCKSFILE}
311   ;;
312 esac
313 }
314
315 die() {
316   echo $1
317   exit 1
318 }
319
320 if is_old ${LOCKSFILE}
321   then
322   mv -f ${LOCKSFILE} ${OLDLOCKSFILE} || die "cannot backup old locks"
323   cat ${OLDLOCKSFILE}| sed "/^\#.*/d"| while read line
324   do
325     append_new_lock $line
326   done
327 fi
328
329 %postun -p /sbin/ldconfig
330
331 %clean
332 rm -rf "$RPM_BUILD_ROOT"
333
334 %files -f zypp.lang
335 %defattr(-,root,root)
336 %dir               %{_sysconfdir}/zypp
337 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
338 %{_sysconfdir}/zypp/repos.d
339 %else
340 %dir               %{_sysconfdir}/zypp/repos.d
341 %endif
342 %dir               %{_sysconfdir}/zypp/services.d
343 %dir               %{_sysconfdir}/zypp/vendors.d
344 %dir               %{_sysconfdir}/zypp/multiversion.d
345 %config(noreplace) %{_sysconfdir}/zypp/zypp.conf
346 %config(noreplace) %{_sysconfdir}/zypp/systemCheck
347 %config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
348 %dir               %{_var}/lib/zypp
349 %dir               %{_var}/log/zypp
350 %dir               %{_var}/cache/zypp
351 %{_prefix}/lib/zypp
352 %{_datadir}/zypp
353 %{_bindir}/*
354 %{_libdir}/libzypp*so.*
355 %doc %{_mandir}/man1/*.1.*
356 %doc %{_mandir}/man5/*.5.*
357
358 %files devel
359 %defattr(-,root,root)
360 %{_libdir}/libzypp.so
361 %{_includedir}/zypp
362 %{_datadir}/cmake/Modules/*
363 %{_libdir}/pkgconfig/libzypp.pc
364
365 %files devel-doc
366 %defattr(-,root,root)
367 %{_docdir}/%{name}
368
369 %changelog