Imported Upstream version 15.22.0
[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
36 Provides:       libzypp(plugin:appdata) = 0
37 Provides:       libzypp(plugin:commit) = 1
38 Provides:       libzypp(plugin:services) = 0
39 Provides:       libzypp(plugin:system) = 1
40 Provides:       libzypp(plugin:urlresolver) = 0
41 Provides:       libzypp(repovarexpand) = 0
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:  libudev-devel
52 %else
53 BuildRequires:  hal-devel
54 %endif
55 BuildRequires:  boost-devel
56 BuildRequires:  dejagnu
57 BuildRequires:  doxygen
58 %if 0%{?force_gcc_46}
59 BuildRequires:  gcc46
60 BuildRequires:  gcc46-c++
61 %else
62 BuildRequires:  gcc-c++ >= 4.6
63 %endif
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.19
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 %if 0%{?suse_version}
90 BuildRequires:  libexpat-devel
91 %else
92 BuildRequires:  expat-devel
93 %endif
94
95 Requires:       rpm
96
97 %if 0%{?suse_version}
98 BuildRequires:  rpm-devel
99 %endif
100
101 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
102 BuildRequires:  glib2-devel
103 BuildRequires:  popt-devel
104 BuildRequires:  rpm-devel
105 %endif
106
107 %if 0%{?mandriva_version}
108 BuildRequires:  glib2-devel
109 BuildRequires:  librpm-devel
110 %endif
111
112 %if 0%{?suse_version}
113 Requires:       gpg2
114 %else
115 Requires:       gnupg2
116 %endif
117
118 %define min_curl_version 7.19.4
119 %if 0%{?suse_version}
120 %if 0%{?suse_version} >= 1100
121 # Code11+
122 BuildRequires:  libcurl-devel >= %{min_curl_version}
123 Requires:       libcurl4   >= %{min_curl_version}
124 %else
125 # Code10
126 BuildRequires:  curl-devel
127 %endif
128 %else
129 # Other distros (Fedora)
130 BuildRequires:  libcurl-devel >= %{min_curl_version}
131 Requires:       libcurl   >= %{min_curl_version}
132 %endif
133
134 %description
135 Package, Patch, Pattern, and Product Management
136
137 %package devel
138 Summary:        Package, Patch, Pattern, and Product Management - developers files
139 Group:          Development/Libraries/C and C++
140 Provides:       yast2-packagemanager-devel
141 Obsoletes:      yast2-packagemanager-devel
142 Requires:       boost-devel
143 Requires:       bzip2
144 Requires:       glibc-devel
145 Requires:       libstdc++-devel
146 Requires:       libxml2-devel
147 Requires:       libzypp = %{version}
148 Requires:       openssl-devel
149 Requires:       popt-devel
150 Requires:       rpm-devel
151 Requires:       zlib-devel
152 %if 0%{?suse_version} >= 1130 || 0%{?fedora_version} >= 16
153 Requires:       libudev-devel
154 %else
155 Requires:       hal-devel
156 %endif
157 Requires:       cmake
158 %if 0%{?suse_version}
159 %if 0%{?suse_version} >= 1100
160 # Code11+
161 Requires:       libcurl-devel >= %{min_curl_version}
162 %else
163 # Code10
164 Requires:       curl-devel
165 %endif
166 %else
167 # Other distros (Fedora)
168 Requires:       libcurl-devel >= %{min_curl_version}
169 %endif
170 %if 0%{?suse_version} >= 1100
171 %requires_ge    libsolv-devel
172 %else
173 Requires:       libsolv-devel
174 %endif
175
176 %description devel
177 Package, Patch, Pattern, and Product Management - developers files
178
179 %package devel-doc
180 Summary:        Package, Patch, Pattern, and Product Management - developers files
181 Group:          Documentation/HTML
182
183 %description devel-doc
184 Package, Patch, Pattern, and Product Management - developers files
185
186 %prep
187 %setup -q
188
189 %build
190 mkdir build
191 cd build
192 %if 0%{?force_gcc_46}
193 export CC=gcc-4.6
194 export CXX=g++-4.6
195 %endif
196 export CFLAGS="$RPM_OPT_FLAGS"
197 export CXXFLAGS="$RPM_OPT_FLAGS"
198 unset EXTRA_CMAKE_OPTIONS
199 # We are moving towards a uniform translation set for SLE and openSUSE.
200 # While separate SLE translations are still present, overlay them.
201 unset TRANSLATION_SET
202 if [ -f ../po/sle-zypp-po.tar.bz2 ]; then
203   export TRANSLATION_SET=sle-zypp
204 fi
205 # No libproxy on SLE11
206 %if 0%{?suse_version} == 1110
207 export EXTRA_CMAKE_OPTIONS="-DDISABLE_LIBPROXY=ON"
208 %endif
209
210 cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
211       -DDOC_INSTALL_DIR=%{_docdir} \
212       -DLIB=%{_lib} \
213       -DCMAKE_BUILD_TYPE=Release \
214       -DCMAKE_SKIP_RPATH=1 \
215       -DUSE_TRANSLATION_SET=${TRANSLATION_SET:-zypp} \
216       ${EXTRA_CMAKE_OPTIONS} \
217       ..
218 make %{?_smp_mflags} VERBOSE=1
219 make -C doc/autodoc %{?_smp_mflags}
220 make -C po %{?_smp_mflags} translations
221
222 %if 0%{?run_testsuite}
223   make -C tests %{?_smp_mflags}
224   pushd tests
225   LD_LIBRARY_PATH=$PWD/../zypp:$LD_LIBRARY_PATH ctest .
226   popd
227 %endif
228
229 #make check
230
231 %install
232 rm -rf "$RPM_BUILD_ROOT"
233 cd build
234 make install DESTDIR=$RPM_BUILD_ROOT
235 make -C doc/autodoc install DESTDIR=$RPM_BUILD_ROOT
236 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
237 ln -s %{_sysconfdir}/yum.repos.d $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
238 %else
239 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
240 %endif
241 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/services.d
242 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/systemCheck.d
243 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/vendors.d
244 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/multiversion.d
245 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/credentials.d
246 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp
247 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins
248 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/appdata
249 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/commit
250 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/services
251 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/system
252 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/urlresolver
253 mkdir -p $RPM_BUILD_ROOT%{_var}/lib/zypp
254 mkdir -p $RPM_BUILD_ROOT%{_var}/log/zypp
255 mkdir -p $RPM_BUILD_ROOT%{_var}/cache/zypp
256
257 make -C po install DESTDIR=$RPM_BUILD_ROOT
258 # Create filelist with translations
259 cd ..
260 %{find_lang} zypp
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 %dir               %{_sysconfdir}/zypp
334 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
335 %{_sysconfdir}/zypp/repos.d
336 %else
337 %dir               %{_sysconfdir}/zypp/repos.d
338 %endif
339 %dir               %{_sysconfdir}/zypp/services.d
340 %dir               %{_sysconfdir}/zypp/systemCheck.d
341 %dir               %{_sysconfdir}/zypp/vendors.d
342 %dir               %{_sysconfdir}/zypp/multiversion.d
343 %dir               %{_sysconfdir}/zypp/credentials.d
344 %config(noreplace) %{_sysconfdir}/zypp/zypp.conf
345 %config(noreplace) %{_sysconfdir}/zypp/systemCheck
346 %config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
347 %dir               %{_var}/lib/zypp
348 %dir               %{_var}/log/zypp
349 %dir               %{_var}/cache/zypp
350 %{_prefix}/lib/zypp
351 %{_datadir}/zypp
352 %{_bindir}/*
353 %{_libdir}/libzypp*so.*
354 %doc %{_mandir}/man1/*.1.*
355 %doc %{_mandir}/man5/*.5.*
356
357 %files devel
358 %defattr(-,root,root)
359 %{_libdir}/libzypp.so
360 %{_includedir}/zypp
361 %{_datadir}/cmake/Modules/*
362 %{_libdir}/pkgconfig/libzypp.pc
363
364 %files devel-doc
365 %defattr(-,root,root)
366 %{_docdir}/%{name}
367
368 %changelog