Accepting request 926674 from home:schubi2

- Use libalternatives instead of update-alternatives. 
From the last try:
"Given the discussion on the openSUSE Factory list concerning the libalternatives, and given the failing on leap, rejecting"
Currently we have already switched about 40 packages to libalternatives. We need it for the next MicroOS release. We do not use libalternatives for previous Leap versions like 15.3. Only the latest factory is for interest. We have already created new RPM Macros, updated old ones and have adapted rpmlint. So it would be nice, if we can have this packages too. ;-)

OBS-URL: https://build.opensuse.org/request/show/926674
OBS-URL: https://build.opensuse.org/package/show/Java:packages/maven?expand=0&rev=25
This commit is contained in:
Fridrich Strba 2021-10-22 05:21:47 +00:00 committed by Git OBS Bridge
parent b1fd090212
commit 757444ac04
2 changed files with 57 additions and 3 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Sep 14 14:44:11 UTC 2021 - Stefan Schubert <schubi@suse.de>
- Use libalternatives instead of update-alternatives.
-------------------------------------------------------------------
Tue May 11 09:57:12 UTC 2021 - Fridrich Strba <fstrba@suse.com>

View File

@ -20,6 +20,13 @@
%global homedir %{_datadir}/%{name}%{?maven_version_suffix}
%global confdir %{_sysconfdir}/%{name}%{?maven_version_suffix}
%bcond_with logback
%if 0%{?suse_version} > 1500
%bcond_without libalternatives
%else
%bcond_with libalternatives
%endif
Name: maven
Version: 3.8.1
Release: 0
@ -99,6 +106,12 @@ Requires(postun):aaa_base
%if %{with logback}
BuildRequires: mvn(ch.qos.logback:logback-classic)
%endif
%if %{with libalternatives}
Requires: alts
%else
Requires(post): update-alternatives
Requires(postun):update-alternatives
%endif
%description
Maven is a software project management and comprehension tool. Based on the
@ -357,9 +370,28 @@ ln -sf %{confdir}/settings.xml %{buildroot}%{homedir}/conf/settings.xml
mv %{buildroot}%{homedir}/conf/logging %{buildroot}%{confdir}/
ln -sf %{confdir}/logging %{buildroot}%{homedir}/conf
# Ghosts for alternatives
install -d -m 755 %{buildroot}%{_bindir}/
install -d -m 755 %{buildroot}%{_mandir}/man1/
%if %{with libalternatives}
ln -sf %{_bindir}/alts %{buildroot}%{_bindir}/mvn
mkdir -p %{buildroot}%{_datadir}/libalternatives/mvn
cat > %{buildroot}%{_datadir}/libalternatives/mvn/%{?maven_alternatives_priority}1.conf <<EOF
binary=%{homedir}/bin/mvn
group=mvn, mvnDebug
EOF
ln -sf %{_bindir}/alts %{buildroot}%{_bindir}/mvnDebug
mkdir -p %{buildroot}%{_datadir}/libalternatives/mvnDebug
cat > %{buildroot}%{_datadir}/libalternatives/mvnDebug/%{?maven_alternatives_priority}1.conf <<EOF
binary=%{homedir}/bin/mvnDebug
group=mvn, mvnDebug
man=mvn.1
EOF
mv %{buildroot}%{homedir}/bin/mvn.1.gz %{buildroot}%{_mandir}/man1
%endif
%if ! %{with libalternatives}
# Ghosts for alternatives
touch %{buildroot}%{_bindir}/{mvn,mvnDebug}
touch %{buildroot}%{_mandir}/man1/{mvn,mvnDebug}.1
@ -373,6 +405,13 @@ update-alternatives --install %{_bindir}/mvn mvn %{homedir}/bin/mvn %{?maven_alt
if [ $1 -eq 0 ]; then
update-alternatives --remove mvn %{homedir}/bin/mvn
fi
%else
%pre
# removing old update-alternatives entries
if [ "$1" > 0 ] && [ -f %{_sbindir}/update-alternatives ] ; then
update-alternatives --remove mvn %{homedir}/bin/mvn
fi
%endif
%files lib -f .mfiles
%doc README.md
@ -385,12 +424,22 @@ fi
%config(noreplace) %{confdir}/logging/simplelogger.properties
%files
%{_datadir}/bash-completion
%if ! 0%{with libalternatives}
%ghost %{_bindir}/mvn
%ghost %{_bindir}/mvnDebug
%{_datadir}/bash-completion
%ghost %{_mandir}/man1/mvn.1.gz
%ghost %{_mandir}/man1/mvnDebug.1.gz
%else
%dir %{_datadir}/libalternatives
%dir %{_datadir}/libalternatives/mvn
%dir %{_datadir}/libalternatives/mvnDebug
%{_datadir}/libalternatives/mvn/%{?maven_alternatives_priority}1.conf
%{_datadir}/libalternatives/mvnDebug/%{?maven_alternatives_priority}1.conf
%{_bindir}/mvn
%{_bindir}/mvnDebug
%{_mandir}/man1/mvn.1.gz
%endif
%files javadoc -f .mfiles-javadoc
%license LICENSE NOTICE