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