Mamoru Tasaka e107dc4
%global	ruby_sitelib		%(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
Mamoru Tasaka e107dc4
%global	ruby_sitearch		%(ruby -rrbconfig -e "puts Config::CONFIG['sitearchdir']")
Mamoru Tasaka e107dc4
%global	rubyabi		1.8
4113b89
Mamoru Tasaka e107dc4
%global	mainver		1.5.0
Mamoru Tasaka b9de8f1
%global	prever			.beta.3
Mamoru Tasaka e107dc4
Mamoru Tasaka b9de8f1
%global	mainrel		2
Mamoru Tasaka e107dc4
%global	prerpmver		%(echo "%{?prever}" | sed -e 's|\\.||g')
Mamoru Tasaka e107dc4
Mamoru Tasaka e107dc4
%global	gemdir			%(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
Mamoru Tasaka e107dc4
%global	gemname		nokogiri
Mamoru Tasaka e107dc4
%global	geminstdir		%{gemdir}/gems/%{gemname}-%{mainver}%{?prever}
4113b89
e52e796
# Note for packager:
Mamoru Tasaka 01c36f3
# Nokogiri 1.4.3.1 gem says that Nokogiri upstream will
Mamoru Tasaka 01c36f3
# no longer support ruby 1.8.6 after 2010-08-01, so
Mamoru Tasaka 01c36f3
# it seems that 1.4.3.1 is the last version for F-13 and below.
e52e796
4113b89
Summary:	An HTML, XML, SAX, and Reader parser
4113b89
Name:		rubygem-%{gemname}
Mamoru Tasaka e107dc4
Version:	%{mainver}
Mamoru Tasaka e107dc4
Release:	%{?prever:0.}%{mainrel}%{?prever:.%{prerpmver}}%{?dist}
4113b89
Group:		Development/Languages
4113b89
License:	MIT
4113b89
URL:		http://nokogiri.rubyforge.org/nokogiri/
Mamoru Tasaka e107dc4
Source0:	http://gems.rubyforge.org/gems/%{gemname}-%{mainver}%{?prever}.gem
Mamoru Tasaka b9de8f1
# ./test/html/test_element_description.rb:62 fails, as usual......
Mamoru Tasaka b9de8f1
Patch0:		rubygem-nokogiri-1.5.0.beta3-test-failure.patch
4113b89
4113b89
BuildRequires:	ruby(abi) = %{rubyabi}
4113b89
BuildRequires:	ruby(rubygems)
Mamoru Tasaka 97ab0c3
BuildRequires(check):	rubygem(hoe)
9727014
# Not available yet
99681b5
# BuildRequires:	rubygem(hoe-debugging)
Mamoru Tasaka 97ab0c3
BuildRequires(check):	rubygem(rake)
Mamoru Tasaka 97ab0c3
BuildRequires(check):	rubygem(rake-compiler)
Mamoru Tasaka 97ab0c3
BuildRequires(check):	rubygem(minitest)
4113b89
BuildRequires:	libxml2-devel
4113b89
BuildRequires:	libxslt-devel
4113b89
BuildRequires:	ruby-devel
4113b89
Requires:	ruby(abi) = %{rubyabi}
4113b89
Requires:	ruby(rubygems)
4113b89
Provides:	rubygem(%{gemname}) = %{version}-%{release}
4113b89
4113b89
%description
4113b89
Nokogiri parses and searches XML/HTML very quickly, and also has
4113b89
correctly implemented CSS3 selector support as well as XPath support.
4113b89
4113b89
Nokogiri also features an Hpricot compatibility layer to help ease the change
4113b89
to using correct CSS and XPath.
4113b89
Mamoru Tasaka e107dc4
%if 0
Mamoru Tasaka e107dc4
%package	jruby
Mamoru Tasaka e107dc4
Summary:	JRuby support for %{name}
Mamoru Tasaka e107dc4
Group:		Development/Languages
Mamoru Tasaka e107dc4
Requires:	%{name} = %{version}-%{release}
Mamoru Tasaka e107dc4
Mamoru Tasaka e107dc4
%description	jruby
Mamoru Tasaka e107dc4
This package contains JRuby support for %{name}.
Mamoru Tasaka e107dc4
%endif
Mamoru Tasaka e107dc4
Mamoru Tasaka e107dc4
4113b89
%package	doc
4113b89
Summary:	Documentation for %{name}
4113b89
Group:		Documentation
4113b89
Requires:	%{name} = %{version}-%{release}
4113b89
4113b89
%description	doc
4113b89
This package contains documentation for %{name}.
4113b89
4113b89
%package	-n ruby-%{gemname}
4113b89
Summary:	Non-Gem support package for %{gemname}
4113b89
Group:		Development/Languages
4113b89
Requires:	%{name} = %{version}-%{release}
4113b89
Provides:	ruby(%{gemname}) = %{version}-%{release}
4113b89
4113b89
%description	-n ruby-%{gemname}
4113b89
This package provides non-Gem support for %{gemname}.
4113b89
4113b89
%prep
4113b89
%setup -q -T -c
4113b89
4113b89
mkdir -p ./%{gemdir}
4113b89
export CONFIGURE_ARGS="--with-cflags='%{optflags}'"
4113b89
gem install \
4113b89
	--local \
4113b89
	--install-dir ./%{gemdir} \
4113b89
	-V --force \
4113b89
	%{SOURCE0}
4113b89
Mamoru Tasaka b9de8f1
# patches
Mamoru Tasaka b9de8f1
pushd .%{geminstdir}
Mamoru Tasaka b9de8f1
%patch0 -p1
Mamoru Tasaka b9de8f1
popd
Mamoru Tasaka b9de8f1
Mamoru Tasaka e107dc4
# Permission
Mamoru Tasaka e107dc4
chmod 0644 .%{gemdir}/cache/%{gemname}-%{mainver}%{?prever}.gem
Mamoru Tasaka e107dc4
Mamoru Tasaka e107dc4
# Remove precompiled Java .jar file
Mamoru Tasaka e107dc4
rm -f .%{geminstdir}/lib/*.jar
Mamoru Tasaka e107dc4
# For now remove JRuby support
Mamoru Tasaka e107dc4
rm -rf .%{geminstdir}/ext/java
14517e3
99681b5
%build
4113b89
# cflags wrong (-O3 passed), recompiling
4113b89
pushd ./%{geminstdir}
4113b89
sed -i.flags -e 's|-O3||' ext/nokogiri/extconf.rb
4113b89
find . -name \*.so -or -name \*.o -exec rm -f {} \;
99681b5
rake -v compile --trace
4113b89
4113b89
%install
4113b89
rm -rf %{buildroot}
4113b89
mkdir -p %{buildroot}%{gemdir}
4113b89
cp -a ./%{gemdir}/* %{buildroot}%{gemdir}
4113b89
117c0dc
# Remove backup file
117c0dc
find %{buildroot} -name \*.orig_\* | xargs rm -vf
117c0dc
4113b89
# move arch dependent files to %%ruby_sitearch
4113b89
mkdir -p %{buildroot}%{ruby_sitearch}/%{gemname}
4113b89
mv %{buildroot}%{geminstdir}/lib/%{gemname}/*.so \
4113b89
	%{buildroot}%{ruby_sitearch}/%{gemname}/
4113b89
9727014
# move bin/ files
9727014
mkdir -p %{buildroot}%{_prefix}
9727014
mv -f %{buildroot}%{gemdir}/bin %{buildroot}%{_prefix}
9727014
4113b89
# remove all shebang
4113b89
for f in $(find %{buildroot}%{geminstdir} -name \*.rb)
4113b89
do
4113b89
	sed -i -e '/^#!/d' $f
4113b89
	chmod 0644 $f
4113b89
done
4113b89
4113b89
# cleanups
Mamoru Tasaka e107dc4
rm -rf %{buildroot}%{geminstdir}/ext/%{gemname}/
Mamoru Tasaka e107dc4
rm -rf %{buildroot}%{geminstdir}/tmp/
9727014
rm -f %{buildroot}%{geminstdir}/{.autotest,.require_paths}
4113b89
4113b89
# The following method is completely copied from rubygem-gettext
4113b89
# spec file
4113b89
#
4113b89
# Create symlinks
4113b89
##
4113b89
## Note that before switching to gem %%{ruby_sitelib}/%%{gemname}
4113b89
## already existed as a directory, so this cannot be replaced
4113b89
## by symlink (cpio fails)
4113b89
## Similarly, all directories under %%{ruby_sitelib} cannot be
4113b89
## replaced by symlink
4113b89
#
4113b89
4113b89
create_symlink_rec(){
4113b89
4113b89
ORIGBASEDIR=$1
4113b89
TARGETBASEDIR=$2
4113b89
4113b89
## First calculate relative path of ORIGBASEDIR 
4113b89
## from TARGETBASEDIR
4113b89
TMPDIR=$TARGETBASEDIR
4113b89
BACKDIR=
4113b89
DOWNDIR=
4113b89
num=0
4113b89
nnum=0
4113b89
while true
4113b89
do
4113b89
	num=$((num+1))
4113b89
	TMPDIR=$(echo $TMPDIR | sed -e 's|/[^/][^/]*$||')
4113b89
	DOWNDIR=$(echo $ORIGBASEDIR | sed -e "s|^$TMPDIR||")
4113b89
	if [ x$DOWNDIR != x$ORIGBASEDIR ]
4113b89
	then
4113b89
		nnum=0
4113b89
		while [ $nnum -lt $num ]
4113b89
		do
4113b89
			BACKDIR="../$BACKDIR"
4113b89
			nnum=$((nnum+1))
4113b89
		done
4113b89
		break
4113b89
	fi
4113b89
done
4113b89
4113b89
RELBASEDIR=$( echo $BACKDIR/$DOWNDIR | sed -e 's|//*|/|g' )
4113b89
4113b89
## Next actually create symlink
4113b89
pushd %{buildroot}/$ORIGBASEDIR
4113b89
find . -type f | while read f
4113b89
do
4113b89
	DIRNAME=$(dirname $f)
4113b89
	BACK2DIR=$(echo $DIRNAME | sed -e 's|/[^/][^/]*|/..|g')
4113b89
	mkdir -p %{buildroot}${TARGETBASEDIR}/$DIRNAME
4113b89
	LNNAME=$(echo $BACK2DIR/$RELBASEDIR/$f | \
4113b89
		sed -e 's|^\./||' | sed -e 's|//|/|g' | \
4113b89
		sed -e 's|/\./|/|' )
4113b89
	ln -s -f $LNNAME %{buildroot}${TARGETBASEDIR}/$f
4113b89
done
4113b89
popd
4113b89
4113b89
}
4113b89
4113b89
create_symlink_rec %{geminstdir}/lib %{ruby_sitelib}
4113b89
4113b89
4113b89
%clean
4113b89
rm -rf %{buildroot}
4113b89
fbf0c0b
%check
bbb64b2
# test_exslt(TestXsltTransforms) [./test/test_xslt_transforms.rb:93]
bbb64b2
# fails without TZ on sparc
bbb64b2
export TZ="Asia/Tokyo"
bbb64b2
fbf0c0b
pushd ./%{geminstdir}
99681b5
rake test --trace
Mamoru Tasaka b9de8f1
# rake spec --trace
fbf0c0b
popd
fbf0c0b
4113b89
%files
4113b89
%defattr(-,root, root,-)
9727014
%{_bindir}/%{gemname}
4113b89
%{ruby_sitearch}/%{gemname}/
4113b89
%dir	%{geminstdir}/
4113b89
%doc	%{geminstdir}/[A-Z]*
9727014
%exclude %{geminstdir}/Rakefile
Mamoru Tasaka e107dc4
%{geminstdir}/bin/
Mamoru Tasaka e107dc4
%{geminstdir}/lib/
Mamoru Tasaka e107dc4
%{gemdir}/cache/%{gemname}-%{mainver}%{?prever}.gem
Mamoru Tasaka e107dc4
%{gemdir}/specifications/%{gemname}-%{mainver}%{?prever}.gemspec
Mamoru Tasaka e107dc4
Mamoru Tasaka e107dc4
%if 0
Mamoru Tasaka e107dc4
%files	jruby
Mamoru Tasaka e107dc4
%defattr(-,root,root,-)
Mamoru Tasaka e107dc4
%{geminstdir}/ext/java/
Mamoru Tasaka e107dc4
%endif
4113b89
4113b89
%files	doc
4113b89
%defattr(-,root,root,-)
9727014
%{geminstdir}/Rakefile
Mamoru Tasaka e107dc4
%{geminstdir}/deps.rip
Mamoru Tasaka b9de8f1
#%%{geminstdir}/spec/
fbf0c0b
%{geminstdir}/tasks/
4113b89
%{geminstdir}/test/
Mamoru Tasaka e107dc4
%{gemdir}/doc/%{gemname}-%{mainver}%{?prever}/
4113b89
4113b89
%files	-n ruby-%{gemname}
4113b89
%defattr(-,root,root,-)
4113b89
%{ruby_sitelib}/*%{gemname}.rb
4113b89
%{ruby_sitelib}/%{gemname}/
bca8565
%{ruby_sitelib}/xsd/
4113b89
4113b89
%changelog
Mamoru Tasaka b9de8f1
* Tue Dec  7 2010 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.5.0-0.2.beta3
Mamoru Tasaka b9de8f1
- 1.5.0.beta.3
Mamoru Tasaka b9de8f1
Mamoru Tasaka e107dc4
* Sun Oct 17 2010 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.5.0-0.1.beta2
Mamoru Tasaka e107dc4
- Try 1.5.0.beta.2
Mamoru Tasaka e107dc4
Mamoru Tasaka 01c36f3
* Fri Jul 30 2010 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.4.3.1-1
Mamoru Tasaka 01c36f3
- 1.4.3.1
Mamoru Tasaka 01c36f3
117c0dc
* Wed May 26 2010 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.4.2-1
117c0dc
- 1.4.2
117c0dc
14517e3
* Thu Apr 29 2010 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.4.1-2
14517e3
- Fix build failure with libxml2 >= 2.7.7
14517e3
6fecb2a
* Tue Dec 15 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.4.1-1
6fecb2a
- 1.4.1
6fecb2a
9e44a20
* Mon Nov  9 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.4.0-1
9e44a20
- 1.4.0
9e44a20
bbb64b2
* Sat Aug 22 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.3.3-2
bbb64b2
- Fix test failure on sparc
bbb64b2
e52e796
* Wed Jul 29 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.3.3-1
e52e796
- 1.3.3
e52e796
0149d8e
* Sat Jul 25 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.3.2-3
0149d8e
- F-12: Mass rebuild
0149d8e
99681b5
* Thu Jul  2 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.3.2-2
99681b5
- Enable test
99681b5
- Recompile with -O2
99681b5
6be617d
* Thu Jun 25 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.3.2-1
6be617d
- 1.3.2
6be617d
9727014
* Thu Jun 11 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.3.1-1
9727014
- 1.3.1
9727014
9612d78
* Thu Mar 26 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.2.3-1
9612d78
- 1.2.3
9612d78
bca8565
* Thu Mar 19 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.2.2-1
bca8565
- 1.2.2
bca8565
fbf0c0b
* Thu Mar 12 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.2.1-1
fbf0c0b
- 1.2.1
fbf0c0b
4176972
* Tue Feb 24 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.1.1-2
4176972
- F-11: Mass rebuild
4176972
4113b89
* Thu Jan 15 2009 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.1.1-1
4113b89
- 1.1.1
4113b89
4113b89
* Thu Dec 25 2008 Mamoru Tasaka <mtasaka@ioa.s.u-tokyo.ac.jp> - 1.1.0-1
4113b89
- Initial packaging
4113b89