libzypp.spec.cmake 9.17 KB
Newer Older
1 2 3
#
# spec file for package libzypp
#
4
# Copyright (c) 2005-2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
5 6 7 8 9 10 11 12 13 14 15 16 17 18
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


19
%define force_gcc_46 0
20 21

Name:           @PACKAGE@
22 23
Version:        @VERSION@
Release:        0
24
License:        GPL-2.0+
25 26
Url:            git://gitorious.org/opensuse/libzypp.git
Summary:        Package, Patch, Pattern, and Product Management
27 28 29 30 31 32 33 34 35
Group:          System/Packages
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source:         %{name}-%{version}.tar.bz2
Source1:        %{name}-rpmlintrc
Provides:       yast2-packagemanager
Obsoletes:      yast2-packagemanager

# Features we provide (update doc/autoinclude/FeatureTest.doc):
Provides:       libzypp(plugin) = 0
36 37
Provides:       libzypp(plugin:appdata) = 0
Provides:       libzypp(plugin:commit) = 1
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
Provides:       libzypp(plugin:services) = 0
Provides:       libzypp(plugin:system) = 0
Provides:       libzypp(plugin:urlresolver) = 0

%if 0%{?suse_version}
Recommends:     logrotate
# lsof is used for 'zypper ps':
Recommends:     lsof
%endif
BuildRequires:  cmake
BuildRequires:  openssl-devel
%if 0%{?suse_version} >= 1130 || 0%{?fedora_version} >= 16
BuildRequires:  libudev-devel
%else
BuildRequires:  hal-devel
%endif
BuildRequires:  boost-devel
BuildRequires:  dejagnu
BuildRequires:  doxygen
%if 0%{?force_gcc_46}
BuildRequires:  gcc46
BuildRequires:  gcc46-c++
%else
BuildRequires:  gcc-c++ >= 4.6
%endif
BuildRequires:  gettext-devel
BuildRequires:  graphviz
65
BuildRequires:  graphviz-gnome
66 67 68 69 70 71 72 73 74 75 76 77
BuildRequires:  libxml2-devel
%if 0%{?suse_version} != 1110
# No libproxy on SLES
BuildRequires:  libproxy-devel
%endif

%if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
BuildRequires:  pkgconfig
%else
BuildRequires:  pkg-config
%endif

78
BuildRequires:  libsolv-devel >= 0.6.7
79
%if 0%{?suse_version} >= 1100
80
BuildRequires:  libsolv-tools
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
%requires_eq    libsolv-tools
%else
Requires:       libsolv-tools
%endif

# required for testsuite, webrick
BuildRequires:  ruby

%if 0%{?suse_version}
BuildRequires:  libexpat-devel
%else
BuildRequires:  expat-devel
%endif

Requires:       rpm

%if 0%{?suse_version}
BuildRequires:  rpm-devel
%endif

%if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
BuildRequires:  glib2-devel
BuildRequires:  popt-devel
BuildRequires:  rpm-devel
%endif

%if 0%{?mandriva_version}
BuildRequires:  glib2-devel
BuildRequires:  librpm-devel
%endif

%if 0%{?suse_version}
Requires:       gpg2
%else
Requires:       gnupg2
%endif

%define min_curl_version 7.19.4
%if 0%{?suse_version}
%if 0%{?suse_version} >= 1100
# Code11+
BuildRequires:  libcurl-devel >= %{min_curl_version}
Requires:       libcurl4   >= %{min_curl_version}
%else
# Code10
BuildRequires:  curl-devel
%endif
%else
# Other distros (Fedora)
BuildRequires:  libcurl-devel >= %{min_curl_version}
Requires:       libcurl   >= %{min_curl_version}
%endif

%description
Package, Patch, Pattern, and Product Management

%package devel
138 139 140 141 142 143 144 145
Summary:        Package, Patch, Pattern, and Product Management - developers files
Group:          Development/Libraries/C and C++
Provides:       yast2-packagemanager-devel
Obsoletes:      yast2-packagemanager-devel
Requires:       boost-devel
Requires:       bzip2
Requires:       glibc-devel
Requires:       libstdc++-devel
146
Requires:       libxml2-devel
147
Requires:       libzypp = %{version}
148
Requires:       openssl-devel
149
Requires:       popt-devel
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
Requires:       rpm-devel
Requires:       zlib-devel
%if 0%{?suse_version} >= 1130 || 0%{?fedora_version} >= 16
Requires:       libudev-devel
%else
Requires:       hal-devel
%endif
Requires:       cmake
%if 0%{?suse_version}
%if 0%{?suse_version} >= 1100
# Code11+
Requires:       libcurl-devel >= %{min_curl_version}
%else
# Code10
Requires:       curl-devel
%endif
%else
# Other distros (Fedora)
Requires:       libcurl-devel >= %{min_curl_version}
%endif
%if 0%{?suse_version} >= 1100
%requires_ge    libsolv-devel
%else
Requires:       libsolv-devel
%endif

176
%description devel
177 178
Package, Patch, Pattern, and Product Management - developers files

179 180 181 182 183 184
%package devel-doc
Summary:        Package, Patch, Pattern, and Product Management - developers files
Group:          Documentation/HTML

%description devel-doc
Package, Patch, Pattern, and Product Management - developers files
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199

%prep
%setup -q

%build
mkdir build
cd build
%if 0%{?force_gcc_46}
export CC=gcc-4.6
export CXX=g++-4.6
%endif
export CFLAGS="$RPM_OPT_FLAGS"
export CXXFLAGS="$RPM_OPT_FLAGS"
unset TRANSLATION_SET
unset EXTRA_CMAKE_OPTIONS
200 201 202 203 204
# Same codebase, but SLES may use it's own translation set.
#     suse_version
# 	1110		SLES11
# 	1315		SLES12
%if 0%{?suse_version} == 1110 || 0%{?suse_version} == 1315
205 206 207 208
if [ -f ../po/sle-zypp-po.tar.bz ]; then
  export TRANSLATION_SET=sle-zypp
fi
%endif
209 210 211 212 213
# No libproxy on SLE11
%if 0%{?suse_version} == 1110
export EXTRA_CMAKE_OPTIONS="-DDISABLE_LIBPROXY=ON"
%endif

214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
      -DDOC_INSTALL_DIR=%{_docdir} \
      -DLIB=%{_lib} \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_SKIP_RPATH=1 \
      -DUSE_TRANSLATION_SET=${TRANSLATION_SET:-zypp} \
      ${EXTRA_CMAKE_OPTIONS} \
      ..
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
%if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
ln -s %{_sysconfdir}/yum.repos.d $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
%else
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
%endif
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/services.d
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/vendors.d
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/multiversion.d
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins
250
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/appdata
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
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

make -C po install DESTDIR=$RPM_BUILD_ROOT
# Create filelist with translations
cd ..
%{find_lang} zypp

%post
/sbin/ldconfig
if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi

# 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               %{_sysconfdir}/zypp
%if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
%{_sysconfdir}/zypp/repos.d
%else
%dir               %{_sysconfdir}/zypp/repos.d
%endif
%dir               %{_sysconfdir}/zypp/services.d
%dir               %{_sysconfdir}/zypp/vendors.d
%dir               %{_sysconfdir}/zypp/multiversion.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
%{_bindir}/*
%{_libdir}/libzypp*so.*
354 355
%doc %{_mandir}/man1/*.1.*
%doc %{_mandir}/man5/*.5.*
356 357 358 359 360 361 362 363

%files devel
%defattr(-,root,root)
%{_libdir}/libzypp.so
%{_includedir}/zypp
%{_datadir}/cmake/Modules/*
%{_libdir}/pkgconfig/libzypp.pc

364 365 366 367
%files devel-doc
%defattr(-,root,root)
%{_docdir}/%{name}

368
%changelog