%define alsa_version 1.0.20

Summary: Advanced Linux Sound Architecture (ALSA) Utils
Summary(ja): Advanced Linux Sound Architecture (ALSA) ユーティリティ集
Name: alsa-utils
Version: 1.0.22
Release: 1%{?_dist_release}
License: GPL
Group: Applications/Multimedia
URL: http://www.alsa-project.org

Source: ftp://ftp.alsa-project.org/pub/utils/alsa-utils-%{version}.tar.bz2
Source1: test.wav
Source10: alsa.rules
Source11: alsactl.conf
Patch0: alsaconf-1.0.19.patch
Patch1: alsa-utils-1.0.19-init.patch
Patch2: alsactl-init-fix-headphone.patch

BuildRequires: alsa-lib-devel >= %{alsa_version}
BuildRequires: ncurses-devel
BuildRequires: gettext
BuildRequires: xmlto
Requires: alsa-driver >= %{alsa_version}, alsa-lib >= %{alsa_version}
Requires(pre): coreutils, bash
Requires(post): coreutils, bash
Provides: alsaconf
Obsoletes: alsaconf

BuildRoot: %{_tmppath}/%{name}-%{version}-root
Vendor: Project Vine
Distribution: Vine Linux

%description
Advanced Linux Sound Architecture (ALSA) - Utils

%description -l ja
Advanced Linux Sound Architecture (ALSA) - ユーティリティ集


%prep
%setup -q
%patch0 -p1 -b .conf
#%patch1 -p1 -b .init
#%patch2 -p1 -b .headphone

%build
%configure --sbindir=/sbin
make %{?_smp_mflags}


%install
rm -rf %{buildroot}
make install DESTDIR=$RPM_BUILD_ROOT

chmod -x config.status
%{__install} -d -m 755 %{buildroot}%{_datadir}/sounds/alsa
%{__install}    -m 660 %{SOURCE1} %{buildroot}%{_datadir}/sounds/alsa/test.wav

# Install ALSA udev rules
mkdir -p -m 755 $RPM_BUILD_ROOT/etc/udev/rules.d
install -p -m 644 %{SOURCE10} $RPM_BUILD_ROOT/etc/udev/rules.d/90-alsa.rules

# Link alsactl to /usr/sbin
mkdir -p %{buildroot}/%{_sbindir}/
ln -sf ../../sbin/alsactl %{buildroot}/%{_sbindir}/

# move alsaconf to /usr/sbin
mv %{buildroot}/sbin/alsaconf %{buildroot}/%{_sbindir}/

# move /usr/share/alsa/init to /lib/alsa/init
mkdir -p -m 755 %{buildroot}/lib/alsa
mv %{buildroot}%{_datadir}/alsa/init %{buildroot}/lib/alsa
ln -sf /lib/alsa/init %{buildroot}%{_datadir}/alsa/

# create /etc/alsa which should owned by this package.
mkdir -p -m 755 %{buildroot}/etc/alsa
install -p -m 644 %{SOURCE11} %{buildroot}/etc/alsa

touch %{buildroot}/etc/asound.state


%clean
rm -rf %{buildroot}

%pretrans
if [ ! -h %{_datadir}/alsa/init ]; then
    mv %{_datadir}/alsa/init %{_datadir}/alsa/init.rpmsave > /dev/null 2>&1 ||:
    ln -sf init.rpmsave %{_datadir}/alsa/init > /dev/null 2>&1 ||:
fi
exit 0

%posttrans
rm -rf %{_datadir}/alsa/init.rpmsave > /dev/null 2>&1 ||:
exit 0


%files
%defattr(-, root, root)
%doc [A-Z][^a]*
%dir /etc/alsa
%dir /lib/alsa
%dir /lib/alsa/init
%config /etc/udev/rules.d/*
%config /etc/alsa/*
/sbin/*
/lib/alsa/init/*
%{_bindir}/*
%{_sbindir}/*
%{_datadir}/sounds/
%{_datadir}/alsa/
%{_datadir}/locale/*/LC_MESSAGES/*.mo
%{_mandir}/man?/*
%{_mandir}/*/man?/*
%ghost /etc/asound.state

%changelog
* Wed Dec 30 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 1.0.22-1
- new upstream release
- added BR: xmlto

* Fri Oct  9 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.0.21-2
- fix alsa_version

* Thu Oct  8 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.0.21-1
- new upstream release
- drop Patch2 (already merged into upstream)

* Thu Jul  2 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.0.20-1
- new upstream release
- drop Patch1 (already merged into upstream)
- import Headphone Volume patch (Patch2) from Fedora

* Mon Apr 27 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.19-4
- add Requires(pre,post): coreutils, bash

* Mon Mar 30 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.19-3
- fix %%pretrans

* Mon Mar 30 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.19-2
- move alsactl to /sbin
- move /usr/share/alsa to /lib/alsa/init
  - alsactl is used by udev
- own /etc/alsa
- add /etc/alsa/alsactrl.conf
- add patch1 to fix volume initialization for some HDA codecs
- add %%pretrans tweaks to upgrade from dir to symlink

* Thu Feb 19 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.0.19-1
- new upstream release

* Mon Sep 01 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.17-1
- new upstream release

* Thu Mar 20 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.16-1vl5
- new upstream release

* Sun Oct 21 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.15-0vl1
- new upstream release
- updated Patch0

* Thu Aug 31 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.12-0vl1
- new upstream release

* Sat Dec 10 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.10-0vl1
- new upstream release
- added man8 files

* Sat Jun 18 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.9a-0vl2
- add Japanese summary and description
- add message catalog to %%files
- use macros

* Fri Jun 17 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.9a-0vl1
- new upstream release

* Wed Aug 04 2004 Satoshi MACHINO <machino@vinelinux.org> 1.0.5-0vl1
- New upstream version (alsa-utils-1.0.5)
- added ncurses-devel in BuildRequires

* Sat May 29 2004 IWAI, Masaharu <iwai@alib.jp> 1.0.4-0vl2
- build for VineSeed
- merged spec file from 1.0.4-0vl2.13

* Mon Apr 26 2004 Masaki Shinomiya <shino@pos.to> 1.0.4-0vl1
- new upstream release

* Sun Mar 21 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.2-0vl2
- build for VineSeed

* Thu Feb 12 2004 Masaki Shinomiya <shino@pos.to> 1.0.2-0vl1
- new upstream release, alsaconf, test.wav
- alsaconf.patch to do snddevices - thanks to Eitetsu Oomoto
- omit config.status from doc

* Fri Feb 15 2002 Toru Sagami <sagami@vinelinux.org> 0.5.10-0vl3
- get rid of executable bit from files in %%doc 

* Sun Jan 14 2001 Toru Sagami <czs14350@mb.infoweb.ne.jp>
- 0.5.10-0vl2
- use better macros and makeinstall

* Thu Dec 07 2000 Toru Sagami <czs14350@mb.infoweb.ne.jp>
- 0.5.10
- FHS stuff: _mandir

* Tue Jun 20 2000 Toru Sagami <czs14350@nifty.ne.jp>
- import to Vine 0.5.8-0vl1 from 0.5.8-0k1
- BuildRequires: alsa-lib >= 0.5.5

* Tue Jun  6 2000 AYUHANA Tomonori <l@kondara.org>
- Version up 0.5.7 -> 0.5.8
- add -q at %setup
- use %%configure

* Thu Apr  9 2000 Toru Hoshina <t@kondara.org>
- Version up 0.5.6 -> 0.5.7

* Wed Mar 15 2000 Daiki Matsuda <dyky@kondara.org>
- Version up 0.5.5 -> 0.5.6

* Thu Mar  2 2000 Toru Hoshina <t@kondara.org>
- Version up 0.5.4 -> 0.5.5

* Sun Feb 27 2000 Toru Hoshina <t@kondara.org>
- Version up 0.4.1e -> 0.5.4

* Sat Jan 29 2000 Toru Hoshina <t@kondara.org>
- stripped. (*^_^*)

* Mon Nov 8 1999 Toru Hoshina <t@kondara.org>
- be a NoSrc :-P

* Mon May 28 1998 Helge Jensen <slog@slog.dk>
- Made SPEC file
