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