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