6b0fa0e
%define	ruby_sitelib		%(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
6b0fa0e
%define	ruby_sitearch		%(ruby -rrbconfig -e "puts Config::CONFIG['sitearchdir']")
6b0fa0e
%define	rubyabi		1.8
6b0fa0e
6b0fa0e
%define	gemdir			%(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
6b0fa0e
%define	gemname		nokogiri
6b0fa0e
%define	geminstdir		%{gemdir}/gems/%{gemname}-%{version}
6b0fa0e
6b0fa0e
Summary:	An HTML, XML, SAX, and Reader parser
6b0fa0e
Name:		rubygem-%{gemname}
a550aec
Version:	1.3.1
6b0fa0e
Release:	1%{?dist}
6b0fa0e
Group:		Development/Languages
6b0fa0e
License:	MIT
6b0fa0e
URL:		http://nokogiri.rubyforge.org/nokogiri/
6b0fa0e
Source0:	http://gems.rubyforge.org/gems/%{gemname}-%{version}.gem
6b0fa0e
6b0fa0e
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
6b0fa0e
BuildRequires:	ruby(abi) = %{rubyabi}
6b0fa0e
BuildRequires:	ruby(rubygems)
1ee2198
BuildRequires:	rubygem(hoe)
6b0fa0e
BuildRequires:	rubygem(rake)
a550aec
# Not available yet
a550aec
# BuildRequires(check):	rubygem(rake-compiler)
6b0fa0e
BuildRequires:	libxml2-devel
6b0fa0e
BuildRequires:	libxslt-devel
6b0fa0e
BuildRequires:	ruby-devel
6b0fa0e
Requires:	ruby(abi) = %{rubyabi}
6b0fa0e
Requires:	ruby(rubygems)
6b0fa0e
Provides:	rubygem(%{gemname}) = %{version}-%{release}
6b0fa0e
6b0fa0e
%description
6b0fa0e
Nokogiri parses and searches XML/HTML very quickly, and also has
6b0fa0e
correctly implemented CSS3 selector support as well as XPath support.
6b0fa0e
6b0fa0e
Nokogiri also features an Hpricot compatibility layer to help ease the change
6b0fa0e
to using correct CSS and XPath.
6b0fa0e
6b0fa0e
%package	doc
6b0fa0e
Summary:	Documentation for %{name}
6b0fa0e
Group:		Documentation
6b0fa0e
# Directory ownership issue
6b0fa0e
Requires:	%{name} = %{version}-%{release}
6b0fa0e
Requires:	ruby(rubygems)
6b0fa0e
6b0fa0e
%description	doc
6b0fa0e
This package contains documentation for %{name}.
6b0fa0e
6b0fa0e
%package	-n ruby-%{gemname}
6b0fa0e
Summary:	Non-Gem support package for %{gemname}
6b0fa0e
Group:		Development/Languages
6b0fa0e
Requires:	%{name} = %{version}-%{release}
6b0fa0e
Provides:	ruby(%{gemname}) = %{version}-%{release}
6b0fa0e
6b0fa0e
%description	-n ruby-%{gemname}
6b0fa0e
This package provides non-Gem support for %{gemname}.
6b0fa0e
6b0fa0e
%prep
6b0fa0e
%setup -q -T -c
6b0fa0e
6b0fa0e
%build
6b0fa0e
mkdir -p ./%{gemdir}
6b0fa0e
export CONFIGURE_ARGS="--with-cflags='%{optflags}'"
6b0fa0e
gem install \
6b0fa0e
	--local \
6b0fa0e
	--install-dir ./%{gemdir} \
6b0fa0e
	-V --force \
6b0fa0e
	%{SOURCE0}
6b0fa0e
6b0fa0e
# cflags wrong (-O3 passed), recompiling
a550aec
# Skip until rubygem(rake-compiler) is available
a550aec
%if 0
6b0fa0e
pushd ./%{geminstdir}
6b0fa0e
sed -i.flags -e 's|-O3||' ext/nokogiri/extconf.rb
6b0fa0e
find . -name \*.so -or -name \*.o -exec rm -f {} \;
21c2bbd
rake -v ext/nokogiri/native.so --trace
a550aec
%endif
6b0fa0e
6b0fa0e
%install
6b0fa0e
rm -rf %{buildroot}
6b0fa0e
mkdir -p %{buildroot}%{gemdir}
6b0fa0e
cp -a ./%{gemdir}/* %{buildroot}%{gemdir}
6b0fa0e
6b0fa0e
# move arch dependent files to %%ruby_sitearch
6b0fa0e
mkdir -p %{buildroot}%{ruby_sitearch}/%{gemname}
6b0fa0e
mv %{buildroot}%{geminstdir}/lib/%{gemname}/*.so \
6b0fa0e
	%{buildroot}%{ruby_sitearch}/%{gemname}/
6b0fa0e
a550aec
# move bin/ files
a550aec
mkdir -p %{buildroot}%{_prefix}
a550aec
mv -f %{buildroot}%{gemdir}/bin %{buildroot}%{_prefix}
a550aec
6b0fa0e
# remove all shebang
6b0fa0e
for f in $(find %{buildroot}%{geminstdir} -name \*.rb)
6b0fa0e
do
6b0fa0e
	sed -i -e '/^#!/d' $f
6b0fa0e
	chmod 0644 $f
6b0fa0e
done
6b0fa0e
6b0fa0e
# cleanups
6b0fa0e
rm -rf %{buildroot}%{geminstdir}/ext
a550aec
rm -f %{buildroot}%{geminstdir}/{.autotest,.require_paths}
6b0fa0e
6b0fa0e
# The following method is completely copied from rubygem-gettext
6b0fa0e
# spec file
6b0fa0e
#
6b0fa0e
# Create symlinks
6b0fa0e
##
6b0fa0e
## Note that before switching to gem %%{ruby_sitelib}/%%{gemname}
6b0fa0e
## already existed as a directory, so this cannot be replaced
6b0fa0e
## by symlink (cpio fails)
6b0fa0e
## Similarly, all directories under %%{ruby_sitelib} cannot be
6b0fa0e
## replaced by symlink
6b0fa0e
#
6b0fa0e
6b0fa0e
create_symlink_rec(){
6b0fa0e
6b0fa0e
ORIGBASEDIR=$1
6b0fa0e
TARGETBASEDIR=$2
6b0fa0e
6b0fa0e
## First calculate relative path of ORIGBASEDIR 
6b0fa0e
## from TARGETBASEDIR
6b0fa0e
TMPDIR=$TARGETBASEDIR
6b0fa0e
BACKDIR=
6b0fa0e
DOWNDIR=
6b0fa0e
num=0
6b0fa0e
nnum=0
6b0fa0e
while true
6b0fa0e
do
6b0fa0e
	num=$((num+1))
6b0fa0e
	TMPDIR=$(echo $TMPDIR | sed -e 's|/[^/][^/]*$||')
6b0fa0e
	DOWNDIR=$(echo $ORIGBASEDIR | sed -e "s|^$TMPDIR||")
6b0fa0e
	if [ x$DOWNDIR != x$ORIGBASEDIR ]
6b0fa0e
	then
6b0fa0e
		nnum=0
6b0fa0e
		while [ $nnum -lt $num ]
6b0fa0e
		do
6b0fa0e
			BACKDIR="../$BACKDIR"
6b0fa0e
			nnum=$((nnum+1))
6b0fa0e
		done
6b0fa0e
		break
6b0fa0e
	fi
6b0fa0e
done
6b0fa0e
6b0fa0e
RELBASEDIR=$( echo $BACKDIR/$DOWNDIR | sed -e 's|//*|/|g' )
6b0fa0e
6b0fa0e
## Next actually create symlink
6b0fa0e
pushd %{buildroot}/$ORIGBASEDIR
6b0fa0e
find . -type f | while read f
6b0fa0e
do
6b0fa0e
	DIRNAME=$(dirname $f)
6b0fa0e
	BACK2DIR=$(echo $DIRNAME | sed -e 's|/[^/][^/]*|/..|g')
6b0fa0e
	mkdir -p %{buildroot}${TARGETBASEDIR}/$DIRNAME
6b0fa0e
	LNNAME=$(echo $BACK2DIR/$RELBASEDIR/$f | \
6b0fa0e
		sed -e 's|^\./||' | sed -e 's|//|/|g' | \
6b0fa0e
		sed -e 's|/\./|/|' )
6b0fa0e
	ln -s -f $LNNAME %{buildroot}${TARGETBASEDIR}/$f
6b0fa0e
done
6b0fa0e
popd
6b0fa0e
6b0fa0e
}
6b0fa0e
6b0fa0e
create_symlink_rec %{geminstdir}/lib %{ruby_sitelib}
6b0fa0e
6b0fa0e
6b0fa0e
%clean
6b0fa0e
rm -rf %{buildroot}
6b0fa0e
c618dab
%check
a550aec
# Skip until rubygem(rake-compiler) is available
a550aec
exit 0
a550aec
c618dab
pushd ./%{geminstdir}
a550aec
rake test
c618dab
popd
c618dab
6b0fa0e
%files
6b0fa0e
%defattr(-,root, root,-)
a550aec
%{_bindir}/%{gemname}
6b0fa0e
%{ruby_sitearch}/%{gemname}/
6b0fa0e
%dir	%{geminstdir}/
6b0fa0e
%doc	%{geminstdir}/[A-Z]*
a550aec
%exclude %{geminstdir}/Rakefile
6b0fa0e
%{geminstdir}/[a-l]*/
6b0fa0e
%{gemdir}/cache/%{gemname}-%{version}.gem
6b0fa0e
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
6b0fa0e
6b0fa0e
%files	doc
6b0fa0e
%defattr(-,root,root,-)
a550aec
%{geminstdir}/Rakefile
c618dab
%{geminstdir}/tasks/
6b0fa0e
%{geminstdir}/test/
6b0fa0e
%{gemdir}/doc/%{gemname}-%{version}/
6b0fa0e
6b0fa0e
%files	-n ruby-%{gemname}
6b0fa0e
%defattr(-,root,root,-)
6b0fa0e
%{ruby_sitelib}/*%{gemname}.rb
6b0fa0e
%{ruby_sitelib}/%{gemname}/
1ee2198
%{ruby_sitelib}/xsd/
6b0fa0e
6b0fa0e
%changelog
a550aec
* Thu Jun 11 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.3.1-1
a550aec
- 1.3.1
a550aec
a5502a7
* Thu Mar 26 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.2.3-1
a5502a7
- 1.2.3
a5502a7
1ee2198
* Thu Mar 19 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.2.2-1
1ee2198
- 1.2.2
1ee2198
c618dab
* Thu Mar 12 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.2.1-1
c618dab
- 1.2.1
c618dab
c618dab
* Tue Feb 24 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.1.1-2
c618dab
- F-11: Mass rebuild
c618dab
6b0fa0e
* Thu Jan 15 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.1.1-1
6b0fa0e
- 1.1.1
6b0fa0e
6b0fa0e
* Thu Dec 25 2008 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.1.0-1
6b0fa0e
- Initial packaging
6b0fa0e