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