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