%define ver 1.8.7
%define rel 0vl5

Summary: an X/Motif calendar and day planner
Summary(ja): X/Motif を用いた高機能スケジューラ

Name:  plan
Version: %{ver}
Release: %{rel}

Source:  ftp://ftp.fu-berlin.de/pub/unix/graphics/plan/plan-%{ver}.tar.gz
# vine sources
Source1: Plan.vine.ad
Source2: holiday_japan_EUC 
Source3: plan-1.8.3.lang.japanese
# from vine-users:023414
Source4: plan_calEUC.ps
Source5: netplan.boot
Source6: plan.sh
Source7: netplangrpadd.sh
Source8: plan.README.vine

# vine patches
Patch:   plan-1.8.7-jp.vine.patch
#jp patch is merged with http://cgi.shikoku.ne.jp/~fun/srpms.html
Patch1:  plan-1.8.7-jp.patch
Patch2:  plan-1.8.7-netplan.patch
Patch3: plan-1.8.4-makefile.patch
URL:	http://www.IN-Berlin.DE/User/bitrot/plan.html
License: distributable
Group: Applications/Productivity
Buildroot: %{_tmppath}/%{name}-root
BuildPrereq: openMotif-devel, byacc, flex
Requires: openMotif

Vendor: Project Vine
Distribution: Vine Linux

%description
Plan is a schedule planner based on X/Motif. It also works with
lesstif instead of Motif. It displays a month calendar similar to
xcal, but every day box is large enough to show appointments in small
print. By pressing on a day box, the appointments for that day can
be listed and edited.

%description -l ja
PlanはX/Motifを用いた高機能スケジューラです．月表示，週表示，一日表示等が
でき，ネットワークを介したグループでの利用もできます．Apple Newton PDA や
PalmPilot PDA とのファイル交換もできます．利用には openMotif が必要です。

netplan を利用するときには、netplan.dir として /home/netplan を利用する
ように設定してあります。

%prep
rm -rf %{buildroot}
%setup -n plan-%{ver}
%patch -p1

%patch1 -p1
%patch2 -p1
# %patch3 -p1

cp %{SOURCE3} language/plan.lang.japanese
cp %{SOURCE4} misc/plan_cal.ps
cp %{SOURCE8} README.vine

%build

chPath(){
for i in $*; do
sed -e "s|/usr/local/bin|/usr/bin|g" \
    -e "s|/usr/local/lib/netplan.dir|/home/netplan|g" \
    -e "s|/usr/local/lib|%{_libdir}/plan|g" \
    -e "s|\!/usr/local/bin/perl|\!/usr/bin/perl|g" \
    -e "s|\!/bin/perl|\!/usr/bin/perl|g" \
    -e "s|\!/usr/bin/sed|\!/bin/sed|g" \
    -e "s|\! /usr/local/bin/perl|\!/usr/bin/perl|g" \
    -e "s|\! /bin/perl|\!/usr/bin/perl|g" \
    -e "s|\! /usr/bin/sed|\!/bin/sed|g" \
    $i > $i.new
mv $i.new $i
done
}

(cd misc
chPath vsc cvs Mkdoc msschedule2plan Killpland
)

cp %{SOURCE2} holiday/holiday_japan

(cd src
make linux
)
(
cd web
for i in *.cgi common.pl; do
	chPath $i
done
)

%install
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}/usr/X11R6/lib/X11/app-defaults
install -m 644 %{SOURCE1} %{buildroot}/usr/X11R6/lib/X11/app-defaults/Plan

(cd src
mkdir -p %{buildroot}/usr/{bin,lib}
mkdir -p %{buildroot}%{_libdir}/plan
mkdir -p %{buildroot}/home/netplan
make DESTDIR=%{buildroot} install
)

mv %{buildroot}%{_bindir}/plan %{buildroot}%{_bindir}/plan.bin
install -m 755 %{SOURCE6} %{buildroot}%{_bindir}/plan
install -m 755 %{SOURCE7} %{buildroot}%{_sbindir}/netplangrpadd

mkdir -p %{buildroot}%{_sysconfdir}/rc.d/init.d
install -m 755 %{SOURCE5} %{buildroot}%{_sysconfdir}/rc.d/init.d/netplan

(cd web
mkdir -p %{buildroot}/home/httpd/html/plan/
install -m 755 *.cgi %{buildroot}/home/httpd/html/plan/
install -m 644 *.pl %{buildroot}/home/httpd/html/plan/
install -m 644 *.{html,jpg} holiday_webplan %{buildroot}/home/httpd/html/plan/
)

(cd misc
install -m 755 msschedule2plan Killpland %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_mandir}/{man1,man4}
install *.1 %{buildroot}%{_mandir}/man1
install *.4 %{buildroot}%{_mandir}/man4

#prepare for doc
rm *.1 *.4 *cat msschedule2plan Killpland *.ps
)

cat > %{buildroot}/home/netplan/.netplan-acl<<EOF
#Examples(see man netplan in detail)
#*: permit read
#*: permit write host daphne
#thomas: deny user *
#thomas: permit read write delete user 207 208
#announce: permit write netmask 255.255.255.0 host 10.0.1.0
#
*: permit read
EOF

%clean
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root)
%doc README* HISTORY holiday/ 
%doc misc/
%{_sysconfdir}/rc.d/init.d/netplan
/home/httpd/html/plan/
/usr/X11R6/lib/X11/app-defaults/Plan
%{_bindir}/plan
%{_bindir}/plan.bin
%{_bindir}/msschedule2plan
%{_bindir}/Killpland
%attr(755,-,-)%dir %{_libdir}/plan/
%{_libdir}/plan/pland
%{_libdir}/plan/notifier
%{_libdir}/plan/plan.help
%{_libdir}/plan/plan.lang.*
%{_libdir}/plan/plan*.ps
%{_sbindir}/netplan
%{_sbindir}/netplangrpadd
%attr(1700,nobody,nobody)%dir /home/netplan/
%attr(-,nobody,nobody)%config(noreplace) /home/netplan/.netplan-acl
%{_mandir}/man1/plan.1*
%{_mandir}/man1/netplan.1*
%{_mandir}/man4/plan.4*

%changelog 
* Tue Oct 24 2006 Ryoichi INAGAKI <ryo1@bc.wakwa.com> 1.8.7-0vl5
- rebuilt for Vine Linux 4.0
- s/Copyright/License/
- added %clean section

* Sat Mar 12 2005 Jun NISHII <jun@vinelinux.org> 1.8.7-0vl4
- build on Vine 3.1
- added byacc, flex in BuildPreReq

* Wed Feb 23 2005 Jun Nishii <jun@vinelinux.org> 1.8.7-0vl3
- fix plan.sh
- update holiday_japan

* Tue Feb 22 2005 Jun Nishii <jun@vinelinux.org> 1.8.7-0vl2
- update holiday_japan

* Mon Oct 27 2003 Jun Nishii <jun@vinelinux.org> 1.8.7-0vl1
- ver.up

* Mon Jun  2 2003 Jun Nishii <jun@vinelinux.org> 1.8.4-0vl6
- build with openMotif

* Mon Feb 17 2003 Jun Nishii <jun@vinelinux.org> 1.8.4-0vl5
- update holiday_japan

* Wed Jan 22 2003 Jun Nishii <jun@vinelinux.org> 1.8.4-0vl4
- plan-1.8.4-jp2.vine.patch (fix locale handling for printing)
- smaller default fonts in month view

* Fri Jan 18 2002 Jun Nishii <jun@vinelinux.org> 1.8.4-0vl3
- rebuild with gcc-2.95.3
- update holiday_japan

* Wed May  9 2001 Jun Nishii <jun@vinelinux.org> 1.8.4-0vl2
- fix LOCALE_EUC as ja_JP.eucJP
- use more macros in spec

* Fri Apr 20 2001 Jun Nishii <jun@vinelinux.org> 1.8.4-0vl1
- ver.up
- move netplan.dir to /home/netplan
- many improvements

* Tue Feb  6 2001 Jun Nishii <jun@vinelinux.org>
- 1.8.3-0vl4
- fix path in common.pl

* Fri Oct  6 2000 Jun Nishii <jun@vinelinux.org>
- 1.8.3-0vl3
- updated holiday_japan

* Wed Jun 14 2000 Jun Nishii <jun@vinelinux.org>
- 1.8.3-0vl2
- merge plan_calEUC.ps from vine-useres:023414

* Fri Feb 11 2000 Jun Nishii <jun@vinelinux.org>
- 1.8.3
- merge japanese patch from http://cgi.shikoku.ne.jp/~fun/srpms.html

