Class: Target::Deb::DebianSourceWrapper

Inherits:
SimpleDelegator
  • Object
show all
Includes:
OverridesPermissions
Defined in:
lib/gpm/target/deb.rb

Instance Method Summary collapse

Methods included from OverridesPermissions

#file_contents, #files

Constructor Details

#initialize(source) ⇒ DebianSourceWrapper

Returns a new instance of DebianSourceWrapper.



37
38
39
40
41
# File 'lib/gpm/target/deb.rb', line 37

def initialize(source)
  raise("nil source") unless source
  super(source)
  @logger = create_logger
end

Instance Method Details

#architectureObject



65
66
67
# File 'lib/gpm/target/deb.rb', line 65

def architecture
  Target::Deb.architecture(__getobj__.architecture)
end

#clean_package_name(name) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/gpm/target/deb.rb', line 46

def clean_package_name(name)
  if name =~ /[A-Z]/
    @logger.info("Debian tools (dpkg/apt) don't do well with packages " \
      "that use capital letters in the name. In some cases it will " \
      "automatically downcase them, in others it will not. It is confusing." \
      "Best to not use any capital letters at all.")
    name = name.downcase
  end

  to_dash = /[._\s]/
  if name =~ (to_dash)
    @logger.info("Package name '#{name}' includes strange characters, (underscores or whitespace, e.g.) converting" \
                 " to dashes")
    name = name.gsub(to_dash, "-")
  end


  return name
end

#default_outputObject

def architecture



69
70
71
72
73
74
75
76
77
# File 'lib/gpm/target/deb.rb', line 69

def default_output
  name_and_version = "#{name}_#{version}"
  architecture_and_type = "#{architecture}.#{type}"
  if build_number
    "#{name_and_version}-b#{build_number}_#{architecture_and_type}"
  else
    "#{name_and_version}_#{architecture_and_type}"
  end
end

#fix_dependency(dep) ⇒ Object

def default_output



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gpm/target/deb.rb', line 78

def fix_dependency(dep)
  if dep =~ /[\(,\|]/
    # Don't "fix" ones that could appear well formed already.
  else
    da = dep.split(/ +/)
    if da.size > 1
      # Convert strings 'foo >= bar' to 'foo (>= bar)'
      dep = "#{da[0]} (#{da[1]} #{da[2]})"
    end
  end

  name_re = /^[^ \(]+/
  name = dep[name_re]
  name = clean_package_name(name)


  # Convert gem ~> X.Y.Z to '>= X.Y.Z' and << X.Y+1.0
  if dep =~ /\(~>/
    name, version = dep.gsub(/[()~>]/, "").split(/ +/)[0..1]
    nextversion = version.split(".").collect { |v| v.to_i }
    l = nextversion.length
    nextversion[l-2] += 1
    nextversion[l-1] = 0
    nextversion = nextversion.join(".")
    return ["#{name} (>= #{version})", "#{name} (<< #{nextversion})"]
  # ignore build_numbers for = dependencies if flag specified
  elsif (m = dep.match(/(\S+)\s+\(= (.+)\)/)) && self.settings[:ignore_build_numbers]
    name, version = m[1..2]
    nextversion = version.split('.').collect { |v| v.to_i }
    nextversion[-1] += 1
    nextversion = nextversion.join(".")
    return ["#{name} (>= #{version})", "#{name} (<< #{nextversion})"]
  else
    return dep
  end
end

#nameObject



43
44
45
# File 'lib/gpm/target/deb.rb', line 43

def name
  clean_package_name(__getobj__.name)
end

#typeObject



114
115
116
# File 'lib/gpm/target/deb.rb', line 114

def type
  "deb"
end