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