Mamoru Tasaka 4729b3
%global	ruby_sitelib	%(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
Mamoru Tasaka 4729b3
%global	ruby_sitearch	%(ruby -rrbconfig -e "puts Config::CONFIG['sitearchdir']")
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%global	gemdir		%(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
Mamoru Tasaka 4729b3
%global	gemname	gio2
Mamoru Tasaka 4729b3
%global	geminstdir	%{gemdir}/gems/%{gemname}-%{version}
Mamoru Tasaka 4729b3
Mamoru Tasaka 68ed8e
%global	glibminver	0.90.5
Mamoru Tasaka 68ed8e
%global	obsoleteevr	0.90.5-1.999
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%global	rubyabi	1.8
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
Summary:	Ruby binding of gio-2.0.x
Mamoru Tasaka 4729b3
Name:		rubygem-%{gemname}
Mamoru Tasaka 68ed8e
Version:	0.90.5
Mamoru Tasaka 68ed8e
Release:	3%{?dist}
Mamoru Tasaka 4729b3
Group:		Development/Languages
Mamoru Tasaka 4729b3
# from README
Mamoru Tasaka 4729b3
License:	LGPLv2
Mamoru Tasaka 4729b3
URL:		http://ruby-gnome2.sourceforge.jp/
Mamoru Tasaka 4729b3
Source0:	http://rubygems.org/gems/%{gemname}-%{version}.gem
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
BuildRequires:	ruby(abi) = %{rubyabi}
Mamoru Tasaka 4729b3
BuildRequires:	rubygems
Mamoru Tasaka 4729b3
BuildRequires:	rubygem-glib2-devel >= %{glibminver}
Mamoru Tasaka 4729b3
BuildRequires:	ruby-devel
Mamoru Tasaka 4729b3
Requires:	ruby(abi) = %{rubyabi}
Mamoru Tasaka 4729b3
Requires:	rubygems
Mamoru Tasaka 4729b3
Requires:	rubygem(glib2) >= %{glibminver}
Mamoru Tasaka 4729b3
Provides:	rubygem(%{gemname}) = %{version}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%description
Mamoru Tasaka 4729b3
Ruby/GIO2 is a Ruby binding of gio-2.0.x.
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%package	doc
Mamoru Tasaka 4729b3
Summary:	Documentation for %{name}
Mamoru Tasaka 4729b3
Group:		Documentation
Mamoru Tasaka 4729b3
Requires:	%{name} = %{version}-%{release}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%description	doc
Mamoru Tasaka 4729b3
This package contains documentation for %{name}.
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%package	-n ruby-%{gemname}
Mamoru Tasaka 4729b3
Summary:	Non-Gem support package for %{gemname}
Mamoru Tasaka 4729b3
Group:		Development/Languages
Mamoru Tasaka 4729b3
Requires:	%{name} = %{version}-%{release}
Mamoru Tasaka 4729b3
# Requires for corresponsing non-gem rpms
Mamoru Tasaka 4729b3
Requires:	ruby(glib2) >= %{glibminver}
Mamoru Tasaka 4729b3
Provides:	ruby(%{gemname}) = %{version}-%{release}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%description	-n ruby-%{gemname}
Mamoru Tasaka 4729b3
This package provides non-Gem support for %{gemname}.
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%package	devel
Mamoru Tasaka 4729b3
Summary:	Ruby/GIO2 development environment
Mamoru Tasaka 4729b3
Group:		Development/Languages
Mamoru Tasaka 4729b3
Requires:	%{name} = %{version}-%{release}
Mamoru Tasaka 4729b3
Requires:	ruby-devel
Mamoru Tasaka 4729b3
# Obsoletes / Provides
Mamoru Tasaka 4729b3
Obsoletes:	ruby-%{gemname}-devel < %{obsoleteevr}
Mamoru Tasaka 4729b3
Provides:	ruby-%{gemname}-devel = %{version}-%{release}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%description devel
Mamoru Tasaka 4729b3
Header files and libraries for building a extension library for the
Mamoru Tasaka 4729b3
rubygem-%{gemname}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%prep
Mamoru Tasaka 4729b3
%setup -q -c -T
Mamoru Tasaka 4729b3
mkdir -p .%{gemdir}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
export CONFIGURE_ARGS="--with-cflags='%{optflags}'"
Mamoru Tasaka 68ed8e
export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-pkg-config-dir=$(pwd)%{_libdir}/pkgconfig"
Mamoru Tasaka 4729b3
gem install \
Mamoru Tasaka 4729b3
	-V \
Mamoru Tasaka 4729b3
	--local \
Mamoru Tasaka 4729b3
	--install-dir .%{gemdir} \
Mamoru Tasaka 4729b3
	--force \
Mamoru Tasaka 4729b3
	--rdoc \
Mamoru Tasaka 4729b3
	%{SOURCE0}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
find . -name \*.gem | xargs chmod 0644
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%build
Mamoru Tasaka 68ed8e
# Move C extension library to some private directory
Mamoru Tasaka 68ed8e
pushd .%{geminstdir}
Mamoru Tasaka 68ed8e
mkdir lib/ruby-gnome2
Mamoru Tasaka 68ed8e
mv lib/%{gemname}.so lib/ruby-gnome2/
Mamoru Tasaka 68ed8e
grep -rl '%{gemname}.so' . | \
Mamoru Tasaka 68ed8e
	xargs sed -i \
Mamoru Tasaka 68ed8e
		-e "\@require@s|'%{gemname}.so'|'ruby-gnome2/%{gemname}.so'|" \
Mamoru Tasaka 68ed8e
		-e '\@require@s|"%{gemname}.so"|"ruby-gnome2/%{gemname}.so"|'
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%install
Mamoru Tasaka 4729b3
rm -rf %{buildroot}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
# Once copy all
Mamoru Tasaka 4729b3
mkdir -p %{buildroot}%{gemdir}
Mamoru Tasaka 4729b3
cp -a .%{gemdir}/* \
Mamoru Tasaka 4729b3
	%{buildroot}%{gemdir}/
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
pushd %{buildroot}
Mamoru Tasaka 4729b3
# move header files, C extension files to the correct directory
Mamoru Tasaka 68ed8e
mkdir -p .%{ruby_sitearch}/ruby-gnome2/
Mamoru Tasaka 4729b3
# mv .%{geminstdir}/lib/*.h .%{ruby_sitearch}/
Mamoru Tasaka 68ed8e
mv .%{geminstdir}/lib/ruby-gnome2/%{gemname}.so .%{ruby_sitearch}/ruby-gnome2/
Mamoru Tasaka 4729b3
popd
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
# move pkgconfig file
Mamoru Tasaka 4729b3
mkdir %{buildroot}%{_libdir}/pkgconfig
Mamoru Tasaka 4729b3
install -cpm 644 ./%{_libdir}/pkgconfig/*.pc \
Mamoru Tasaka 4729b3
	%{buildroot}%{_libdir}/pkgconfig/
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
# Cleanups
Mamoru Tasaka 4729b3
pushd %{buildroot}
Mamoru Tasaka 4729b3
rm -rf .%{geminstdir}/ext/
Mamoru Tasaka 4729b3
rm -f .%{geminstdir}/extconf.rb
Mamoru Tasaka 4729b3
popd
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
# The following method is completely copied from rubygem-gettext
Mamoru Tasaka 4729b3
# spec file
Mamoru Tasaka 4729b3
#
Mamoru Tasaka 4729b3
# Create symlinks
Mamoru Tasaka 4729b3
##
Mamoru Tasaka 4729b3
## Note that before switching to gem %%{ruby_sitelib}/%%{gemname}
Mamoru Tasaka 4729b3
## already existed as a directory, so this cannot be replaced
Mamoru Tasaka 4729b3
## by symlink (cpio fails)
Mamoru Tasaka 4729b3
## Similarly, all directories under %%{ruby_sitelib} cannot be
Mamoru Tasaka 4729b3
## replaced by symlink
Mamoru Tasaka 4729b3
#
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
create_symlink_rec(){
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
ORIGBASEDIR=$1
Mamoru Tasaka 4729b3
TARGETBASEDIR=$2
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
## First calculate relative path of ORIGBASEDIR 
Mamoru Tasaka 4729b3
## from TARGETBASEDIR
Mamoru Tasaka 4729b3
TMPDIR=$TARGETBASEDIR
Mamoru Tasaka 4729b3
BACKDIR=
Mamoru Tasaka 4729b3
DOWNDIR=
Mamoru Tasaka 4729b3
num=0
Mamoru Tasaka 4729b3
nnum=0
Mamoru Tasaka 4729b3
while true
Mamoru Tasaka 4729b3
do
Mamoru Tasaka 4729b3
	num=$((num+1))
Mamoru Tasaka 4729b3
	TMPDIR=$(echo $TMPDIR | sed -e 's|/[^/][^/]*$||')
Mamoru Tasaka 4729b3
	DOWNDIR=$(echo $ORIGBASEDIR | sed -e "s|^$TMPDIR||")
Mamoru Tasaka 4729b3
	if [ x$DOWNDIR != x$ORIGBASEDIR ]
Mamoru Tasaka 4729b3
	then
Mamoru Tasaka 4729b3
		nnum=0
Mamoru Tasaka 4729b3
		while [ $nnum -lt $num ]
Mamoru Tasaka 4729b3
		do
Mamoru Tasaka 4729b3
			BACKDIR="../$BACKDIR"
Mamoru Tasaka 4729b3
			nnum=$((nnum+1))
Mamoru Tasaka 4729b3
		done
Mamoru Tasaka 4729b3
		break
Mamoru Tasaka 4729b3
	fi
Mamoru Tasaka 4729b3
done
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
RELBASEDIR=$( echo $BACKDIR/$DOWNDIR | sed -e 's|//*|/|g' )
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
## Next actually create symlink
Mamoru Tasaka 4729b3
pushd %{buildroot}/$ORIGBASEDIR
Mamoru Tasaka 4729b3
find . -type f | while read f
Mamoru Tasaka 4729b3
do
Mamoru Tasaka 4729b3
	DIRNAME=$(dirname $f)
Mamoru Tasaka 4729b3
	BACK2DIR=$(echo $DIRNAME | sed -e 's|/[^/][^/]*|/..|g')
Mamoru Tasaka 4729b3
	mkdir -p %{buildroot}${TARGETBASEDIR}/$DIRNAME
Mamoru Tasaka 4729b3
	LNNAME=$(echo $BACK2DIR/$RELBASEDIR/$f | \
Mamoru Tasaka 4729b3
		sed -e 's|^\./||' | sed -e 's|//|/|g' | \
Mamoru Tasaka 4729b3
		sed -e 's|/\./|/|' )
Mamoru Tasaka 4729b3
	ln -s -f $LNNAME %{buildroot}${TARGETBASEDIR}/$f
Mamoru Tasaka 4729b3
done
Mamoru Tasaka 4729b3
popd
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
create_symlink_rec %{geminstdir}/lib %{ruby_sitelib}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%check
Mamoru Tasaka 4729b3
# Currently no testsuite is available
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%clean
Mamoru Tasaka 4729b3
rm -rf %{buildroot}
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%files
Mamoru Tasaka 4729b3
%defattr(-,root,root,-)
Mamoru Tasaka 4729b3
%dir	%{geminstdir}
Mamoru Tasaka 4729b3
%dir	%{geminstdir}/lib/
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%doc	%{geminstdir}/[A-Z]*
Mamoru Tasaka 4729b3
%exclude	%{geminstdir}/Rakefile
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%{geminstdir}/lib/%{gemname}.rb
Mamoru Tasaka 68ed8e
# %%ruby_sitearch/ruby-gnome2 is owned by rubygem-glib2
Mamoru Tasaka 68ed8e
%{ruby_sitearch}/ruby-gnome2/%{gemname}.so
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%{gemdir}/cache/%{gemname}-%{version}.gem
Mamoru Tasaka 4729b3
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%files	-n ruby-%{gemname}
Mamoru Tasaka 4729b3
%defattr(-,root,root,-)
Mamoru Tasaka 4729b3
%{ruby_sitelib}/*.rb
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%files	devel
Mamoru Tasaka 4729b3
%defattr(-,root,root,-)
Mamoru Tasaka 4729b3
%{_libdir}/pkgconfig/ruby-%{gemname}.pc
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%files	doc
Mamoru Tasaka 4729b3
%defattr(-,root,root,-)
Mamoru Tasaka 4729b3
%{gemdir}/doc/%{gemname}-%{version}
Mamoru Tasaka 4729b3
%{geminstdir}/Rakefile
Mamoru Tasaka 4729b3
Mamoru Tasaka 4729b3
%changelog
Mamoru Tasaka 68ed8e
* Sun Oct 31 2010 Mamoru Taska  <mtasaka@ioa.s.u-tokyo.ac.jp> - 0.90.5-3
Mamoru Tasaka 68ed8e
- 0.90.5
Mamoru Tasaka 68ed8e
- Move C extension so that "require %%gemname" works correctly
Mamoru Tasaka 68ed8e
Mamoru Tasaka 4729b3
* Sun Oct 24 2010 Mamoru Taska <mtasaka@ioa.s.u-tokyo.ac.jp> - 0.90.4-2
Mamoru Tasaka 4729b3
- Initial package