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