capistrano-karaf 1.5.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ SSHKit.config.command_map[:features_info] = 'features:info'
14
14
  SSHKit.config.command_map[:headers] = 'osgi:headers --force'
15
15
  SSHKit.config.command_map[:list] = 'osgi:list'
16
16
  SSHKit.config.command_map[:list_all] = 'osgi:list -t 0'
17
+ SSHKit.config.command_map[:list_urls] = 'osgi:list -t 0 -l'
17
18
  SSHKit.config.command_map[:log_set] = 'log:set'
18
19
  SSHKit.config.command_map[:stop] = 'osgi:stop'
19
20
  SSHKit.config.command_map[:start] = 'osgi:start'
@@ -83,18 +84,15 @@ module Capistrano_Karaf
83
84
  def feature_uninstall(name, version)
84
85
 
85
86
  # Keep track of the bundles that are part of the feature
86
- #bundles = feature_bundles(name, version)
87
- execute(:features_uninstall, name)
87
+ feature_bundle_urls = feature_bundles(name, version).collect {|b| b[:url]}
88
+ execute(:features_uninstall, "#{name}/#{version}")
88
89
 
89
90
  # Verify all bundles have been uninstalled and remove the bundle if not
90
- #headers = list_headers
91
- #bundles.each do |b|
92
- # matching_headers = headers.find do |h|
93
- # h['Bundle-SymbolicName'] == b[:artifactId] && h['Bundle-Version'] == b[:version]
94
- # end
95
-
96
- # matching_headers.each {|h| uninstall['Bundle-Number']}
97
- #end
91
+ list_bundle_locations.each do |installed_bundle|
92
+ if feature_bundle_urls.include? installed_bundle[:url] then
93
+ uninstall installed_bundle[:id]
94
+ end
95
+ end
98
96
  end
99
97
 
100
98
  # Set the log level on the karaf server
@@ -180,9 +178,9 @@ module Capistrano_Karaf
180
178
  def list_features
181
179
  feature_line_matcher =
182
180
  %r{ (?<status> \w+){0}
183
- (?<version> [\d\w\-\.\s]+){0}
181
+ (?<version> [\d\w\-\.]+){0}
184
182
  (?<name> [\w\-\.\:]+){0}
185
- (?<repository> [\w\-\s\:\.]+){0}
183
+ (?<repository> [\w\-\:\.]+){0}
186
184
 
187
185
  ^\[\s*\g<status>\s*\]\s\[\s*\g<version>\s*\]\s*\g<name>\s*\g<repository>
188
186
  }x
@@ -244,7 +242,7 @@ module Capistrano_Karaf
244
242
  # # => [{:id => "10", :status => "INSTALLED", :blueprint => "", :context => "", :level => "60", :name => "camel-core", :version => "1.0.0"}]
245
243
  #
246
244
  # Returns a list of hashmaps containing the installed bundles
247
- def list_all_bundles
245
+ def list_bundles
248
246
  bundle_line_matcher =
249
247
  %r{ (?<id> \d+){0}
250
248
  (?<status> \w+){0}
@@ -256,6 +254,51 @@ module Capistrano_Karaf
256
254
 
257
255
  ^\[\s*\g<id>\]\s\[\s*\g<status>\s*\]\s\[\s*\g<blueprint>\s*\]\s\[\s*\g<context>\s*\]\s\[\s*\g<level>\s*\]\s\g<name>\s\(\g<version>\)
258
256
  }x
257
+
258
+ fragments_matcher = /\s*Fragments: ([\d\s]+)\s*/
259
+
260
+ data = capture(:list)
261
+
262
+ fragments = []
263
+ bundles = []
264
+
265
+ data.lines.each do |line|
266
+ m1 = bundle_line_matcher.match line
267
+ m2 = fragments_matcher.match line
268
+
269
+ if m1 then
270
+ bundles.push(m1)
271
+ elsif m2 then
272
+ fragment_bundles = m2[1].split /\s+/
273
+ fragment_bundles.each {|fb| fragments.push fb}
274
+ end
275
+ end
276
+
277
+ bundles1 = bundles.collect {|m| Hash[m.names.collect {|k| k.to_sym }.zip(m.captures)]}
278
+ bundles1.collect do |b|
279
+ b[:fragment] = fragments.include? b[:id]
280
+ b
281
+ end
282
+ end
283
+
284
+ # List bundle locations
285
+ #
286
+ # Examples
287
+ # list_bundle_locations
288
+ # # => [{:id => "10", :status => "INSTALLED", :blueprint => "", :context => "", :level => "60", :url => "mvn:org.springframework/spring-webmvc/3.0.5.RELEASE"}]
289
+ #
290
+ # Returns a list of hashmaps containing the installed bundles and their url
291
+ def list_bundle_locations
292
+ bundle_line_matcher =
293
+ %r{ (?<id> \d+){0}
294
+ (?<status> \w+){0}
295
+ (?<blueprint> \w*){0}
296
+ (?<context> \w*){0}
297
+ (?<level> \d+){0}
298
+ (?<url> [\w:\.\/\-]+){0}
299
+
300
+ ^\[\s*\g<id>\]\s\[\s*\g<status>\s*\]\s\[\s*\g<blueprint>\s*\]\s\[\s*\g<context>\s*\]\s\[\s*\g<level>\s*\]\s\g<url>
301
+ }x
259
302
 
260
303
  data = capture(:list_all)
261
304
  matcher_to_hash(bundle_line_matcher, data)
@@ -310,11 +353,12 @@ module Capistrano_Karaf
310
353
  def extract_bundles_from_feature (data)
311
354
  bundles = []
312
355
  data.lines.each do |l|
313
- m = l.match(/.*mvn:(?<GroupId>[\w\.]+)\/(?<ArtifactId>[-\w\.]+)\/(?<Version>[-\d\w\.]+)/)
356
+ m = l.match(/mvn:(?<GroupId>[\w\.]+)\/(?<ArtifactId>[-\w\.]+)\/(?<Version>[-\d\w\.]+)/)
314
357
  if m then
315
358
  bundles.push({ :groupId => m['GroupId'],
316
359
  :artifactId => m['ArtifactId'],
317
- :version => m['Version']})
360
+ :version => m['Version'],
361
+ :url => m[0]})
318
362
  end
319
363
  end
320
364
  bundles
@@ -49,12 +49,12 @@ module Capistrano_Karaf
49
49
  # name - a string containing the feature name
50
50
  #
51
51
  # Examples
52
- # feature_uninstall_safe "test"
52
+ # feature_uninstall_safe "test", "1.0.0"
53
53
  # # => nil
54
54
  #
55
55
  # Returns nothing
56
- def feature_uninstall_safe (name)
57
- feature_uninstall name unless !feature_installed? name
56
+ def feature_uninstall_safe (name, version)
57
+ feature_uninstall name, version unless !feature_installed? name, version
58
58
  end
59
59
 
60
60
  # Verify if a bundle is a fragment bundle
@@ -125,8 +125,8 @@ module Capistrano_Karaf
125
125
  # # => true
126
126
  #
127
127
  # Returns true if the feature is installed
128
- def feature_installed? (name)
129
- feature = list_features.find {|f| f[:name]==name}
128
+ def feature_installed? (name, version)
129
+ feature = list_features.find {|f| f[:name]==name and f[:version] == version}
130
130
  feature[:status] == 'installed' unless feature.nil?
131
131
  end
132
132
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-karaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: