1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#!/bin/bash
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-ruby/ruby-config/files/ruby-config.sh,v 1.3 2004/07/14 22:04:35 agriffis Exp $
# Author: Mamoru KOMACHI <usata@gentoo.org>
if [ -z "${PORTDIR}" ] ; then
[ -r /etc/make.conf ] && source /etc/make.conf
if [ -z "${PORTDIR}" ] ; then
[ -r /etc/make.globals ] && source /etc/make.globals
fi
fi
if [ -r /etc/init.d/functions.sh ] ; then
source /etc/init.d/functions.sh
else
echo "Could not find /etc/init.d/functions.sh"
exit 1
fi
#dummy function
EXPORT_FUNCTIONS() { :; }
if [ -r ${PORTDIR:-/usr/portage}/eclass/alternatives.eclass ] ; then
source ${PORTDIR:-/usr/portage}/eclass/alternatives.eclass
else
echo "Could not find ${PORTDIR:-/usr/portage}/bin/ebuild.sh"
exit 1
fi
usage() {
cat << "USAGE_END"
Usage: ruby-config [Option] [Ruby Profile]
Change the current ruby profile, or give info about profiles.
Options:
-c, --get-current-profile
Print current used ruby profile.
-l, --list-profiles
List available ruby profiles.
-h, --show-help
Print this help.
The profile name is either ruby16, ruby18 or ruby19.
USAGE_END
exit 1
}
if [ "$#" -lt 1 ] ; then
usage
fi
switch_profile() {
if [ "$EUID" != 0 ] ; then
eerror "You need root privilege to switch profile."
exit 1
fi
if [ "`expr $1 : ruby`" != 0 -a "$1" != "ruby" ] ; then
local suf=${1/ruby/}
# don't make symlink to ri
for i in ruby irb erb testrb rdoc ; do
alternatives_makesym \
/usr/bin/$i /usr/bin/${i}{$suf,18,16,19}
done
alternatives_makesym \
/usr/lib/libruby.so /usr/lib/libruby{$suf,18,16,19}.so
alternatives_makesym \
/usr/share/man/man1/ruby.1.gz \
/usr/share/man/man1/ruby{$suf,18,16,19}.1.gz
else
eerror "Unsupported profile."
fi
}
get_current_profile() {
if [ ! -L /usr/bin/ruby ] ; then
eerror "Your ruby doesn't seem to support SLOT."
exit 1
fi
einfo "Your current profile refers to $(readlink /usr/bin/ruby)."
}
list_profiles() {
einfo "Supported profiles are:"
for f in /usr/bin/ruby[0-9][0-9] ; do
einfo "\t${f#/usr/bin/}"
done
einfo "You can specify one of the profiles listed above."
einfo "e.g.) ruby-config ruby16"
}
for x in $* ; do
if [ "$#" -gt 1 ] ; then
eerror "ruby-config accepts only one argument."
eerror "Run $0 -h for help."
exit 1
fi
case "${x}" in
-c|--get-current-profile)
get_current_profile
;;
-h|--show-help)
usage
;;
-l|--list-profiles)
list_profiles
;;
-*)
eerror "Invalid option. Run $0 -h for help."
exit 1
;;
*)
switch_profile $*
;;
esac
exit 0
done
|