4113b89
%define	ruby_sitelib		%(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
4113b89
%define	ruby_sitearch		%(ruby -rrbconfig -e "puts Config::CONFIG['sitearchdir']")
4113b89
%define	rubyabi		1.8
4113b89
4113b89
%define	gemdir			%(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
4113b89
%define	gemname		nokogiri
4113b89
%define	geminstdir		%{gemdir}/gems/%{gemname}-%{version}
4113b89
e52e796
# Note for packager:
e52e796
# Check if we can update nokogiri to 1.4.0 on < F-12:
e52e796
# It seems that some functions will be removed on 1.4.0
e52e796
4113b89
Summary:	An HTML, XML, SAX, and Reader parser
4113b89
Name:		rubygem-%{gemname}
9e44a20
Version:	1.4.0
9e44a20
Release:	1%{?dist}
4113b89
Group:		Development/Languages
4113b89
License:	MIT
4113b89
URL:		http://nokogiri.rubyforge.org/nokogiri/
4113b89
Source0:	http://gems.rubyforge.org/gems/%{gemname}-%{version}.gem
4113b89
4113b89
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
4113b89
BuildRequires:	ruby(abi) = %{rubyabi}
4113b89
BuildRequires:	ruby(rubygems)
bca8565
BuildRequires:	rubygem(hoe)
9727014
# Not available yet
99681b5
# BuildRequires:	rubygem(hoe-debugging)
99681b5
BuildRequires:	rubygem(rake)
99681b5
BuildRequires:	rubygem(rake-compiler)
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
4113b89
%package	doc
4113b89
Summary:	Documentation for %{name}
4113b89
Group:		Documentation
4113b89
# Directory ownership issue
4113b89
Requires:	%{name} = %{version}-%{release}
4113b89
Requires:	ruby(rubygems)
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
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
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
99681b5
rm -rf %{buildroot}%{geminstdir}/{ext,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
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
4113b89
%{geminstdir}/[a-l]*/
4113b89
%{gemdir}/cache/%{gemname}-%{version}.gem
4113b89
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
4113b89
4113b89
%files	doc
4113b89
%defattr(-,root,root,-)
9727014
%{geminstdir}/Rakefile
fbf0c0b
%{geminstdir}/tasks/
4113b89
%{geminstdir}/test/
4113b89
%{gemdir}/doc/%{gemname}-%{version}/
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
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