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