9532d5602836655f9e5ba98aee139d45f36fadd1
[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}/log/zypp
245 mkdir -p $RPM_BUILD_ROOT%{_var}/cache/zypp
246
247 # Default to 'solver.dupAllowVendorChange = false' on TW and post SLE12
248 %if 0%{?suse_version} >= 1330 || "%{distribution}" == "openSUSE Tumbleweed"
249 sed -i "s|# solver.dupAllowVendorChange = true|solver.dupAllowVendorChange = false|g" %{buildroot}%{_sysconfdir}/zypp/zypp.conf
250 %endif
251
252 make -C po install DESTDIR=$RPM_BUILD_ROOT
253 # Create filelist with translations
254 cd ..
255 %{find_lang} zypp
256
257 %check
258 pushd build/tests
259 LD_LIBRARY_PATH=$RPM_BUILD_ROOT%{_libdir}:${LD_LIBRARY_PATH} ctest .
260 popd
261
262 %post
263 /sbin/ldconfig
264 if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi
265
266 # convert old lock file to new
267 # TODO make this a separate file?
268 # TODO run the sript only when updating form pre-11.0 libzypp versions
269 LOCKSFILE=%{_sysconfdir}/zypp/locks
270 OLDLOCKSFILE=%{_sysconfdir}/zypp/locks.old
271
272 is_old(){
273   # if no such file, exit with false (1 in bash)
274   test -f ${LOCKSFILE} || return 1
275   TEMP_FILE=`mktemp`
276   cat ${LOCKSFILE} | sed '/^\#.*/ d;/.*:.*/d;/^[^[a-zA-Z\*?.0-9]*$/d' > ${TEMP_FILE}
277   if [ -s ${TEMP_FILE} ]
278   then
279     RES=0
280   else
281     RES=1
282   fi
283   rm -f ${TEMP_FILE}
284   return ${RES}
285 }
286
287 append_new_lock(){
288   case "$#" in
289     1 )
290   echo "
291 solvable_name: $1
292 match_type: glob
293 " >> ${LOCKSFILE}
294 ;;
295     2 ) #TODO version
296   echo "
297 solvable_name: $1
298 match_type: glob
299 version: $2
300 " >> ${LOCKSFILE}
301 ;;
302     3 ) #TODO version
303   echo "
304 solvable_name: $1
305 match_type: glob
306 version: $2 $3
307 " >> ${LOCKSFILE}
308   ;;
309 esac
310 }
311
312 die() {
313   echo $1
314   exit 1
315 }
316
317 if is_old ${LOCKSFILE}
318   then
319   mv -f ${LOCKSFILE} ${OLDLOCKSFILE} || die "cannot backup old locks"
320   cat ${OLDLOCKSFILE}| sed "/^\#.*/d"| while read line
321   do
322     append_new_lock $line
323   done
324 fi
325
326 %postun -p /sbin/ldconfig
327
328 %clean
329 rm -rf "$RPM_BUILD_ROOT"
330
331 %files -f zypp.lang
332 %defattr(-,root,root)
333 %if 0%{?suse_version} >= 1500
334 %license COPYING
335 %endif
336 %dir               %{_sysconfdir}/zypp
337 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
338 %{_sysconfdir}/zypp/repos.d
339 %else
340 %dir               %{_sysconfdir}/zypp/repos.d
341 %endif
342 %dir               %{_sysconfdir}/zypp/services.d
343 %dir               %{_sysconfdir}/zypp/systemCheck.d
344 %dir               %{_sysconfdir}/zypp/vars.d
345 %dir               %{_sysconfdir}/zypp/vendors.d
346 %dir               %{_sysconfdir}/zypp/multiversion.d
347 %dir               %{_sysconfdir}/zypp/credentials.d
348 %config(noreplace) %{_sysconfdir}/zypp/zypp.conf
349 %config(noreplace) %{_sysconfdir}/zypp/systemCheck
350 %config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
351 %dir               %{_var}/lib/zypp
352 %dir               %{_var}/log/zypp
353 %dir               %{_var}/cache/zypp
354 %{_prefix}/lib/zypp
355 %{_datadir}/zypp
356 %{_bindir}/*
357 %{_libdir}/libzypp*so.*
358 %doc %{_mandir}/man1/*.1.*
359 %doc %{_mandir}/man5/*.5.*
360
361 %files devel
362 %defattr(-,root,root)
363 %{_libdir}/libzypp.so
364 %{_includedir}/zypp
365 %{_datadir}/cmake/Modules/*
366 %{_libdir}/pkgconfig/libzypp.pc
367
368 %files devel-doc
369 %defattr(-,root,root)
370 %{_docdir}/%{name}
371
372 %changelog