fix build with libproxy < 0.4.1 by building without it
[platform/upstream/libzypp.git] / libzypp.spec.cmake
index 358f78a..d35da5b 100644 (file)
 # norootforbuild
 
 Name:           @PACKAGE@
-License:        GPL v2 or later
+License:        GPLv2+
 Group:          System/Packages
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-Autoreqprov:    on
 Summary:        Package, Patch, Pattern, and Product Management
 Version:        @VERSION@
 Release:        0
-Source:         @PACKAGE@-@VERSION@.tar.bz2
-Source1:        @PACKAGE@-rpmlintrc
-Prefix:         /usr
+Source:         %{name}-%{version}.tar.bz2
+Source1:        %{name}-rpmlintrc
 Provides:       yast2-packagemanager
 Obsoletes:      yast2-packagemanager
+%if 0%{?suse_version}
+Recommends:     logrotate
+%endif
 BuildRequires:  cmake
-BuildRequires:  libsatsolver-devel openssl-devel
-BuildRequires:  boost-devel curl-devel dejagnu doxygen gcc-c++ gettext-devel graphviz hal-devel libxml2-devel rpm-devel
+BuildRequires:  openssl-devel
+BuildRequires:  libudev-devel
+BuildRequires:  boost-devel
+BuildRequires:  dejagnu
+BuildRequires:  doxygen
+BuildRequires:  gcc-c++
+BuildRequires:  gettext-devel
+BuildRequires:  graphviz
+BuildRequires:  libxml2-devel
+BuildRequires:  libproxy-devel
 
+BuildRequires:  libsatsolver-devel >= 0.14.17
 %if 0%{?suse_version}
-BuildRequires:  hicolor-icon-theme update-desktop-files
+%requires_eq    satsolver-tools
+%else
+Requires:       satsolver-tools
 %endif
 
-%if 0%{?mandriva_version}
-BuildRequires:  sqlite3-devel
-BuildRequires:  glib2-devel
+# required for testsuite, webrick
+BuildRequires:  ruby
+
+%if 0%{?suse_version}
+BuildRequires:  libexpat-devel
 %else
-BuildRequires:  sqlite-devel
+BuildRequires:  expat-devel
+%endif
+
+%if 0%{?suse_version}
+BuildRequires:  hicolor-icon-theme
+BuildRequires:  update-desktop-files
+BuildRequires:  rpm-devel
+Requires:       /usr/bin/uuidgen
 %endif
 
+%if 0%{?fedora_version}
+BuildRequires:  glib2-devel
+BuildRequires:  popt-devel
+BuildRequires:  rpm-devel
+%endif
 
+%if 0%{?mandriva_version}
+BuildRequires:  glib2-devel
+BuildRequires:  librpm-devel
+# uuidgen
+Requires:       e2fsprogs
+%endif
 
 %if 0%{?suse_version}
 Requires:       gpg2
 %else
-Requires:       gnupg
+Requires:       gnupg2
+%endif
+
+# ---------------------------------------------------------------
+%if 0%{?suse_version} == 1110
+# (almost) common codebase, but on SLES11-SP1 (according to Rudi
+# suse_version == 1110) we have a patched libcurl-7.19.0-11.22,
+# and no aria2. Furthermore SLE may use it's own set of .po files
+# from po/sle-zypp-po.tar.bz2.
+%define min_curl_version 7.19.0-11.22
+%define use_translation_set sle-zypp
+# ---------------------------------------------------------------
+%else
+# ---------------------------------------------------------------
+# This is >=11.2 (better not sles11-sp1)
+# need CURLOPT_REDIR_PROTOCOLS:
+%define min_curl_version 7.19.4
 %endif
+# No requirement, but as we'd use it in case it is present,
+# check for a sufficient version:
+%define min_aria_version 1.1.2
+Conflicts:      aria2 < %{min_aria_version}
+# ---------------------------------------------------------------
 
-Requires:       satsolver-tools == %( echo `rpm -q --queryformat '%{VERSION}' satsolver-tools`)
+%if 0%{?suse_version}
+Requires:       libcurl4 >= %{min_curl_version}
+%else
+Requires:       libcurl >= %{min_curl_version}
+%endif
+BuildRequires:  libcurl-devel >= %{min_curl_version}
 
 %description
 Package, Patch, Pattern, and Product Management
@@ -63,10 +121,24 @@ Authors:
     Ladislav Slezak <lslezak@suse.cz>
 
 %package devel
-Requires:       libzypp == @VERSION@
-Requires:       libxml2-devel curl-devel openssl-devel rpm-devel glibc-devel zlib-devel
-Requires:       bzip2 popt-devel dbus-1-devel glib2-devel hal-devel boost-devel libstdc++-devel
-Requires:       cmake libsatsolver-devel
+Requires:       libzypp = %{version}
+Requires:       libxml2-devel
+Requires:       openssl-devel
+Requires:       rpm-devel
+Requires:       glibc-devel
+Requires:       zlib-devel
+Requires:       bzip2
+Requires:       popt-devel
+Requires:       boost-devel
+Requires:       libstdc++-devel
+Requires:       libudev-devel
+Requires:       cmake
+Requires:       libcurl-devel >= %{min_curl_version}
+%if 0%{?suse_version}
+%requires_ge    libsatsolver-devel
+%else
+Requires:       libsatsolver-devel
+%endif
 Summary:        Package, Patch, Pattern, and Product Management - developers files
 Group:          System/Packages
 Provides:       yast2-packagemanager-devel
@@ -92,25 +164,49 @@ Authors:
 %build
 mkdir build
 cd build
-cmake -DCMAKE_INSTALL_PREFIX=%{prefix} \
+export CFLAGS="$RPM_OPT_FLAGS"
+export CXXFLAGS="$RPM_OPT_FLAGS"
+cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+      -DDOC_INSTALL_DIR=%{_docdir} \
       -DLIB=%{_lib} \
-      -DCMAKE_C_FLAGS_RELEASE:STRING="%{optflags}" \
-      -DCMAKE_CXX_FLAGS_RELEASE:STRING="%{optflags}" \
       -DCMAKE_BUILD_TYPE=Release \
       -DCMAKE_SKIP_RPATH=1 \
+      %{?use_translation_set:-DUSE_TRANSLATION_SET=%use_translation_set} \
       ..
-make %{?jobs:-j %jobs} VERBOSE=1
-make -C doc/autodoc %{?jobs:-j %jobs}
-make -C po %{?jobs:-j %jobs} translations
+make %{?_smp_mflags} VERBOSE=1
+make -C doc/autodoc %{?_smp_mflags}
+make -C po %{?_smp_mflags} translations
+
+%if 0%{?run_testsuite}
+  make -C tests %{?_smp_mflags}
+  pushd tests
+  LD_LIBRARY_PATH=$PWD/../zypp:$LD_LIBRARY_PATH ctest .
+  popd
+%endif
 
 #make check
 
 %install
+rm -rf "$RPM_BUILD_ROOT"
 cd build
 make install DESTDIR=$RPM_BUILD_ROOT
 make -C doc/autodoc install DESTDIR=$RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT/etc/zypp/repos.d
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/services.d
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/commit
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/services
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/system
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/urlresolver
+mkdir -p $RPM_BUILD_ROOT%{_var}/lib/zypp
+mkdir -p $RPM_BUILD_ROOT%{_var}/log/zypp
+mkdir -p $RPM_BUILD_ROOT%{_var}/cache/zypp
+
+%if 0%{?suse_version}
 %suse_update_desktop_file -G "" -C "" package-manager
+%endif
+
 make -C po install DESTDIR=$RPM_BUILD_ROOT
 # Create filelist with translations
 cd ..
@@ -118,39 +214,99 @@ cd ..
 
 
 %post
-%run_ldconfig
+/sbin/ldconfig
 if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi
-#%{prefix}/lib/zypp/zypp-migrate-sources
 
-%postun
-%run_ldconfig
+# convert old lock file to new
+# TODO make this a separate file?
+# TODO run the sript only when updating form pre-11.0 libzypp versions
+LOCKSFILE=%{_sysconfdir}/zypp/locks
+OLDLOCKSFILE=%{_sysconfdir}/zypp/locks.old
+
+is_old(){
+  # if no such file, exit with false (1 in bash)
+  test -f ${LOCKSFILE} || return 1
+  TEMP_FILE=`mktemp`
+  cat ${LOCKSFILE} | sed '/^\#.*/ d;/.*:.*/d;/^[^[a-zA-Z\*?.0-9]*$/d' > ${TEMP_FILE}
+  if [ -s ${TEMP_FILE} ]
+  then
+    RES=0
+  else
+    RES=1
+  fi
+  rm -f ${TEMP_FILE}
+  return ${RES}
+}
+
+append_new_lock(){
+  case "$#" in
+    1 )
+  echo "
+solvable_name: $1
+match_type: glob
+" >> ${LOCKSFILE}
+;;
+    2 ) #TODO version
+  echo "
+solvable_name: $1
+match_type: glob
+version: $2
+" >> ${LOCKSFILE}
+;;
+    3 ) #TODO version
+  echo "
+solvable_name: $1
+match_type: glob
+version: $2 $3
+" >> ${LOCKSFILE}
+  ;;
+esac
+}
+
+die() {
+  echo $1
+  exit 1
+}
+
+if is_old ${LOCKSFILE}
+  then
+  mv -f ${LOCKSFILE} ${OLDLOCKSFILE} || die "cannot backup old locks"
+  cat ${OLDLOCKSFILE}| sed "/^\#.*/d"| while read line
+  do
+    append_new_lock $line
+  done
+fi
+
+
+%postun -p /sbin/ldconfig
 
 %clean
+rm -rf "$RPM_BUILD_ROOT"
 
 %files -f zypp.lang
 %defattr(-,root,root)
-%dir               /etc/zypp
-%dir               /etc/zypp/repos.d
-%config(noreplace) /etc/zypp/zypp.conf
-#%{prefix}/lib/zypp
-%{prefix}/share/zypp
-%{prefix}/share/applications/package-manager.desktop
-%{prefix}/share/icons/hicolor/scalable/apps/package-manager-icon.svg
-%{prefix}/share/icons/hicolor/16x16/apps/package-manager-icon.png
-%{prefix}/share/icons/hicolor/32x32/apps/package-manager-icon.png
-%{prefix}/share/icons/hicolor/48x48/apps/package-manager-icon.png
-%{prefix}/bin/package-manager
-%{prefix}/bin/package-manager-su
+%dir               %{_sysconfdir}/zypp
+%dir               %{_sysconfdir}/zypp/repos.d
+%dir               %{_sysconfdir}/zypp/services.d
+%config(noreplace) %{_sysconfdir}/zypp/zypp.conf
+%config(noreplace) %{_sysconfdir}/zypp/systemCheck
+%config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
+%dir               %{_var}/lib/zypp
+%dir               %{_var}/log/zypp
+%dir               %{_var}/cache/zypp
+%{_prefix}/lib/zypp
+%{_datadir}/zypp
+%{_datadir}/applications/package-manager.desktop
+%{_bindir}/*
 %{_libdir}/libzypp*so.*
+%doc %{_mandir}/man5/locks.5.*
 
 %files devel
 %defattr(-,root,root)
 %{_libdir}/libzypp.so
-#%dir %{_libdir}/libzypp.la
 %{_docdir}/%{name}
-%dir %{prefix}/include/zypp
-%{prefix}/include/zypp/*
-%{prefix}/share/cmake/Modules/*
+%{_includedir}/zypp
+%{_datadir}/cmake/Modules/*
 %{_libdir}/pkgconfig/libzypp.pc
 
 %changelog