diff options
author | Amy Fong <amy.fong@windriver.com> | 2014-05-20 15:16:29 -0400 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-05-24 00:27:13 -0400 |
commit | c56b588e08e946e5d012651bc0b23d398ec4a925 (patch) | |
tree | f6e3101963ba036608de6d3b1ade8de0743aeb8e /meta-openstack/classes | |
parent | 6920d5fffce091065632ca70c3b936d1b2760322 (diff) | |
download | meta-cloud-services-c56b588e08e946e5d012651bc0b23d398ec4a925.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/classes')
-rw-r--r-- | meta-openstack/classes/ruby.bbclass | 119 |
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 | # | ||
4 | DEPENDS += " \ | ||
5 | ruby-native \ | ||
6 | " | ||
7 | RDEPENDS += " \ | ||
8 | ruby \ | ||
9 | " | ||
10 | |||
11 | #${PN}_do_compile[depends] += "ruby-native:do_populate_sysroot" | ||
12 | |||
13 | def 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 | |||
33 | def 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 | |||
55 | def 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 | |||
75 | RUBY_VERSION ?= "${@get_rubyversion("${STAGING_BINDIR_NATIVE}")}" | ||
76 | RUBY_GEM_DIRECTORY ?= "${@get_rubygemslocation("${STAGING_BINDIR_NATIVE}")}" | ||
77 | RUBY_GEM_VERSION ?= "${@get_rubygemsversion("${STAGING_BINDIR_NATIVE}")}" | ||
78 | |||
79 | export GEM_HOME = "${STAGING_DIR_NATIVE}/usr/lib/ruby/gems/${RUBY_GEM_VERSION}" | ||
80 | |||
81 | RUBY_BUILD_GEMS ?= "${BPN}.gemspec" | ||
82 | RUBY_INSTALL_GEMS ?= "${BPN}-${BPV}.gem" | ||
83 | |||
84 | RUBY_COMPILE_FLAGS ?= 'LANG="C.UTF-8" LC_ALL="C.UTF-8"' | ||
85 | |||
86 | ruby_do_compile() { | ||
87 | for gem in ${RUBY_BUILD_GEMS}; do | ||
88 | ${RUBY_COMPILE_FLAGS} gem build $gem | ||
89 | done | ||
90 | } | ||
91 | |||
92 | |||
93 | ruby_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 | |||
99 | EXPORT_FUNCTIONS do_compile do_install | ||
100 | |||
101 | PACKAGES = "${PN}-dbg ${PN} ${PN}-doc ${PN}-dev" | ||
102 | |||
103 | FILES_${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 | |||
110 | FILES_${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 | |||
117 | FILES_${PN}-doc += " \ | ||
118 | ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/doc \ | ||
119 | " | ||