%define pcmciaver 3.2.7

Name:          kernel-pcmcia-cs
Version:       %{pcmciaver}
Release:       0vl3
Summary:       The daemon, scripts and config files for using PCMCIA adapters.
Summary(ja):   PCMCIA アダプタ用のデーモン/スクリプト/設定ファイル
Group:         System Environment/Kernel
Copyright:     GPL
ExclusiveArch: i386 ppc
Epoch:         1
BuildRoot:     %{_tmppath}/%{name}-%{version}-root
BuildRequires: kernel-source, byacc

Vendor:        Project Vine
Distribution:  Vine Linux

Source0:       ftp://projects.sourceforge.net/pub/pcmcia-cs/pcmcia-cs-%{pcmciaver}.tar.gz
Source1:       pcmcia-cs-2.8.8-network.script
Source2:       pcmcia-cs-3.1.24-isdn.script
Source3:       pcmcia-vine-config
URL:           http://pcmcia-cs.sourceforge.net/
# pcmcia configs
Source100:     http://www.st.rim.or.jp/~adats/WL/add.conf
Source110:     vine.conf
%{?nosrc:NoSource: 0}

Patch0:        pcmcia-cs-3.1.18-script.patch
Patch1:        pcmcia-cs-3.1.18-config.patch
Patch3:        pcmcia-cs-3.2.1-rctrans.patch
Patch4:        pcmcia-cs-3.1.30-yenta.patch
Patch5:        pcmcia-cs-3.1.23-updfstab.patch
Patch6:        pcmcia-cs-3.1.24-portrange.patch
Patch7:        pcmcia-cs-3.1.24-wireless.patch
Patch8:        pcmcia-cs-3.1.29-build.patch.bz2
Patch9:        pcmcia-cs-3.2.4-pmac.patch
Patch10:       pcmcia-cs-3.2.1-installman.patch
Patch11:       pcmcia-cs-3.1.31-configure.patch
Patch12:       pcmcia-cs-3.1.31-fixbuild.patch.bz2
Patch13:       pcmcia-cs-3.1.31-umask.patch.bz2
Patch14:       pcmcia-cs-3.2.0-no-function-binding.patch.bz2
Patch15:       pcmcia-cs-3.2.3-no-forms.patch.bz2

Requires:      kernel >= 2.4.3, chkconfig, kudzu >= 0.95, murasaki
Obsoletes:     kernel24-pcmcia-cs, pcmcia-cs


%description
Many laptop machines (and some non-laptops) support PCMCIA cards for
expansion. Also known as "credit card adapters," PCMCIA cards are
small cards for everything from SCSI support to modems. PCMCIA cards
are hot swappable (i.e., they can be exchanged without rebooting the
system) and quite convenient to use. The kernel-pcmcia-cs package
contains a card manager daemon that can respond to card insertion and
removal events by loading and unloading drivers on demand.  The daemon
also supports hot swapping, so that the cards can be safely inserted
and ejected at any time.

%description -l ja
多くのラップトップ機 (および一部のデスクトップ機) は PCMCIA カードを
サポートしています．「クレジットカードアタプタ」という別名の通り，
PCMCIA カードは SCSI サポートからモデムまで様々な機能を提供する
カードです．PCMCIA カードはホットスワップ可能 (詰まりシステムを
再起動することなく差し替え可能) で，非常に便利に使うことができます．
kernel-pcmcia-cs パッケージにはそしてカードを挿したり抜いたりする
のにあわせてドライバを動的に読み込み/切り離しするカードマネージャ
デーモン等が収められています．このデーモンはホットスワップに対応
しており， PCMCIA カードをいつでも好きなときに抜き差しすることを
可能にしています．


%prep
%setup -n pcmcia-cs-%{version} -q
%patch0 -p1 -b .script
%patch1 -p2 -b .config
%patch3 -p1 -b .rctrans
#%patch4 -p1 -b .yenta
%patch5 -p1 -b .fstab
%patch6 -p1 -b .portrange
%patch7 -p1 -b .wireless
%patch8 -p1 -b .build
%patch9 -p1 -b .ppc
%patch10 -p1 -b .installman
%patch11 -p0 -b .configure
%patch12 -p1 -b .fixbuild
%patch13 -p1 -b .umask
%patch14 -p1 -b .no-function
%patch15 -p1 -b .no-forms

# replace pcmcia-cs *_cb driver with kernel-2.4 driver
perl -pi -e 's/_cb//g' etc/config etc/memory


%build

./Configure -n --kernel=/usr/src/linux \
	--target=$RPM_BUILD_ROOT --trust --cardbus --srctree \
	--sysv --rcdir=/etc/rc.d 

perl -pi -e 's/\/usr\/man/'`echo %{_mandir} | sed 's_/_\\\\/_g'`/ man/Makefile
make all
make debug-tools/lspnp


%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_mandir}
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
make MANDIR=$RPM_BUILD_ROOT%{_mandir} PREFIX=$RPM_BUILD_ROOT install
# before we(who?) get into RedHat style, leave pcmcia-cs guy
mv $RPM_BUILD_ROOT/etc/pcmcia/network \
        $RPM_BUILD_ROOT/etc/pcmcia/network.pcmcia-cs
mv $RPM_BUILD_ROOT/etc/pcmcia/network.opts \
        $RPM_BUILD_ROOT/etc/pcmcia/network.pcmcia-cs.opts
# Install our own network up/down script
install -m755 %{SOURCE1} $RPM_BUILD_ROOT/etc/pcmcia/network
install -m755 %{SOURCE2} $RPM_BUILD_ROOT/etc/pcmcia/isdn
install -m755 %{SOURCE3} $RPM_BUILD_ROOT/etc/pcmcia/config

# Install configs for Vine Linux
install -m644 %{SOURCE100} $RPM_BUILD_ROOT/etc/pcmcia/
install -m644 %{SOURCE110} $RPM_BUILD_ROOT/etc/pcmcia/

# We need our own default /etc/sysconfig/pcmcia
cat > $RPM_BUILD_ROOT/etc/sysconfig/pcmcia <<EOF
PCMCIA=yes
PCIC=yenta_socket
#PCIC_OPTS=do_scan=0
PCIC_OPTS=
CORE_OPTS="unreset_delay=400"
CARDMGR_OPTS=-f
EOF

install -m755 debug-tools/lspnp $RPM_BUILD_ROOT/sbin/lspnp


%clean
rm -rf $RPM_BUILD_ROOT


%post
/sbin/chkconfig --add pcmcia


%preun
if [ $1 = 0 ]; then
    /sbin/chkconfig --del pcmcia
fi
exit 0


%triggerpostun -- kernel-pcmcia-cs < 2.2.5
if [ -f /etc/rc.d/init.d/pcmcia ] ; then
    /sbin/chkconfig --add pcmcia
fi


%triggerpostun -- kernel24-pcmcia-cs
if [ -f /etc/rc.d/init.d/pcmcia ] ; then
    /sbin/chkconfig --add pcmcia
fi


%files
%defattr(-,root,root)
%doc doc/PCMCIA-HOWTO 
%doc doc/PCMCIA-PROG
%doc SUPPORTED.CARDS 
%doc CHANGES 
%doc COPYING* 
%doc README*
%ifnarch ppc
/sbin/pcic_probe
%endif
/sbin/lspnp
%attr(4755,root,root) /sbin/cardctl
/sbin/cardmgr
/sbin/dump_cis
/sbin/ftl_check
/sbin/ftl_format
/sbin/ifport
/sbin/ifuser
/sbin/pack_cis
/sbin/scsi_info
/sbin/ide_info
/sbin/pcinitrd
%{_mandir}/man[45]/*
%{_mandir}/man8/*
/etc/pcmcia/cis
%dir /etc/pcmcia
%config /etc/pcmcia/config
%config(noreplace) /etc/pcmcia/config.opts
/etc/pcmcia/ftl
%config(noreplace) /etc/pcmcia/ftl.opts
/etc/pcmcia/ide
%config(noreplace) /etc/pcmcia/ide.opts
/etc/pcmcia/memory
%config(noreplace) /etc/pcmcia/memory.opts
/etc/pcmcia/network
/etc/pcmcia/isdn
/etc/pcmcia/parport
%config(noreplace) /etc/pcmcia/parport.opts
/etc/pcmcia/scsi
%config(noreplace) /etc/pcmcia/scsi.opts
/etc/pcmcia/serial
%config(noreplace) /etc/pcmcia/serial.opts
/etc/pcmcia/wireless
%config(noreplace) /etc/pcmcia/wireless.opts
/etc/pcmcia/shared
/etc/pcmcia/vine.conf
/etc/pcmcia/add.conf
/etc/pcmcia/ieee1394
%config(noreplace) /etc/pcmcia/ieee1394.opts
%attr(755,root,root) /etc/pcmcia/usb_ohci
%config(noreplace) /etc/pcmcia/usb_ohci.opts
%attr(644,root,root) /etc/pcmcia/network.pcmcia-cs
%attr(644,root,root) /etc/pcmcia/network.pcmcia-cs.opts
#/etc/rc.d/init.d/pcmcia
%attr(755,root,root) %config /etc/rc.d/init.d/pcmcia
%dir /var/lib/pcmcia
%config(noreplace) /etc/sysconfig/pcmcia


%changelog
* Fri Jul 30 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 3.2.7-0vl3
- fixed typo in vine.conf

* Wed Jul 28 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 3.2.7-0vl2
- update vine.conf to support BUFFALO LPC4-CLX
  (thanks to Mikawaya Cima-nosuke)

* Sat Jun 19 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.2.7-0vl1
- source update

* Sun Oct 12 2003 Daisuke SUZUKI <daisuke@linux.or.jp> 3.2.5-0vl2
- update vine.conf
  - add BUFFALO LPC-CF-CLT R01 (thanks to NAKAJIMA Mikio)

* Sun Oct 05 2003 Daisuke SUZUKI <daisuke@linux.or.jp> 3.2.5-0vl1
- new upstream release
- modify /etc/pcmcia/config to use kernel-2.4 driver

* Sun Jun 02 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.2.4-0vl5
- fixed Patch9

* Sun Apr 27 2003 Satoshi MACHINO <machino@vinelinux.org> 3.2.4-0vl4
- updated vine.conf
	-- added PLANEX GW-NS11H

* Fri Apr 19 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.2.4-0vl3
- removed Pathc4(yenta)
- changed default /etc/sysconfig/pcmcia
  PCMCIA=yes
  PCIC=yenta_socket
  PCIC_OPTS=do_scan=0
  CORE_OPTS="unreset_delay=400"
  CARDMGR_OPTS=-f

* Wed Mar 26 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.2.4-0vl1
- source update
- added again (noreplace) tag at config.opts
- changed default /etc/sysconfig/pcmcia
  PCMCIA=yes
  PCIC=
  PCIC_OPTS=do_scan=0
  CORE_OPTS="unreset_delay=400"
  CARDMGR_OPTS=-f

* Sat Sep 14 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.2.1-0vl3
- fixed again config
- removed (noreplace) tag at config.opts

* Fri Sep 13 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.2.1-0vl2
- fixed config, add.conf, vine.conf and config.opts.ppc

* Fri Sep 13 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.2.1-0vl1
- source update

* Sun Mar 31 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 3.1.31-0vl7
- modified Patch4 again

* Sat Mar 30 2002 Daisuke SUZUKI <daisuke@linux.or.jp> 3.1.31-0vl6
- changed patch4, we are use kernel-2.4 for default.
  replace yenta and i82365 for PCIC environment.

* Thu Mar 14 2002 Daisuke SUZUKI <daisuke@linux.or.jp> 3.1.31-0vl5
- update add.conf/vine.conf/config to use orinoco_cs
- update add.conf

* Sat Mar 09 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 3.1.31-0vl4
- added %%triggerpostun -- kernel24-pcmcia-cs

* Mon Mar 04 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 3.1.31-0vl3
- Obsoletes kernel24-pcmcia-cs
- modified summary and description (this package doesn't contain any drivers)

* Sun Mar 03 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.1.31-0vl2
- rename from kernel24 to kernel
- Configure checks $LINUX/configs/kernel-{ver}-{arch}.config

* Sun Feb 24 2002 Daisuke SUZUKI <daisuke@linux.or.jp> 3.1.31-0vl2
- remove lspnp for all arch.

* Thu Feb 21 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.1.31-0vl1
- source update

* Sun Jan 27 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.1.30-0vl5
- in rc.pcmcia, changed kudzu -> /usr/sbin/kudzu
	- [VineSeed:05523] by MATSUBAYASHI 'Shaolin' Kohji

* Sun Jan 13 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.1.30-0vl4
- set cardctl setuid root
- fixed add.conf and vine.conf

* Sat Jan 12 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.1.30-0vl3
- reverted to using Configure script

* Thu Jan 10 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.1.30-0vl2
- added Requires: murasaki

* Wed Jan 09 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.1.30-0vl1
- based on kernel-pcmcia-cs-3.1.27-11
