1
# Copyright 2008 Amazon.com, Inc. or its affiliates. All Rights
2
# Reserved. Licensed under the Amazon Software License (the
3
# "License"). You may not use this file except in compliance with the
4
# License. A copy of the License is located at
5
# http://aws.amazon.com/asl or in the "license" file accompanying this
6
# file. This file is distributed on an "AS IS" BASIS, WITHOUT
7
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
8
# the License for the specific language governing permissions and
9
# limitations under the License.
11
require 'ec2/platform/linux/constants'
17
EXECUTABLE=EC2::Platform::Linux::Constants::Utility::TAR
18
def initialize(e = EXECUTABLE)
24
def version; @options << '--version'; self; end
25
def verbose; @options << '-v'; self; end
26
def create; @options << '-c'; self; end
27
def bzip2; @options << '-j'; self; end
28
def diff; @options << '-d'; self; end
29
def gzip; @options << '-z'; self; end
30
def extract; @options << '-x'; self; end
31
def update; @options << '-u'; self; end
32
def sparse; @options << '-S'; self; end
33
def dereference; @options << '-h'; self; end
36
filename = '-' if filename.nil?
37
@options << "-f #{filename}"
42
@options << "-C #{dir}" unless dir.nil?
46
def add(filename, dir = nil)
47
item = dir.nil? ? filename : "-C #{dir} #{filename}"
52
"#{@executable} #{@options.join(' ')} #{@files.join(' ')}".strip
56
RECOMMENDED = 'tar 1.15'
57
REGEX = /(?:tar).*?(\d+)\.(\d+)\.?(\d*)/
61
def initialize(str=nil)
63
@string = default if str.nil? or str.empty?
64
@values = Version.parse @string
67
s = `#{Command.new.version.expand}`.strip
68
s = nil unless $? == 0
73
@values = Version.parse @string
76
return nil if @values.nil?
77
if other.nil? or not other.is_a? Version
78
raise ArgumentError, "Cannot compare with invalid version #{other}"
80
@values.zip(other.values).each do |mine, others|
81
return false if mine < others
82
return true if mine > others
87
self >= Version.new(Version::RECOMMENDED)
90
match = REGEX.match(str)
91
return nil if match.nil?
93
items = match.captures.collect do |cap|