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