Imported Upstream version 14.45.17
[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.1
36 Provides:       libzypp(plugin:appdata) = 0
37 Provides:       libzypp(plugin:commit) = 1
38 Provides:       libzypp(plugin:services) = 1
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:  graphviz-gnome
67 BuildRequires:  libxml2-devel
68 %if 0%{?suse_version} != 1110
69 # No libproxy on SLES
70 BuildRequires:  libproxy-devel
71 %endif
72
73 %if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
74 BuildRequires:  pkgconfig
75 %else
76 BuildRequires:  pkg-config
77 %endif
78
79 BuildRequires:  libsolv-devel >= 0.6.19
80 %if 0%{?suse_version} >= 1100
81 BuildRequires:  libsolv-tools
82 %requires_eq    libsolv-tools
83 %else
84 Requires:       libsolv-tools
85 %endif
86
87 # required for testsuite, webrick
88 BuildRequires:  ruby
89
90 %if 0%{?suse_version}
91 BuildRequires:  libexpat-devel
92 %else
93 BuildRequires:  expat-devel
94 %endif
95
96 Requires:       rpm
97
98 %if 0%{?suse_version}
99 BuildRequires:  rpm-devel
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 %endif
112
113 %if 0%{?suse_version}
114 Requires:       gpg2
115 %else
116 Requires:       gnupg2
117 %endif
118
119 %define min_curl_version 7.19.4
120 %if 0%{?suse_version}
121 %if 0%{?suse_version} >= 1100
122 # Code11+
123 BuildRequires:  libcurl-devel >= %{min_curl_version}
124 Requires:       libcurl4   >= %{min_curl_version}
125 %else
126 # Code10
127 BuildRequires:  curl-devel
128 %endif
129 %else
130 # Other distros (Fedora)
131 BuildRequires:  libcurl-devel >= %{min_curl_version}
132 Requires:       libcurl   >= %{min_curl_version}
133 %endif
134
135 %description
136 Package, Patch, Pattern, and Product Management
137
138 %package devel
139 Summary:        Package, Patch, Pattern, and Product Management - developers files
140 Group:          Development/Libraries/C and C++
141 Provides:       yast2-packagemanager-devel
142 Obsoletes:      yast2-packagemanager-devel
143 Requires:       boost-devel
144 Requires:       bzip2
145 Requires:       glibc-devel
146 Requires:       libstdc++-devel
147 Requires:       libxml2-devel
148 Requires:       libzypp = %{version}
149 Requires:       openssl-devel
150 Requires:       popt-devel
151 Requires:       rpm-devel
152 Requires:       zlib-devel
153 %if 0%{?suse_version} >= 1130 || 0%{?fedora_version} >= 16
154 Requires:       libudev-devel
155 %else
156 Requires:       hal-devel
157 %endif
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 TRANSLATION_SET
199 unset EXTRA_CMAKE_OPTIONS
200 # Same codebase, but SLES may use it's own translation set.
201 #     suse_version
202 #       1110            SLES11
203 #       1315            SLES12
204 %if 0%{?suse_version} == 1110 || 0%{?suse_version} == 1315
205 if [ -f ../po/sle-zypp-po.tar.bz ]; then
206   export TRANSLATION_SET=sle-zypp
207 fi
208 %endif
209 # No libproxy on SLE11
210 %if 0%{?suse_version} == 1110
211 export EXTRA_CMAKE_OPTIONS="-DDISABLE_LIBPROXY=ON"
212 %endif
213
214 cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
215       -DDOC_INSTALL_DIR=%{_docdir} \
216       -DLIB=%{_lib} \
217       -DCMAKE_BUILD_TYPE=Release \
218       -DCMAKE_SKIP_RPATH=1 \
219       -DUSE_TRANSLATION_SET=${TRANSLATION_SET:-zypp} \
220       ${EXTRA_CMAKE_OPTIONS} \
221       ..
222 make %{?_smp_mflags} VERBOSE=1
223 make -C doc/autodoc %{?_smp_mflags}
224 make -C po %{?_smp_mflags} translations
225
226 %if 0%{?run_testsuite}
227   make -C tests %{?_smp_mflags}
228   pushd tests
229   LD_LIBRARY_PATH=$PWD/../zypp:$LD_LIBRARY_PATH ctest .
230   popd
231 %endif
232
233 #make check
234
235 %install
236 rm -rf "$RPM_BUILD_ROOT"
237 cd build
238 make install DESTDIR=$RPM_BUILD_ROOT
239 make -C doc/autodoc install DESTDIR=$RPM_BUILD_ROOT
240 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
241 ln -s %{_sysconfdir}/yum.repos.d $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
242 %else
243 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
244 %endif
245 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/services.d
246 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/vendors.d
247 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/multiversion.d
248 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/credentials.d
249 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp
250 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins
251 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/appdata
252 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/commit
253 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/services
254 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/system
255 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/urlresolver
256 mkdir -p $RPM_BUILD_ROOT%{_var}/lib/zypp
257 mkdir -p $RPM_BUILD_ROOT%{_var}/log/zypp
258 mkdir -p $RPM_BUILD_ROOT%{_var}/cache/zypp
259
260 make -C po install DESTDIR=$RPM_BUILD_ROOT
261 # Create filelist with translations
262 cd ..
263 %{find_lang} zypp
264
265 %post
266 /sbin/ldconfig
267 if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi
268
269 # convert old lock file to new
270 # TODO make this a separate file?
271 # TODO run the sript only when updating form pre-11.0 libzypp versions
272 LOCKSFILE=%{_sysconfdir}/zypp/locks
273 OLDLOCKSFILE=%{_sysconfdir}/zypp/locks.old
274
275 is_old(){
276   # if no such file, exit with false (1 in bash)
277   test -f ${LOCKSFILE} || return 1
278   TEMP_FILE=`mktemp`
279   cat ${LOCKSFILE} | sed '/^\#.*/ d;/.*:.*/d;/^[^[a-zA-Z\*?.0-9]*$/d' > ${TEMP_FILE}
280   if [ -s ${TEMP_FILE} ]
281   then
282     RES=0
283   else
284     RES=1
285   fi
286   rm -f ${TEMP_FILE}
287   return ${RES}
288 }
289
290 append_new_lock(){
291   case "$#" in
292     1 )
293   echo "
294 solvable_name: $1
295 match_type: glob
296 " >> ${LOCKSFILE}
297 ;;
298     2 ) #TODO version
299   echo "
300 solvable_name: $1
301 match_type: glob
302 version: $2
303 " >> ${LOCKSFILE}
304 ;;
305     3 ) #TODO version
306   echo "
307 solvable_name: $1
308 match_type: glob
309 version: $2 $3
310 " >> ${LOCKSFILE}
311   ;;
312 esac
313 }
314
315 die() {
316   echo $1
317   exit 1
318 }
319
320 if is_old ${LOCKSFILE}
321   then
322   mv -f ${LOCKSFILE} ${OLDLOCKSFILE} || die "cannot backup old locks"
323   cat ${OLDLOCKSFILE}| sed "/^\#.*/d"| while read line
324   do
325     append_new_lock $line
326   done
327 fi
328
329 %postun -p /sbin/ldconfig
330
331 %clean
332 rm -rf "$RPM_BUILD_ROOT"
333
334 %files -f zypp.lang
335 %defattr(-,root,root)
336 %dir               %{_sysconfdir}/zypp
337 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
338 %{_sysconfdir}/zypp/repos.d
339 %else
340 %dir               %{_sysconfdir}/zypp/repos.d
341 %endif
342 %dir               %{_sysconfdir}/zypp/services.d
343 %dir               %{_sysconfdir}/zypp/vendors.d
344 %dir               %{_sysconfdir}/zypp/multiversion.d
345 %dir               %{_sysconfdir}/zypp/credentials.d
346 %config(noreplace) %{_sysconfdir}/zypp/zypp.conf
347 %config(noreplace) %{_sysconfdir}/zypp/systemCheck
348 %config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
349 %dir               %{_var}/lib/zypp
350 %dir               %{_var}/log/zypp
351 %dir               %{_var}/cache/zypp
352 %{_prefix}/lib/zypp
353 %{_datadir}/zypp
354 %{_bindir}/*
355 %{_libdir}/libzypp*so.*
356 %doc %{_mandir}/man1/*.1.*
357 %doc %{_mandir}/man5/*.5.*
358
359 %files devel
360 %defattr(-,root,root)
361 %{_libdir}/libzypp.so
362 %{_includedir}/zypp
363 %{_datadir}/cmake/Modules/*
364 %{_libdir}/pkgconfig/libzypp.pc
365
366 %files devel-doc
367 %defattr(-,root,root)
368 %{_docdir}/%{name}
369
370 %changelog