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