Class: Aptly::CliHelper
- Inherits:
-
Object
- Object
- Aptly::CliHelper
- Defined in:
- lib/cli_helper.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ CliHelper
constructor
A new instance of CliHelper.
- #mirror_create(name, url, distribution, options = {}) ⇒ Object
- #mirror_drop(name, options = {}) ⇒ Object
- #mirror_list(options = {}) ⇒ Object
- #mirror_update(name, options = {}) ⇒ Object
- #publish_drop(distribution, prefix, options = {}) ⇒ Object
- #publish_list(options = {}) ⇒ Object
- #publish_repo(names, prefix, options = {}) ⇒ Object
- #publish_snapshot(names, prefix, options = {}) ⇒ Object
- #publish_switch(distribution, prefix, snapshots, options = {}) ⇒ Object
- #publish_update(distribution, prefix, options = {}) ⇒ Object
- #repo_add(name, package_or_directory, options = {}) ⇒ Object
- #repo_create(name, options = {}) ⇒ Object
- #repo_drop(name, options = {}) ⇒ Object
- #repo_list(options = {}) ⇒ Object
- #repo_remove(name, package_query, options = {}) ⇒ Object
- #snapshot_create(name, from, options = {}) ⇒ Object
- #snapshot_drop(name, options = {}) ⇒ Object
- #snapshot_list(options = {}) ⇒ Object
Constructor Details
#initialize(options) ⇒ CliHelper
Returns a new instance of CliHelper.
10 11 12 13 14 15 |
# File 'lib/cli_helper.rb', line 10 def initialize() require 'json' require 'open3' @aptly = .delete(:aptly_binary_path) || 'aptly' end |
Instance Method Details
#mirror_create(name, url, distribution, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cli_helper.rb', line 17 def mirror_create(name, url, distribution, = {}) cmd = [@aptly, 'mirror', 'create'] cmd += () cmd << "-filter=#{[:filter]}" if [:filter] cmd << '-filter-with-deps' if [:filter_with_deps] cmd << '-force-architectures' if [:force_architectures] cmd << '-force-components' if [:force_components] cmd << '-ignore-signatures' if [:ignore_signatures] cmd += Array([:keyring]).map { |x| "-keyring=#{x}" } cmd << "-max-tries=#{[:max_tries]}" if [:max_tries] cmd << '-with-installer' if [:with_installer] cmd << '-with-sources' if [:with_sources] cmd << '-with-udebs' if [:with_udebs] cmd += [name, url, distribution] cmd += Array([:component]) execute(cmd) end |
#mirror_drop(name, options = {}) ⇒ Object
54 55 56 |
# File 'lib/cli_helper.rb', line 54 def mirror_drop(name, = {}) something_drop('mirror', name, ) end |
#mirror_list(options = {}) ⇒ Object
50 51 52 |
# File 'lib/cli_helper.rb', line 50 def mirror_list( = {}) something_list('mirror', ) end |
#mirror_update(name, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cli_helper.rb', line 35 def mirror_update(name, = {}) cmd = [@aptly, 'mirror', 'update'] cmd += () cmd << "-download-limit=#{[:download_limit]}" if [:download_limit] cmd << "-downloader=#{[:downloader]}" if [:downloader] cmd << '-force' if [:force] cmd << '-ignore-checksums' if [:ignore_checksums] cmd << '-ignore-signatures' if [:ignore_signatures] cmd += Array([:keyring]).map { |x| "-keyring=#{x}" } cmd << "-max-tries=#{[:max_tries]}" if [:max_tries] cmd << '-skip-existing-packages' if [:skip_existing_packages] cmd << name execute(cmd) end |
#publish_drop(distribution, prefix, options = {}) ⇒ Object
151 152 153 154 155 156 157 158 159 |
# File 'lib/cli_helper.rb', line 151 def publish_drop(distribution, prefix, = {}) cmd = [@aptly, 'publish', 'drop'] cmd += () cmd << '-force-drop' if [:force_drop] cmd << '-skip-cleanup' if [:skip_cleanup] cmd << distribution cmd << prefix execute(cmd) end |
#publish_list(options = {}) ⇒ Object
147 148 149 |
# File 'lib/cli_helper.rb', line 147 def publish_list( = {}) something_list('publish', ) end |
#publish_repo(names, prefix, options = {}) ⇒ Object
135 136 137 |
# File 'lib/cli_helper.rb', line 135 def publish_repo(names, prefix, = {}) publish_something('repo', names, prefix, ) end |
#publish_snapshot(names, prefix, options = {}) ⇒ Object
131 132 133 |
# File 'lib/cli_helper.rb', line 131 def publish_snapshot(names, prefix, = {}) publish_something('snapshot', names, prefix, ) end |
#publish_switch(distribution, prefix, snapshots, options = {}) ⇒ Object
139 140 141 |
# File 'lib/cli_helper.rb', line 139 def publish_switch(distribution, prefix, snapshots, = {}) publish_somehow('switch', distribution, prefix, snapshots, ) end |
#publish_update(distribution, prefix, options = {}) ⇒ Object
143 144 145 |
# File 'lib/cli_helper.rb', line 143 def publish_update(distribution, prefix, = {}) publish_somehow('update', distribution, prefix, nil, ) end |
#repo_add(name, package_or_directory, options = {}) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/cli_helper.rb', line 72 def repo_add(name, package_or_directory, = {}) cmd = [@aptly, 'repo', 'add'] cmd += () cmd << '-force-replace' if [:force_replace] cmd << '-remove-files' if [:remove_files] cmd << name cmd << package_or_directory execute(cmd) end |
#repo_create(name, options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cli_helper.rb', line 58 def repo_create(name, = {}) cmd = [@aptly, 'repo', 'create'] cmd += () cmd << "-comment=#{[:comment]}" if [:comment] cmd << "-component=#{[:component]}" if [:component] cmd << "-distribution=#{[:distribution]}" if [:distribution] cmd << "-uploaders-file=#{[:uploaders_file]}" if [:uploaders_file] cmd << name cmd += ['from', 'snapshot', [:snapshot]] if [:snapshot] execute(cmd) end |
#repo_drop(name, options = {}) ⇒ Object
96 97 98 |
# File 'lib/cli_helper.rb', line 96 def repo_drop(name, = {}) something_drop('repo', name, ) end |
#repo_list(options = {}) ⇒ Object
92 93 94 |
# File 'lib/cli_helper.rb', line 92 def repo_list( = {}) something_list('repo', ) end |
#repo_remove(name, package_query, options = {}) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/cli_helper.rb', line 83 def repo_remove(name, package_query, = {}) cmd = [@aptly, 'repo', 'remove'] cmd += () cmd << name cmd += Array(package_query) execute(cmd) end |
#snapshot_create(name, from, options = {}) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/cli_helper.rb', line 100 def snapshot_create(name, from, = {}) cmd = [@aptly, 'snapshot', 'create'] cmd += () cmd << name case from when 'mirror' raise Aptly::Error, '`mirror` option should be defined' unless [:mirror] cmd += ['from', 'mirror', [:mirror]] when 'repo' raise Aptly::Error, '`repo` option should be defined' unless [:repo] cmd += ['from', 'repo', [:repo]] when 'empty' cmd += %w[empty] else raise Aptly::Error, '`from` argument must be one of: mirror, repo, empty' end execute(cmd) end |
#snapshot_drop(name, options = {}) ⇒ Object
127 128 129 |
# File 'lib/cli_helper.rb', line 127 def snapshot_drop(name, = {}) something_drop('snapshot', name, ) end |
#snapshot_list(options = {}) ⇒ Object
123 124 125 |
# File 'lib/cli_helper.rb', line 123 def snapshot_list( = {}) something_list('snapshot', ) end |