fixup Fix to build with libxml 2.12.x (fixes #505)
[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 %if 0%{?is_opensuse} && (0%{?sle_version} >= 150100 || 0%{?suse_version} > 1500)
19 %bcond_without zchunk
20 %else
21 %bcond_with zchunk
22 %endif
23
24 %bcond_without mediabackend_tests
25
26 Name:           libzypp
27 Version:        @VERSION@
28 Release:        0
29 License:        GPL-2.0+
30 Url:            https://github.com/openSUSE/libzypp
31 Summary:        Library for package, patch, pattern and product management
32 Group:          System/Packages
33 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
34 Source:         %{name}-%{version}.tar.bz2
35 Source1:        %{name}-rpmlintrc
36 Provides:       yast2-packagemanager
37 Obsoletes:      yast2-packagemanager
38
39 # Features we provide (update doc/autoinclude/FeatureTest.doc):
40 Provides:       libzypp(plugin) = 0.1
41 Provides:       libzypp(plugin:appdata) = 0
42 Provides:       libzypp(plugin:commit) = 1
43 Provides:       libzypp(plugin:services) = 1
44 Provides:       libzypp(plugin:system) = 1
45 Provides:       libzypp(plugin:urlresolver) = 0
46 Provides:       libzypp(repovarexpand) = 1.1
47
48 %if 0%{?suse_version}
49 Recommends:     logrotate
50 # lsof is used for 'zypper ps':
51 Recommends:     lsof
52 %endif
53 BuildRequires:  cmake >= 3.1
54 BuildRequires:  openssl-devel
55 BuildRequires:  pkgconfig(libudev)
56 %if 0%{?suse_version} >= 1330
57 BuildRequires:  libboost_headers-devel
58 BuildRequires:  libboost_program_options-devel
59 BuildRequires:  libboost_test-devel
60 BuildRequires:  libboost_thread-devel
61 %else
62 BuildRequires:  boost-devel
63 %endif
64 BuildRequires:  dejagnu
65 BuildRequires:  doxygen
66 BuildRequires:  gcc-c++ >= 7
67 BuildRequires:  gettext-devel
68 BuildRequires:  graphviz
69 BuildRequires:  libxml2-devel
70 %if 0%{?suse_version} != 1110
71 # No libproxy on SLES
72 BuildRequires:  libproxy-devel
73 %endif
74
75 %if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
76 BuildRequires:  pkgconfig
77 %else
78 BuildRequires:  pkg-config
79 %endif
80
81 BuildRequires:  libsolv-devel >= 0.7.11
82 %if 0%{?suse_version} >= 1100
83 BuildRequires:  libsolv-tools
84 %requires_eq    libsolv-tools
85 %else
86 Requires:       libsolv-tools
87 %endif
88
89 BuildRequires:  glib2-devel
90 BuildRequires:  libsigc++2-devel
91
92 # required for testsuite
93 %if %{with mediabackend_tests}
94 BuildRequires:  nginx
95 %endif
96
97 Requires:       rpm
98
99 %if 0%{?suse_version}
100 BuildRequires:  rpm-devel > 4.4
101 %endif
102
103 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
104 BuildRequires:  popt-devel
105 BuildRequires:  rpm-devel > 4.4
106 %endif
107
108 %if 0%{?mandriva_version}
109 BuildRequires:  librpm-devel > 4.4
110 %endif
111
112 %if 0%{?suse_version}
113 BuildRequires:  libgpgme-devel
114 #testsuite
115 %if %{with mediabackend_tests}
116 BuildRequires:  FastCGI-devel
117 %endif
118 %else
119 BuildRequires:  gpgme-devel
120 #testsuite
121 %if %{with mediabackend_tests}
122 BuildRequires:  fcgi-devel
123 %endif
124 %endif
125
126 %define min_curl_version 7.19.4
127 %if 0%{?suse_version}
128 %if 0%{?suse_version} >= 1100
129 # Code11+
130 BuildRequires:  libcurl-devel >= %{min_curl_version}
131 Requires:       libcurl4   >= %{min_curl_version}
132 %else
133 # Code10
134 BuildRequires:  curl-devel
135 %endif
136 %else
137 # Other distros (Fedora)
138 BuildRequires:  libcurl-devel >= %{min_curl_version}
139 Requires:       libcurl   >= %{min_curl_version}
140 %endif
141
142 # required for documentation
143 %if 0%{?suse_version} >= 1330
144 BuildRequires:  rubygem(asciidoctor)
145 %else
146 BuildRequires:  asciidoc
147 BuildRequires:  libxslt-tools
148 %endif
149
150 %if %{with zchunk}
151 BuildRequires:  libzck-devel
152 %endif
153
154 %description
155 libzypp is the package management library that powers applications
156 like YaST, zypper and the openSUSE/SLE implementation of PackageKit.
157
158 libzypp provides functionality for a package manager:
159
160   * An API for package repository management, supporting most common
161     repository metadata formats and signed repositories.
162   * An API for solving packages, products, patterns and patches
163     (installation, removal, update and distribution upgrade
164     operations) dependencies, with additional features like locking.
165   * An API for commiting the transaction to the system over a rpm
166     target. Supporting deltarpm calculation, media changing and
167     installation order calculation.
168   * An API for browsing available and installed software, with some
169     facilities for programs with an user interface.
170
171 %package devel
172 Summary:        Header files for libzypp, a library for package management
173 Group:          Development/Libraries/C and C++
174 Provides:       yast2-packagemanager-devel
175 Obsoletes:      yast2-packagemanager-devel
176 %if 0%{?suse_version} >= 1330
177 Requires:       libboost_headers-devel
178 Requires:       libboost_program_options-devel
179 Requires:       libboost_test-devel
180 Requires:       libboost_thread-devel
181 %else
182 Requires:       boost-devel
183 %endif
184 Requires:       bzip2
185 Requires:       glibc-devel
186 Requires:       libstdc++-devel
187 Requires:       libxml2-devel
188 Requires:       libzypp = %{version}
189 Requires:       openssl-devel
190 Requires:       popt-devel
191 Requires:       rpm-devel > 4.4
192 Requires:       zlib-devel
193 Requires:       libudev-devel
194 %if 0%{?suse_version}
195 %if 0%{?suse_version} >= 1100
196 # Code11+
197 Requires:       libcurl-devel >= %{min_curl_version}
198 %else
199 # Code10
200 Requires:       curl-devel
201 %endif
202 %else
203 # Other distros (Fedora)
204 Requires:       libcurl-devel >= %{min_curl_version}
205 %endif
206 %if 0%{?suse_version} >= 1100
207 %requires_ge    libsolv-devel
208 %else
209 Requires:       libsolv-devel
210 %endif
211
212 %description devel
213 Development files for libzypp, a library for package, patch, pattern
214 and product management.
215
216 %package devel-doc
217 Summary:        Developer documentation for libzypp
218 Group:          Documentation/HTML
219
220 %description devel-doc
221 Developer documentation for libzypp.
222
223 %prep
224 %setup -q
225
226 %build
227 mkdir build
228 cd build
229 export CFLAGS="%{optflags}"
230 export CXXFLAGS="%{optflags}"
231 unset EXTRA_CMAKE_OPTIONS
232 # No libproxy on SLE11
233 %if 0%{?suse_version} == 1110
234 export EXTRA_CMAKE_OPTIONS="-DDISABLE_LIBPROXY=ON"
235 %endif
236
237 cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
238       -DENABLE_BUILD_DOCS=TRUE \
239       -DENABLE_BUILD_TRANS=TRUE \
240       -DENABLE_BUILD_TESTS=TRUE \
241       -DDOC_INSTALL_DIR=%{_docdir} \
242       -DLIB=%{_lib} \
243       -DCMAKE_BUILD_TYPE=Release \
244       -DCMAKE_SKIP_RPATH=1 \
245       %{?with_zchunk:-DENABLE_ZCHUNK_COMPRESSION=1} \
246       %{!?with_mediabackend_tests:-DDISABLE_MEDIABACKEND_TESTS=1} \
247       ${EXTRA_CMAKE_OPTIONS} \
248       ..
249 make %{?_smp_mflags} VERBOSE=1
250
251 %install
252 cd build
253 %make_install
254 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
255 ln -s %{_sysconfdir}/yum.repos.d %{buildroot}/%{_sysconfdir}/zypp/repos.d
256 %else
257 mkdir -p %{buildroot}/%{_sysconfdir}/zypp/repos.d
258 %endif
259 mkdir -p %{buildroot}/%{_sysconfdir}/zypp/services.d
260 mkdir -p %{buildroot}/%{_sysconfdir}/zypp/systemCheck.d
261 mkdir -p %{buildroot}/%{_sysconfdir}/zypp/vars.d
262 mkdir -p %{buildroot}/%{_sysconfdir}/zypp/vendors.d
263 mkdir -p %{buildroot}/%{_sysconfdir}/zypp/multiversion.d
264 mkdir -p %{buildroot}/%{_sysconfdir}/zypp/needreboot.d
265 mkdir -p %{buildroot}/%{_sysconfdir}/zypp/credentials.d
266 mkdir -p %{buildroot}/%{_prefix}/lib/zypp
267 mkdir -p %{buildroot}/%{_prefix}/lib/zypp/plugins
268 mkdir -p %{buildroot}/%{_prefix}/lib/zypp/plugins/appdata
269 mkdir -p %{buildroot}/%{_prefix}/lib/zypp/plugins/commit
270 mkdir -p %{buildroot}/%{_prefix}/lib/zypp/plugins/services
271 mkdir -p %{buildroot}/%{_prefix}/lib/zypp/plugins/system
272 mkdir -p %{buildroot}/%{_prefix}/lib/zypp/plugins/urlresolver
273 mkdir -p %{buildroot}/%{_var}/lib/zypp
274 mkdir -p %{buildroot}/%{_var}/log/zypp
275 mkdir -p %{buildroot}/%{_var}/cache/zypp
276
277 # Default to 'solver.dupAllowVendorChange = false' on TW and post SLE12
278 %if 0%{?suse_version} >= 1330 || "%{distribution}" == "openSUSE Tumbleweed"
279 sed -i "s|# solver.dupAllowVendorChange = true|solver.dupAllowVendorChange = false|g" %{buildroot}%{_sysconfdir}/zypp/zypp.conf
280 %endif
281
282 cd ..
283
284 # Create filelist with translations
285 %{find_lang} zypp
286
287 %check
288 pushd build/tests
289 LD_LIBRARY_PATH="$(pwd)/../zypp:$LD_LIBRARY_PATH" ctest --output-on-failure .
290 popd
291
292 %post
293 /sbin/ldconfig
294 if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi
295
296 # convert old lock file to new
297 # TODO make this a separate file?
298 # TODO run the sript only when updating form pre-11.0 libzypp versions
299 LOCKSFILE=%{_sysconfdir}/zypp/locks
300 OLDLOCKSFILE=%{_sysconfdir}/zypp/locks.old
301
302 is_old(){
303   # if no such file, exit with false (1 in bash)
304   test -f ${LOCKSFILE} || return 1
305   TEMP_FILE=`mktemp`
306   cat ${LOCKSFILE} | sed '/^\#.*/ d;/.*:.*/d;/^[^[a-zA-Z\*?.0-9]*$/d' > ${TEMP_FILE}
307   if [ -s ${TEMP_FILE} ]
308   then
309     RES=0
310   else
311     RES=1
312   fi
313   rm -f ${TEMP_FILE}
314   return ${RES}
315 }
316
317 append_new_lock(){
318   case "$#" in
319     1 )
320   echo "
321 solvable_name: $1
322 match_type: glob
323 " >> ${LOCKSFILE}
324 ;;
325     2 ) #TODO version
326   echo "
327 solvable_name: $1
328 match_type: glob
329 version: $2
330 " >> ${LOCKSFILE}
331 ;;
332     3 ) #TODO version
333   echo "
334 solvable_name: $1
335 match_type: glob
336 version: $2 $3
337 " >> ${LOCKSFILE}
338   ;;
339 esac
340 }
341
342 die() {
343   echo $1
344   exit 1
345 }
346
347 if is_old ${LOCKSFILE}
348   then
349   mv -f ${LOCKSFILE} ${OLDLOCKSFILE} || die "cannot backup old locks"
350   cat ${OLDLOCKSFILE}| sed "/^\#.*/d"| while read line
351   do
352     append_new_lock $line
353   done
354 fi
355
356 %postun -p /sbin/ldconfig
357
358 %files -f zypp.lang
359 %defattr(-,root,root)
360 %if 0%{?suse_version} >= 1500
361 %license COPYING
362 %endif
363 %dir               %{_sysconfdir}/zypp
364 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
365 %{_sysconfdir}/zypp/repos.d
366 %else
367 %dir               %{_sysconfdir}/zypp/repos.d
368 %endif
369 %dir               %{_sysconfdir}/zypp/services.d
370 %dir               %{_sysconfdir}/zypp/systemCheck.d
371 %dir               %{_sysconfdir}/zypp/vars.d
372 %dir               %{_sysconfdir}/zypp/vendors.d
373 %dir               %{_sysconfdir}/zypp/multiversion.d
374 %config(noreplace) %{_sysconfdir}/zypp/needreboot
375 %dir               %{_sysconfdir}/zypp/needreboot.d
376 %dir               %{_sysconfdir}/zypp/credentials.d
377 %config(noreplace) %{_sysconfdir}/zypp/zypp.conf
378 %config(noreplace) %{_sysconfdir}/zypp/systemCheck
379 %config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
380 %dir               %{_var}/lib/zypp
381 %dir %attr(750,root,root) %{_var}/log/zypp
382 %dir               %{_var}/cache/zypp
383 %{_prefix}/lib/zypp
384 %{_datadir}/zypp
385 %{_bindir}/*
386 %{_libdir}/libzypp*so.*
387 %doc %{_mandir}/man1/*.1.*
388 %doc %{_mandir}/man5/*.5.*
389
390 %files devel
391 %defattr(-,root,root)
392 %{_libdir}/libzypp.so
393 %{_includedir}/zypp
394 %{_datadir}/cmake/Modules/*
395 %{_libdir}/pkgconfig/libzypp.pc
396
397 %files devel-doc
398 %defattr(-,root,root)
399 %{_docdir}/%{name}
400
401 %changelog