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