%define FBversion 1.1.1
%define patchversion 1.1.0.1

%define fbumenu_version 0.5.2
%define vinefiles_version 9.8

Summary:        Fluxbox is a windowmanager that is based on Blackbox.
summary(ja):    Fluxbox は Blackbox から派生したウインドウマネージャです。
Name:           fluxbox
Version:        %{FBversion}
Release:        1%{?_dist_release}
Group:          User Interface/Desktops
License:        MIT
URL:            http://fluxbox.org/
Vendor:         Project Vine
Distribution:   Vine Linux
Source0:        http://downloads.sourceforge.net/fluxbox/%{name}-%{version}.tar.bz2
# styles & scripts 
Source1:        vinefiles-%{vinefiles_version}.tar.bz2
Source2:        styles2.tar.bz2

Patch0:         fluxbox-%{version}.init-in.patch
##Patch1:               fluxbox-%{patchversion}.src-clock-tool.patch
##Patch2:               fluxbox-%{patchversion}.src-Makefile-in.patch
Patch3:         fluxbox-%{patchversion}.nls-ja.patch
Patch4:         fluxbox-%{version}.startfb.patch
Patch5:         fluxbox-%{patchversion}.menugen-menu-default.patch
Patch6:         fluxbox-%{patchversion}.menugen-add-app.patch
Patch8:         fluxbox-%{patchversion}.menugen-utf-8.patch
Patch9:         fluxbox-%{patchversion}.menugen-vine-ext.patch

Patch10:        fbsetbg_setter_priority.patch
Patch20:        fluxbox-%{patchversion}.Xclients.patch
##Patch30:      fluxbox-%{patchversion}.nls-hh.patch
Patch40:        fluxbox-%{patchversion}.nls-ja-make.patch
Patch41:        fluxbox-%{patchversion}.update_cfg.patch

#Patch100:       fluxbox-%{patchversion}.20080913.patch

BuildRoot:      %{_tmppath}/%{name}-buildroot
BuildRequires:  libX11-devel libXext-devel 
BuildRequires:  bzip2 imlib2-devel zlib-devel freetype2-devel
Requires:       imlib2 imlib2-loader ImageMagick nkf xsri xinitrc

%description

Fluxbox is yet another windowmanager for X.
It's based on the Blackbox 0.61.1 code. 
Fluxbox looks like blackbox and handles styles, colors, window 
placement and similar thing exactly like blackbox 
    (100% theme/style compability).
So what's the difference between fluxbox and blackbox then?
The answer is: LOTS!
Here is a list of features that fluxbox already has, or is in the works...

%description -l ja

fluxbox は X Window System 用の、一味違ったウィンドウマネージャです。
それは blackbox-0.61.1 のプログラムコードをベースに開発されています。
fluxbox は blackbox によく似ていて、スタイル、カラーリング、ウィンドウ
の配置などを blackbox 同様に処理します。(スタイル(テーマ)は 100% 互換)
では、fluxbox と blackbox の違いは？  ...  その答えは「いっぱい」!

fluxbox に何が出来るか、今後何を計画しているのか？
詳しくは http://fluxbox.sourceforge.net/ をご覧下さい。

%prep
%__rm -rf %{buildroot}
##%%setup -T -n %{name}-%{version} -c
%setup -q -a 1

##%__tar jxf  %{SOURCE0}
##mv -f %{name}-%{FBversion}/* ./
##rm -rf %{name}-%{FBversion}

%patch0 -p1
##%patch1 -p1
##%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
##%patch30 -p1
%patch40 -p1
%patch41 -p1

##%patch100 -p1

%__tar jxf  %{SOURCE1}
%__tar jxf  %{SOURCE2}

%build

CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \
./configure --enable-nls \
        --prefix=%{_prefix} \
        --exec-prefix=%{_exec_prefix} \
        --bindir=%{_bindir} \
        --sbindir=%{_sbindir} \
        --sysconfdir=%{_sysconfdir} \
        --datadir=%{_datadir} \
        --includedir=%{_includedir} \
        --libdir=%{_libdir} \
        --libexecdir=%{_libexecdir} \
        --localstatedir=%{_localstatedir} \
        --sharedstatedir=%{_sharedstatedir} \
        --mandir=%{_mandir} \
        --infodir=%{_infodir}

%__make

%install
%__rm -rf  %{buildroot}
# fluxbox installation
make "DESTDIR=%{buildroot}" install

%__rm data/styles/Makefile*
%__cp -a data/styles                %{buildroot}%{_datadir}/%{name}/
%__cp -a data/styles2               %{buildroot}%{_datadir}/%{name}/
%__cp -a data/backgrounds           %{buildroot}%{_datadir}/%{name}/
%__cp -a data/images                %{buildroot}%{_datadir}/%{name}/
%__cp -a data/UserMenu              %{buildroot}%{_datadir}/%{name}/
%__cp data/fb_welcome.sh            %{buildroot}%{_datadir}/%{name}/
%__cp data/*.html                   %{buildroot}%{_datadir}/%{name}/
%__cp data/fluxbox.desktop.seed     %{buildroot}%{_datadir}/%{name}/fluxbox.desktop
%__cp data/*.sample                 %{buildroot}%{_datadir}/%{name}/
%__cp data/fb_welcome               %{buildroot}%{_datadir}/%{name}/
%__cp data/cng_fbtips               %{buildroot}%{_datadir}/%{name}/
%__cp data/change-rootcmd           %{buildroot}%{_datadir}/%{name}/
%__cp data/change-init_rootcmd      %{buildroot}%{_datadir}/%{name}/
%__cp %{PATCH20}                    %{buildroot}%{_datadir}/%{name}/
%__cp data/mk-rootcmds              %{buildroot}%{_bindir}/
%__cp data/fbumenu_gen-%{fbumenu_version} %{buildroot}%{_bindir}/fbumenu_gen
%__cp ChangeLog                     %{buildroot}%{_datadir}/%{name}/

# gdm session
%__mkdir_p %{buildroot}%{_sysconfdir}/X11/dm/Sessions/
%__cp %{buildroot}%{_datadir}/fluxbox/fluxbox.desktop %{buildroot}%{_sysconfdir}/X11/dm/Sessions/

if [ -z "$DEBUG" ]; then
        strip   %{buildroot}%{_bindir}/fluxbox \
                %{buildroot}%{_bindir}/fbsetroot \
                %{buildroot}%{_bindir}/fbrun
fi

bzip2 %{buildroot}%{_mandir}/man1/*.1

%post

local_lang=`echo $LANG | grep ja_JP`
if ! [ -z "$local_lang" ]; then
    l_lang=`echo $LANG | grep ja_JP | cut -d '.' -f 2`
    case $l_lang in
        UTF-8)
            nkfopt="-w"
            ;;
        eucJP)
            nkfopt="-e"
            ;;
    esac
fi

if [ -n "`grep -n "startWM FluxBox fluxbox" /etc/X11/xinit/Xclients | grep "^43:"`" ]; then
    %__patch -p0 < %{_datadir}/%{name}/fluxbox-%{patchversion}.Xclients.patch
elif [ -z "`grep "startWM" /etc/X11/xinit/Xclients | grep "startfluxbox$"`" ]; then
    cat << EOF | nkf $nkfopt

最新でない、改変された /etc/X11/xinit/Xclients が使われているようです。
起動コマンドを "fluxbox" ではなく "startfluxbox" に設定して下さい。

EOF
fi

# New menu-system
%__rm %{_datadir}/fluxbox/menu*
%{_bindir}/fluxbox-generate_menu \
        -p %{_prefix} \
        -o %{_datadir}/fluxbox/menu 2> /dev/null

cat << EOF | nkf $nkfopt

* fluxbox-%{version} : インストール|アップグレードされました。*

※幾つかの更新が有ります。詳細は、
    file:///usr/share/fluxbox/flux_news.html
を御覧下さい。

EOF

%clean

%__rm -rf %{buildroot}

%files
%defattr(-,root,root,755)
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README TODO
%dir %{_datadir}/%{name}
%{_bindir}/*
%{_mandir}/*
%{_datadir}/%{name}/*
%{_sysconfdir}/X11/dm/Sessions/fluxbox.desktop

%changelog
* Fri Sep 19 2008 KATO Masashi <mkato@par.odn.ne.jp> 1.1.1-1
- new upstream release.
- removed upstream patchs.
- rewrote Vine documents.

* Sat Sep 14 2008 KATO Masashi <mkato@par.odn.ne.jp> 1.1.0.1-3
- Applied upstream patchs.

* Fri Sep 12 2008 KATO Masashi <mkato@par.odn.ne.jp> 1.1.0.1-2
- updated mk-rootcmds
- updated vine documents. (keys.html, flux_news.html)

* Thu Sep 11 2008 KATO Masashi <mkato@par.odn.ne.jp> 1.1.0.1-1
- new upstream release
- removed fluxbox-%{FBversion}.nls-hh.patch
- rewrote documents. (keys.html, flux_news.html)
- added new default keys file

* Sun Aug 24 2008 KATO Masashi <mkato@par.odn.ne.jp> 1.0.0-6
- fixed locale problem
-     rewrote scripts for eucJP and UTF-8
- revived fluxbox-%{FBversion}.Xclients.patch. (for startx)

* Sun Jun 22 2008 KATO Masashi <mkato@par.odn.ne.jp> 1.0.0-5
- add new style. (tux)

* Mon Jun 16 2008  KATO Masashi <mkato@par.odn.ne.jp> 1.0.0-3
- corrected line gap of nls-header
-   (fluxbox-1.0.0.nls-hh.patch) 

* Tue May 27 2008  KATO Masashi <mkato@par.odn.ne.jp> 1.0.0-2
- adjust startup sequence
-   (rewrite desktop entry file for dm sessions)
-   (remove fluxbox-%{FBversion}.Xclients.patch)

* Sun May 25 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.0-1
- applied new versioning policy
- rebuilt with xorg-x11 7.3
- spec in UTF-8

* Tue Dec  4 2007 KATO Masashi <mkato@par.odn.ne.jp> 1.0.0-0vl3, 4
- retouch patchs for ja_JP.UTF-8 locale
-     : for root menu & help message
- rewrite vine documents

* Mon Oct 15 2007 KATO Masashi <mkato@par.odn.ne.jp> 1.0.0-0vl1, 2
- new upstream 'stable' release
- add new documents(styles tips, keys tips).
- add new styles
- update patch files, vine documents, vine scripts

* Wed Apr 11 2007 KATO Masashi <mkato@par.odn.ne.jp> 1.0-0vl0.rc3.1, 2
- new upstream release
- add rewrited system styles
- update patch files
- update vine documents

* Sun Dec 24 2006 KATO Masashi <mkato@par.odn.ne.jp> 1.0-0vl0.rc2.3, 4
- add BuildRequires: zlib-devel freetype2-devel
- add Requires: xsri
- Change wpsetter's priority (fbsetbg_setter_priority.patch)

* Thu Jul 20 2006 KATO Masashi <mkato@par.odn.ne.jp> 1.0-0vl0.rc2.1, 2
- new upstream release
- update patch files
- update vine documents

* Thu Jul  6 2006 KATO Masashi <mkato@par.odn.ne.jp> 1.0-0vl0.rc0.1, 2
- new upstream release
- update patch files
- added 'additional applications' extension to fluxbox-generate_menu

* Tue Apr  8 2006 KATO Masashi <mkato@par.odn.ne.jp> 0.9.15.1-0vl1, 2
- new upstream release
- add 'init file rewrite' script for back-compatible
- rewrite documents

* Wed Mar 29 2006 KATO Masashi <mkato@par.odn.ne.jp> 0.9.15-0vl1, 2
- new upstream release
- update *tips*
- update patch files
- add & update script files
- update & retouch style files (VineStyle*, BlueStar*)
- retouch menu structure (Vine tools)
- add script for back compatible to background-style

* Sun Mar 19 2006 KATO Masashi <mkato@par.odn.ne.jp> 0.9.14-0vl1.1, 2.2
- update *_tips.html
    (retouch link errors)
- retouch ja_JP/Translation.m 
- update menugen patch
- update style file (VineStyle, BlueStar)
- add index.html, scripts for 'wellcome'

* Tue Oct 25 2005 KATO Masashi <mkato@par.odn.ne.jp> 0.9.14-0vl1, 2
- new upstream release
- update vine patch
        (retouch init file for new spec.)
- update vinefiles
    (update fbumenu_gen(usermenu generator))
        (update 2 style files for new spec.)
        (update fluxtips.txt)
- update fluxbox_menu_tips.html

* Sun Jun  5 2005 KATO Masashi <mkato@par.odn.ne.jp> 0.9.13-0vl3, 4
- update vine patch 
        (add some menu items to fluxbox-generate_menu)
            (retouch menu structure)
                (rewrite 'about menu')
- update vinefiles
    (add usermenu generator to x-utilus)
- update fluxbox_menu_tips.html

* Fri May 27 2005 KATO Masashi <mkato@par.odn.ne.jp> 0.9.13-0vl1
- new upstream release
- update vine patch 
        (add some menu items to fluxbox-generate_menu)
                (extend 'about toolbar')
- update nls-ja patch
- update fluxtips.txt
    (rewrite, add '0.9.13 news')

* Sun Feb  6 2005 KATO Masashi <mkato@par.odn.ne.jp> 0.9.12-0vl1
- new upstream release
- update vine patch 
        (add some menu items to fluxbox-generate_menu)
            (include blackbox styles)
                (extend 'my_mail')
                (extend 'about menu')
- add nls-ja patch

* Sun Dec 12 2004 KATO Masashi <mkato@par.odn.ne.jp> 0.9.11-0vl1
- new upstream release
- update vine patch 
    (generate japanese menu)
        (add some menu items to fluxbox-generate_menu)
        (retouch menu structure)
        (fix menu backup problem)

* Wed Nov 24 2004 IWAI, Masaharu <iwai@alib.jp> 0.9.10-0vl1
- new upstream release
- update vine patch ( merged vine patches )
- add font_locale patch ( Patch100 )
- fix typo: s/buidroot/buildroot/g

* Sun Jun 20 2004 KATO Masashi <mkato@par.odn.ne.jp> 0.9.9-0vl2
- rewrite 2 styles (VineStyleII, BlueStarII)
- rewrite fluxtips.txt(for 0.9.x)
- modifying menu-generator
    (fix problems of 'can't generates some menus')
    (add some menu items)
    (Japanese help messages)
- modifying 'init' file(default style, menu-alpha)
- append sample of 'keys' file

* Sun May  2 2004 IWAI, Masaharu <iwai@alib.jp> 0.9.9-0vl1
- new upstream release

* Sun Mar 14 2004 IWAI, Masaharu <iwai@alib.jp> 0.9.8-0vl2
- using rpm macros
- fix nonexistent directory for styles in postscript
- add BuildRequires: bzip2
- drop Prefix tag

* Sat Mar  6 2004 IWAI, Masaharu <iwai@alib.jp> 0.9.8-0vl1
- new upstream release
- update vine patch (Patch101)

* Mon Aug 11 2003 IWAI, Masaharu <iwai@alib.jp> 0.1.14-1_0vl2
- build for VineSeed
- fix Group tag for VineLinux:
    Graphical desktop/Other -> User Interface/Desktops
- add /usr/share/%%{name} directory in %%files section

* Sat May 31 2003 KATO Masashi <mkato@par.odn.ne.jp> 0.1.14-1_0vl1
- fluxbox for Vine Linux. Japanese menu enabled at default.
- modified menu-generator patch (x-terminals)
- modified init.in patch (date,workspace name,default style)
- added 2 styles (VineStyle, BlueStar)

* Mon Dec  9 2002 Han Boetes <han@mijncomputer.nl> 0.1.14-1
- And we have a new release

* Sun Dec  1 2002 Han Boetes <han@linux-mandrake.com> 0.1.13-4
- added only missing patch from bugfixpatch

* Mon Nov 25 2002 Han Boetes <han@linux-mandrake.com> 0.1.13-3
- aa-startup- and openoffice-patch from Rathnor

* Thu Nov 21 2002 Han Boetes <han@linux-mandrake.com> 0.1.13-2
- Fix locales patch

* Tue Nov 19 2002 Han Boetes <han@linux-mandrake.com> 0.1.13-1
- Bump

* Fri Sep 13 2002 Han Boetes <han@linux-mandrake.com> 0.1.12-1
- Bump

* Tue Sep 10 2002 Han Boetes <han@linux-mandrake.com> 0.1.11-3
- Applied bugfix2 patch

* Tue Sep 10 2002 Han Boetes <han@linux-mandrake.com> 0.1.11-2
- Applied bugfix1 patch

* Tue Sep  3 2002 Han Boetes <han@mijncomputer.nl> 0.1.11-1
- Bump

* Mon Jul 15 2002 Han Boetes <han@mijncomputer.nl> 0.1.10-1
- Bump ;kudo's to Kurt Bechstein for recovering the rpm.

* Mon Jun  3 2002 Han Boetes <han@mijncomputer.nl> 0.1.9-2
- Applied bugfix-patch 2

* Sat May 25 2002 Han Boetes <han@mijncomputer.nl> 0.1.9-1
- Version Bump
- New menu-system

* Thu May  9 2002 Han Boetes <han@mijncomputer.nl> 0.1.8-4
- Esthetic and Profilactic cleanups

* Fri May  3 2002 Han Boetes <han@mijncomputer.nl> 0.1.8-3
- Applied bugfix-patch 1+2+3

* Sat Apr 27 2002 Han Boetes <han@mijncomputer.nl> 0.1.8-2
- Applied bugfix-patch 1

* Fri Apr 19 2002 Han Boetes <han@mijncomputer.nl> 0.1.8-1
- Bump to version 0.1.8

* Sat Mar  9 2002 Han Boetes <han@mijncomputer.nl> 0.1.7-3
- Applied patch 1

* Wed Mar  6 2002 Han Boetes <han@mijncomputer.nl> 0.1.7-2
- Added DEBUG flavor

* Fri Mar  1 2002 Han Boetes <han@mijncomputer.nl> 0.1.7-1
- BUMP!

* Thu Feb 07 2002 Christian Pelealu <chris@nerv-9.net> 0.1.6-3RH
- Changed a lot of the build spec for RedHat 7.2

* Tue Jan 29 2002 Han Boetes <han@mijncomputer.nl> 0.1.6-3
- Applied patch 2

* Sun Jan 13 2002 Han Boetes <han@mijncomputer.nl> 0.1.6-2
- Applied patch.

* Fri Jan 11 2002 Han Boetes <han@mijncomputer.nl> 0.1.6-1
- Bump version.

* Fri Dec 28 2001 Han Boetes <han@mijncomputer.nl> 0.1.5-1
- Initial build

