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