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