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