From cdb990ae1f2ab69d20e2f1539fc5bf014d571ee2945ee59807809e9301dfe552 Mon Sep 17 00:00:00 2001 From: Simon Lees Date: Thu, 16 Sep 2021 09:31:14 +0000 Subject: [PATCH] Accepting request 919476 from home:schubi2 Use libalternatives instead of update-alternatives. OBS-URL: https://build.opensuse.org/request/show/919476 OBS-URL: https://build.opensuse.org/package/show/Base:System/dbus-1?expand=0&rev=304 --- dbus-1-x11.changes | 5 +++++ dbus-1-x11.spec | 36 ++++++++++++++++++++++++++++++++++++ dbus-1.changes | 5 +++++ dbus-1.spec | 40 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/dbus-1-x11.changes b/dbus-1-x11.changes index ab4418e..650c89d 100644 --- a/dbus-1-x11.changes +++ b/dbus-1-x11.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Aug 4 10:04:12 UTC 2021 - Stefan Schubert + +- Use libalternatives instead of update-alternatives. + ------------------------------------------------------------------- Thu Jul 16 21:28:10 UTC 2020 - Matthias Eliasson diff --git a/dbus-1-x11.spec b/dbus-1-x11.spec index cd02f4f..f8f4ffd 100644 --- a/dbus-1-x11.spec +++ b/dbus-1-x11.spec @@ -16,6 +16,12 @@ # +%if 0%{?suse_version} > 1500 +%bcond_without libalternatives +%else +%bcond_with libalternatives +%endif + %define _name dbus %define _libname libdbus-1-3 %if 0%{?suse_version} <= 1320 @@ -45,8 +51,13 @@ BuildRequires: libtool BuildRequires: pkgconfig BuildRequires: pkgconfig(libsystemd) >= 209 BuildRequires: pkgconfig(x11) +%if %{with libalternatives} +Requires: alts +Requires(pre): update-alternatives +%else Requires(post): update-alternatives Requires(preun):update-alternatives +%endif Supplements: (dbus-1 and libX11-6) Provides: dbus-launch %if %{with selinux} @@ -94,9 +105,27 @@ tdir=$(mktemp -d) make DESTDIR=$tdir install mkdir -p %{buildroot}/%{_bindir} mv $tdir/%{_bindir}/dbus-launch %{buildroot}/%{_bindir}/dbus-launch.x11 +%if ! %{with libalternatives} +# create symlinks for update-alternatives mkdir -p %{buildroot}%{_sysconfdir}/alternatives ln -s -f %{_sysconfdir}/alternatives/dbus-launch %{buildroot}%{_bindir}/dbus-launch +%else +# create entries for libalternatives +ln -sf %{_bindir}/alts %{buildroot}%{_bindir}/dbus-launch +mkdir -p %{buildroot}%{_datadir}/libalternatives/dbus-launch +cat > %{buildroot}%{_datadir}/libalternatives/dbus-launch/20.conf < 0 ] ; then + %{_sbindir}/update-alternatives --remove dbus-launch %{_bindir}/dbus-launch.x11 +fi +%else %post %{_sbindir}/update-alternatives --install %{_bindir}/dbus-launch dbus-launch %{_bindir}/dbus-launch.x11 20 @@ -104,9 +133,16 @@ ln -s -f %{_sysconfdir}/alternatives/dbus-launch %{buildroot}%{_bindir}/dbus-lau if [ "$1" = 0 ] ; then %{_sbindir}/update-alternatives --remove dbus-launch %{_bindir}/dbus-launch.x11 fi +%endif %files +%if ! %{with libalternatives} %ghost %{_sysconfdir}/alternatives/dbus-launch +%else +%dir %{_datadir}/libalternatives +%dir %{_datadir}/libalternatives/dbus-launch +%{_datadir}/libalternatives/dbus-launch/20.conf +%endif %{_bindir}/dbus-launch %{_bindir}/dbus-launch.x11 diff --git a/dbus-1.changes b/dbus-1.changes index 4183f43..0a495d9 100644 --- a/dbus-1.changes +++ b/dbus-1.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Aug 4 10:03:46 UTC 2021 - Stefan Schubert + +- Use libalternatives instead of update-alternatives. + ------------------------------------------------------------------- Wed Apr 7 22:35:58 UTC 2021 - Dirk Müller diff --git a/dbus-1.spec b/dbus-1.spec index 7bbd57c..c319d8a 100644 --- a/dbus-1.spec +++ b/dbus-1.spec @@ -16,6 +16,12 @@ # +%if 0%{?suse_version} > 1500 +%bcond_without libalternatives +%else +%bcond_with libalternatives +%endif + %define with_systemd 1 %define _name dbus %define _libname libdbus-1-3 @@ -48,10 +54,15 @@ BuildRequires: sysuser-tools BuildRequires: xmlto BuildRequires: pkgconfig(libsystemd) >= 209 Requires(post): %{_libname} = %{version} -Requires(post): update-alternatives Requires(post): diffutils Requires(pre): permissions +%if %{with libalternatives} +Requires: alts +Requires(pre): update-alternatives +%else +Requires(post): update-alternatives Requires(preun):update-alternatives +%endif Provides: dbus-launch %sysusers_requires %if %{with selinux} @@ -161,8 +172,19 @@ ln -sf /%{_bindir}/dbus-update-activation-environment %{buildroot}/bin/dbus-upda ln -sf /%{_bindir}/dbus-uuidgen %{buildroot}/bin/dbus-uuidgen %endif +%if ! %{with libalternatives} +# create symlinks for update-alternatives mkdir -p %{buildroot}%{_sysconfdir}/alternatives ln -s -f %{_sysconfdir}/alternatives/dbus-launch %{buildroot}%{_bindir}/dbus-launch +%else +# create entries for libalternatives +ln -sf %{_bindir}/alts %{buildroot}%{_bindir}/dbus-launch +mkdir -p %{buildroot}%{_datadir}/libalternatives/dbus-launch +cat > %{buildroot}%{_datadir}/libalternatives/dbus-launch/10.conf < 0 ] ; then + %{_sbindir}/update-alternatives --remove dbus-launch %{_bindir}/dbus-launch.nox11 +fi +%endif %post if [ -e %{_localstatedir}/lib/dbus/machine-id -a -e %{_sysconfdir}/machine-id ]; then @@ -191,14 +219,18 @@ fi /sbin/ldconfig %set_permissions %{_libexecdir}/dbus-1/dbus-daemon-launch-helper +%if ! %{with libalternatives} %{_sbindir}/update-alternatives --install %{_bindir}/dbus-launch dbus-launch %{_bindir}/dbus-launch.nox11 10 +%endif %service_add_post dbus.service dbus.socket %tmpfiles_create %{_prefix}/lib/tmpfiles.d/dbus.conf %preun +%if ! %{with libalternatives} if [ "$1" = 0 ] ; then %{_sbindir}/update-alternatives --remove dbus-launch %{_bindir}/dbus-launch.nox11 fi +%endif %service_del_preun dbus.service dbus.socket %postun @@ -259,7 +291,13 @@ fi %{_userunitdir}/dbus.socket %dir %{_userunitdir}/sockets.target.wants %{_userunitdir}/sockets.target.wants/dbus.socket +%if ! %{with libalternatives} %ghost %{_sysconfdir}/alternatives/dbus-launch +%else +%dir %{_datadir}/libalternatives +%dir %{_datadir}/libalternatives/dbus-launch +%{_datadir}/libalternatives/dbus-launch/10.conf +%endif %{_bindir}/dbus-launch.nox11 %{_bindir}/dbus-launch