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