Commit feca0376 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

apkbuild-gem-resolver: option for updating APKBUILD files

parent 8704797e
......@@ -46,6 +46,10 @@ class Package
pkg
end
def self.save
fail unless @@augeas.save
end
def initialize name
@name = name
@depends = []
......@@ -61,10 +65,13 @@ class Package
def depends
for dep in @depends
unless @@packages.has_key? dep
raise "Dependency for #{@name} does not exist: #{dep}"
# ruby-gems: workaround for v2.6
if dep.start_with?('ruby-') && dep != 'ruby-gems'
unless @@packages.has_key? dep
raise "Dependency for #{@name} does not exist: #{dep}"
end
yield @@packages[dep]
end
yield @@packages[dep]
end
end
......@@ -85,8 +92,7 @@ class Aport < Package
@path = path + '/APKBUILD/'
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'
add_dependency dep
end
end
......@@ -98,6 +104,16 @@ class Aport < Package
get_param 'pkgver'
end
def version= version
set_param 'pkgver', version
set_param 'pkgrel', '0'
end
def del_dependency name
@depends.delete name
set_param 'depends', "\"#{@depends.join ' '}\""
end
private
def get_param name
......@@ -105,6 +121,10 @@ class Aport < Package
raise name + ' not defined for ' + @name unless value
value
end
def set_param name, value
@@augeas.set(@path + name, value)
end
end
class Subpackage < Package
......@@ -306,10 +326,14 @@ end
testing = false
update = false
OptionParser.new do |opts|
opts.on('-t', '--testing') do |t|
testing = t
end
opts.on('-u', '--update') do |u|
update = u
end
end.parse! ARGV
Package.initialize testing
......@@ -330,8 +354,21 @@ end
update.resolve
for pkg in update
obs = pkg[:obsolete_deps]
obs = obs.empty? ? nil : " (obsolete dependencies: #{obs.join ', '})"
obsolete = pkg[:obsolete_deps]
obs = obsolete.empty? ?
nil : " (obsolete dependencies: #{obsolete.join ', '})"
puts "#{pkg[:name]}-#{pkg[:version]}#{obs}"
if update
package = Package.get(pkg[:name])
package.version = pkg[:version]
for dep in obsolete
package.del_dependency dep
end
end
end
if update
Package.save
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment