summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apkbuild-gem-resolver.in53
1 files changed, 33 insertions, 20 deletions
diff --git a/apkbuild-gem-resolver.in b/apkbuild-gem-resolver.in
index 7262e14..e4ef424 100644
--- a/apkbuild-gem-resolver.in
+++ b/apkbuild-gem-resolver.in
@@ -46,10 +46,8 @@ class Package
pkg
end
- def initialize name, gem, version
+ def initialize name
@name = name
- @gem = gem
- @version = version
@depends = []
@users = []
@@packages[name] = self
@@ -59,7 +57,7 @@ class Package
@depends << name
end
- attr_reader :gem, :name, :version
+ attr_reader :name
def depends
for dep in @depends
@@ -83,21 +81,30 @@ end
class Aport < Package
def initialize path
- name = path.split('/')[-1]
+ super path.split('/')[-1]
+ @path = path + '/APKBUILD/'
- get = proc{ |param|
- res = @@augeas.get(path + '/APKBUILD/' + param)
- raise param + ' not defined for ' + name unless res
- res
- }
-
- super name, get.call('_gemname'), get.call('pkgver')
-
- for dep in `echo #{get.call('depends')}`.split
+ for dep in `echo #{get_param 'depends'}`.split
# ruby-gems: workaround for v2.6
add_dependency dep if dep.start_with?('ruby-') && dep != 'ruby-gems'
end
end
+
+ def gem
+ get_param '_gemname'
+ end
+
+ def version
+ get_param 'pkgver'
+ end
+
+ private
+
+ def get_param name
+ value = @@augeas.get(@path + name)
+ raise name + ' not defined for ' + @name unless value
+ value
+ end
end
class Subpackage < Package
@@ -140,12 +147,7 @@ class Subpackage < Package
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
+ new name, attrs
end
end
@@ -154,6 +156,17 @@ class Subpackage < Package
yield pkg
end
end
+
+ def initialize name, attrs
+ super name
+ @gem, @version, *deps = attrs
+ for dep in deps
+ add_dependency dep
+ end
+ @@subpackages << self
+ end
+
+ attr_reader :gem, :version
end