summaryrefslogtreecommitdiff
path: root/apkbuild-gem-resolver.in
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2015-07-09 11:32:03 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2015-07-09 19:40:38 +0300
commitfeca037655ed2d3914c792885f09830833284a14 (patch)
treef42e5576636f2d95793a57dddad6e4ed448b2c5e /apkbuild-gem-resolver.in
parent8704797efea97c8b01dbb7cdea34c3a701c04e85 (diff)
downloadabuild-feca037655ed2d3914c792885f09830833284a14.tar.gz
abuild-feca037655ed2d3914c792885f09830833284a14.tar.bz2
abuild-feca037655ed2d3914c792885f09830833284a14.tar.xz
abuild-feca037655ed2d3914c792885f09830833284a14.zip
apkbuild-gem-resolver: option for updating APKBUILD files
Diffstat (limited to 'apkbuild-gem-resolver.in')
-rw-r--r--apkbuild-gem-resolver.in51
1 files changed, 44 insertions, 7 deletions
diff --git a/apkbuild-gem-resolver.in b/apkbuild-gem-resolver.in
index 9622928..77e0cb6 100644
--- a/apkbuild-gem-resolver.in
+++ b/apkbuild-gem-resolver.in
@@ -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