summaryrefslogtreecommitdiffstats
path: root/meta-openstack
diff options
context:
space:
mode:
authorAmy Fong <amy.fong@windriver.com>2014-05-20 15:16:29 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2014-05-24 00:27:56 -0400
commit8c3f37aa1ae64a4971dac3573fe3fbcc81c1cf15 (patch)
tree81e188d6cc88d9dfc186415cfd24e2802fa2e212 /meta-openstack
parent4f07e79bed4c13746d4557950f2d5a0c110095b7 (diff)
downloadmeta-cloud-services-8c3f37aa1ae64a4971dac3573fe3fbcc81c1cf15.tar.gz
Ruby/chef solo: Add classes/ruby.bbclass
In order to build chef we create a new ruby.bbclass to handle packaging ruby gems. The gem install technique we make use of avoids dependency issues which are not easily worked around yet care must be taken to ensure runtime dependencies are properly listed. Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com> Signed-off-by: Amy Fong <amy.fong@windriver.com>
Diffstat (limited to 'meta-openstack')
-rw-r--r--meta-openstack/classes/ruby.bbclass119
1 files changed, 119 insertions, 0 deletions
diff --git a/meta-openstack/classes/ruby.bbclass b/meta-openstack/classes/ruby.bbclass
new file mode 100644
index 0000000..6161698
--- /dev/null
+++ b/meta-openstack/classes/ruby.bbclass
@@ -0,0 +1,119 @@
1#
2# Copyright (C) 2014 Wind River Systems, Inc.
3#
4DEPENDS += " \
5 ruby-native \
6"
7RDEPENDS += " \
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 from subprocess import check_output
17 found_version = "SOMETHING FAILED!"
18
19 cmd = "%s/ruby" % p
20
21 if not isfile(cmd):
22 return found_version
23
24 version = check_output([cmd, "--version"])
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 from subprocess import check_output
37 found_loc = "SOMETHING FAILED!"
38
39 cmd = "%s/gem" % p
40
41 if not isfile(cmd):
42 return found_loc
43
44 loc = check_output([cmd, "env"]).split('\n')
45
46 r = re.compile(".*\- (/usr.*/ruby/gems/.*)")
47 for line in loc:
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 from subprocess import check_output
59 found_version = "SOMETHING FAILED!"
60
61 cmd = "%s/gem" % p
62
63 if not isfile(cmd):
64 return found_version
65
66 version = check_output([cmd, "env", "gemdir"])
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="C.UTF-8" LC_ALL="C.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
99EXPORT_FUNCTIONS do_compile do_install
100
101PACKAGES = "${PN}-dbg ${PN} ${PN}-doc ${PN}-dev"
102
103FILES_${PN}-dbg += " \
104 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/.debug \
105 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/.debug \
106 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/*/.debug \
107 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/*/*/.debug \
108 "
109
110FILES_${PN} += " \
111 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems \
112 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/cache \
113 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin \
114 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/specifications \
115 "
116
117FILES_${PN}-doc += " \
118 ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/doc \
119 "