From 3764ff5a51a832d35a880ef56359df82b48f1f78 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Thu, 9 Jul 2015 10:15:06 +0300 Subject: [PATCH] apkbuild-gem-resolver: Subpackage class --- apkbuild-gem-resolver.in | 113 ++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/apkbuild-gem-resolver.in b/apkbuild-gem-resolver.in index 7ba5780..9e4457c 100644 --- a/apkbuild-gem-resolver.in +++ b/apkbuild-gem-resolver.in @@ -10,45 +10,7 @@ require 'rubygems/resolver' require 'rubygems/spec_fetcher' class Package - RUBY_SUBPACKAGES = { - '2.0.0_p353' => { - 'ruby-minitest' => ['minitest', '4.3.2'], - 'ruby-rake' => ['rake', '0.9.6'], - 'ruby-rdoc' => ['rdoc', '4.0.0', 'ruby-json'] - }, - '2.0.0_p481' => { - 'ruby-minitest' => ['minitest', '4.3.2'], - 'ruby-rake' => ['rake', '0.9.6'], - 'ruby-rdoc' => ['rdoc', '4.0.0', 'ruby-json'] - }, - '2.1.5' => { - 'ruby-json' => ['json', '1.8.1'], - 'ruby-minitest' => ['minitest', '4.7.5'], - 'ruby-rake' => ['rake', '10.1.0'], - 'ruby-rdoc' => ['rdoc', '4.1.0', 'ruby-json'] - }, - '2.2.1' => { - 'ruby-json' => ['json', '1.8.1'], - 'ruby-minitest' => ['minitest', '5.4.3'], - 'ruby-rake' => ['rake', '10.4.2'], - 'ruby-rdoc' => ['rdoc', '4.2.0', 'ruby-json'], - 'ruby-io-console' => [ 'io-console', '0.4.2'] # its actually 0.4.3 but - # that version is not - # published on network - }, - '2.2.2' => { - 'ruby-json' => ['json', '1.8.1'], - 'ruby-minitest' => ['minitest', '5.4.3'], - 'ruby-rake' => ['rake', '10.4.2'], - 'ruby-rdoc' => ['rdoc', '4.2.0', 'ruby-json'], - 'ruby-io-console' => [ 'io-console', '0.4.2'] # its actually 0.4.3 but - # that version is not - # published on network - } - } - @@packages = {} - @@subpackages = [] def self.initialize testing Augeas::open(nil, nil, Augeas::NO_MODL_AUTOLOAD) do |aug| @@ -67,16 +29,7 @@ class Package end end - for name, attrs in RUBY_SUBPACKAGES[ - aug.get("#{apath}/main/ruby/APKBUILD/pkgver") - ] - gem, version, *deps = attrs - pkg = new name, gem, version - for dep in deps - pkg.add_dependency dep - end - @@subpackages << pkg - end + Subpackage.initialize aug.get("#{apath}/main/ruby/APKBUILD/pkgver") end @@packages.each_value do |pkg| @@ -92,12 +45,6 @@ class Package pkg end - def self.ruby_subpkgs - for pkg in @@subpackages - yield pkg - end - end - def initialize name, gem, version @name = name @gem = gem @@ -152,6 +99,62 @@ class Aport < Package end end +class Subpackage < Package + RUBY_SUBPACKAGES = { + '2.0.0_p353' => { + 'ruby-minitest' => ['minitest', '4.3.2'], + 'ruby-rake' => ['rake', '0.9.6'], + 'ruby-rdoc' => ['rdoc', '4.0.0', 'ruby-json'] + }, + '2.0.0_p481' => { + 'ruby-minitest' => ['minitest', '4.3.2'], + 'ruby-rake' => ['rake', '0.9.6'], + 'ruby-rdoc' => ['rdoc', '4.0.0', 'ruby-json'] + }, + '2.1.5' => { + 'ruby-json' => ['json', '1.8.1'], + 'ruby-minitest' => ['minitest', '4.7.5'], + 'ruby-rake' => ['rake', '10.1.0'], + 'ruby-rdoc' => ['rdoc', '4.1.0', 'ruby-json'] + }, + '2.2.1' => { + # it's actually 0.4.3 but that version is not published on network + 'ruby-io-console' => ['io-console', '0.4.2'], + 'ruby-json' => ['json', '1.8.1'], + 'ruby-minitest' => ['minitest', '5.4.3'], + 'ruby-rake' => ['rake', '10.4.2'], + 'ruby-rdoc' => ['rdoc', '4.2.0', 'ruby-json'] + }, + '2.2.2' => { + # it's actually 0.4.3 but that version is not published on network + 'ruby-io-console' => ['io-console', '0.4.2'], + 'ruby-json' => ['json', '1.8.1'], + 'ruby-minitest' => ['minitest', '5.4.3'], + 'ruby-rake' => ['rake', '10.4.2'], + 'ruby-rdoc' => ['rdoc', '4.2.0', 'ruby-json'] + } + } + + @@subpackages = [] + + def self.initialize version + for name, attrs in RUBY_SUBPACKAGES[version] + gem, version, *deps = attrs + pkg = new name, gem, version + for dep in deps + pkg.add_dependency dep + end + @@subpackages << pkg + end + end + + def self.each + for pkg in @@subpackages + yield pkg + end + end +end + class Update def initialize @@ -165,7 +168,7 @@ class Update end def resolve - Package.ruby_subpkgs do |pkg| + for pkg in Subpackage require_version pkg.name, pkg.version unless @gems[pkg.gem] end