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