diff options
| -rw-r--r-- | meta-ruby/classes/ruby.bbclass | 125 | ||||
| -rw-r--r-- | meta-ruby/recipes-devtools/ruby/bundler_git.bb | 29 |
2 files changed, 154 insertions, 0 deletions
diff --git a/meta-ruby/classes/ruby.bbclass b/meta-ruby/classes/ruby.bbclass new file mode 100644 index 0000000000..9c4fcf9c3c --- /dev/null +++ b/meta-ruby/classes/ruby.bbclass | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | BPV ?= "${PV}" | ||
| 2 | |||
| 3 | DEPENDS += " \ | ||
| 4 | ruby-native \ | ||
| 5 | " | ||
| 6 | RDEPENDS_${PN} += " \ | ||
| 7 | ruby \ | ||
| 8 | " | ||
| 9 | |||
| 10 | def get_rubyversion(p): | ||
| 11 | import re | ||
| 12 | from os.path import isfile | ||
| 13 | import subprocess | ||
| 14 | found_version = "SOMETHING FAILED!" | ||
| 15 | |||
| 16 | cmd = "%s/ruby" % p | ||
| 17 | |||
| 18 | if not isfile(cmd): | ||
| 19 | return found_version | ||
| 20 | |||
| 21 | version = subprocess.Popen([cmd, "--version"], stdout=subprocess.PIPE).communicate()[0] | ||
| 22 | |||
| 23 | r = re.compile("ruby ([0-9]+\.[0-9]+\.[0-9]+)*") | ||
| 24 | m = r.match(version) | ||
| 25 | if m: | ||
| 26 | found_version = m.group(1) | ||
| 27 | |||
| 28 | return found_version | ||
| 29 | |||
| 30 | def get_rubygemslocation(p): | ||
| 31 | import re | ||
| 32 | from os.path import isfile | ||
| 33 | import subprocess | ||
| 34 | found_loc = "SOMETHING FAILED!" | ||
| 35 | |||
| 36 | cmd = "%s/gem" % p | ||
| 37 | |||
| 38 | if not isfile(cmd): | ||
| 39 | return found_loc | ||
| 40 | |||
| 41 | loc = subprocess.Popen([cmd, "env"], stdout=subprocess.PIPE).communicate()[0] | ||
| 42 | |||
| 43 | r = re.compile(".*\- (/usr.*/ruby/gems/.*)") | ||
| 44 | for line in loc.split('\n'): | ||
| 45 | m = r.match(line) | ||
| 46 | if m: | ||
| 47 | found_loc = m.group(1) | ||
| 48 | break | ||
| 49 | |||
| 50 | return found_loc | ||
| 51 | |||
| 52 | def get_rubygemsversion(p): | ||
| 53 | import re | ||
| 54 | from os.path import isfile | ||
| 55 | import subprocess | ||
| 56 | found_version = "SOMETHING FAILED!" | ||
| 57 | |||
| 58 | cmd = "%s/gem" % p | ||
| 59 | |||
| 60 | if not isfile(cmd): | ||
| 61 | return found_version | ||
| 62 | |||
| 63 | version = subprocess.Popen([cmd, "env", "gemdir"], stdout=subprocess.PIPE).communicate()[0] | ||
| 64 | |||
| 65 | r = re.compile(".*([0-9]+\.[0-9]+\.[0-9]+)$") | ||
| 66 | m = r.match(version) | ||
| 67 | if m: | ||
| 68 | found_version = m.group(1) | ||
| 69 | |||
| 70 | return found_version | ||
| 71 | |||
| 72 | RUBY_VERSION ?= "${@get_rubyversion("${STAGING_BINDIR_NATIVE}")}" | ||
| 73 | RUBY_GEM_DIRECTORY ?= "${@get_rubygemslocation("${STAGING_BINDIR_NATIVE}")}" | ||
| 74 | RUBY_GEM_VERSION ?= "${@get_rubygemsversion("${STAGING_BINDIR_NATIVE}")}" | ||
| 75 | |||
| 76 | export GEM_HOME = "${STAGING_DIR_NATIVE}/usr/lib/ruby/gems/${RUBY_GEM_VERSION}" | ||
| 77 | |||
| 78 | RUBY_BUILD_GEMS ?= "${BPN}.gemspec" | ||
| 79 | RUBY_INSTALL_GEMS ?= "${BPN}-${BPV}.gem" | ||
| 80 | |||
| 81 | RUBY_COMPILE_FLAGS ?= 'LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8"' | ||
| 82 | |||
| 83 | ruby_do_compile() { | ||
| 84 | for gem in ${RUBY_BUILD_GEMS}; do | ||
| 85 | ${RUBY_COMPILE_FLAGS} gem build $gem | ||
| 86 | done | ||
| 87 | } | ||
| 88 | |||
| 89 | |||
| 90 | ruby_do_install() { | ||
| 91 | for gem in ${RUBY_INSTALL_GEMS}; do | ||
| 92 | gem install --ignore-dependencies --local --env-shebang --install-dir ${D}/${libdir}/ruby/gems/${RUBY_GEM_VERSION}/ $gem | ||
| 93 | done | ||
| 94 | |||
| 95 | # create symlink from the gems bin directory to /usr/bin | ||
| 96 | for i in ${D}/${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin/*; do | ||
| 97 | if [ -e "$i" ]; then | ||
| 98 | if [ ! -d ${D}/${bindir} ]; then mkdir -p ${D}/${bindir}; fi | ||
| 99 | b=`basename $i` | ||
| 100 | ln -sf ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin/$b ${D}/${bindir}/$b | ||
| 101 | fi | ||
| 102 | done | ||
| 103 | } | ||
| 104 | |||
| 105 | EXPORT_FUNCTIONS do_compile do_install | ||
| 106 | |||
| 107 | PACKAGES = "${PN}-dbg ${PN} ${PN}-doc ${PN}-dev" | ||
| 108 | |||
| 109 | FILES_${PN}-dbg += " \ | ||
| 110 | ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/.debug \ | ||
| 111 | ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/.debug \ | ||
| 112 | ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/*/.debug \ | ||
| 113 | ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/*/*/.debug \ | ||
| 114 | " | ||
| 115 | |||
| 116 | FILES_${PN} += " \ | ||
| 117 | ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems \ | ||
| 118 | ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/cache \ | ||
| 119 | ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin \ | ||
| 120 | ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/specifications \ | ||
| 121 | " | ||
| 122 | |||
| 123 | FILES_${PN}-doc += " \ | ||
| 124 | ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/doc \ | ||
| 125 | " | ||
diff --git a/meta-ruby/recipes-devtools/ruby/bundler_git.bb b/meta-ruby/recipes-devtools/ruby/bundler_git.bb new file mode 100644 index 0000000000..2adde4d215 --- /dev/null +++ b/meta-ruby/recipes-devtools/ruby/bundler_git.bb | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | SUMMARY = "Makes sure Ruby applications run the same code on every machine." | ||
| 2 | DESCRIPTION = "Bundler makes sure Ruby applications run the same code \ | ||
| 3 | on every machine. It does this by managing the gems that the \ | ||
| 4 | application depends on. Given a list of gems, it can automatically \ | ||
| 5 | download and install those gems, as well as any other gems needed by \ | ||
| 6 | the gems that are listed. Before installing gems, it checks the \ | ||
| 7 | versions of every gem to make sure that they are compatible, and can \ | ||
| 8 | all be loaded at the same time. After the gems have been installed, \ | ||
| 9 | Bundler can help you update some or all of them when new versions \ | ||
| 10 | become available. Finally, it records the exact versions that have \ | ||
| 11 | been installed, so that others can install the exact same gems." | ||
| 12 | |||
| 13 | LICENSE = "MIT" | ||
| 14 | LIC_FILES_CHKSUM = "file://LICENSE.md;md5=196bb963e601609817d7e9ac9a64a867" | ||
| 15 | |||
| 16 | PR = "r0" | ||
| 17 | |||
| 18 | PV = "1.6.2" | ||
| 19 | SRCREV = "06e3647c117da210ffd15a174624497830addd7b" | ||
| 20 | |||
| 21 | S = "${WORKDIR}/git" | ||
| 22 | |||
| 23 | SRC_URI = " \ | ||
| 24 | git://github.com/bundler/bundler.git \ | ||
| 25 | " | ||
| 26 | |||
| 27 | inherit ruby | ||
| 28 | |||
| 29 | BBCLASSEXTEND = "native" | ||
