Switch to using libsolv instead of satsolver
[platform/upstream/libzypp.git] / libzypp.spec.cmake
1 #
2 # spec file for package libzypp
3 #
4 # Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
5 # This file and all modifications and additions to the pristine
6 # package are under the same license as the package itself.
7 #
8 # Please submit bugfixes or comments via http://bugs.opensuse.org/
9 #
10
11 # norootforbuild
12
13 Name:           @PACKAGE@
14 License:        GPLv2
15 Group:          System/Packages
16 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
17 Summary:        Package, Patch, Pattern, and Product Management
18 Version:        @VERSION@
19 Release:        0
20 Source:         %{name}-%{version}.tar.bz2
21 Source1:        %{name}-rpmlintrc
22 Provides:       yast2-packagemanager
23 Obsoletes:      yast2-packagemanager
24
25 # Features we provide (update doc/autoinclude/FeatureTest.doc):
26 Provides:       libzypp(plugin) = 0
27 Provides:       libzypp(plugin:commit) = 0
28 Provides:       libzypp(plugin:services) = 0
29 Provides:       libzypp(plugin:system) = 0
30 Provides:       libzypp(plugin:urlresolver) = 0
31
32 %if 0%{?suse_version}
33 Recommends:     logrotate
34 # lsof is used for 'zypper ps':
35 Recommends:     lsof
36 %endif
37 BuildRequires:  cmake
38 BuildRequires:  openssl-devel
39 %if 0%{?suse_version} >= 1130
40 BuildRequires:  libudev-devel
41 %else
42 BuildRequires:  hal-devel
43 %endif
44 BuildRequires:  boost-devel
45 BuildRequires:  dejagnu
46 BuildRequires:  doxygen
47 BuildRequires:  gcc-c++ >= 4.5
48 BuildRequires:  gettext-devel
49 BuildRequires:  graphviz
50 BuildRequires:  libxml2-devel
51 BuildRequires:  libproxy-devel
52
53 BuildRequires:  libsolv-devel
54 %if 0%{?suse_version} >= 1100
55 %requires_eq    libsolv-tools
56 %else
57 Requires:       libsolv-tools
58 %endif
59
60 # required for testsuite, webrick
61 BuildRequires:  ruby
62
63 %if 0%{?suse_version}
64 BuildRequires:  libexpat-devel
65 %else
66 BuildRequires:  expat-devel
67 %endif
68
69 Requires:       rpm
70
71 %if 0%{?suse_version}
72 BuildRequires:  rpm-devel
73 Requires:       /usr/bin/uuidgen
74 %if 0%{?suse_version} > 1020
75 BuildRequires:  hicolor-icon-theme
76 %endif
77 %endif
78
79 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
80 BuildRequires:  glib2-devel
81 BuildRequires:  popt-devel
82 BuildRequires:  rpm-devel
83 %endif
84
85 %if 0%{?mandriva_version}
86 BuildRequires:  glib2-devel
87 BuildRequires:  librpm-devel
88 # uuidgen
89 Requires:       e2fsprogs
90 %endif
91
92 %if 0%{?suse_version}
93 Requires:       gpg2
94 %else
95 Requires:       gnupg2
96 %endif
97
98 # ---------------------------------------------------------------
99 %if 0%{?suse_version} >= 1110
100 # (almost) common codebase, but on SLES11-SP1 (according to Rudi
101 # suse_version == 1110) we have a patched libcurl-7.19.0-11.22,
102 # and no aria2. Furthermore SLE may use it's own set of .po files
103 # from po/sle-zypp-po.tar.bz2.
104
105 # this check should use 7.19.0 if SLE and 7.19.4 if not (backported
106 # CURLOPT_REDIR_PROTOCOLS)
107 %define min_curl_version 7.19.0-11.22
108 %endif
109
110 # ---------------------------------------------------------------
111
112 %if 0%{?suse_version}
113 %if 0%{?suse_version} >= 1100
114 # Code11+
115 BuildRequires:  libcurl-devel >= %{min_curl_version}
116 Requires:       libcurl4   >= %{min_curl_version}
117 %else
118 # Code10
119 BuildRequires:  curl-devel
120 %endif
121 %else
122 # Other distros (Fedora)
123 BuildRequires:  libcurl-devel >= %{min_curl_version}
124 Requires:       libcurl   >= %{min_curl_version}
125 %endif
126
127 %description
128 Package, Patch, Pattern, and Product Management
129
130 Authors:
131 --------
132     Michael Andres <ma@suse.de>
133     Jiri Srain <jsrain@suse.cz>
134     Stefan Schubert <schubi@suse.de>
135     Duncan Mac-Vicar <dmacvicar@suse.de>
136     Klaus Kaempf <kkaempf@suse.de>
137     Marius Tomaschewski <mt@suse.de>
138     Stanislav Visnovsky <visnov@suse.cz>
139     Ladislav Slezak <lslezak@suse.cz>
140
141 %package devel
142 Requires:       libzypp = %{version}
143 Requires:       libxml2-devel
144 Requires:       openssl-devel
145 Requires:       rpm-devel
146 Requires:       glibc-devel
147 Requires:       zlib-devel
148 Requires:       bzip2
149 Requires:       popt-devel
150 Requires:       boost-devel
151 Requires:       libstdc++-devel
152 %if 0%{?suse_version} >= 1130
153 Requires:       libudev-devel
154 %else
155 Requires:       hal-devel
156 %endif
157 Requires:       cmake
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 Summary:        Package, Patch, Pattern, and Product Management - developers files
176 Group:          System/Packages
177 Provides:       yast2-packagemanager-devel
178 Obsoletes:      yast2-packagemanager-devel
179
180 %description -n libzypp-devel
181 Package, Patch, Pattern, and Product Management - developers files
182
183 Authors:
184 --------
185     Michael Andres <ma@suse.de>
186     Jiri Srain <jsrain@suse.cz>
187     Stefan Schubert <schubi@suse.de>
188     Duncan Mac-Vicar <dmacvicar@suse.de>
189     Klaus Kaempf <kkaempf@suse.de>
190     Marius Tomaschewski <mt@suse.de>
191     Stanislav Visnovsky <visnov@suse.cz>
192     Ladislav Slezak <lslezak@suse.cz>
193
194 %prep
195 %setup -q
196
197 %build
198 mkdir build
199 cd build
200 export CFLAGS="$RPM_OPT_FLAGS"
201 export CXXFLAGS="$RPM_OPT_FLAGS"
202 unset TRANSLATION_SET
203 # SLE11-* might want its own translation set:
204 %if 0%{?suse_version} == 1110
205 if [ -f ../po/sle-zypp-po.tar.bz ]; then
206   export TRANSLATION_SET=sle-zypp
207 fi
208 %endif
209 cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
210       -DDOC_INSTALL_DIR=%{_docdir} \
211       -DLIB=%{_lib} \
212       -DCMAKE_BUILD_TYPE=Release \
213       -DCMAKE_SKIP_RPATH=1 \
214       -DUSE_TRANSLATION_SET=${TRANSLATION_SET:-zypp} \
215       ..
216 make %{?_smp_mflags} VERBOSE=1
217 make -C doc/autodoc %{?_smp_mflags}
218 make -C po %{?_smp_mflags} translations
219
220 %if 0%{?run_testsuite}
221   make -C tests %{?_smp_mflags}
222   pushd tests
223   LD_LIBRARY_PATH=$PWD/../zypp:$LD_LIBRARY_PATH ctest .
224   popd
225 %endif
226
227 #make check
228
229 %install
230 rm -rf "$RPM_BUILD_ROOT"
231 cd build
232 make install DESTDIR=$RPM_BUILD_ROOT
233 make -C doc/autodoc install DESTDIR=$RPM_BUILD_ROOT
234 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
235 ln -s %{_sysconfdir}/yum.repos.d $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
236 %else
237 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
238 %endif
239 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/services.d
240 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp
241 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins
242 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/commit
243 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/services
244 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/system
245 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/urlresolver
246 mkdir -p $RPM_BUILD_ROOT%{_var}/lib/zypp
247 mkdir -p $RPM_BUILD_ROOT%{_var}/log/zypp
248 mkdir -p $RPM_BUILD_ROOT%{_var}/cache/zypp
249
250 make -C po install DESTDIR=$RPM_BUILD_ROOT
251 # Create filelist with translations
252 cd ..
253 %{find_lang} zypp
254
255
256 %post
257 /sbin/ldconfig
258 if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi
259
260 # convert old lock file to new
261 # TODO make this a separate file?
262 # TODO run the sript only when updating form pre-11.0 libzypp versions
263 LOCKSFILE=%{_sysconfdir}/zypp/locks
264 OLDLOCKSFILE=%{_sysconfdir}/zypp/locks.old
265
266 is_old(){
267   # if no such file, exit with false (1 in bash)
268   test -f ${LOCKSFILE} || return 1
269   TEMP_FILE=`mktemp`
270   cat ${LOCKSFILE} | sed '/^\#.*/ d;/.*:.*/d;/^[^[a-zA-Z\*?.0-9]*$/d' > ${TEMP_FILE}
271   if [ -s ${TEMP_FILE} ]
272   then
273     RES=0
274   else
275     RES=1
276   fi
277   rm -f ${TEMP_FILE}
278   return ${RES}
279 }
280
281 append_new_lock(){
282   case "$#" in
283     1 )
284   echo "
285 solvable_name: $1
286 match_type: glob
287 " >> ${LOCKSFILE}
288 ;;
289     2 ) #TODO version
290   echo "
291 solvable_name: $1
292 match_type: glob
293 version: $2
294 " >> ${LOCKSFILE}
295 ;;
296     3 ) #TODO version
297   echo "
298 solvable_name: $1
299 match_type: glob
300 version: $2 $3
301 " >> ${LOCKSFILE}
302   ;;
303 esac
304 }
305
306 die() {
307   echo $1
308   exit 1
309 }
310
311 if is_old ${LOCKSFILE}
312   then
313   mv -f ${LOCKSFILE} ${OLDLOCKSFILE} || die "cannot backup old locks"
314   cat ${OLDLOCKSFILE}| sed "/^\#.*/d"| while read line
315   do
316     append_new_lock $line
317   done
318 fi
319
320
321 %postun -p /sbin/ldconfig
322
323 %clean
324 rm -rf "$RPM_BUILD_ROOT"
325
326 %files -f zypp.lang
327 %defattr(-,root,root)
328 %dir               %{_sysconfdir}/zypp
329 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
330 %{_sysconfdir}/zypp/repos.d
331 %else
332 %dir               %{_sysconfdir}/zypp/repos.d
333 %endif
334 %dir               %{_sysconfdir}/zypp/services.d
335 %config(noreplace) %{_sysconfdir}/zypp/zypp.conf
336 %config(noreplace) %{_sysconfdir}/zypp/systemCheck
337 %config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
338 %dir               %{_var}/lib/zypp
339 %dir               %{_var}/log/zypp
340 %dir               %{_var}/cache/zypp
341 %{_prefix}/lib/zypp
342 %{_datadir}/zypp
343 %{_bindir}/*
344 %{_libdir}/libzypp*so.*
345 %doc %{_mandir}/man5/locks.5.*
346
347 %files devel
348 %defattr(-,root,root)
349 %{_libdir}/libzypp.so
350 %{_docdir}/%{name}
351 %{_includedir}/zypp
352 %{_datadir}/cmake/Modules/*
353 %{_libdir}/pkgconfig/libzypp.pc
354
355 %changelog