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