Imported Upstream version 17.8.1
[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:        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.6.35
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 Package, Patch, Pattern, and Product Management
138
139 %package devel
140 Summary:        Package, Patch, Pattern, and Product Management - developers files
141 Group:          Development/Libraries/C and C++
142 Provides:       yast2-packagemanager-devel
143 Obsoletes:      yast2-packagemanager-devel
144 %if 0%{?suse_version} >= 1330
145 Requires:       libboost_headers-devel
146 Requires:       libboost_program_options-devel
147 Requires:       libboost_test-devel
148 Requires:       libboost_thread-devel
149 %else
150 Requires:       boost-devel
151 %endif
152 Requires:       bzip2
153 Requires:       glibc-devel
154 Requires:       libstdc++-devel
155 Requires:       libxml2-devel
156 Requires:       libzypp = %{version}
157 Requires:       openssl-devel
158 Requires:       popt-devel
159 Requires:       rpm-devel > 4.4
160 Requires:       zlib-devel
161 %if 0%{?suse_version} >= 1130 || 0%{?fedora_version} >= 16
162 Requires:       libudev-devel
163 %else
164 Requires:       hal-devel
165 %endif
166 %if 0%{?suse_version}
167 %if 0%{?suse_version} >= 1100
168 # Code11+
169 Requires:       libcurl-devel >= %{min_curl_version}
170 %else
171 # Code10
172 Requires:       curl-devel
173 %endif
174 %else
175 # Other distros (Fedora)
176 Requires:       libcurl-devel >= %{min_curl_version}
177 %endif
178 %if 0%{?suse_version} >= 1100
179 %requires_ge    libsolv-devel
180 %else
181 Requires:       libsolv-devel
182 %endif
183
184 %description devel
185 Package, Patch, Pattern, and Product Management - developers files
186
187 %package devel-doc
188 Summary:        Package, Patch, Pattern, and Product Management - developers files
189 Group:          Documentation/HTML
190
191 %description devel-doc
192 Package, Patch, Pattern, and Product Management - developers files
193
194 %prep
195 %setup -q
196
197 %build
198 mkdir build
199 cd build
200 export CFLAGS="$RPM_OPT_FLAGS"
201 export CXXFLAGS="$RPM_OPT_FLAGS"
202 unset EXTRA_CMAKE_OPTIONS
203 # No libproxy on SLE11
204 %if 0%{?suse_version} == 1110
205 export EXTRA_CMAKE_OPTIONS="-DDISABLE_LIBPROXY=ON"
206 %endif
207
208 cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
209       -DDOC_INSTALL_DIR=%{_docdir} \
210       -DLIB=%{_lib} \
211       -DCMAKE_BUILD_TYPE=Release \
212       -DCMAKE_SKIP_RPATH=1 \
213       ${EXTRA_CMAKE_OPTIONS} \
214       ..
215 make %{?_smp_mflags} VERBOSE=1
216 make -C doc/autodoc %{?_smp_mflags}
217 make -C po %{?_smp_mflags} translations
218 make -C tests %{?_smp_mflags}
219
220 %install
221 rm -rf "$RPM_BUILD_ROOT"
222 cd build
223 make install DESTDIR=$RPM_BUILD_ROOT
224 make -C doc/autodoc install DESTDIR=$RPM_BUILD_ROOT
225 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
226 ln -s %{_sysconfdir}/yum.repos.d $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
227 %else
228 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
229 %endif
230 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/services.d
231 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/systemCheck.d
232 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/vars.d
233 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/vendors.d
234 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/multiversion.d
235 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/credentials.d
236 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp
237 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins
238 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/appdata
239 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/commit
240 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/services
241 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/system
242 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/urlresolver
243 mkdir -p $RPM_BUILD_ROOT%{_var}/lib/zypp
244 mkdir -p $RPM_BUILD_ROOT%{_var}/lib/zypp/needreboot.d
245 mkdir -p $RPM_BUILD_ROOT%{_var}/log/zypp
246 mkdir -p $RPM_BUILD_ROOT%{_var}/cache/zypp
247
248 # Default to 'solver.dupAllowVendorChange = false' on TW and post SLE12
249 %if 0%{?suse_version} >= 1330 || "%{distribution}" == "openSUSE Tumbleweed"
250 sed -i "s|# solver.dupAllowVendorChange = true|solver.dupAllowVendorChange = false|g" %{buildroot}%{_sysconfdir}/zypp/zypp.conf
251 %endif
252
253 make -C po install DESTDIR=$RPM_BUILD_ROOT
254 # Create filelist with translations
255 cd ..
256 %{find_lang} zypp
257
258 %check
259 pushd build/tests
260 LD_LIBRARY_PATH=$RPM_BUILD_ROOT%{_libdir}:${LD_LIBRARY_PATH} ctest .
261 popd
262
263 %post
264 /sbin/ldconfig
265 if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi
266
267 # convert old lock file to new
268 # TODO make this a separate file?
269 # TODO run the sript only when updating form pre-11.0 libzypp versions
270 LOCKSFILE=%{_sysconfdir}/zypp/locks
271 OLDLOCKSFILE=%{_sysconfdir}/zypp/locks.old
272
273 is_old(){
274   # if no such file, exit with false (1 in bash)
275   test -f ${LOCKSFILE} || return 1
276   TEMP_FILE=`mktemp`
277   cat ${LOCKSFILE} | sed '/^\#.*/ d;/.*:.*/d;/^[^[a-zA-Z\*?.0-9]*$/d' > ${TEMP_FILE}
278   if [ -s ${TEMP_FILE} ]
279   then
280     RES=0
281   else
282     RES=1
283   fi
284   rm -f ${TEMP_FILE}
285   return ${RES}
286 }
287
288 append_new_lock(){
289   case "$#" in
290     1 )
291   echo "
292 solvable_name: $1
293 match_type: glob
294 " >> ${LOCKSFILE}
295 ;;
296     2 ) #TODO version
297   echo "
298 solvable_name: $1
299 match_type: glob
300 version: $2
301 " >> ${LOCKSFILE}
302 ;;
303     3 ) #TODO version
304   echo "
305 solvable_name: $1
306 match_type: glob
307 version: $2 $3
308 " >> ${LOCKSFILE}
309   ;;
310 esac
311 }
312
313 die() {
314   echo $1
315   exit 1
316 }
317
318 if is_old ${LOCKSFILE}
319   then
320   mv -f ${LOCKSFILE} ${OLDLOCKSFILE} || die "cannot backup old locks"
321   cat ${OLDLOCKSFILE}| sed "/^\#.*/d"| while read line
322   do
323     append_new_lock $line
324   done
325 fi
326
327 %postun -p /sbin/ldconfig
328
329 %clean
330 rm -rf "$RPM_BUILD_ROOT"
331
332 %files -f zypp.lang
333 %defattr(-,root,root)
334 %if 0%{?suse_version} >= 1500
335 %license COPYING
336 %endif
337 %dir               %{_sysconfdir}/zypp
338 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
339 %{_sysconfdir}/zypp/repos.d
340 %else
341 %dir               %{_sysconfdir}/zypp/repos.d
342 %endif
343 %dir               %{_sysconfdir}/zypp/services.d
344 %dir               %{_sysconfdir}/zypp/systemCheck.d
345 %dir               %{_sysconfdir}/zypp/vars.d
346 %dir               %{_sysconfdir}/zypp/vendors.d
347 %dir               %{_sysconfdir}/zypp/multiversion.d
348 %dir               %{_sysconfdir}/zypp/credentials.d
349 %config(noreplace) %{_sysconfdir}/zypp/zypp.conf
350 %config(noreplace) %{_sysconfdir}/zypp/systemCheck
351 %config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
352 %dir               %{_var}/lib/zypp
353 %config(noreplace) %{_var}/lib/zypp/needreboot
354 %dir               %{_var}/lib/zypp/needreboot.d
355 %dir               %{_var}/log/zypp
356 %dir               %{_var}/cache/zypp
357 %{_prefix}/lib/zypp
358 %{_datadir}/zypp
359 %{_bindir}/*
360 %{_libdir}/libzypp*so.*
361 %doc %{_mandir}/man1/*.1.*
362 %doc %{_mandir}/man5/*.5.*
363
364 %files devel
365 %defattr(-,root,root)
366 %{_libdir}/libzypp.so
367 %{_includedir}/zypp
368 %{_datadir}/cmake/Modules/*
369 %{_libdir}/pkgconfig/libzypp.pc
370
371 %files devel-doc
372 %defattr(-,root,root)
373 %{_docdir}/%{name}
374
375 %changelog