Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 203706 | Differences between
and this patch

Collapse All | Expand All

(-)/usr/portage/eclass/gems.eclass (-23 / +51 lines)
Lines 10-19 Link Here
10
# the Gentoo Linux system.
10
# the Gentoo Linux system.
11
#
11
#
12
# - Features:
12
# - Features:
13
# gems_location()	  - Set ${GEMSDIR} with gem install dir and ${GEM_SRC} with path to gem to install
13
# gems_location()	  - Set ${GEMSDIR} with gem install dir and ${GEM_SRC} with
14
# 						path to gem to install. Optionally takes a ruby version string, like 
15
#						"ruby18" as a parameter.
14
# gems_src_unpack()	  - Does nothing.
16
# gems_src_unpack()	  - Does nothing.
15
# gems_src_compile()  - Does nothing.
17
# gems_src_compile()  - Does nothing.
16
# gems_src_install()  - installs a gem into ${D}
18
# gems_src_install()  - installs a gem into ${D} using each ruby version that is both 
19
# 						installed and specified in USE_RUBY.
17
#
20
#
18
# NOTE:
21
# NOTE:
19
# See http://dev.gentoo.org/~pythonhead/ruby/gems.html for notes on using gems with portage
22
# See http://dev.gentoo.org/~pythonhead/ruby/gems.html for notes on using gems with portage
Lines 33-41 Link Here
33
36
34
gems_location() {
37
gems_location() {
35
	local sitelibdir
38
	local sitelibdir
36
	sitelibdir=$(ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]')
39
	local ruby_version
40
	if [[ -z "$1" ]]; then
41
		ruby_version="ruby"
42
	else
43
		ruby_version=$1
44
	fi
45
	sitelibdir=$(/usr/bin/${ruby_version} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]')
37
	export GEMSDIR=${sitelibdir/site_ruby/gems}
46
	export GEMSDIR=${sitelibdir/site_ruby/gems}
38
39
}
47
}
40
48
41
gems_src_unpack() {
49
gems_src_unpack() {
Lines 47-62 Link Here
47
}
55
}
48
56
49
gems_src_install() {
57
gems_src_install() {
50
	gems_location
51
52
	if [[ -z "${MY_P}" ]]; then
53
		[[ -z "${GEM_SRC}" ]] && GEM_SRC="${DISTDIR}/${P}"
54
		spec_path="${D}/${GEMSDIR}/specifications/${P}.gemspec"
55
	else
56
		[[ -z "${GEM_SRC}" ]] && GEM_SRC="${DISTDIR}/${MY_P}"
57
		spec_path="${D}/${GEMSDIR}/specifications/${MY_P}.gemspec"
58
	fi
59
60
	local myconf
58
	local myconf
61
	if use doc; then
59
	if use doc; then
62
		myconf="--rdoc --ri"
60
		myconf="--rdoc --ri"
Lines 64-79 Link Here
64
		myconf="--no-rdoc --no-ri"
62
		myconf="--no-rdoc --no-ri"
65
	fi
63
	fi
66
64
67
	dodir ${GEMSDIR}
65
	# I'm not sure how many ebuilds have correctly set USE_RUBY - let's assume
68
	gem install ${GEM_SRC} --version ${PV} ${myconf} \
66
	# ruby18 if they haven't, since even pure Ruby gems that have been written
69
		--local --install-dir "${D}/${GEMSDIR}" || die "gem install failed"
67
	# against 1.8 can explode under 1.9.
70
68
	if [[ -z "${USE_RUBY}" ]]; then
71
	if [[ -d "${D}/${GEMSDIR}/bin" ]] ; then
69
		USE_RUBY="ruby18"
72
		exeinto /usr/bin
70
	elif [[ "${USE_RUBY}" == "any" ]]; then
73
		for exe in ${D}/${GEMSDIR}/bin/* ; do
71
		# Get the installed versions.
74
			doexe ${exe}
72
		USE_RUBY=`ls /usr/bin/ruby* | grep -E 'ruby1(8|9)' | sed -e 's@/usr/bin/@@g'`
75
		done
76
	fi
73
	fi
74
75
	local num_ruby_slots=$(echo "${USE_RUBY}" | wc -w)
76
77
	for ruby_version in ${USE_RUBY} ; do
78
		einfo "Installing for ${ruby_version}..."
79
		gems_location ${ruby_version}
80
		dodir ${GEMSDIR}
81
82
		if [[ -z "${MY_P}" ]]; then
83
			[[ -z "${GEM_SRC}" ]] && GEM_SRC="${DISTDIR}/${P}"
84
			spec_path="${D}/${GEMSDIR}/specifications/${P}.gemspec"
85
		else
86
			[[ -z "${GEM_SRC}" ]] && GEM_SRC="${DISTDIR}/${MY_P}"
87
			spec_path="${D}/${GEMSDIR}/specifications/${MY_P}.gemspec"
88
		fi
89
90
		/usr/bin/${ruby_version} /usr/bin/gem install ${GEM_SRC} --version ${PV} ${myconf} \
91
			--local --install-dir "${D}/${GEMSDIR}" || die "gem install failed"
92
93
		if [[ -d "${D}/${GEMSDIR}/bin" ]] ; then
94
			exeinto /usr/bin
95
			for exe in ${D}/${GEMSDIR}/bin/* ; do
96
				if [ "$num_ruby_slots" -ge 2 ] ; then
97
					# Ensures that the exe file gets run using the currently
98
					# selected version of ruby.
99
					sed -i -e 's@^#!/usr/bin/ruby.*$@#!/usr/bin/ruby@' "${exe}"
100
				fi
101
				doexe ${exe}
102
			done
103
		fi
104
	done
77
}
105
}
78
106
79
EXPORT_FUNCTIONS src_unpack src_compile src_install
107
EXPORT_FUNCTIONS src_unpack src_compile src_install

Return to bug 203706