File deb.spec of Package deb

#
# spec file for package deb
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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/
#


%define admindir %{_localstatedir}/lib/rpm/
%define debhelper_ver 9.20120518
%define devscripts_ver 2.11.7
%define dhmake_ver 0.60
%define dhautoreconf_ver 6

%{!?py_ver: %global py_ver %(echo `python -c "import sys; sys.stdout.write(sys.version[:3])"`)}
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}

Name:           deb
Version:        1.16.3
Release:        0
Summary:        Tools for Debian Packages
License:        GPL-2.0+
Group:          System/Packages
Url:            http://www.debian.org
Source0:        http://ftp.de.debian.org/debian/pool/main/d/dpkg/dpkg_%{version}.tar.bz2
Source1:        http://ftp.de.debian.org/debian/pool/main/d/debhelper/debhelper_%{debhelper_ver}.tar.gz
Source2:        http://ftp.de.debian.org/debian/pool/main/d/devscripts/devscripts_%{devscripts_ver}.tar.gz
Source3:        sensible-editor
Source4:        http://ftp.de.debian.org/debian/pool/main/d/dh-make/dh-make_%{dhmake_ver}.tar.gz
Source5:        http://ftp.de.debian.org/debian/pool/main/d/dh-autoreconf/dh-autoreconf_%{dhautoreconf_ver}.tar.gz
# PATCH-FIX-UPSTREAM not build translated-manpages.
Patch0:         debhelper-no-localized-manpages.patch
# PATCH-FIX-UPSTREAM remove bash auto completion and fix docbook template directories path.
Patch1:         devscripts-2.11.7-buildfix.patch
# PATCH-FIX-UPSTREAM remove --utf8 since we only build En manpages.
Patch2:         debhelper-pod2man-no-utf8.patch
# PATCH-FIX-UPSTREAM hg can't commit empty, fix it.
Patch3:         devscripts-2.11.7-debcommit-hg16.patch
# PATCH-FIX-OPENSUSE replace debian with opensuse. replace macros. update-alternatives temp directories' path and name from dpkg* to rpm*.
Patch4:         update-alternatives-%{version}-suse.patch
# PATCH-FIX-OPENSUSE add openSUSE supported architectures
Patch5:         dpkg-archtable-suse.patch
# PATCH-FIX-UPSTREAM remove --utf8 since we only build En manpages.
Patch6:         dpkg-pod2man-no-utf8.patch
# PATCH-FIX-UPSTREAM remove --utf8 since we only build En manpages.
Patch7:         devscripts-pod2man-no-utf8.patch
# PATCH-FIX-UPSTREAM remove unrecognized --install-layout=deb from scripts/setup.py and fix prefix
Patch8:         devscripts-2.11.7-remove-install-layout-deb.patch
BuildRequires:  gcc-c++
BuildRequires:  ncurses-devel
BuildRequires:  python-devel
# we are sorry to drop sles10 support, but no setuptools
BuildRequires:  python-setuptools
BuildRequires:  zlib-devel
Requires:       cpio
Requires:       html2text
Requires:       make
Requires:       patch
Requires:       perl = %{perl_version}
Provides:       debhelper
Provides:       devscripts
Provides:       dpkg
Provides:       dpkg-dev
Provides:       dpkg-doc
Provides:       dselect
%if 0%{?suse_version} > 1010
BuildRequires:  fdupes
%endif
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  libxslt
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(pre):  /bin/touch

%if 0%{?suse_version}
BuildRequires:  libbz2-devel
BuildRequires:  sgmltool
BuildRequires:  texlive-latex
BuildRequires:  update-alternatives
Requires:       update-alternatives
%if 0%{?suse_version} > 1100
BuildRequires:  libselinux-devel
%define use_selinux 1
%endif
%if 0%{?suse_version} < 1120
%define _libexecdir /usr/lib
%endif
%endif
%if 0%{?fedora_version}
BuildRequires:  libselinux-devel
BuildRequires:  linuxdoc-tools
BuildRequires:  tetex-latex
BuildRequires:  texinfo-tex
%define use_selinux 1
%endif
%if 0%{?rhel_version}
BuildRequires:  libselinux-devel
BuildRequires:  linuxdoc-tools
BuildRequires:  tetex-latex
BuildRequires:  texinfo-tex
%define use_selinux 1
%endif
%if 0%{?centos_version}
BuildRequires:  libselinux-devel
BuildRequires:  linuxdoc-tools
BuildRequires:  tetex-latex
BuildRequires:  texinfo-tex
%define use_selinux 1
%endif

%description
This package contains tools for working with Debian packages. It makes
it possible to create and extract Debian packages. If Alien is
installed, the packages can be converted to RPMs.

This package contains the following Debian packages: dpkg, dselect,
dpkg-doc, dpkg-dev, debhelper, and devscripts.

%package devel
Summary:        Development files for dpkg
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
Libraries and header files for dpkg.

%lang_package
%prep
%setup -q -n dpkg-%{version} -b 1 -b 2 -b 4 -b 5
# do not unpack anything, just cd to source dir
cd ..

%patch0
%patch1
%if 0%{?suse_version} && 0%{?suse_version} < 1130
%patch2
%patch6
%patch7
%endif
%patch3
%patch4
%patch5
%patch8

%build
export CFLAGS="%{optflags}"
%if 0%{?use_selinux}
export SELINUX_LIBS="-lselinux"
%endif
%{configure}\
%if 0%{?use_selinux}
	--with-selinux \
%endif
%if 0%{?suse_version} && 0%{?suse_version} < 1110
	--disable-compiler-warnings \
%endif
	--localstatedir=%{_localstatedir}/lib\
        --with-admindir=%{_localstatedir}/lib/dpkg

# configure somehow does not detect architecture correctly in OBS (bnc#469337), so
# let's do an awful hack and fix it in config.h
# XXX: who knows if this works on s390? :)

%define debarch %{_arch}
%ifarch x86_64
%define debarch amd64
%endif
%ifarch %ix86
%define debarch i386
%endif
%ifarch ppc powerpc
%define debarch powerpc
%endif
%ifarch ppc64 powerpc64
%define debarch ppc64
%endif
sed -i 's/^#define ARCHITECTURE ""/#define ARCHITECTURE "%{debarch}"/' config.h

make %{?_smp_mflags}
#popd # dpkg

# This makes debhelper man pages
pushd ../debhelper
make %{?_smp_mflags} VERSION='%{debhelper_ver}'
popd

pushd ../devscripts-%{devscripts_ver}
# need dpkg-parsechangelog for devscripts
export PATH="$RPM_BUILD_DIR/dpkg-%{version}/scripts:$PATH"
export PERL5LIB="$RPM_BUILD_DIR/dpkg-%{version}/scripts"
cd ../devscripts-%{devscripts_ver}
make %{?_smp_mflags}

%install
# use makeinstall for sles10 compatibility.
%makeinstall

# remove update-alternatives stuff (included in separate package)
rm -rf %{buildroot}%{_sysconfdir}/alternatives
rm -rf %{buildroot}%{_localstatedir}/lib/dpkg/alternatives
rm -rf %{buildroot}%{_bindir}/update-alternatives
rm -rf %{buildroot}%{_sbindir}/update-alternatives
rm -rf %{buildroot}%{_mandir}/man8/update-alternatives.8
rm -rf %{buildroot}%{_mandir}/*/man8/update-alternatives.8

# locales
%{find_lang} dpkg
%{find_lang} dselect
%{find_lang} dpkg-dev
cat dpkg.lang dselect.lang dpkg-dev.lang > %{name}.lang

# docs
install -d -m 755 %{buildroot}/%{_docdir}/deb/dpkg
install -m 644 ABOUT-NLS %{buildroot}/%{_docdir}/deb/dpkg
install -m 644 AUTHORS %{buildroot}/%{_docdir}/deb/dpkg
install -m 644 COPYING %{buildroot}/%{_docdir}/deb/dpkg
install -m 644 doc/triggers.txt %{buildroot}/%{_docdir}/deb/dpkg
install -m 644 NEWS %{buildroot}/%{_docdir}/deb/dpkg
install -m 644 README* %{buildroot}/%{_docdir}/deb/dpkg
install -m 644 THANKS %{buildroot}/%{_docdir}/deb/dpkg
install -m 644 TODO %{buildroot}/%{_docdir}/deb/dpkg
install -m 644 debian/changelog %{buildroot}/%{_docdir}/deb/dpkg

pushd ../debhelper
# autoscripts
install -d -m 755 %{buildroot}%{_datadir}/debhelper/autoscripts
install -m 644 autoscripts/* %{buildroot}%{_datadir}/debhelper/autoscripts
# perl modules:
install -d -m 755 %{buildroot}%{perl_vendorlib}/Debian/Debhelper
install -d -m 755 %{buildroot}%{perl_vendorlib}/Debian/Debhelper/Sequence
install -d -m 755 %{buildroot}%{perl_vendorlib}/Debian/Debhelper/Buildsystem
install -m 644 Debian/Debhelper/Buildsystem/*.pm %{buildroot}%{perl_vendorlib}/Debian/Debhelper/Buildsystem
install -m 644 Debian/Debhelper/Sequence/*.pm %{buildroot}%{perl_vendorlib}/Debian/Debhelper/Sequence
install -m 644 Debian/Debhelper/*.pm %{buildroot}%{perl_vendorlib}/Debian/Debhelper
# docs:
install -d -m 755 %{buildroot}%{_docdir}/deb/debhelper/examples
install -m 644 examples/* %{buildroot}%{_docdir}/deb/debhelper/examples
install -m 644 doc/* %{buildroot}%{_docdir}/deb/debhelper
install -m 644 debian/{changelog,copyright} %{buildroot}%{_docdir}/deb/debhelper
# man pages:
install -d -m 755 %{buildroot}%{_mandir}/man1
install -d -m 755 %{buildroot}%{_mandir}/man7
install -m 644 *.1 %{buildroot}%{_mandir}/man1
install -m 644 debhelper.7 %{buildroot}%{_mandir}/man7
# binaries:
install -d -m 755 %{buildroot}%{_bindir}
install -m 755 dh_*[^1-9] %{buildroot}%{_bindir}
install -m 755 dh %{buildroot}%{_bindir}
popd # debhelper

pushd ../devscripts-%{devscripts_ver}
%makeinstall
install -D -m 644 scripts/*.1 %{buildroot}%{_mandir}/man1/
install -D -m 644 scripts/*.5 %{buildroot}%{_mandir}/man5/
while read target link; do
  if [ -d $(dirname "%{buildroot}$link") ]; then
    ln -sf $target %{buildroot}$link
  fi
done <debian/links
# fix docs
mkdir -pv %{buildroot}%{_docdir}
mv %{buildroot}%{_datadir}/doc/devscripts %{buildroot}%{_docdir}
chmod -x %{buildroot}%{_docdir}/devscripts/README
popd

pushd ../dh-make
install -m 755 dh_make %{buildroot}%{_bindir}
install -d -m 755 %{buildroot}%{_datadir}/debhelper/dh_make
mv lib/* %{buildroot}%{_datadir}/debhelper/dh_make/
install -m 644 *.1 %{buildroot}%{_mandir}/man1
popd # dh-make

pushd ../dh-autoreconf-%{dhautoreconf_ver}
install -m 755 dh_autoreconf %{buildroot}%{_bindir}
install -m 755 dh_autoreconf_clean %{buildroot}%{_bindir}
install -m 644 autoreconf.pm %{buildroot}%{perl_vendorlib}/Debian/Debhelper/Sequence
install -d -m 755 %{buildroot}%{_datadir}/cdbs/1/rules/
install -m 644 autoreconf.mk %{buildroot}%{_datadir}/cdbs/1/rules
install -d -m 755 %{buildroot}%{_datadir}/dh-autoreconf/
install -m 644 ltmain-as-needed.diff %{buildroot}%{_datadir}/dh-autoreconf/
#manpages
pod2man -r "dh-autoreconf v%{dhautoreconf_ver}" -c dh-autoreconf --section=1 dh_autoreconf dh_autoreconf.1
pod2man -r "dh-autoreconf v%{dhautoreconf_ver}" -c dh-autoreconf --section=1 dh_autoreconf_clean dh_autoreconf_clean.1
pod2man -r "dh-autoreconf v%{dhautoreconf_ver}" -c dh-autoreconf --section=7 dh-autoreconf.pod dh-autoreconf.7
install -m 644 *.1 %{buildroot}%{_mandir}/man1
install -m 644 *.7 %{buildroot}%{_mandir}/man7
popd # dh-autoreconf

# extras
install -m 755 %{SOURCE3} %{buildroot}%{_bindir}

%if 0%{?suse_version} > 1010
%fdupes %{buildroot}
%endif

%post
cd %{_localstatedir}/lib/dpkg
for f in diversions statoverride status ; do
    [ ! -f $f ] && touch $f
done
exit 0

%if 0%{?suse_version} > 1010

%files lang -f %{name}.lang
%endif

%files
%defattr(-,root,root)
%doc %{_docdir}/deb
%doc %{_mandir}/man*/*
%dir %{_sysconfdir}/dpkg
%config(noreplace) %{_sysconfdir}/dpkg/*
%{_bindir}/*
%{_sbindir}/*
%{_libdir}/dpkg
%{_datadir}/dpkg
%{_localstatedir}/lib/dpkg
%{_datadir}/debhelper
%{perl_vendorlib}/Debian
%{perl_vendorlib}/Dpkg
%{perl_vendorlib}/Dpkg.pm
%{python_sitelib}/devscripts/
%{python_sitelib}/devscripts-%{devscripts_ver}-py%{py_ver}.egg-info/
%{_libexecdir}/devscripts
%{_datadir}/devscripts
%{_docdir}/devscripts
%{_datadir}/cdbs/
%{_datadir}/dh-autoreconf/
%if 0%{?suse_version} < 1110
%{_datadir}/locale/*/LC_MESSAGES/*
%dir %{_datadir}/locale/ast
%dir %{_datadir}/locale/ast/LC_MESSAGES
%endif

%files devel
%defattr(-,root,root)
%{_libdir}/libdpkg.a
%{_libdir}/pkgconfig/libdpkg.pc
%{_includedir}/dpkg

%changelog
openSUSE Build Service is sponsored by