aptly_cli 0.0.2 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzYwM2FhMDFmMTM2YWI5NjFkY2JmMDE4YjY4Yzk0Y2VmNDRmMmExOA==
4
+ ZWUyN2Q1NGNjNGY5MDNlMTcwNDI5ODdjMjg5ODcyMDY5NmFlOTY0Yg==
5
5
  data.tar.gz: !binary |-
6
- ZjQ5NjZlYTJkZGYxYzcxOWMwZjlkZTAxNjZjMTA1NmEyNDFiOGQ5ZQ==
6
+ MTFkNTg3MmU0NWI0ZTA5OTAxN2ZkZmJlYTVmZDY2ZTEzZDI0ZWYyMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTk3YTY3ODc2NWVjZjk1ZTRiYjZhODgzOTA3NjlhMTZlYmZlMWMzZDRmZTg4
10
- NzJmYzM2MDExMjEzODkwMWQ0MTI2NTlmNjllZTVlMzBkNmY5ZTQxMGQxMjY3
11
- NWZjNDMxNGViMTc5NzBiY2I4MGE2NzY4ZWViNDRiY2Y1Zjk4ZjE=
9
+ MDNmNDU0NGU1YTczYTc1NGNkNmEwMTA2ZmY4NzFkMWNiMmU2ZTVlMjJmZjg4
10
+ N2RiNTQ1MjQzOTRjMjFlNzZjZGZiNTQ3MWM3NDBkOTZmOWFjMmI1YTk2OTI2
11
+ MjUzYmIxODhiNzAxM2U1YTNhYTkyYzRjOWZiMjc4MmM3NTM4MWE=
12
12
  data.tar.gz: !binary |-
13
- M2QzOWUyZjdjNDZlNjZjOWJlMDFmNTlmZWNkNWFjODVlY2I5OTkxZjY0OTcx
14
- ZGM0M2RhYmNlMzNhZGMwMjNiNmNkOWQ4MTVmMmIxY2RjYmZmMDNkMDA5ZWM2
15
- OTk0M2EwZWY4N2Q4ZWZhNDEzYmZlMDZiOTg2NjNiODRkYzQzZjE=
13
+ NzdmZjI0N2M5NzFlMTdiNzI2MDBjNjFiNWYyNTExYjI2OGI0YWY2YTZjMjVm
14
+ NWI4ZGI2OTE5ZWUzZjg3NWUzMjQ4MjBhYTgwNDI2NzY5YzkwYjRhMWY0ZTgy
15
+ M2M5NDkxNjJjYjFlMDI2YjE0Nzk1YjFlZDI3OWRmNjk1NTk1Mjk=
data/README.md CHANGED
@@ -2,15 +2,13 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/sepulworld/aptly_cli.svg)](https://travis-ci.org/sepulworld/aptly_cli)
4
4
 
5
- A command line interace to execute Aptly commands againts a remote Aptly API server. Aptly-cli will allow you to interact with the repo, snapshot, publish, packages, graph and version API endpoints of your Aptly server.
5
+ A command line interace to execute Aptly commands againts remote Aptly API servers. Aptly-cli will allow you to interact with the file, repo, snapshot, publish, packages, graph and version API endpoints of your Aptly server.
6
6
 
7
7
  ## Installation
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- ```ruby
12
- gem 'aptly_cli'
13
- ```
11
+ $ ruby gem 'aptly_cli'
14
12
 
15
13
  And then execute:
16
14
 
@@ -22,62 +20,121 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- ### aptly-cli file [options]
23
+ ### aptly-cli file_list [options]
24
+
25
+ NAME:
26
+
27
+ file_list
28
+
29
+ SYNOPSIS:
30
+
31
+ aptly-cli file_list [options]
26
32
 
27
33
  DESCRIPTION:
28
34
 
29
- All uploaded files are stored under rootDir/upload directory (see your Aptly configuration). This directory would be created automatically if it doesn’t exist. Uploaded files are grouped by directories to support concurrent uploads from multiple package sources. Local repos add API can operate on directory (adding all files from directory) or on individual package files. By default, all successfully added package files would be removed.
35
+ List all directories that contain uploaded files
30
36
 
31
37
  EXAMPLES:
32
38
 
33
- # List of directories or files
34
- aptly-cli file --list /
35
- geoipupdate_2.0.0_amd64.deb
36
- geoipupdate_2.0.0_i386.deb
37
- mongo
38
- mongodb-mms-monitoring-agent_latest_i386.deb
39
- redis
40
- redis-server_2.8.3_amd64-cc1.deb
41
- test
42
- xsp_2.11.0.0-git-master-04062013_i386.deb
43
-
44
- # Upload file to a directory
45
- aptly-cli file --upload /tmp/redis/test_1.0_amd64.deb --dest_uri /redis
46
- test/test_1.0_amd64.deb
47
-
48
- # Delete file or directory
49
- aptly-cli file --delete /redis/test_1.0_amd64.deb
50
- {}
39
+ # List all directories for file uploads
40
+ aptly-cli file_list
41
+ # List all files in redis directory
42
+ aptly-cli file_list --directory redis
51
43
 
52
44
  OPTIONS:
53
45
 
54
- --list URI_FILE_PATH
55
- URI path to list files
46
+ --directory DIRECTORY
47
+ Directory to list on server
56
48
 
57
- --upload LOCAL_FILE_PATH/PACKAGE
58
- Path to package to upload
49
+ ### aptly-cli file_upload [options]
50
+
51
+ NAME:
59
52
 
60
- --dest_uri URI_FILE_PATH
61
- URI path to directory to upload into
53
+ file_upload
62
54
 
63
- --delete URI_FILE_PATH/PACKAGE
64
- URI path to directory to delete or specific package
55
+ SYNOPSIS:
65
56
 
66
- ### aptly-cli repo [options]
57
+ aptly-cli file_upload [options]
67
58
 
68
- TODO
59
+ DESCRIPTION:
69
60
 
70
- ### aptly-cli snapshot [options]
61
+ File upload
71
62
 
72
- TODO
63
+ EXAMPLES:
73
64
 
74
- ### aptly-cli publish [options]
65
+ # upload file package.deb to apt server inside directory /aptlyserver_directory/
66
+ aptly-cli file_upload --upload /local/copy/of/package.deb --directory /aptlyserver_directory/
75
67
 
76
- TODO
68
+ OPTIONS:
69
+
70
+ --directory DIRECTORY
71
+ Directory to load packages into
72
+
73
+ --upload UPLOAD
74
+ Package(s) to upload
75
+
76
+ ### aptly-cli file_delete [options]
77
+
78
+ NAME:
79
+
80
+ file_delete
81
+
82
+ SYNOPSIS:
83
+
84
+ aptly-cli file_delete [options]
85
+
86
+ DESCRIPTION:
87
+
88
+ File delete
89
+
90
+ EXAMPLES:
77
91
 
92
+ # Delete package redis-server found in redis upload directory
93
+ aptly-cli file_delete --target /redis/redis-server_2.8.3_i386-cc1.deb
94
+
95
+ OPTIONS:
96
+
97
+ --target TARGET
98
+ Path to directory or specific package to delete
99
+
100
+ ### aptly-cli repo_create [options]
101
+
102
+ NAME:
103
+
104
+ repo_create
105
+
106
+ SYNOPSIS:
107
+
108
+ aptly-cli repo_create [options]
109
+
110
+ DESCRIPTION:
111
+
112
+ Create a new repository, requires --name
113
+
114
+ EXAMPLES:
115
+
116
+ # creat repo
117
+ aptly-cli repo_create --name megatronsoftware
118
+ # creat repo with distribution set to 'trusty'
119
+ aptly-cli repo_create --name megatronsoftware --default_distribution trusty
120
+
121
+ OPTIONS:
122
+
123
+ --name NAME
124
+ Local repository name, required
125
+
126
+ --comment COMMENT
127
+ Text describing local repository for the user
128
+
129
+ --default_distribution DISTRIBUTION
130
+ Default distribution when publishing from this local repo
131
+
132
+
133
+ --default_component COMPONENT
134
+ Default component when publishing from this local repo
78
135
  ### aptly-cli package [options]
79
136
 
80
- TODO
137
+ functions, fixtures, tests done. Need to add to bin/aptly-cli and document
81
138
 
82
139
  ### aptly-cli graph [options]
83
140
 
data/bin/aptly-cli CHANGED
@@ -4,82 +4,271 @@ require 'rubygems'
4
4
  require 'commander/import'
5
5
  require 'aptly_cli'
6
6
 
7
- program :version, '0.0.1'
7
+ program :version, '0.1.1'
8
8
  program :description, 'Aptly repository API client'
9
9
 
10
- command :file do |c|
11
- c.syntax = 'aptly-cli file [options]'
12
- c.summary = 'Upload package files temporarily to aptly service'
13
-
14
- c.description = 'All uploaded files are stored under <rootDir>/upload directory (see configuration). This directory would be created automatically if it doesn’t exist. Uploaded files are grouped by directories to support concurrent uploads from multiple package sources. Local repos add API can operate on directory (adding all files from directory) or on individual package files. By default, all successfully added package files would be removed.'
10
+ command :file_list do |c|
11
+ c.syntax = 'aptly-cli file_list [options]'
12
+ c.summary = 'List all directories that contain uploaded files'
13
+ c.description = 'List all directories'
14
+ c.example 'List all directories for file uploads', 'aptly-cli file_list'
15
+ c.option '--directory DIRECTORY', String, 'Directory to list packages on server'
16
+ c.action do |args, options|
17
+ aptly_command = AptlyCli::AptlyFile.new
18
+ if options.directory
19
+ puts aptly_command.file_get(options.directory)
20
+ else
21
+ puts aptly_command.file_dir()
22
+ end
23
+ end
24
+ end
25
+
26
+ command :file_upload do |c|
27
+ c.syntax = 'aptly-cli file_upload [options]'
28
+ c.summary = 'Parameter --directory is upload directory name. Directory would be created if it doesn’t exist.'
29
+ c.description = 'File upload'
30
+ c.example 'description', 'aptly-cli file_upload --upload /local/copy/of/package.deb --directory /aptlyserver_directory/'
31
+ c.option '--directory DIRECTORY', String, 'Directory to load packages into'
32
+ c.option '--upload UPLOAD', String, 'Package(s) to upload'
33
+ c.action do |args, options|
34
+ aptly_command = AptlyCli::AptlyFile.new
35
+ puts aptly_command.file_post(:file_uri => options.directory, :package => options.upload, :local_file => options.upload)
36
+ end
37
+ end
15
38
 
16
- c.example 'List of directories or files', 'aptly-cli file --list / or aptly-cli file --list /redis'
17
- c.example 'Upload file to a directory', 'aptly-cli file --upload /tmp/redis/test_1.0_amd64.deb --dest_uri /redis'
18
- c.example 'Delete file or directory', 'aptly-cli file --delete /test/test_1.0_amd64.deb'
19
- c.option '--list URI_FILE_PATH', String, 'URI path to list files'
20
- c.option '--upload LOCAL_FILE_PATH/PACKAGE', String, 'Path to package to upload'
21
- c.option '--dest_uri URI_FILE_PATH', String, 'URI path to directory to upload into'
22
- c.option '--delete URI_FILE_PATH/PACKAGE', String, 'URI path to directory to delete or specific package'
39
+ command :file_delete do |c|
40
+ c.syntax = 'aptly-cli file_delete [options]'
41
+ c.summary = 'Deletes all files in upload directory and directory itself. Or delete just a file'
42
+ c.description = 'File delete'
43
+ c.example 'Delete package redis-server found in redis upload directory', 'aptly-cli file_delete --target /redis/redis-server_2.8.3_i386-cc1.deb'
44
+ c.option '--target TARGET', String, 'Path to directory or specific package to delete'
23
45
  c.action do |args, options|
24
46
  aptly_command = AptlyCli::AptlyFile.new
25
- puts aptly_command.file_get(options.list) if options.list
26
- puts aptly_command.file_post(:file_uri => options.dest_uri, :package => options.upload, :local_file => options.upload) if options.upload and options.dest_uri
27
- puts aptly_command.file_delete(options.delete) if options.delete
47
+ puts aptly_command.file_delete(options.target)
48
+ end
49
+ end
50
+
51
+ command :repo_create do |c|
52
+ c.syntax = 'aptly-cli repo_create [options]'
53
+ c.summary = 'Create a new repository, requires --name'
54
+ c.description = 'Create a new repository, requires --name'
55
+ c.example 'create repo', 'aptly-cli repo_create --name meagasoftware'
56
+ c.example 'creat repo with distribution set to "trusty"', 'aptly-cli repo_create --name megatronsoftware --default_distribution trusty'
57
+ c.option '--name NAME', String, 'Local repository name, required'
58
+ c.option '--comment COMMENT', String, 'Text describing local repository for the user'
59
+ c.option '--default_distribution DISTRIBUTION', String, 'Default distribution when publishing from this local repo'
60
+ c.option '--default_component COMPONENT', String, 'Default component when publishing from this local repo'
61
+ c.action do |args, options|
62
+ puts options.name
63
+ aptly_command = AptlyCli::AptlyRepo.new
64
+ repo_options = { :name => options.name.to_s,
65
+ :comment => options.comment.to_s,
66
+ :DefaultDistribution => options.default_distribution.to_s,
67
+ :DefaultComponent => options.default_component.to_s }
68
+ puts aptly_command.repo_create(repo_options)
69
+ end
70
+ end
71
+
72
+ command :repo_delete do |c|
73
+ c.syntax = 'aptly-cli repo_delete [options]'
74
+ c.summary = 'Delete a local repository, requires --name'
75
+ c.description = 'Delete a local repository, requires --name'
76
+ c.example 'description', 'aptly-cli repo_delete --name megatronsoftware'
77
+ c.option '--name NAME', String, 'Local repository name, required'
78
+ c.option '--force'
79
+ c.action do |args, options|
80
+ aptly_command = AptlyCli::AptlyRepo.new
81
+ repo_options = { :name => options.name.to_s,
82
+ :force => options.force.to_s }
83
+ puts aptly_command.repo_delete(repo_options)
84
+ end
85
+ end
86
+
87
+ command :repo_edit do |c|
88
+ c.syntax = 'aptly-cli repo_edit [options]'
89
+ c.summary = 'Edit a local repository metadata, requires --name'
90
+ c.description = 'Edit a local repository metadata, requires --name'
91
+ c.example 'description', 'aptly-cli repo_edit --name megatronsoftware --default_distribution trusty'
92
+ c.option '--name NAME', String, 'Local repository name, required'
93
+ c.option '--comment COMMENT', String, 'Edit repository comment'
94
+ c.option '--default_distribution DISTRIBUTION', String, 'Edit DefaultDistribution for repo'
95
+ c.option '--default_component COMPONENT', String, 'Edit DefaultComponent for repo'
96
+ c.action do |args, options|
97
+ aptly_command = AptlyCli::AptlyRepo.new
98
+ if options.default_distribution
99
+ repo_options = { :DefaultDistribution => options.default_distribution.to_s }
100
+ end
101
+ if options.default_component
102
+ repo_options = { :DefaultComponent => options.default_component.to_s }
103
+ end
104
+ if options.comment
105
+ repo_options = { :Comment => options.comment.to_s }
106
+ end
107
+ puts aptly_command.repo_edit(options.name.to_s, repo_options)
108
+ end
109
+ end
110
+
111
+ command :repo_list do |c|
112
+ c.syntax = 'aptly-cli repo_list [options]'
113
+ c.summary = 'Show list of currently available local repositories'
114
+ c.description = 'Show list of currently available local repositories'
115
+ c.example 'description', 'aptly-cli repo_list'
116
+ c.action do |args, options|
117
+ aptly_command = AptlyCli::AptlyRepo.new
118
+ puts aptly_command.repo_list()
119
+ end
120
+ end
121
+
122
+ command :repo_package_query do |c|
123
+ c.syntax = 'aptly-cli repo_package_query [options]'
124
+ c.summary = 'List all packages in local repository or perform search on repository contents and return result., requires --name'
125
+ c.description = 'List all packages or search on repo contents, requires --name'
126
+ c.example 'description', 'aptly-cli repo_package_query --name megatronsoftware -query geoipupdate'
127
+ c.option '--name NAME', String, 'Local repository name, required'
128
+ c.option '--query QUERY', String, 'Package to query'
129
+ c.option '--with_deps', 'Return results with dependencies'
130
+ c.option '--format FORMAT', String, 'Format type to return, compact by default. "details" is an option'
131
+ c.action do |args, options|
132
+ aptly_command = AptlyCli::AptlyRepo.new
133
+ if options.query
134
+ repo_options = { :name => options.name.to_s, :query => options.query.to_s }
135
+ elsif options.with_deps and options.query.nil?
136
+ repo_options = { :name => options.name.to_s, :with_deps => options.with_deps.to_s }
137
+ elsif options.format and options.query.nil?
138
+ repo_options = { :name => options.name.to_s, :format => options.format.to_s }
139
+ else
140
+ repo_options = { :name => options.name.to_s }
141
+ end
142
+ puts aptly_command.repo_package_query(repo_options)
143
+ end
144
+ end
145
+
146
+ command :repo_upload do |c|
147
+ c.syntax = 'aptly-cli repo_upload [options]'
148
+ c.summary = 'Import packages from files (uploaded using File Upload API) to the local repository. If directory specified, aptly would discover package files automatically.
149
+
150
+ Adding same package to local repository is not an error.
151
+
152
+ By default aptly would try to remove every successfully processed file and directory :dir (if it becomes empty after import).'
153
+ c.description = 'Import packages from files'
154
+ c.example 'description', 'aptly-cli repo_upload --name rocksoftware --dir rockpackages --noremove'
155
+ c.option '--name NAME', String, 'Local repository name, required'
156
+ c.option '--dir DIR', String, 'Directory where packages are stored via File API'
157
+ c.option '--file FILE', String, 'Specific file to upload, if not provided the entire directory of files will be uploaded'
158
+ c.option '--noremove', 'Flag to not remove any files that were uploaded via File API after repo upload'
159
+ c.option '--forcereplace', 'flag to replace file(s) already in the repo'
160
+ c.action do |args, options|
161
+ aptly_command = AptlyCli::AptlyRepo.new
162
+ puts aptly_command.repo_upload({ :name => options.name, :dir => options.dir,
163
+ :file => options.file, :noremove => options.noremove,
164
+ :forcereplace => options.forcereplace })
165
+ end
166
+ end
167
+
168
+ command :repo_show do |c|
169
+ c.syntax = 'aptly-cli repo_show [options]'
170
+ c.summary = 'Returns basic information about local repository'
171
+ c.description = 'Returns basic information about local repository, require --name'
172
+ c.example 'description', 'aptly-cli repo_show --name megatronsoftware'
173
+ c.option '--name NAME', String, 'Local repository name, required'
174
+ c.action do |args, options|
175
+ aptly_command = AptlyCli::AptlyRepo.new
176
+ puts aptly_command.repo_show(options.name)
28
177
  end
29
178
  end
30
179
 
31
- command :repo do |c|
32
- c.syntax = 'aptly-cli repo [options]'
33
- c.summary = ''
34
- c.description = ''
35
- c.example 'description', 'command example'
36
- c.option '--some-switch', 'Some switch that does something'
180
+ command :publish_drop do |c|
181
+ c.syntax = 'aptly-cli publish_drop [options]'
182
+ c.summary = 'Delete published repository, clean up files in published directory.'
183
+ c.description = 'Delete published repository'
184
+ c.example 'Delete publish repository called ', 'aptly-cli repo_list'
185
+ c.option '--prefix', String, 'prefix, optional'
186
+ c.option '--distribution', String, 'distribution'
187
+ c.option '--force', 'force published repository removal even if component cleanup fails'
37
188
  c.action do |args, options|
38
- # Do something or c.when_called Aptly-cli::Commands::Repo
189
+ aptly_command = AptlyCli::AptlyPublish.new
190
+ puts aptly_command.publish_drop({ :prefix => options.prefix, :distribution => options.distribution, :force => options.force })
39
191
  end
40
192
  end
41
193
 
42
- command :snapshot do |c|
43
- c.syntax = 'aptly-cli snapshot [options]'
44
- c.summary = ''
45
- c.description = ''
46
- c.example 'description', 'command example'
47
- c.option '--some-switch', 'Some switch that does something'
194
+ command :publish_list do |c|
195
+ c.syntax = 'aptly-cli publish_list [options]'
196
+ c.summary = 'List published repositories.'
197
+ c.description = 'List published repositories.'
198
+ c.example 'List published repositories', 'aptly-cli publish_list'
48
199
  c.action do |args, options|
49
- # Do something or c.when_called Aptly-cli::Commands::Snapshot
200
+ aptly_command = AptlyCli::AptlyPublish.new
201
+ puts aptly_command.publish_list()
50
202
  end
51
203
  end
52
204
 
53
- command :publish do |c|
54
- c.syntax = 'aptly-cli publish [options]'
55
- c.summary = ''
56
- c.description = ''
57
- c.example 'description', 'command example'
58
- c.option '--some-switch', 'Some switch that does something'
205
+ command :publish_repo do |c|
206
+ c.syntax = 'aptly-cli publish_repo [options]'
207
+ c.summary = 'Publish local repository or snapshot under specified prefix. Storage might be passed in prefix as well, e.g. s3:packages/. To supply empty prefix, just remove last part (POST /api/publish/:prefix/<:repos>or<:snapshots>'
208
+ c.description = 'Publish local repository or snapshot under specified prefix'
209
+ c.example 'description', 'aptly-cli publish_repo --sourcekind local --name precise/megatronsoftware trusty/rocksoftware22 --architectures i386 amd64'
210
+ c.example 'description', 'aptly-cli publish_repo --sourcekind local --name megatronsoftware --architectures i386 amd64 --forceoverwrite true'
211
+ c.example 'description', 'aptly-cli publish_repo --sourcekind snapshot --name precise/rocksoftware300 --label test_snap'
212
+ c.example 'description', 'aptly-cli publish_repo --sourcekind snapshot --name precise/rocksoftware300 --origin testorigin'
213
+ c.example 'publish repo with signing keyring', 'aptly-cli publish_repo --sourcekind snapshot --name precise/rocksoftware300 --origin testorigin --gpg_keyring /etc/apt/trustdb.gpg'
214
+ c.option '--name NAME', String, 'Local repository name with optional component, required'
215
+ c.option '--sourcekind SOURCEKIND', String, 'Local for local repositories and snapshot for snapshots, required'
216
+ c.option '--distribution DISTRIBUTION', String, 'Distribution name, if missing aptly would try to guess from sources'
217
+ c.option '--label LABEL', String, 'value of Label: field in published repository stanza'
218
+ c.option '--origin ORIGIN', String, 'value of Origin: field in published repository stanza'
219
+ c.option '--forceoverwrite FORCEOVERWRITE', String, 'when publishing, overwrite files in pool/ directory without notice'
220
+ c.option '--architectures ARCHITECTURES', String, 'override list of published architectures'
221
+ c.option '--gpg_skip', 'Don’t sign published repository'
222
+ c.option '--gpg_batch', 'should be set if passing passphrase'
223
+ c.option '--gpg_key GPGKEY', String, 'gpg key name (local to aptly server/user)'
224
+ c.option '--gpg_keyring GPGKEYRING', String, 'gpg keyring filename (local to aptly server/user)'
225
+ c.option '--gpg_secret_keyring GPGSECRET', String, 'gpg secret keyring filename (local to aptly server/user)'
226
+ c.option '--gpg_passphrase GPGPASS', String, 'gpg key passphrase (if using over http, would be transmitted in clear text!)'
227
+ c.option '--gpg_passphrase_file GPGPASSFILE', String, 'gpg passphrase file (local to aptly server/user)'
59
228
  c.action do |args, options|
60
- # Do something or c.when_called Aptly-cli::Commands::Publish
229
+ aptly_command = AptlyCli::AptlyPublish.new
230
+ puts aptly_command.publish_repo(options.name, { :sourcekind => options.sourcekind, :label => options.label, :distribution => options.distribution,
231
+ :origin => options.origin, :forceoverwrite => options.forceoverwrite,
232
+ :architectures => options.architectures, :skip => options.gpg_skip, :batch => options.gpg_batch,
233
+ :gpgKey => options.gpg_key, :keyring => options.gpg_keyring, :secretKeyring => options.gpg_secret_keyring,
234
+ :passphrase => options.gpg_passphrase, :passphraseFile => options.gpg_passphrase_file })
61
235
  end
62
236
  end
63
237
 
64
- command :package do |c|
65
- c.syntax = 'aptly-cli package [options]'
66
- c.summary = ''
67
- c.description = ''
68
- c.example 'description', 'command example'
69
- c.option '--some-switch', 'Some switch that does something'
238
+ command :publish_update do |c|
239
+ c.syntax = 'aptly-cli publish_update [options]'
240
+ c.summary = 'Update published repository. If local repository has been published, published repository would be updated to match local repository contents. If snapshots have been been published, it is possible to switch each component to new snapshot'
241
+ c.description = 'Update published repository'
242
+ c.example 'description', 'aptly-cli publish_update --sourcekind snapshot --name precise/rocksoftware300 --origin testorigin'
243
+ c.option '--prefix PREFIX', String, 'Publishing prefix, default root'
244
+ c.option '--distribution DISTRIBUTION', String, 'Distribution name'
245
+ c.option '--snapshots SNAPSHOTS', String, 'When updating published snapshots, list of objects component/name seperated by space'
246
+ c.option '--forceoverwrite FORCEOVERWRITE', String, 'When publishing, overwrite files in pool/ directory without notice'
247
+ c.option '--gpg_skip', 'Don’t sign published repository'
248
+ c.option '--gpg_batch', 'should be set if passing passphrase'
249
+ c.option '--gpg_key GPGKEY', String, 'gpg key name (local to aptly server/user)'
250
+ c.option '--gpg_keyring GPGKEYRING', String, 'gpg keyring filename (local to aptly server/user)'
251
+ c.option '--gpg_secret_keyring GPGSECRET', String, 'gpg secret keyring filename (local to aptly server/user)'
252
+ c.option '--gpg_passphrase GPGPASS', String, 'gpg key passphrase (if using over http, would be transmitted in clear text!)'
253
+ c.option '--gpg_passphrase_file GPGPASSFILE', String, 'gpg passphrase file (local to aptly server/user)'
70
254
  c.action do |args, options|
71
- # Do something or c.when_called Aptly-cli::Commands::Package
255
+ aptly_command = AptlyCli::AptlyPublish.new
256
+ puts aptly_command.publish_update(options.snapshots, { :prefix => options.prefix, :distribution => options.distribution, :forceoverwrite => options.forceoverwrite,
257
+ :skip => options.gpg_skip, :batch => options.gpg_batch, :gpgKey => options.gpg_key,
258
+ :keyring => options.gpg_keyring, :secretKeyring => options.gpg_secret_keyring,
259
+ :passphrase => options.gpg_passphrase, :passphraseFile => options.gpg_passphrase_file })
72
260
  end
73
261
  end
74
262
 
75
263
  command :graph do |c|
76
264
  c.syntax = 'aptly-cli graph [options]'
77
- c.summary = ''
78
- c.description = ''
79
- c.example 'description', 'command example'
80
- c.option '--some-switch', 'Some switch that does something'
265
+ c.summary = 'Download a graph of repository layout. Current options are "svg" and "png"'
266
+ c.description = 'Download an svg or png graph of repository layout'
267
+ c.example 'description', 'aptly-cli graph png > ~/repo_graph.png'
268
+ c.option '--type GRAPH_TYPE', String, 'Type of graph to download, present options are png or svg'
81
269
  c.action do |args, options|
82
- # Do something or c.when_called Aptly-cli::Commands::Graph
270
+ aptly_command = AptlyCli::AptlyMisc.new
271
+ puts aptly_command.get_graph(options.type)
83
272
  end
84
273
  end
85
274
 
@@ -88,7 +277,8 @@ command :version do |c|
88
277
  c.description = 'Display aptly server version'
89
278
  c.example 'description', 'aptly-cli version'
90
279
  c.action do |args, options|
91
- # Do something or c.when_called Aptly-cli::Commands::Version
280
+ aptly_command = AptlyCli::AptlyMisc.new
281
+ puts aptly_command.get_version()
92
282
  end
93
283
  end
94
284
 
@@ -1,3 +1,3 @@
1
1
  module AptlyCli
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/aptly_file.rb CHANGED
@@ -15,11 +15,16 @@ module AptlyCli
15
15
  def initialize(file_uri=nil, package=nil, local_file_path=nil)
16
16
  end
17
17
 
18
+ def file_dir()
19
+ uri = "/files"
20
+ self.class.get uri
21
+ end
22
+
18
23
  def file_get(file_uri)
19
24
  if file_uri == "/"
20
25
  uri = "/files"
21
26
  else
22
- uri = "/files" + file_uri
27
+ uri = "/files/" + file_uri
23
28
  end
24
29
 
25
30
  self.class.get uri
data/lib/aptly_misc.rb ADDED
@@ -0,0 +1,26 @@
1
+ require "aptly_cli/version"
2
+ require "aptly_load"
3
+ require "httmultiparty"
4
+ require "json"
5
+
6
+ module AptlyCli
7
+ class AptlyMisc
8
+
9
+ include HTTMultiParty
10
+
11
+ # Load aptly-cli.conf and establish base_uri
12
+ config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf")
13
+ base_uri "http://#{config[:server]}:#{config[:port]}/api"
14
+
15
+ def get_graph(extension)
16
+ uri = "/graph.#{extension}"
17
+ self.class.get(uri)
18
+ end
19
+
20
+ def get_version()
21
+ uri = "/version"
22
+ self.class.get(uri)
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require "aptly_cli/version"
2
+ require "aptly_load"
3
+ require "httmultiparty"
4
+ require "json"
5
+
6
+ module AptlyCli
7
+ class AptlyPackage
8
+
9
+ include HTTMultiParty
10
+
11
+ # Load aptly-cli.conf and establish base_uri
12
+ config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf")
13
+ base_uri "http://#{config[:server]}:#{config[:port]}/api"
14
+
15
+ def package_show(package_key)
16
+ uri = "/packages/#{package_key}"
17
+ self.class.get(uri)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,137 @@
1
+ require "aptly_cli/version"
2
+ require "aptly_load"
3
+ require "httmultiparty"
4
+ require "json"
5
+
6
+ module AptlyCli
7
+ class AptlyPublish
8
+
9
+ include HTTMultiParty
10
+
11
+ # Load aptly-cli.conf and establish base_uri
12
+ config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf")
13
+ base_uri "http://#{config[:server]}:#{config[:port]}/api"
14
+
15
+ @@available_gpg_options = [ :skip, :batch, :gpgKey, :keyring, :secretKeyring,
16
+ :passphrase, :passphraseFile ]
17
+
18
+ @@available_options_for_repo = [ :distribution, :label, :origin, :forceoverwrite, :architectures, ]
19
+ @@available_options_for_update = [ :prefix, :distribution, :forceoverwrite, ]
20
+
21
+ def publish_drop(publish_options={})
22
+ uri = "/publish"
23
+
24
+ if publish_options[:prefix]
25
+ uri = uri + "/#{publish_options[:prefix]}"
26
+ end
27
+
28
+ uri = uri + "/#{publish_options[:distribution]}"
29
+
30
+ if publish_options[:force] == true
31
+ uri = uri + "?force=1"
32
+ end
33
+
34
+ self.class.delete(uri)
35
+ end
36
+
37
+ def publish_list()
38
+ uri = "/publish"
39
+ self.class.get(uri)
40
+ end
41
+
42
+ def parse_names(names, label_type)
43
+ repos_to_publish = Array.new
44
+ if names.is_a? String
45
+ names = [names]
46
+ end
47
+
48
+ names.each do |k|
49
+ if k.include? "/"
50
+ repo, component = k.split("/")
51
+ repos_to_publish << {"#{label_type}" => component, "Component" => repo }
52
+ else
53
+ repos_to_publish << {"#{label_type}" => k}
54
+ end
55
+ end
56
+
57
+ return repos_to_publish
58
+ end
59
+
60
+ def parse_gpg_options(available_gpg_options, publish_options)
61
+ gpg_options = {}
62
+ available_gpg_options.each do |option|
63
+ if publish_options.has_key?(option)
64
+ unless publish_options[option].nil?
65
+ gpg_options.merge!("#{option.capitalize}" => "#{publish_options[option]}")
66
+ end
67
+ end
68
+ end
69
+
70
+ return gpg_options
71
+ end
72
+
73
+ def build_body(available_options_for_func, publish_options, body)
74
+ available_options_for_func.each do |option|
75
+ if publish_options.has_key?(option)
76
+ body[option.capitalize] = publish_options[option]
77
+ end
78
+ end
79
+
80
+ return body
81
+ end
82
+
83
+ def publish_repo(names, publish_options={})
84
+ uri = "/publish"
85
+ label_type = "Name"
86
+ repos = self.parse_names(names, label_type)
87
+ gpg_options = self.parse_gpg_options(@@available_gpg_options, publish_options)
88
+
89
+ @body = {}
90
+ @body[:SourceKind] = publish_options[:sourcekind]
91
+ @body[:Sources] = repos
92
+ build_body(@@available_options_for_repo, publish_options, @body)
93
+
94
+ unless gpg_options.empty?
95
+ @body[:Signing] = gpg_options
96
+ end
97
+
98
+ if publish_options[:prefix]
99
+ uri = uri + publish_options[:prefix]
100
+ end
101
+
102
+ @body_json = @body.to_json
103
+
104
+ self.class.post(uri, :headers => { 'Content-Type'=>'application/json' }, :body => @body_json)
105
+
106
+ end
107
+
108
+ def publish_update(snapshots=[], publish_options={})
109
+ uri = "/publish"
110
+ label_type = "Snapshots"
111
+ gpg_options = self.parse_gpg_options(@@available_gpg_options, publish_options)
112
+ @body = {}
113
+
114
+ unless snapshots.nil?
115
+ snapshots = self.parse_names(snapshots, label_type)
116
+ @body[:Snapshots] = snapshots
117
+ end
118
+
119
+ build_body(@@available_options_for_update, publish_options, @body)
120
+
121
+ if publish_options[:prefix]
122
+ uri = uri + "/#{publish_options[:prefix]}"
123
+ else
124
+ uri = uri + "/"
125
+ end
126
+
127
+ uri = uri + "/#{publish_options[:distribution]}"
128
+
129
+ @body_json = @body.to_json
130
+
131
+ self.class.put(uri, :headers => { 'Content-Type'=>'application/json' }, :body => @body_json)
132
+
133
+ end
134
+
135
+
136
+ end
137
+ end
data/lib/aptly_repo.rb ADDED
@@ -0,0 +1,144 @@
1
+ require "aptly_cli/version"
2
+ require "aptly_load"
3
+ require "httmultiparty"
4
+ require "json"
5
+
6
+ module AptlyCli
7
+ class AptlyRepo
8
+
9
+ include HTTMultiParty
10
+
11
+ # Load aptly-cli.conf and establish base_uri
12
+ config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf")
13
+ base_uri "http://#{config[:server]}:#{config[:port]}/api"
14
+
15
+ def repo_create(repo_options = {:name => nil, :comment => nil, :DefaultDistribution => nil, :DefaultComponent => nil})
16
+ uri = "/repos"
17
+ name = repo_options[:name]
18
+ comment = repo_options[:comment]
19
+ default_distribution = repo_options[:DefaultDistribution]
20
+ default_component = repo_options[:DefaultComponent]
21
+
22
+ self.class.post(uri, :query => { 'Name' => name, 'Comment' => comment, 'DefaultDistribution' => default_distribution, 'DefaultComponent' => default_component }.to_json, :headers => {'Content-Type'=>'application/json'})
23
+ end
24
+
25
+ def repo_delete(repo_options = {:name => nil, :force => nil})
26
+ uri = "/repos/" + repo_options[:name]
27
+
28
+ if repo_options[:force] == true
29
+ uri = uri + "?force=1"
30
+ end
31
+
32
+ self.class.delete(uri)
33
+ end
34
+
35
+ def repo_edit(name, repo_options = { k => v })
36
+ repo_option = String.new
37
+ repo_value = String.new
38
+
39
+ if name == nil
40
+ raise ArgumentError.new('Must pass a repository name')
41
+ else
42
+ uri = "/repos/" + name
43
+ end
44
+
45
+ repo_options.each do |k, v|
46
+ repo_option = k
47
+ repo_value = v
48
+ end
49
+
50
+ self.class.put(uri, :query => { repo_option => repo_value }.to_json, :headers => {'Content-Type'=>'application/json'})
51
+ end
52
+
53
+ def repo_list()
54
+ uri = "/repos"
55
+
56
+ self.class.get(uri)
57
+ end
58
+
59
+ def repo_package_query(repo_options = {:name => nil, :query => nil, :withdeps => false, :format => nil})
60
+ if repo_options[:name] == nil
61
+ raise ArgumentError.new('Must pass a repository name')
62
+ else
63
+ uri = "/repos/" + repo_options[:name] + "/packages"
64
+ end
65
+
66
+ if repo_options[:query]
67
+ uri = uri + "?q=" + repo_options[:query]
68
+ if repo_options[:withdeps] or repo_options[:format]
69
+ puts "When specifiying specific package query, other options are invalid."
70
+ end
71
+ elsif repo_options[:format]
72
+ uri = uri + "?format=#{repo_options[:format]}"
73
+ elsif repo_options[:withdeps] == true
74
+ uri = uri + "?withDeps=1"
75
+ end
76
+
77
+ self.class.get uri
78
+
79
+ end
80
+
81
+ def repo_show(name)
82
+ if name == nil
83
+ uri = "/repos"
84
+ else
85
+ uri = "/repos/" + name
86
+ end
87
+
88
+ self.class.get uri
89
+ end
90
+
91
+ def repo_upload(repo_options = {:name => nil, :dir => nil, :file => nil,
92
+ :noremove => false, :forcereplace => false})
93
+
94
+ name = repo_options[:name]
95
+ dir = repo_options[:dir]
96
+ file = repo_options[:file]
97
+ noremove = repo_options[:noremove]
98
+ forcereplace = repo_options[:forcereplace]
99
+
100
+ if file == nil
101
+ uri = "/repos/#{name}/file/#{dir}"
102
+ else
103
+ uri = "/repos/#{name}/file/#{dir}/#{file}"
104
+ end
105
+
106
+ if forcereplace == true
107
+ uri = uri + "?forceReplace=1"
108
+ end
109
+
110
+ if noremove == true
111
+ uri = uri + "?noRemove=1"
112
+ end
113
+
114
+ response = self.class.post(uri)
115
+
116
+ case response.code
117
+ when 404
118
+ puts 'repository with such name does not exist'
119
+ end
120
+
121
+ json_response = JSON.parse(response.body)
122
+
123
+ unless json_response["failedFiles"].empty?
124
+ begin
125
+ rescue StandardError => e
126
+ puts "Files that failed to upload... #{json_response["failedFiles"]}"
127
+ puts e
128
+ end
129
+ end
130
+
131
+ unless json_response["report"]["warnings"].empty?
132
+ begin
133
+ rescue StandardError => e
134
+ puts "File upload warning message[s]...#{json_response["report"]["warnings"]}"
135
+ puts e
136
+ end
137
+ end
138
+
139
+ return response
140
+
141
+ end
142
+
143
+ end
144
+ end
@@ -0,0 +1,100 @@
1
+ require "aptly_cli/version"
2
+ require "aptly_load"
3
+ require "httmultiparty"
4
+ require "json"
5
+
6
+ module AptlyCli
7
+ class AptlySnapshot
8
+
9
+ include HTTMultiParty
10
+
11
+ # Load aptly-cli.conf and establish base_uri
12
+ config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf")
13
+ base_uri "http://#{config[:server]}:#{config[:port]}/api"
14
+
15
+ def snapshot_delete(name, force=0)
16
+ uri = "/snapshots/#{name}"
17
+
18
+ if force == 1
19
+ uri = uri + "?force=1"
20
+ end
21
+
22
+ self.class.delete(uri)
23
+ end
24
+
25
+ def snapshot_list(sort=nil)
26
+ uri = "/snapshots"
27
+
28
+ if sort
29
+ uri = uri + "?sort=#{sort}"
30
+ end
31
+
32
+ self.class.get(uri)
33
+ end
34
+
35
+ def snapshot_create(name, repo, description=nil)
36
+ # Build uri to create snapshot, requires name of snap and name of repo
37
+ uri = "/repos/#{repo}/" + "snapshots"
38
+
39
+ self.class.post(uri, :query => { 'Name' => name, 'Description' => description }.to_json, :headers => {'Content-Type'=>'application/json'})
40
+ end
41
+
42
+ def snapshot_create_ref(name, description=nil, sourcesnapshots=[], packagerefs=[])
43
+ uri = "/snapshots"
44
+
45
+ begin
46
+ self.class.post(uri, :query => { 'Name' => name,
47
+ 'Description' => description,
48
+ 'SourceSnapshots' => sourcesnapshots,
49
+ 'PackageRefs' => packagerefs }.to_json,
50
+ :headers => {'Content-Type'=>'application/json'})
51
+ rescue HTTParty::Error => e
52
+ return e
53
+ end
54
+
55
+ end
56
+
57
+ def snapshot_diff(name, with_snapshot)
58
+ uri = "/snapshots/#{name}/diff/#{with_snapshot}"
59
+ self.class.get(uri)
60
+ end
61
+
62
+ def snapshot_search(name, search_options={})
63
+ uri = "/snapshots/#{name}/packages"
64
+ @options = { query: {} }
65
+
66
+ if search_options.has_key?(:format)
67
+ @options[:query] = {format: "#{search_options[:format]}" }
68
+ end
69
+
70
+ if search_options.has_key?(:q)
71
+ @options[:query] = {q: "Name (~ #{search_options[:q]})" }
72
+ end
73
+
74
+ if search_options[:withDeps] == 1
75
+ @options[:query] = {withDeps: "1" }
76
+ end
77
+
78
+ self.class.get(uri, @options)
79
+
80
+ end
81
+
82
+ def snapshot_show(name)
83
+ uri = "/snapshots/#{name}"
84
+ self.class.get(uri)
85
+ end
86
+
87
+ def snapshot_update(name, name_update, description=nil)
88
+ uri = "/snapshots/#{name}"
89
+
90
+ begin
91
+ self.class.put(uri, :query => { 'Name' => name_update,
92
+ 'Description' => description }.to_json,
93
+ :headers => {'Content-Type'=>'application/json'})
94
+ rescue HTTPary::Error => e
95
+ puts e
96
+ end
97
+
98
+ end
99
+ end
100
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptly_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,6 +130,11 @@ files:
130
130
  - lib/aptly_cli/version.rb
131
131
  - lib/aptly_file.rb
132
132
  - lib/aptly_load.rb
133
+ - lib/aptly_misc.rb
134
+ - lib/aptly_package.rb
135
+ - lib/aptly_publish.rb
136
+ - lib/aptly_repo.rb
137
+ - lib/aptly_snapshot.rb
133
138
  homepage: https://github.com/sepulworld/aptly_cli
134
139
  licenses:
135
140
  - MIT