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