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