Imported Upstream version 14.45.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 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
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 Requires:       cmake
159 %if 0%{?suse_version}
160 %if 0%{?suse_version} >= 1100
161 # Code11+
162 Requires:       libcurl-devel >= %{min_curl_version}
163 %else
164 # Code10
165 Requires:       curl-devel
166 %endif
167 %else
168 # Other distros (Fedora)
169 Requires:       libcurl-devel >= %{min_curl_version}
170 %endif
171 %if 0%{?suse_version} >= 1100
172 %requires_ge    libsolv-devel
173 %else
174 Requires:       libsolv-devel
175 %endif
176
177 %description devel
178 Package, Patch, Pattern, and Product Management - developers files
179
180 %package devel-doc
181 Summary:        Package, Patch, Pattern, and Product Management - developers files
182 Group:          Documentation/HTML
183
184 %description devel-doc
185 Package, Patch, Pattern, and Product Management - developers files
186
187 %prep
188 %setup -q
189
190 %build
191 mkdir build
192 cd build
193 %if 0%{?force_gcc_46}
194 export CC=gcc-4.6
195 export CXX=g++-4.6
196 %endif
197 export CFLAGS="$RPM_OPT_FLAGS"
198 export CXXFLAGS="$RPM_OPT_FLAGS"
199 unset TRANSLATION_SET
200 unset EXTRA_CMAKE_OPTIONS
201 # Same codebase, but SLES may use it's own translation set.
202 #     suse_version
203 #       1110            SLES11
204 #       1315            SLES12
205 %if 0%{?suse_version} == 1110 || 0%{?suse_version} == 1315
206 if [ -f ../po/sle-zypp-po.tar.bz ]; then
207   export TRANSLATION_SET=sle-zypp
208 fi
209 %endif
210 # No libproxy on SLE11
211 %if 0%{?suse_version} == 1110
212 export EXTRA_CMAKE_OPTIONS="-DDISABLE_LIBPROXY=ON"
213 %endif
214
215 cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
216       -DDOC_INSTALL_DIR=%{_docdir} \
217       -DLIB=%{_lib} \
218       -DCMAKE_BUILD_TYPE=Release \
219       -DCMAKE_SKIP_RPATH=1 \
220       -DUSE_TRANSLATION_SET=${TRANSLATION_SET:-zypp} \
221       ${EXTRA_CMAKE_OPTIONS} \
222       ..
223 make %{?_smp_mflags} VERBOSE=1
224 make -C doc/autodoc %{?_smp_mflags}
225 make -C po %{?_smp_mflags} translations
226
227 %if 0%{?run_testsuite}
228   make -C tests %{?_smp_mflags}
229   pushd tests
230   LD_LIBRARY_PATH=$PWD/../zypp:$LD_LIBRARY_PATH ctest .
231   popd
232 %endif
233
234 #make check
235
236 %install
237 rm -rf "$RPM_BUILD_ROOT"
238 cd build
239 make install DESTDIR=$RPM_BUILD_ROOT
240 make -C doc/autodoc install DESTDIR=$RPM_BUILD_ROOT
241 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
242 ln -s %{_sysconfdir}/yum.repos.d $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
243 %else
244 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
245 %endif
246 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/services.d
247 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/vendors.d
248 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/multiversion.d
249 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/credentials.d
250 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp
251 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins
252 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/appdata
253 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/commit
254 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/services
255 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/system
256 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/urlresolver
257 mkdir -p $RPM_BUILD_ROOT%{_var}/lib/zypp
258 mkdir -p $RPM_BUILD_ROOT%{_var}/log/zypp
259 mkdir -p $RPM_BUILD_ROOT%{_var}/cache/zypp
260
261 make -C po install DESTDIR=$RPM_BUILD_ROOT
262 # Create filelist with translations
263 cd ..
264 %{find_lang} zypp
265
266 %post
267 /sbin/ldconfig
268 if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi
269
270 # convert old lock file to new
271 # TODO make this a separate file?
272 # TODO run the sript only when updating form pre-11.0 libzypp versions
273 LOCKSFILE=%{_sysconfdir}/zypp/locks
274 OLDLOCKSFILE=%{_sysconfdir}/zypp/locks.old
275
276 is_old(){
277   # if no such file, exit with false (1 in bash)
278   test -f ${LOCKSFILE} || return 1
279   TEMP_FILE=`mktemp`
280   cat ${LOCKSFILE} | sed '/^\#.*/ d;/.*:.*/d;/^[^[a-zA-Z\*?.0-9]*$/d' > ${TEMP_FILE}
281   if [ -s ${TEMP_FILE} ]
282   then
283     RES=0
284   else
285     RES=1
286   fi
287   rm -f ${TEMP_FILE}
288   return ${RES}
289 }
290
291 append_new_lock(){
292   case "$#" in
293     1 )
294   echo "
295 solvable_name: $1
296 match_type: glob
297 " >> ${LOCKSFILE}
298 ;;
299     2 ) #TODO version
300   echo "
301 solvable_name: $1
302 match_type: glob
303 version: $2
304 " >> ${LOCKSFILE}
305 ;;
306     3 ) #TODO version
307   echo "
308 solvable_name: $1
309 match_type: glob
310 version: $2 $3
311 " >> ${LOCKSFILE}
312   ;;
313 esac
314 }
315
316 die() {
317   echo $1
318   exit 1
319 }
320
321 if is_old ${LOCKSFILE}
322   then
323   mv -f ${LOCKSFILE} ${OLDLOCKSFILE} || die "cannot backup old locks"
324   cat ${OLDLOCKSFILE}| sed "/^\#.*/d"| while read line
325   do
326     append_new_lock $line
327   done
328 fi
329
330 %postun -p /sbin/ldconfig
331
332 %clean
333 rm -rf "$RPM_BUILD_ROOT"
334
335 %files -f zypp.lang
336 %defattr(-,root,root)
337 %dir               %{_sysconfdir}/zypp
338 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
339 %{_sysconfdir}/zypp/repos.d
340 %else
341 %dir               %{_sysconfdir}/zypp/repos.d
342 %endif
343 %dir               %{_sysconfdir}/zypp/services.d
344 %dir               %{_sysconfdir}/zypp/vendors.d
345 %dir               %{_sysconfdir}/zypp/multiversion.d
346 %dir               %{_sysconfdir}/zypp/credentials.d
347 %config(noreplace) %{_sysconfdir}/zypp/zypp.conf
348 %config(noreplace) %{_sysconfdir}/zypp/systemCheck
349 %config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
350 %dir               %{_var}/lib/zypp
351 %dir               %{_var}/log/zypp
352 %dir               %{_var}/cache/zypp
353 %{_prefix}/lib/zypp
354 %{_datadir}/zypp
355 %{_bindir}/*
356 %{_libdir}/libzypp*so.*
357 %doc %{_mandir}/man1/*.1.*
358 %doc %{_mandir}/man5/*.5.*
359
360 %files devel
361 %defattr(-,root,root)
362 %{_libdir}/libzypp.so
363 %{_includedir}/zypp
364 %{_datadir}/cmake/Modules/*
365 %{_libdir}/pkgconfig/libzypp.pc
366
367 %files devel-doc
368 %defattr(-,root,root)
369 %{_docdir}/%{name}
370
371 %changelog