Name:                alsa-utils
Version:             1.2.2
Release:             2
Summary:             Advanced linux sound architecture (ALSA) utility to the Linux operating system.
License:             GPLv2+
URL:                 http://www.alsa-project.org/
Source:              ftp://ftp.alsa-project.org/pub/utils/alsa-utils-%{version}.tar.bz2
Source1:             alsaunmute
Source2:             alsaunmute.1
Source3:             alsa.rules
Source4:             alsactl.conf
Source5:             alsa-restore.service
Source6:             alsa-state.service
BuildRequires:       gcc alsa-lib-devel >= %{version} libsamplerate-devel ncurses-devel
BuildRequires:       gettext-devel xmlto python3-docutils systemd
Requires:            systemd alsa-lib >= %{version} alsa-ucm >= %{version} alsa-topology >= %{version}
Provides:            alsa-ucm-utils = %{version}-%{release}
Obsoletes:           alsa-ucm-utils < %{version}-%{release}
Provides:            alsa-topology-utils = %{version}-%{release}
Obsoletes:           alsa-topology-utils < %{version}-%{release}

%description
This package provides command line utilities for audio and MIDI functionality
to the Linux operating system. In addition, it also contains Use Case Manager tools
and topology tools for Advanced Linux Sound Architecture (ALSA) framework.

%package devel
Summary:             ALSA - Basic Audio Tester
BuildRequires:       fftw-devel
Provides:            %{name}-alsabat = %{version}-%{release}
Obsoletes:           %{name}-alsabat < %{version}-%{release}

%description devel
This package contains tool for basic audio testing using ALSA framework
and Fast Fourier Transform library.

%package help
Summary:             ALSA help

%description help
This package contains help docs for alsa-utils.

%prep
%autosetup -n %{name}-%{version} -p1

%build
%configure CFLAGS="$RPM_OPT_FLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" --disable-alsaconf \
   --with-udev-rules-dir=%{_prefix}/lib/udev/rules.d --with-systemdsystemunitdir=%{_unitdir}
%make_build

cp %{SOURCE1} .

%install
%make_install
%find_lang %{name}
install -d %{buildroot}/%{_prefix}/lib/udev/rules.d
install -p -m 644 %{SOURCE3} %{buildroot}/%{_prefix}/lib/udev/rules.d/90-alsa-restore.rules
sed -e 's,@bindir@,%{_bindir},g' alsaucm/89-alsa-ucm.rules.in > alsaucm/89-alsa-ucm.rules
install -p -m 644 alsaucm/89-alsa-ucm.rules %{buildroot}/%{_prefix}/lib/udev/rules.d/89-alsa-ucm.rules
install -d %{buildroot}/%{_unitdir}
install -p -m 644 %{SOURCE5} %{buildroot}/%{_unitdir}/alsa-restore.service
install -p -m 644 %{SOURCE6} %{buildroot}/%{_unitdir}/alsa-state.service
install -d -m755 %{buildroot}/%{_bindir}
install -p -m 755 %{SOURCE1} %{buildroot}/%{_bindir}
install -d -m755 %{buildroot}/%{_mandir}/man1
install -p -m 644 %{SOURCE2} %{buildroot}/%{_mandir}/man1/alsaunmute.1
install -d -m 755 %{buildroot}%{_prefix}/lib/alsa
mv %{buildroot}%{_datadir}/alsa/init %{buildroot}%{_prefix}/lib/alsa
ln -s ../../lib/alsa/init %{buildroot}%{_datadir}/alsa/init
install -d -m 755 %{buildroot}/etc/alsa
install -p -m 644 %{SOURCE4} %{buildroot}/etc/alsa
install -d -m 755 %{buildroot}%{_sharedstatedir}/alsa

%pre
if [ ! -r %{_unitdir}/alsa-state.service ]; then
  [ -d /etc/alsa ] || mkdir -m 0755 /etc/alsa
  echo "# Remove this file to disable the alsactl daemon mode" > \
    /etc/alsa/state-daemon.conf
fi

%post
%systemd_post alsa-state.service

%preun
%systemd_preun alsa-state.service

%postun
%systemd_postun_with_restart alsa-state.service

%files -f %{name}.lang
%doc COPYING ChangeLog
%config /etc/alsa/*
%{_prefix}/lib/udev/rules.d/*
%{_prefix}/lib/alsa/init/*
%{_prefix}/lib/udev/rules.d/*alsa-ucm*
%{_unitdir}/*
%{_unitdir}/sound.target.wants/*
%{_sbindir}/*
%{_datadir}/alsa/
%{_datadir}/sounds/*
%dir /etc/alsa/
%dir %{_prefix}/lib/alsa/
%dir %{_prefix}/lib/alsa/init/
%dir %{_sharedstatedir}/alsa/
%{_bindir}/*
%exclude %{_bindir}/alsabat
%exclude %{_sbindir}/alsabat-test.sh
%exclude %{_prefix}/lib/udev/rules.d/*alsa-ucm*

%files devel
%{_bindir}/alsabat
%{_sbindir}/alsabat-test.sh

%files help
%{_mandir}/*/*
%doc README.md TODO

%changelog
* Tue Apr 28 2020 Guoshuai Sun <sunguoshuai@huawei.com> - 1.2.2-2
- package init

* Fri Feb 14 2020 gulining<gulining1@huawei.com> - 1.1.6-8
- Package init
