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
4113b89
Summary:	An HTML, XML, SAX, and Reader parser
4113b89
Name:		rubygem-%{gemname}
4113b89
Version:	1.1.1
4176972
Release:	2%{?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)
4113b89
BuildRequires:	rubygem(rake)
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
%build
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
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 {} \;
4113b89
rake -v ext/nokogiri/native.so
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
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
4113b89
rm -rf %{buildroot}%{geminstdir}/ext
4113b89
rm -f %{buildroot}%{geminstdir}/{.require_paths,Rakefile}
4113b89
4113b89
# only needed by Rakefile, removing
4113b89
## First remove only files, then check if the directory
4113b89
## is empty
4113b89
rm -f %{buildroot}/%{geminstdir}/vendor/hoe.rb
4113b89
rmdir %{buildroot}/%{geminstdir}/vendor/
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
4113b89
%files
4113b89
%defattr(-,root, root,-)
4113b89
%{ruby_sitearch}/%{gemname}/
4113b89
%dir	%{geminstdir}/
4113b89
%doc	%{geminstdir}/[A-Z]*
4113b89
%{geminstdir}/[a-l]*/
4113b89
%{gemdir}/cache/%{gemname}-%{version}.gem
4113b89
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
4113b89
4113b89
%files	doc
4113b89
%defattr(-,root,root,-)
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}/
4113b89
4113b89
%changelog
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