Class: PuppetX::Aptly::CliHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/voxpupuli/aptly/cli_helper.rb

Class Method Summary collapse

Class Method Details

.aptly_command(*args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 14

def self.aptly_command(*args)
  opts = args.shift
  cmd = opts[:aptly_command] || 'aptly'
  env = opts[:aptly_environment] || {}

  result = []
  result << env if env.any?
  result << cmd
  result + args
end

.mirror_create(name, url, distribution, options = {}) ⇒ Object

Mirror



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 26

def self.mirror_create(name, url, distribution, options = {})
  cmd = aptly_command(options, 'mirror', 'create')
  cmd += parse_common_options(options)
  cmd << "-filter=#{options[:filter]}" if options[:filter]
  cmd << '-filter-with-deps' if options[:filter_with_deps]
  cmd << '-force-architectures' if options[:force_architectures]
  cmd << '-force-components' if options[:force_components]
  cmd << '-ignore-signatures' if options[:ignore_signatures]
  cmd += Array(options[:keyring]).map { |x| "-keyring=#{x}" }
  cmd << "-max-tries=#{options[:max_tries]}" if options[:max_tries]
  cmd << '-with-installer' if options[:with_installer]
  cmd << '-with-sources' if options[:with_sources]
  cmd << '-with-udebs' if options[:with_udebs]
  cmd += [name, url, distribution]
  cmd += Array(options[:component])
  execute(cmd)
end

.mirror_drop(name, options = {}) ⇒ Object



67
68
69
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 67

def self.mirror_drop(name, options = {})
  something_drop('mirror', name, options)
end

.mirror_edit(name, options = {}) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 71

def self.mirror_edit(name, options = {})
  cmd = aptly_command(options, 'mirror', 'edit')
  cmd += parse_common_options(options)
  cmd << "-archive-url=#{options[:archive_url]}" if options[:archive_url]
  cmd << "-filter=#{options[:filter]}" if options[:filter]
  cmd << '-filter-with-deps' if options[:filter_with_deps]
  cmd << '-ignore-signatures' if options[:ignore_signatures]
  cmd += Array(options[:keyring]).map { |x| "-keyring=#{x}" }
  cmd << '-with-installer' if options[:with_installer]
  cmd << '-with-sources' if options[:with_sources]
  cmd << '-with-udebs' if options[:with_udebs]
  cmd << name

  execute(cmd)
end

.mirror_list(options = {}) ⇒ Object



59
60
61
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 59

def self.mirror_list(options = {})
  something_list('mirror', options)
end

.mirror_show(name, options = {}) ⇒ Object



63
64
65
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 63

def self.mirror_show(name, options = {})
  something_show('mirror', name, options)
end

.mirror_update(name, options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 44

def self.mirror_update(name, options = {})
  cmd = aptly_command(options, 'mirror', 'update')
  cmd += parse_common_options(options)
  cmd << "-download-limit=#{options[:download_limit]}" if options[:download_limit]
  cmd << "-downloader=#{options[:downloader]}" if options[:downloader]
  cmd << '-force' if options[:force]
  cmd << '-ignore-checksums' if options[:ignore_checksums]
  cmd << '-ignore-signatures' if options[:ignore_signatures]
  cmd += Array(options[:keyring]).map { |x| "-keyring=#{x}" }
  cmd << "-max-tries=#{options[:max_tries]}" if options[:max_tries]
  cmd << '-skip-existing-packages' if options[:skip_existing_packages]
  cmd << name
  execute(cmd)
end

.publish_drop(distribution, prefix, options = {}) ⇒ Object



198
199
200
201
202
203
204
205
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 198

def self.publish_drop(distribution, prefix, options = {})
  cmd = aptly_command(options, 'publish', 'drop')
  cmd += parse_common_options(options)
  cmd << '-force-drop' if options[:force_drop]
  cmd << '-skip-cleanup' if options[:skip_cleanup]
  cmd << distribution << prefix
  execute(cmd)
end

.publish_list(options = {}) ⇒ Object



187
188
189
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 187

def self.publish_list(options = {})
  something_list('publish', options)
end

.publish_repo(names, prefix, options = {}) ⇒ Object



175
176
177
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 175

def self.publish_repo(names, prefix, options = {})
  publish_something('repo', names, prefix, options)
end

.publish_show(distribution, prefix, options = {}) ⇒ Object



191
192
193
194
195
196
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 191

def self.publish_show(distribution, prefix, options = {})
  cmd = aptly_command(options, 'publish', 'show', '-json')
  cmd += parse_common_options(options)
  cmd << distribution << prefix
  execute_and_parse(cmd)
end

.publish_snapshot(names, prefix, options = {}) ⇒ Object

Publish



171
172
173
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 171

def self.publish_snapshot(names, prefix, options = {})
  publish_something('snapshot', names, prefix, options)
end

.publish_switch(distribution, prefix, snapshots, options = {}) ⇒ Object



179
180
181
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 179

def self.publish_switch(distribution, prefix, snapshots, options = {})
  publish_somehow('switch', distribution, prefix, snapshots, options)
end

.publish_update(distribution, prefix, options = {}) ⇒ Object



183
184
185
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 183

def self.publish_update(distribution, prefix, options = {})
  publish_somehow('update', distribution, prefix, nil, options)
end

.repo_add(name, package_or_directory, options = {}) ⇒ Object



102
103
104
105
106
107
108
109
110
111
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 102

def self.repo_add(name, package_or_directory, options = {})
  cmd = aptly_command(options, 'repo', 'add')
  cmd += parse_common_options(options)
  cmd << '-force-replace' if options[:force_replace]
  cmd << '-remove-files' if options[:remove_files]
  cmd << name
  cmd << package_or_directory

  execute(cmd)
end

.repo_create(name, options = {}) ⇒ Object

Repo



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 88

def self.repo_create(name, options = {})
  cmd = aptly_command(options, 'repo', 'create')
  cmd += parse_common_options(options)
  cmd << "-comment=#{options[:comment]}" if options[:comment]
  cmd << "-component=#{options[:component]}" if options[:component]
  cmd << "-distribution=#{options[:distribution]}" if options[:distribution]
  cmd << "-uploaders-file=#{options[:uploaders_file]}" if options[:uploaders_file]
  cmd << name

  cmd += ['from', 'snapshot', options[:snapshot]] if options[:snapshot]

  execute(cmd)
end

.repo_drop(name, options = {}) ⇒ Object



130
131
132
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 130

def self.repo_drop(name, options = {})
  something_drop('repo', name, options)
end

.repo_list(options = {}) ⇒ Object



122
123
124
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 122

def self.repo_list(options = {})
  something_list('repo', options)
end

.repo_remove(name, package_query, options = {}) ⇒ Object



113
114
115
116
117
118
119
120
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 113

def self.repo_remove(name, package_query, options = {})
  cmd = aptly_command(options, 'repo', 'remove')
  cmd += parse_common_options(options)
  cmd << name
  cmd += Array(package_query)

  execute(cmd)
end

.repo_show(name, options = {}) ⇒ Object



126
127
128
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 126

def self.repo_show(name, options = {})
  something_show('repo', name, options)
end

.snapshot_create(name, from, options = {}) ⇒ Object

Snapshot



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 135

def self.snapshot_create(name, from, options = {})
  cmd = aptly_command(options, 'snapshot', 'create')
  cmd += parse_common_options(options)
  cmd << name

  case from
  when 'mirror'
    raise PuppetX::Aptly::Error, '`mirror` option should be defined' unless options[:mirror]

    cmd += ['from', 'mirror', options[:mirror]]
  when 'repo'
    raise PuppetX::Aptly::Error, '`repo` option should be defined' unless options[:repo]

    cmd += ['from', 'repo', options[:repo]]
  when 'empty'
    cmd += %w[empty]
  else
    raise PuppetX::Aptly::Error, '`from` argument must be one of: mirror, repo, empty'
  end

  execute(cmd)
end

.snapshot_drop(name, options = {}) ⇒ Object



166
167
168
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 166

def self.snapshot_drop(name, options = {})
  something_drop('snapshot', name, options)
end

.snapshot_list(options = {}) ⇒ Object



158
159
160
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 158

def self.snapshot_list(options = {})
  something_list('snapshot', options)
end

.snapshot_show(name, options = {}) ⇒ Object



162
163
164
# File 'lib/puppet_x/voxpupuli/aptly/cli_helper.rb', line 162

def self.snapshot_show(name, options = {})
  something_show('snapshot', name, options)
end