summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorMark Asselstine <mark.asselstine@windriver.com>2015-09-15 09:47:48 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2015-09-16 16:07:28 -0400
commit8c9558234d451daa242df9b22cbd854a7cefa177 (patch)
treeaad61e1024e52e8cbd6fbe5c95a683a66232824f /classes
parent0c46635d8449d8b4131f0dc75cd0955230fc7009 (diff)
downloadmeta-cloud-services-8c9558234d451daa242df9b22cbd854a7cefa177.tar.gz
ruby.bbclass: move to base layer
In commit 1aa30310259027ebb87ee95ef914ca3de55d6a09 [puppet: move to base layer] we made puppet available to all sub-layers but since we didn't move the required ruby.bbclass we couldn't actually use it without using meta-openstack. Complete the move by moving the ruby.bbclass to the base layer. At some point I think we still want to remove ruby.bbclass from meta-cloud-services completely and use meta-ruby, but we will do that at another time. Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'classes')
-rw-r--r--classes/ruby.bbclass131
1 files changed, 131 insertions, 0 deletions
diff --git a/classes/ruby.bbclass b/classes/ruby.bbclass
new file mode 100644
index 0000000..0c842d5
--- /dev/null
+++ b/classes/ruby.bbclass
@@ -0,0 +1,131 @@
1#
2# Copyright (C) 2014 Wind River Systems, Inc.
3#
4DEPENDS += " \
5 ruby-native \
6"
7RDEPENDS_${PN} += " \
8 ruby \
9"
10
11#${PN}_do_compile[depends] += "ruby-native:do_populate_sysroot"
12
13def get_rubyversion(p):
14 import re
15 from os.path import isfile
16 import subprocess
17 found_version = "SOMETHING FAILED!"
18
19 cmd = "%s/ruby" % p
20
21 if not isfile(cmd):
22 return found_version
23
24 version = subprocess.Popen([cmd, "--version"], stdout=subprocess.PIPE).communicate()[0]
25
26 r = re.compile("ruby ([0-9]+\.[0-9]+\.[0-9]+)*")
27 m = r.match(version)
28 if m:
29 found_version = m.group(1)
30
31 return found_version
32
33def get_rubygemslocation(p):
34 import re
35 from os.path import isfile
36 import subprocess
37 found_loc = "SOMETHING FAILED!"
38
39 cmd = "%s/gem" % p
40
41 if not isfile(cmd):
42 return found_loc
43
44 loc = subprocess.Popen([cmd, "env"], stdout=subprocess.PIPE).communicate()[0]
45
46 r = re.compile(".*\- (/usr.*/ruby/gems/.*)")
47 for line in loc.split('\n'):
48 m = r.match(line)
49 if m:
50 found_loc = m.group(1)
51 break
52
53 return found_loc
54
55def get_rubygemsversion(p):
56 import re
57 from os.path import isfile
58 import subprocess
59 found_version = "SOMETHING FAILED!"
60
61 cmd = "%s/gem" % p
62
63 if not isfile(cmd):
64 return found_version
65
66 version = subprocess.Popen([cmd, "env", "gemdir"], stdout=subprocess.PIPE).communicate()[0]
67
68 r = re.compile(".*([0-9]+\.[0-9]+\.[0-9]+)$")
69 m = r.match(version)
70 if m:
71 found_version = m.group(1)
72
73 return found_version
74
75RUBY_VERSION ?= "${@get_rubyversion("${STAGING_BINDIR_NATIVE}")}"
76RUBY_GEM_DIRECTORY ?= "${@get_rubygemslocation("${STAGING_BINDIR_NATIVE}")}"
77RUBY_GEM_VERSION ?= "${@get_rubygemsversion("${STAGING_BINDIR_NATIVE}")}"
78
79export GEM_HOME = "${STAGING_DIR_NATIVE}/usr/lib/ruby/gems/${RUBY_GEM_VERSION}"
80
81RUBY_BUILD_GEMS ?= "${BPN}.gemspec"
82RUBY_INSTALL_GEMS ?= "${BPN}-${BPV}.gem"
83
84RUBY_COMPILE_FLAGS ?= 'LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8"'
85
86ruby_do_compile() {
87 for gem in ${RUBY_BUILD_GEMS}; do
88 ${RUBY_COMPILE_FLAGS} gem build $gem
89 done
90}
91
92
93ruby_do_install() {
94 for gem in ${RUBY_INSTALL_GEMS}; do
95 gem install --ignore-dependencies --local --env-shebang --install-dir ${D}/${libdir}/ruby/gems/${RUBY_GEM_VERSION}/ $gem
96 done
97
98 # create symlink from the gems bin directory to /usr/bin
99 for i in ${D}/${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin/*; do
100 if [ -e "$i" ]; then
101 if [ ! -d ${D}/${bindir} ]; then mkdir -p ${D}/${bindir}; fi
102 b=`basename $i`
103 ln -sf ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin/$b ${D}/${bindir}/$b
104 fi
105 done
106}
107
108EXPORT_FUNCTIONS do_compile do_install
109
110PACKAGES = "${PN}-dbg ${PN} ${PN}-doc ${PN}-dev"
111
112FILES_${PN}-dbg += " \
113 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/.debug \
114 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/.debug \
115 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/*/.debug \
116 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/*/*/.debug \
117 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/extensions/*/*/*/*/*/.debug \
118 "
119
120FILES_${PN} += " \
121 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems \
122 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/cache \
123 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin \
124 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/specifications \
125 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/build_info \
126 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/extensions \
127 "
128
129FILES_${PN}-doc += " \
130 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/doc \
131 "