fixed spec for fedora
[platform/upstream/libzypp.git] / libzypp.spec.cmake
1 #
2 # spec file for package libzypp
3 #
4 # Copyright (c) 2005-2011 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 # norootforbuild
19
20
21 Name:           @PACKAGE@
22 License:        GPLv2+
23 Group:          System/Packages
24 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
25 Summary:        Package, Patch, Pattern, and Product Management
26 Version:        @VERSION@
27 Release:        1
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) = 0
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 BuildRequires:  gcc-c++ >= 4.6
56 BuildRequires:  gettext-devel
57 BuildRequires:  graphviz
58 BuildRequires:  libxml2-devel
59 BuildRequires:  libproxy-devel
60
61 %if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
62 BuildRequires:  pkgconfig
63 %else
64 BuildRequires:  pkg-config
65 %endif
66
67 BuildRequires:  libsolv-devel
68 %if 0%{?suse_version} >= 1100
69 %requires_eq    libsolv-tools
70 %else
71 Requires:       libsolv-tools
72 %endif
73
74 # required for testsuite, webrick
75 BuildRequires:  ruby
76
77 %if 0%{?suse_version}
78 BuildRequires:  libexpat-devel
79 %else
80 BuildRequires:  expat-devel
81 %endif
82
83 Requires:       rpm
84
85 %if 0%{?suse_version}
86 BuildRequires:  rpm-devel
87 Requires:       /usr/bin/uuidgen
88 %if 0%{?suse_version} > 1020
89 BuildRequires:  hicolor-icon-theme
90 %endif
91 %endif
92
93 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
94 BuildRequires:  glib2-devel
95 BuildRequires:  popt-devel
96 BuildRequires:  rpm-devel
97 %endif
98
99 %if 0%{?mandriva_version}
100 BuildRequires:  glib2-devel
101 BuildRequires:  librpm-devel
102 # uuidgen
103 Requires:       e2fsprogs
104 %endif
105
106 %if 0%{?suse_version}
107 Requires:       gpg2
108 %else
109 Requires:       gnupg2
110 %endif
111
112 %define min_curl_version 7.19.4
113 %if 0%{?suse_version}
114 %if 0%{?suse_version} >= 1100
115 # Code11+
116 BuildRequires:  libcurl-devel >= %{min_curl_version}
117 Requires:       libcurl4   >= %{min_curl_version}
118 %else
119 # Code10
120 BuildRequires:  curl-devel
121 %endif
122 %else
123 # Other distros (Fedora)
124 BuildRequires:  libcurl-devel >= %{min_curl_version}
125 Requires:       libcurl   >= %{min_curl_version}
126 %endif
127
128 %description
129 Package, Patch, Pattern, and Product Management
130
131 Authors:
132 --------
133     Michael Andres <ma@suse.de>
134     Jiri Srain <jsrain@suse.cz>
135     Stefan Schubert <schubi@suse.de>
136     Duncan Mac-Vicar <dmacvicar@suse.de>
137     Klaus Kaempf <kkaempf@suse.de>
138     Marius Tomaschewski <mt@suse.de>
139     Stanislav Visnovsky <visnov@suse.cz>
140     Ladislav Slezak <lslezak@suse.cz>
141
142 %package devel
143 License:        GPLv2+
144 Requires:       libzypp = %{version}
145 Requires:       libxml2-devel
146 Requires:       openssl-devel
147 Requires:       rpm-devel
148 Requires:       glibc-devel
149 Requires:       zlib-devel
150 Requires:       bzip2
151 Requires:       popt-devel
152 Requires:       boost-devel
153 Requires:       libstdc++-devel
154 %if 0%{?suse_version} >= 1130
155 Requires:       libudev-devel
156 %else
157 Requires:       hal-devel
158 %endif
159 Requires:       cmake
160 %if 0%{?suse_version}
161 %if 0%{?suse_version} >= 1100
162 # Code11+
163 Requires:       libcurl-devel >= %{min_curl_version}
164 %else
165 # Code10
166 Requires:       curl-devel
167 %endif
168 %else
169 # Other distros (Fedora)
170 Requires:       libcurl-devel >= %{min_curl_version}
171 %endif
172 %if 0%{?suse_version} >= 1100
173 %requires_ge    libsolv-devel
174 %else
175 Requires:       libsolv-devel
176 %endif
177 Summary:        Package, Patch, Pattern, and Product Management - developers files
178 Group:          System/Packages
179 Provides:       yast2-packagemanager-devel
180 Obsoletes:      yast2-packagemanager-devel
181
182 %description -n libzypp-devel
183 Package, Patch, Pattern, and Product Management - developers files
184
185 Authors:
186 --------
187     Michael Andres <ma@suse.de>
188     Jiri Srain <jsrain@suse.cz>
189     Stefan Schubert <schubi@suse.de>
190     Duncan Mac-Vicar <dmacvicar@suse.de>
191     Klaus Kaempf <kkaempf@suse.de>
192     Marius Tomaschewski <mt@suse.de>
193     Stanislav Visnovsky <visnov@suse.cz>
194     Ladislav Slezak <lslezak@suse.cz>
195
196 %prep
197 %setup -q
198
199 %build
200 mkdir build
201 cd build
202 export CFLAGS="$RPM_OPT_FLAGS"
203 export CXXFLAGS="$RPM_OPT_FLAGS"
204 unset TRANSLATION_SET
205 # SLE11-* might want its own translation set:
206 %if 0%{?suse_version} == 1110
207 if [ -f ../po/sle-zypp-po.tar.bz ]; then
208   export TRANSLATION_SET=sle-zypp
209 fi
210 %endif
211 cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
212       -DDOC_INSTALL_DIR=%{_docdir} \
213       -DLIB=%{_lib} \
214       -DCMAKE_BUILD_TYPE=Release \
215       -DCMAKE_SKIP_RPATH=1 \
216       -DUSE_TRANSLATION_SET=${TRANSLATION_SET:-zypp} \
217       ..
218 make %{?_smp_mflags} VERBOSE=1
219 make -C doc/autodoc %{?_smp_mflags}
220 make -C po %{?_smp_mflags} translations
221
222 %if 0%{?run_testsuite}
223   make -C tests %{?_smp_mflags}
224   pushd tests
225   LD_LIBRARY_PATH=$PWD/../zypp:$LD_LIBRARY_PATH ctest .
226   popd
227 %endif
228
229 #make check
230
231 %install
232 rm -rf "$RPM_BUILD_ROOT"
233 cd build
234 make install DESTDIR=$RPM_BUILD_ROOT
235 make -C doc/autodoc install DESTDIR=$RPM_BUILD_ROOT
236 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
237 ln -s %{_sysconfdir}/yum.repos.d $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
238 %else
239 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
240 %endif
241 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/services.d
242 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp
243 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins
244 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/commit
245 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/services
246 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/system
247 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/urlresolver
248 mkdir -p $RPM_BUILD_ROOT%{_var}/lib/zypp
249 mkdir -p $RPM_BUILD_ROOT%{_var}/log/zypp
250 mkdir -p $RPM_BUILD_ROOT%{_var}/cache/zypp
251
252 make -C po install DESTDIR=$RPM_BUILD_ROOT
253 # Create filelist with translations
254 cd ..
255 %{find_lang} zypp
256
257 %post
258 /sbin/ldconfig
259 if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi
260
261 # convert old lock file to new
262 # TODO make this a separate file?
263 # TODO run the sript only when updating form pre-11.0 libzypp versions
264 LOCKSFILE=%{_sysconfdir}/zypp/locks
265 OLDLOCKSFILE=%{_sysconfdir}/zypp/locks.old
266
267 is_old(){
268   # if no such file, exit with false (1 in bash)
269   test -f ${LOCKSFILE} || return 1
270   TEMP_FILE=`mktemp`
271   cat ${LOCKSFILE} | sed '/^\#.*/ d;/.*:.*/d;/^[^[a-zA-Z\*?.0-9]*$/d' > ${TEMP_FILE}
272   if [ -s ${TEMP_FILE} ]
273   then
274     RES=0
275   else
276     RES=1
277   fi
278   rm -f ${TEMP_FILE}
279   return ${RES}
280 }
281
282 append_new_lock(){
283   case "$#" in
284     1 )
285   echo "
286 solvable_name: $1
287 match_type: glob
288 " >> ${LOCKSFILE}
289 ;;
290     2 ) #TODO version
291   echo "
292 solvable_name: $1
293 match_type: glob
294 version: $2
295 " >> ${LOCKSFILE}
296 ;;
297     3 ) #TODO version
298   echo "
299 solvable_name: $1
300 match_type: glob
301 version: $2 $3
302 " >> ${LOCKSFILE}
303   ;;
304 esac
305 }
306
307 die() {
308   echo $1
309   exit 1
310 }
311
312 if is_old ${LOCKSFILE}
313   then
314   mv -f ${LOCKSFILE} ${OLDLOCKSFILE} || die "cannot backup old locks"
315   cat ${OLDLOCKSFILE}| sed "/^\#.*/d"| while read line
316   do
317     append_new_lock $line
318   done
319 fi
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