Skip to content

Commit 2fc6ecf

Browse files
committed
ruby: Adapt recipe to the oelint-adv spectations
Changes in the recipe to fullfill the guide lines from oelint-adv. Maintenance-Type: linter
1 parent 6beac02 commit 2fc6ecf

File tree

1 file changed

+65
-63
lines changed

1 file changed

+65
-63
lines changed

classes/ruby.bbclass

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,9 @@
1-
DEPENDS += " \
1+
DEPENDS += "\
22
ruby-native \
33
"
4-
RDEPENDS:${PN} += " \
5-
ruby \
6-
"
74

85
#${PN}_do_compile[depends] += "ruby-native:do_populate_sysroot"
96

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-
307
def get_rubygemslocation(p):
318
import re
329
from os.path import isfile
@@ -69,7 +46,29 @@ def get_rubygemsversion(p):
6946

7047
return found_version
7148

49+
# nooelint: oelint.vars.mispell - New variabled defined here
7250
RUBY_VERSION ?= "${@get_rubyversion("${STAGING_BINDIR_NATIVE}")}"
51+
52+
def get_rubyversion(p):
53+
import re
54+
from os.path import isfile
55+
import subprocess
56+
found_version = "SOMETHING FAILED!"
57+
58+
cmd = "%s/ruby" % p
59+
60+
if not isfile(cmd):
61+
return found_version
62+
63+
version = subprocess.Popen([cmd, "--version"], stdout=subprocess.PIPE).communicate()[0]
64+
65+
r = re.compile("ruby ([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+
7372
RUBY_GEM_DIRECTORY ?= "${@get_rubygemslocation("${STAGING_BINDIR_NATIVE}")}"
7473
RUBY_GEM_VERSION ?= "${@get_rubygemsversion("${STAGING_BINDIR_NATIVE}")}"
7574

@@ -81,18 +80,18 @@ RUBY_INSTALL_GEMS ?= "${BPN}-${BPV}.gem"
8180
RUBY_COMPILE_FLAGS ?= 'LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8"'
8281

8382
ruby_gen_extconf_fix() {
84-
cat<<EOF>append
83+
cat<<EOF>append
8584
RbConfig::MAKEFILE_CONFIG['CPPFLAGS'] = ENV['CPPFLAGS'] if ENV['CPPFLAGS']
8685
\$CPPFLAGS = ENV['CPPFLAGS'] if ENV['CPPFLAGS']
8786
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
8887
RbConfig::MAKEFILE_CONFIG['LD'] = ENV['LD'] if ENV['LD']
8988
RbConfig::MAKEFILE_CONFIG['CFLAGS'] = ENV['CFLAGS'] if ENV['CFLAGS']
9089
RbConfig::MAKEFILE_CONFIG['CXXFLAGS'] = ENV['CXXFLAGS'] if ENV['CXXFLAGS']
9190
EOF
92-
cat append2>>append
93-
sysroot_ruby=${STAGING_INCDIR}/ruby-${RUBY_GEM_VERSION}
94-
ruby_arch=`ls -1 ${sysroot_ruby} |grep -v ruby |tail -1 2> /dev/null`
95-
cat<<EOF>>append
91+
cat append2>>append
92+
sysroot_ruby=${STAGING_INCDIR}/ruby-${RUBY_GEM_VERSION}
93+
ruby_arch=`ls -1 ${sysroot_ruby} |grep -v ruby |tail -1 2> /dev/null`
94+
cat<<EOF>>append
9695
system("perl -p -i -e 's#^topdir.*#topdir = ${sysroot_ruby}#' Makefile")
9796
system("perl -p -i -e 's#^hdrdir.*#hdrdir = ${sysroot_ruby}#' Makefile")
9897
system("perl -p -i -e 's#^arch_hdrdir.*#arch_hdrdir = ${sysroot_ruby}/\\\\\$(arch)#' Makefile")
@@ -103,7 +102,6 @@ EOF
103102
EOF
104103
}
105104

106-
107105
ruby_do_compile() {
108106
EXTCONF_FILES=$(find . -name extconf.rb -exec ls {} \;)
109107
for e in $EXTCONF_FILES
@@ -128,42 +126,46 @@ ruby_do_compile() {
128126
}
129127

130128
ruby_do_install() {
131-
for gem in ${RUBY_INSTALL_GEMS}; do
132-
gem install --ignore-dependencies --local --env-shebang --install-dir ${D}/${libdir}/ruby/gems/${RUBY_GEM_VERSION}/ $gem
133-
done
134-
135-
# create symlink from the gems bin directory to /usr/bin
136-
for i in ${D}/${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin/*; do
137-
if [ -e "$i" ]; then
138-
if [ ! -d ${D}/${bindir} ]; then mkdir -p ${D}/${bindir}; fi
139-
b=`basename $i`
140-
ln -sf ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin/$b ${D}/${bindir}/$b
141-
fi
142-
done
129+
for gem in ${RUBY_INSTALL_GEMS}; do
130+
gem install --ignore-dependencies --local --env-shebang --install-dir ${D}/${libdir}/ruby/gems/${RUBY_GEM_VERSION}/ $gem
131+
done
132+
133+
# create symlink from the gems bin directory to /usr/bin
134+
for i in ${D}/${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin/*; do
135+
if [ -e "$i" ]; then
136+
if [ ! -d ${D}/${bindir} ]; then mkdir -p ${D}/${bindir}; fi
137+
b=`basename $i`
138+
ln -sf ${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin/$b ${D}/${bindir}/$b
139+
fi
140+
done
143141
}
144142

145143
EXPORT_FUNCTIONS do_compile do_install
146144

147145
PACKAGES = "${PN}-dbg ${PN} ${PN}-doc ${PN}-dev"
148146

149-
FILES:${PN}-dbg += " \
150-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/.debug \
151-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/.debug \
152-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/*/.debug \
153-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/*/*/.debug \
154-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/extensions/*/*/*/*/*/.debug \
155-
"
156-
157-
FILES:${PN} += " \
158-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems \
159-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/cache \
160-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin \
161-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/specifications \
162-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/build_info \
163-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/extensions \
164-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/plugins \
165-
"
166-
167-
FILES:${PN}-doc += " \
168-
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/doc \
169-
"
147+
FILES:${PN}-dbg += "\
148+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/.debug \
149+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/.debug \
150+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/*/.debug \
151+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems/*/*/*/*/*/.debug \
152+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/extensions/*/*/*/*/*/.debug \
153+
"
154+
155+
FILES:${PN} += "\
156+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/gems \
157+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/cache \
158+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/bin \
159+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/specifications \
160+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/build_info \
161+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/extensions \
162+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/plugins \
163+
"
164+
165+
FILES:${PN}-doc += "\
166+
${libdir}/ruby/gems/${RUBY_GEM_VERSION}/doc \
167+
"
168+
169+
RDEPENDS:${PN} += "\
170+
ruby \
171+
"

0 commit comments

Comments
 (0)