Class: Aptly::Mirror

Inherits:
Object
  • Object
show all
Defined in:
lib/aptly/mirror.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Mirror

Instantiates a new Mirror object

Parameters:

name

Then name associated with the mirror



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/aptly/mirror.rb', line 95

def initialize name
  if !Aptly::list_mirrors.include? name
    raise AptlyError.new("Mirror '#{name}' does not exist")
  end

  info = Aptly::mirror_info name
  @name = info['Name']
  @baseurl = info['Archive Root URL']
  @dist = info['Distribution']
  @components = info['Components']
  @archlist = info['Architectures']
end

Instance Attribute Details

#archlistObject

Returns the value of attribute archlist.



81
82
83
# File 'lib/aptly/mirror.rb', line 81

def archlist
  @archlist
end

#baseurlObject

Returns the value of attribute baseurl.



81
82
83
# File 'lib/aptly/mirror.rb', line 81

def baseurl
  @baseurl
end

#componentsObject

Returns the value of attribute components.



81
82
83
# File 'lib/aptly/mirror.rb', line 81

def components
  @components
end

#distObject

Returns the value of attribute dist.



81
82
83
# File 'lib/aptly/mirror.rb', line 81

def dist
  @dist
end

#nameObject

Returns the value of attribute name.



81
82
83
# File 'lib/aptly/mirror.rb', line 81

def name
  @name
end

Instance Method Details

#dropObject

Drops an existing mirror from aptly’s configuration



109
110
111
# File 'lib/aptly/mirror.rb', line 109

def drop
  Aptly::runcmd "aptly mirror drop #{@name.quote}"
end

#list_packagesObject

List all packages contained in a mirror

Returns:

An array of packages



118
119
120
121
122
# File 'lib/aptly/mirror.rb', line 118

def list_packages
  res = []
  out = Aptly::runcmd "aptly mirror show -with-packages #{@name.quote}"
  Aptly::parse_indented_list out.lines
end

#snapshot(name) ⇒ Object

Shortcut method to snapshot an Aptly::Mirror object



125
126
127
# File 'lib/aptly/mirror.rb', line 125

def snapshot name
  Aptly::create_mirror_snapshot name, @name
end

#update(kwargs = {}) ⇒ Object

Updates a repository, syncing in all packages which have not already been downloaded and caches them locally.

Parameters:

ignore_cksum

Ignore checksum mismatches

ignore_sigs

Ignore author signature mismatches



138
139
140
141
142
143
144
145
146
147
148
# File 'lib/aptly/mirror.rb', line 138

def update kwargs={}
  ignore_cksum = kwargs.arg :ignore_cksum, false
  ignore_sigs = kwargs.arg :ignore_sigs, false

  cmd = 'aptly mirror update'
  cmd += ' -ignore-checksums' if ignore_cksum
  cmd += ' -ignore-signatures' if ignore_sigs
  cmd += " #{@name.quote}"

  Aptly::runcmd cmd
end