#
# spec file for package update-alternatives
#
# Copyright (c) 2017 SUSE LINUX 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/
Name:           update-alternatives
Version:        1.18.23
Release:        1.5
Summary:        Maintain symbolic links determining default commands
License:        GPL-2.0+
Group:          System/Management
Url:            http://ftp.de.debian.org/debian/pool/main/d/dpkg/
Source0:        http://ftp.de.debian.org/debian/pool/main/d/dpkg/dpkg_%{version}.tar.xz
Source3:        sensible-editor
Patch0:         update-alternatives-suse.patch

# patch for eisfair
Patch100:         update-alternatives-eisfair.patch

# PATCH-FIX-SUSE: update if two alternatives have same priority bnc#969171
Patch7:         0001-In-case-of-equal-priority-rather-update.patch
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libtool
BuildRequires:  ncurses-devel
BuildRequires:  pkgconfig
BuildRequires:  xz
Requires(post): coreutils
Requires(post): update-alternatives
Provides:       alternatives = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
update-alternatives creates, removes, maintains and displays
information about the symbolic links comprising the alternatives
system. It is possible for several programs fulfilling the same or
similar functions to be installed on a single system at the same time.
For example, many systems have several text editors installed at once.
This gives choice to the users of a system, allowing each to use a
different editor, if desired, but makes it difficult for a program to
make a good choice of editor to invoke if the user has not specified a
particular preference.

%prep
%setup -q -n dpkg-%{version}
#%patch0 -p1
%patch7 -p1

#for eisfair
%patch100 -p1

%build
autoreconf -fvi
%configure \
    --disable-silent-rules \
    --with-admindir=%{admindir}

make -C lib/compat %{?_smp_mflags}
make -C utils/ %{?_smp_mflags}
make -C man/ %{?_smp_mflags}

%install
install -d -m 0755 %{buildroot}/%{_sbindir}/
install -d -m 0755 %{buildroot}/%{_mandir}/man1/
install -d -m 0755 %{buildroot}/%{_sysconfdir}/alternatives
install -d -m 0755 %{buildroot}/%{admindir}/alternatives
install -d -m 0755 %{buildroot}/%{_localstatedir}/log

install -m 0755 utils/%{name} %{buildroot}/%{_sbindir}
ln -s %{name} %{buildroot}/%{_sbindir}/alternatives
install -m 0644 man/%{name}.1 %{buildroot}/%{_mandir}/man1/

%post
touch %{_localstatedir}/log/alternatives.log
# Fix broken alternatives list bnc#969171
cd %{_sysconfdir}/alternatives/
for i in $(ls .) ; do
    # continue on errors but still print them out
    update-alternatives --auto $i || :
done

%files
%defattr(-,root,root,-)
%doc COPYING
%dir %{_sysconfdir}/alternatives
%dir %{_localstatedir}/lib/rpm/alternatives
%{_sbindir}/alternatives
%{_sbindir}/update-alternatives
%{_mandir}/man1/update-alternatives.1%{ext_man}
%ghost %{_localstatedir}/log/alternatives.log

%changelog
* Mon Mar 27 2017 tchvatal@suse.com
- Update to 1.18.23:
  * Various small fixes and memleaks removed
- Make sure to generate manpage
- Refresh patch update-alternatives-suse.patch
* Wed Sep  7 2016 tchvatal@suse.com
- Version update to 1.18.10:
  * Various few fixes, see changelog file in the package
  * Refresh patch update-alternatives-suse.patch
  * Remove patch dpkg-sparc.diff
* Wed Sep  7 2016 tchvatal@suse.com
- Use ls . instead of * to avoid error when nothing is in alternatives
  directory
* Tue May 31 2016 tchvatal@suse.com
- Require touch in post phase bnc#982336
* Fri May 13 2016 tchvatal@suse.com
- Provide alternatives binary and alternatives = %%{version} symbol
* Wed Apr  6 2016 tchvatal@suse.com
- Fix bnc#969171 by updating even with equal priority
  * 0001-In-case-of-equal-priority-rather-update.patch
- Try to autorefresh all the alternatives in post in case some of
  them were broken
* Wed Apr  6 2016 tchvatal@suse.com
- The logfile for update-alternatives is /var/log/alternatives.log
  so stop using update-alternatives.log file which is empty
* Fri Mar 25 2016 tchvatal@suse.com
- Update to the 1.18.4:
  * Rebase patch update-alternatives-suse.patch
  * Touch the gost file in post
* Fri Jun  5 2015 tchvatal@suse.com
- Adjust to the new manpage location
* Thu Jun  4 2015 tchvatal@suse.com
- Verion bump to 1.18.1:
  * Bump to latest upstream release
  * Plenty of fixes with too long changelog, see changelog file in
    documentation
  * Also fixes bnc#926749 CVE-2015-0840
  * Refresh patch:
    + update-alternatives-suse.patch
* Wed Apr  1 2015 tchvatal@suse.com
- Cleanup with spec-cleaner
* Wed Apr  1 2015 tchvatal@suse.com
- Update to 1.11.24:
  * Translation updates
  * Various small fixes
* Tue Feb 17 2015 p.drouand@gmail.com
- Update to version 1.17.23
  + Use a matching group instead of ${^MATCH} in s/// in dselect build script.
  + Skip tar extractor tests if tar is not GNU tar >= 1.27.
  + Reset the trigger cycle tracking on unsatisfied dependencies during
    trigger processing. Closes: bdo#771730
  + Fix out-of-bounds buffer read accesses when parsing field and trigger
    names or checking package ownership of conffiles and directories.
  + Add versioned Breaks on packages creating trigger cycles. Namely auctex,
    apt-cudf, ccache, cups, distcc, fusionforge-plugin-mediawiki, gap-core,
    gxine, hoogle, icecc, libjs-protoaculous, mcollective, pypy, wordpress
    and xfonts-traditional.
  + Update translations
- Remove unapplied patches; SLE11 support is disabled in project home
  + dpkg-pod2man-no-utf8.patch
  + dpkg-old-File-Path.patch
  + dpkg-old-Test-More.patch
- Remove obsolete patches
  * dpkg-ppc64le.diff
  * dpkg-archive_tar_format_gnu.patch
  * dpkg-archtable-suse.patch
- Rename updated patch
  pdate-alternatives-1.16.8-suse.patch > pdate-alternatives-suse.patch
- Clean up a bit specfile
* Mon May 12 2014 tchvatal@suse.com
- Use SUSE not SuSE.
* Mon Dec  2 2013 dvaleev@suse.com
- add dpkg-ppc64le.diff (adds ppc64le architecture)
* Wed Jul  3 2013 jengelh@inai.de
- Add dpkg-sparc.diff to unbreak compilation on sparcv9 build
* Mon Mar 25 2013 frank.lichtenheld@sophos.com
- update to 1.16.10
  * Fix update-alternatives test suite to behave correctly on non-Debian
  binary paths. Known to be affecting at least Gentoo and Mac OS X.
  * Do not leak subcall command arguments in update-alternatives.
  * Fix segfault on update-alternatives when passing --slave without any
  action at all. lp#1037431
* Thu Sep 27 2012 frank.lichtenheld@sophos.com
- update to 1.16.8
* Fri Jul  6 2012 frank.lichtenheld@sophos.com
- update to 1.16.7
  * Print master and slave alternarive link names in update-alternatives
  - -query and always print alternative link in --config. Closes: #679010
  * Check parsed integers for invalid or no digit errors in
  update-alternatives. Check all parsed integers for out of range
  errors. On "update-alternatives --install" only warn for now on
  out of range priorities and clamp the values
* Wed Jun  6 2012 coolo@suse.com
- fix the reworked patch
* Mon May 21 2012 i@marguerite.su
- update to 1.16.3
- reworked patch
* Sun Jan 29 2012 frank.lichtenheld@sophos.com
- update to 1.15.8.12
  * no changes, just keep in sync with deb
* Sat Nov 26 2011 frank.lichtenheld@sophos.com
- update to 1.15.8.11
- remove unused tarballs and patches
* Sun Sep 18 2011 jengelh@medozas.de
- Remove redundant tags/sections from specfile
  (cf. packaging guidelines)
- Use %%_smp_mflags for parallel build
* Thu Mar 17 2011 mvyskocil@suse.cz
- update to 1.15.8.10 - bug fix release
- build it in the same source tree as package deb
* Mon Mar 14 2011 mvyskocil@suse.cz
- update to 1.15.8.5
  * update-alternatives is now implemented in C
- fix bnc#647151 - update-alternatives: false claim in the description
  * removed jpackage only part, as it's now don't have any sense
* Thu Feb 17 2011 mvyskocil@suse.cz
- fix bnc#669716 - update-alternatives corrupt
  the pack/unpack removal code broke the java update-alternatives file
* Mon Jul 21 2008 mvyskocil@suse.cz
- fix of enhancenment request[bnc#261246] - update-alternatives should support --set
  - update to the 1.14.19
* Tue Nov  6 2007 mvyskocil@suse.cz
- fix the manual link state after --install and --remove commands [#334783]
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Wed Sep 28 2005 dmueller@suse.de
- add norootforbuild
* Wed Sep  1 2004 skh@suse.de
- Initial package version 1.8.3