Browse Source

Merge pull request #2294 from luizluca/ruby-refactor

ruby: refactor package to use more macros
lilik-openwrt-22.03
Luiz Angelo Daros de Luca 9 years ago
parent
commit
97df1dc2b3
3 changed files with 519 additions and 1192 deletions
  1. +471
    -1148
      lang/ruby/Makefile
  2. +36
    -40
      lang/ruby/ruby_find_pkgsdeps
  3. +12
    -4
      lang/ruby/ruby_missingfiles

+ 471
- 1148
lang/ruby/Makefile
File diff suppressed because it is too large
View File


+ 36
- 40
lang/ruby/ruby_find_pkgsdeps View File

@ -6,13 +6,14 @@
# Must run inside a openwrt with all *ruby* packages installed # Must run inside a openwrt with all *ruby* packages installed
# #
RUBY_SIMPLE_VERSION = RUBY_VERSION.split(".")[0..1].join(".")
failed = false failed = false
puts "Looking for installed ruby packages..." puts "Looking for installed ruby packages..."
packages=`opkg list-installed '*ruby*' | cut -d' ' -f 1`.split("\n") packages=`opkg list-installed '*ruby*' | cut -d' ' -f 1`.split("\n")
puts "Looking for packages files..." puts "Looking for packages files..."
package_files=Hash.new([])
package_files=Hash.new { |h,k| h[k]=[] }
packages.each do packages.each do
|pkg| |pkg|
files=`opkg files "#{pkg}" | sed -e 1d`.split("\n") files=`opkg files "#{pkg}" | sed -e 1d`.split("\n")
@ -24,7 +25,7 @@ require_regex_ignore=/^require ([a-zA-Z\$]|["']$|.*\/$)/
require_ignore=%w{drb/invokemethod16 foo rubygems/defaults/operating_system win32console java Win32API require_ignore=%w{drb/invokemethod16 foo rubygems/defaults/operating_system win32console java Win32API
builder/xchar json/pure simplecov win32/sspi rdoc/markdown/literals_1_8 enumerator win32/resolv rbtree builder/xchar json/pure simplecov win32/sspi rdoc/markdown/literals_1_8 enumerator win32/resolv rbtree
nqxml/streamingparser nqxml/treeparser xmlscan/parser xmlscan/scanner xmltreebuilder xml/parser xmlparser xml/encoding-ja xmlencoding-ja nqxml/streamingparser nqxml/treeparser xmlscan/parser xmlscan/scanner xmltreebuilder xml/parser xmlparser xml/encoding-ja xmlencoding-ja
iconv uconv win32ole gettext/po_parser gettext/mo libxml}
iconv uconv win32ole gettext/po_parser gettext/mo libxml psych.jar jar-dependencies}
builtin_enc=[ builtin_enc=[
Encoding.find("ASCII-8BIT"), Encoding.find("ASCII-8BIT"),
@ -34,7 +35,7 @@ builtin_enc=[
] ]
puts "Looking for requires in files..." puts "Looking for requires in files..."
files_requires=Hash.new([])
files_requires=Hash.new { |h,k| h[k]=[] }
packages.each do packages.each do
|pkg| |pkg|
package_files[pkg].each do package_files[pkg].each do
@ -93,7 +94,7 @@ packages.each do
next next
end end
files_requires[file]=files_requires[file] + [require]
files_requires[file] += [require]
when /Encoding::/ when /Encoding::/
encs=line.scan(/Encoding::[[:alnum:]_]+/).collect {|enc| eval(enc) }.select {|enc| enc.kind_of? Encoding } encs=line.scan(/Encoding::[[:alnum:]_]+/).collect {|enc| eval(enc) }.select {|enc| enc.kind_of? Encoding }
@ -104,7 +105,7 @@ packages.each do
required_encs = (encs - builtin_enc).collect {|enc| "enc/#{enc.name.downcase.gsub("-","_")}" } required_encs = (encs - builtin_enc).collect {|enc| "enc/#{enc.name.downcase.gsub("-","_")}" }
required_encs << "enc/encdb" if need_encdb required_encs << "enc/encdb" if need_encdb
files_requires[file] = files_requires[file] + required_encs
files_requires[file] += required_encs
end end
end end
end end
@ -119,10 +120,18 @@ package_files.each do |(pkg,files)| files.each do |file|
end end
end; end end; end
puts "Merging requirements into packages..."
package_requires = Hash[packages.collect { |pkg| [pkg, package_files[pkg].collect {|file| files_requires[file] }.inject([],:+).uniq] }]
puts "Grouping package requirements per package"
package_requires_files = Hash.new{|h,k| h[k] = Hash.new { |h2,k2| h2[k2] = [] } }
package_files.each do |(pkg,files)|
package_requires_files[pkg]
files.each do |file|
files_requires[file].each do |requires|
package_requires_files[pkg][requires] << file
end
end
end
weak_dependency=Hash.new([])
weak_dependency=Hash.new { |h,k| h[k]=[] }
weak_dependency.merge!({ weak_dependency.merge!({
"ruby-misc"=>["ruby-openssl","ruby-fiddle"], #securerandom.rb "ruby-misc"=>["ruby-openssl","ruby-fiddle"], #securerandom.rb
"ruby-debuglib"=>["ruby-readline"], #debug.rb "ruby-debuglib"=>["ruby-readline"], #debug.rb
@ -136,6 +145,7 @@ weak_dependency.merge!({
"ruby-rdoc"=>["ruby-gems","ruby-readline","ruby-webrick", #/usr/bin/rdoc and others "ruby-rdoc"=>["ruby-gems","ruby-readline","ruby-webrick", #/usr/bin/rdoc and others
"ruby-io-console"], #rdoc/stats/normal.rb "ruby-io-console"], #rdoc/stats/normal.rb
"ruby-webrick"=>["ruby-openssl"], #webrick/ssl.rb "ruby-webrick"=>["ruby-openssl"], #webrick/ssl.rb
"ruby-testunit"=>["ruby-io-console"], #gems/test-unit-3.1.5/lib/test/unit/ui/console/testrunner.rb
}) })
puts "Preloading gems..." puts "Preloading gems..."
@ -143,12 +153,12 @@ Gem::Specification.all.each{ |x| gem x.name }
puts "Looking for package dependencies..." puts "Looking for package dependencies..."
package_provides = {} package_provides = {}
package_dependencies = Hash.new([])
package_requires.each do
|(pkg,requires)|
package_dependencies = Hash.new { |h,k| h[k]=[] }
package_requires_files.each do
|(pkg,requires_files)|
requires.each do
|require|
requires_files.each do
|(require,files)|
if package_provides.include?(require) if package_provides.include?(require)
found = package_provides[require] found = package_provides[require]
else else
@ -159,13 +169,13 @@ package_requires.each do
next next
end end
found = found.first found = found.first
package_provides[require]=found
package_provides[require] = found
end end
if weak_dependency[pkg].include?(found) if weak_dependency[pkg].include?(found)
puts "#{pkg}: #{found} provides #{require} (ignored WEAK dep)"
puts "#{pkg}: #{found} provides #{require} (weak depedendency ignored)"
else else
puts "#{pkg}: #{found} provides #{require}"
package_dependencies[pkg]=package_dependencies[pkg] + [found]
puts "#{pkg}: #{found} provides #{require} for #{files.collect {|file| file.sub("/usr/lib/ruby/","") }.join(",")}"
package_dependencies[pkg] += [found]
end end
end end
end end
@ -174,20 +184,16 @@ if failed
puts "Please, fix the missing files or ignore them on require_ignore var" puts "Please, fix the missing files or ignore them on require_ignore var"
exit(1) exit(1)
end end
package_dependencies.each do
|(pkg,deps)|
package_dependencies[pkg]=deps.uniq.sort - [pkg]
end
# Remove self dependency
package_dependencies = Hash[package_dependencies.collect {|(pkg,deps)| [pkg,package_dependencies[pkg]=deps.uniq.sort - [pkg]]}]
package_dependencies.default = []
puts "Expanding dependencies..." puts "Expanding dependencies..."
begin begin
changed=false changed=false
package_dependencies.each do package_dependencies.each do
|(pkg,deps)| |(pkg,deps)|
next if deps.empty? next if deps.empty?
deps_new = deps.collect {|dep| [dep] + package_dependencies[dep] }.inject([],:+).uniq.sort deps_new = deps.collect {|dep| [dep] + package_dependencies[dep] }.inject([],:+).uniq.sort
if not deps == deps_new if not deps == deps_new
puts "#{pkg}: #{deps.join(",")}" puts "#{pkg}: #{deps.join(",")}"
@ -198,6 +204,12 @@ begin
end end
end if not changed end if not changed
puts "Removing redundant dependencies..."
package_dependencies.each do
|(pkg,deps)|
package_dependencies[pkg]=deps.uniq - [pkg]
end
puts "Checking for mutual dependencies..." puts "Checking for mutual dependencies..."
package_dependencies.each do package_dependencies.each do
|(pkg,deps)| |(pkg,deps)|
@ -208,11 +220,6 @@ package_dependencies.each do
end end
exit(1) if failed exit(1) if failed
puts "Removing redundant dependencies..."
package_dependencies.each do
|(pkg,deps)|
package_dependencies[pkg]=deps.uniq - [pkg]
end
package_dependencies2=package_dependencies.dup package_dependencies2=package_dependencies.dup
package_dependencies.each do package_dependencies.each do
@ -256,15 +263,4 @@ end
puts "All dependencies are OK." if ok puts "All dependencies are OK." if ok
__END__ __END__
puts RUBY_VERSION, RUBY_PLATFORM
puts 123
puts Object.contants
#RUBY_VER=2.1
#RUBY_ARCH=i486-linux-gnu
#RUBYLIB=/usr/lib/ruby/$RUBY_VER/
#RUBYLIB_A=/usr/lib/ruby/$RUBY_ARCH/$RUBY_VER/

+ 12
- 4
lang/ruby/ruby_missingfiles View File

@ -1,20 +1,28 @@
#!/bin/bash #!/bin/bash
# #
# bash feeds/packages/lang/ruby/ruby_missingfiles staging_dir/target-i386_i486_musl-1.1.11/ bin/x86/packages/packages/*ruby*_2.3.0*
#
function list_staging_files { function list_staging_files {
cd staging_dir/target-*/; find \
cd "$1"; find \
\( \( -name "root-x86" -or -name "packages" -or -name "stamp" -or -name "pkginfo" \) -prune \) -or -true \ \( \( -name "root-x86" -or -name "packages" -or -name "stamp" -or -name "pkginfo" \) -prune \) -or -true \
\( -path "*ruby*" -or -name "erb" -or -name "gem" -or -name "irb" -or -name "rake" -or -name "rdoc" -or -name "ri" -or -name "testrb" \) \ \( -path "*ruby*" -or -name "erb" -or -name "gem" -or -name "irb" -or -name "rake" -or -name "rdoc" -or -name "ri" -or -name "testrb" \) \
-not -path "*/usr/include/*" -not -path "*/usr/lib/pkgconfig/*" -not -path "*/usr/lib/lib*.a" \
-not -path "*/usr/lib/ruby/gems/*/cache/*" \
-print | sort -print | sort
} }
function list_ipkg_files { function list_ipkg_files {
for OPKG in bin/*/packages/packages/*ruby*; do
for OPKG; do
tar --to-stdout -xzf "$OPKG" ./data.tar.gz | tar tz | sed -e 's%/$%%' tar --to-stdout -xzf "$OPKG" ./data.tar.gz | tar tz | sed -e 's%/$%%'
done | sort -u done | sort -u
} }
echo " Staging Packages"
diff -y <(list_staging_files) <(list_ipkg_files)
echo " Staging Packages"
: ${1:?First arg is staging_dir}
: ${2:?Second and following args are ruby ipkg packages}
STAGING_DIR=$1; shift
diff -d -y <(list_staging_files "$STAGING_DIR") <(list_ipkg_files "$@")

Loading…
Cancel
Save