From a6e5a745966a6748d356ca10ddefe42f26ea9fd3617dec828bd4cb4dd02a0489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Mon, 20 Nov 2017 12:45:54 +0000 Subject: [PATCH] Accepting request 543853 from home:pluskalm:branches:system:packagemanager - Move update alternatives database to new location OBS-URL: https://build.opensuse.org/request/show/543853 OBS-URL: https://build.opensuse.org/package/show/system:packagemanager/dpkg?expand=0&rev=53 --- update-alternatives.changes | 5 +++++ update-alternatives.spec | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/update-alternatives.changes b/update-alternatives.changes index 62a6b3c..2ec7ff6 100644 --- a/update-alternatives.changes +++ b/update-alternatives.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Nov 20 09:13:55 UTC 2017 - mpluskal@suse.com + +- Move update alternatives database to new location + ------------------------------------------------------------------- Tue Nov 7 19:57:49 UTC 2017 - mpluskal@suse.com diff --git a/update-alternatives.spec b/update-alternatives.spec index db14694..a56f2ad 100644 --- a/update-alternatives.spec +++ b/update-alternatives.spec @@ -22,7 +22,7 @@ Release: 0 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/ +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 @@ -33,7 +33,9 @@ BuildRequires: automake BuildRequires: libtool BuildRequires: ncurses-devel BuildRequires: pkgconfig -%requires_eq rpm +# As we are using macros from rpm for location we need to have same rpm as +# one used during build of this package +Requires: %(rpm -q --queryformat '%{NAME} = %{VERSION}-%{RELEASE}\n' rpm) Requires(post): coreutils Requires(post): update-alternatives Provides: alternatives = %{version} @@ -57,8 +59,8 @@ particular preference. %build autoreconf -fvi %configure \ - --disable-silent-rules \ - --with-admindir=%{_dbpath} + --disable-silent-rules \ + --with-admindir=%{_localstatedir}/lib make -C lib/compat %{?_smp_mflags} make -C utils/ %{?_smp_mflags} @@ -68,7 +70,7 @@ make -C man/ %{?_smp_mflags} 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}/%{_dbpath}/alternatives +install -d -m 0755 %{buildroot}%{_localstatedir}/lib/alternatives install -d -m 0755 %{buildroot}/%{_localstatedir}/log install -pm 0755 utils/%{name} %{buildroot}/%{_sbindir} @@ -76,6 +78,16 @@ ln -s %{name} %{buildroot}/%{_sbindir}/alternatives install -pm 0644 man/%{name}.1 %{buildroot}/%{_mandir}/man1/ %post +# Migrate to new location +if [ -d %{_dbpath}/alternatives ]; then + echo "migrating update alternatives database to new location" + # We proceed even if no alternatives directory exists, such situation + # occurs in buildroot environment (we can't buildrequire package + # itself). + mv -f %{_dbpath}/alternatives/* /var/lib/alternatives/ || : + rmdir %{_dbpath}/alternatives ||: +fi + touch %{_localstatedir}/log/alternatives.log # Fix broken alternatives list bnc#969171 cd %{_sysconfdir}/alternatives/ @@ -87,7 +99,7 @@ done %files %doc COPYING %dir %{_sysconfdir}/alternatives -%dir %{_dbpath}/alternatives +%dir %{_localstatedir}/lib/alternatives %{_sbindir}/alternatives %{_sbindir}/update-alternatives %{_mandir}/man1/update-alternatives.1%{ext_man}