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