depot3 3.0.15 → 3.0.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,6 @@
22
22
  ###
23
23
  ###
24
24
 
25
-
26
25
  ###
27
26
  module D3
28
27
 
@@ -33,26 +32,35 @@ module D3
33
32
 
34
33
  ################# Module Constants #################
35
34
 
36
- PREFS_DIR = Pathname.new(ENV['HOME'].to_s).expand_path + "Library/Preferences"
37
- PREFS_FILE = PREFS_DIR + "com.pixar.d3.admin.yaml"
35
+ PREFS_DIR = Pathname.new(ENV['HOME'].to_s).expand_path + 'Library/Preferences'
36
+ PREFS_FILE = PREFS_DIR + 'com.pixar.d3.admin.yaml'
38
37
 
39
38
  PREF_KEYS = {
40
- :workspace => {
39
+ workspace: {
41
40
  description: "Path to the directory where new pkg and dmg packages are built.\n If unset, defaults to your home folder"
42
41
  },
43
42
 
44
- :editor =>{
45
- description: "Preferred shell command for editing package descriptions in --walkthru"
43
+ editor: {
44
+ description: 'Preferred shell command for editing package descriptions in --walkthru'
46
45
  },
47
46
 
48
- :apple_pkg_id_prefix => {
47
+ apple_pkg_id_prefix: {
49
48
  description: "The Apple package id prefix, e.g. 'com.mycompany'.\nWhen .pkgs are built, the identifier will be this, plus the basename.\n If unset, the default is '#{D3::Admin::DFT_PKG_ID_PREFIX}'"
50
49
  },
51
50
 
52
- :last_config => {
53
- description: "Timestamp of the last configuration for setting servers, credentials and/or prefs"
51
+ last_config: {
52
+ description: 'Timestamp of the last configuration for setting servers, credentials and/or prefs'
53
+ },
54
+
55
+ signing_identity: {
56
+ description: "Developer ID Installer certificate issued by the Apple Developer ID Certification Authority.\n This identity (certificate and private key) should be stored in the login.keychain of the user operating d3admin unless otherwise specified in signing options. Signing is optional."
57
+ },
58
+
59
+ signing_options: {
60
+ description: 'If a signing identity is defined, this String of options will be passed to pkgbuild. See man pkgbuild for more information'
54
61
  }
55
- }
62
+
63
+ }.freeze
56
64
 
57
65
  @@prefs = PREFS_FILE.readable? ? YAML.load(PREFS_FILE.read) : {}
58
66
 
@@ -71,8 +79,8 @@ module D3
71
79
  ### @param value[Object] the value to save with the pref
72
80
  ###
73
81
  ### @return [Boolean] true of the pref was set and saved
74
- def self.set_pref (pref, value)
75
- raise JSS::InvalidDataError, "first argument must be a pref key from D3::Admin::Prefs::PREF_KEYS" unless PREF_KEYS.keys.include? pref
82
+ def self.set_pref(pref, value)
83
+ raise JSS::InvalidDataError, 'first argument must be a pref key from D3::Admin::Prefs::PREF_KEYS' unless PREF_KEYS.keys.include? pref
76
84
  @@prefs[pref] = value
77
85
  save_prefs
78
86
  end
@@ -81,11 +89,10 @@ module D3
81
89
  ###
82
90
  ### @return [void]
83
91
  def self.save_prefs
84
- @@prefs[:last_config] = Time.now
92
+ @@prefs[:last_config] = Time.now
85
93
  PREFS_FILE.jss_save YAML.dump(@@prefs)
86
94
  end
87
95
 
88
-
89
96
  ### Run the Admin config, saving hostnames, usernames and pws
90
97
  ### as needed.
91
98
  ###
@@ -98,54 +105,70 @@ module D3
98
105
  ###
99
106
  ### @todo improve this a lot
100
107
  ###
101
- def self.config (targets, options)
102
-
108
+ def self.config(targets, options)
103
109
  if options.walkthru
104
- tgt = D3::Admin::Interactive.get_value :get_config_target, "all"
110
+ tgt = D3::Admin::Interactive.get_value :get_config_target, 'all'
105
111
  targets = [tgt]
106
112
  end
107
113
 
108
- if targets.empty? or targets.include?("all")
109
- targets = D3::Admin::CONFIG_TARGETS - ["all"]
114
+ if targets.empty? or targets.include?('all')
115
+ targets = D3::Admin::CONFIG_TARGETS - ['all']
110
116
  end
111
117
 
112
118
  targets.each do |target|
113
119
  case target
114
- when"jss"
115
- puts "******** JSS-API LOCATION AND READ-WRITE CREDENTIALS ********"
120
+ when 'jss'
121
+ puts '******** JSS-API LOCATION AND READ-WRITE CREDENTIALS ********'
116
122
  D3::Admin::Auth.ask_for_rw_credentials :jss
117
123
 
118
- when "db"
119
- puts "******** JSS MYSQL LOCATION AND READ-WRITE CREDENTIALS ********"
124
+ when 'db'
125
+ puts '******** JSS MYSQL LOCATION AND READ-WRITE CREDENTIALS ********'
120
126
  D3::Admin::Auth.ask_for_rw_credentials :db
121
127
 
122
- when "dist"
123
- puts "******** MASTER DIST-POINT READ-WRITE PASSWORD ********"
124
- D3::Admin::Auth.ask_for_rw_credentials :dist
128
+ when 'dist'
129
+ puts '******** MASTER DIST-POINT READ-WRITE PASSWORD ********'
130
+ D3::Admin::Auth.ask_for_rw_credentials :dist
125
131
 
126
- when "workspace"
127
- puts "******** LOCAL PKG/DMG BUILD WORKSPACE ********"
132
+ when 'workspace'
133
+ puts '******** LOCAL PKG/DMG BUILD WORKSPACE ********'
128
134
  pth = D3::Admin::Interactive.get_value :workspace, D3::Admin::Prefs.prefs[:workspace]
129
135
  D3::Admin::Prefs.set_pref :workspace, pth
130
136
  D3::Admin::Prefs.save_prefs
131
- puts "Thank you, the path has been saved in your d3admin prefs"
137
+ puts 'Thank you, the path has been saved in your d3admin prefs'
132
138
  puts
133
139
 
134
- when "editor"
135
- puts "******** TEXT EDITOR ********"
140
+ when 'editor'
141
+ puts '******** TEXT EDITOR ********'
136
142
  cmd = D3::Admin::Interactive.get_value :get_editor, D3::Admin::Prefs.prefs[:editor]
137
143
  D3::Admin::Prefs.set_pref :editor, cmd
138
144
  D3::Admin::Prefs.save_prefs
139
- puts "Thank you, the command has been saved in your d3admin prefs"
145
+ puts 'Thank you, the command has been saved in your d3admin prefs'
140
146
  puts
141
147
 
142
- when "pkg-id-prefix"
143
- puts "******** .PKG IDENTIFIER PREFIX ********"
148
+ when 'pkg-id-prefix'
149
+ puts '******** .PKG IDENTIFIER PREFIX ********'
144
150
  pfx = D3::Admin::Interactive.get_value(:get_pkg_identifier_prefix, D3::Admin::Prefs.prefs[:apple_pkg_id_prefix], :validate_package_identifier_prefix)
145
151
  D3::Admin::Prefs.set_pref :apple_pkg_id_prefix, pfx
146
152
  D3::Admin::Prefs.save_prefs
147
- puts "Thank you, the prefix has been saved in your d3admin prefs"
153
+ puts 'Thank you, the prefix has been saved in your d3admin prefs'
154
+ puts
155
+
156
+ when 'signing_identity'
157
+ puts '******** PACKAGE SIGNING IDENTITY ********'
158
+ sid = D3::Admin::Interactive.get_value :get_signing_identity, D3::Admin::Prefs.prefs[:signing_identity]
159
+ D3::Admin::Prefs.set_pref :signing_identity, sid
160
+ D3::Admin::Prefs.save_prefs
161
+ puts 'Thank you, the signing identity has been saved in your d3admin prefs'
148
162
  puts
163
+
164
+ when 'signing_options'
165
+ puts '******** PACKAGE SIGNING OPTIONS ********'
166
+ sopts = D3::Admin::Interactive.get_value :get_signing_options, D3::Admin::Prefs.prefs[:signing_options]
167
+ D3::Admin::Prefs.set_pref :signing_options, sopts
168
+ D3::Admin::Prefs.save_prefs
169
+ puts 'Thank you, signing options have been saved in your d3admin prefs'
170
+ puts
171
+
149
172
  else
150
173
  puts "(skipping unknown config setting: #{target}"
151
174
  end # case
@@ -171,35 +194,43 @@ module D3
171
194
  pkg_id_pfx = D3::Admin::Prefs.prefs[:apple_pkg_id_prefix]
172
195
  editor = D3::Admin::Prefs.prefs[:editor]
173
196
 
197
+ signing_id = D3::Admin::Prefs.prefs[:signing_identity]
198
+ signing_opts = D3::Admin::Prefs.prefs[:signing_options]
199
+
174
200
  puts <<-DISPLAY
175
201
  ******** Current d3admin config ********
176
202
  JSS API
177
203
  Hostname: #{jss_server}
178
204
  Port: #{jss_port}
179
- Read/Write user: #{jss_creds[:user] ? jss_creds[:user] : 'unset' }
180
- Read/Write password: #{jss_creds[:password] ? 'stored in keychain' : 'unset' }
205
+ Read/Write user: #{jss_creds[:user] ? jss_creds[:user] : 'unset'}
206
+ Read/Write password: #{jss_creds[:password] ? 'stored in keychain' : 'unset'}
181
207
 
182
208
  JSS MySQL
183
209
  Hostname: #{db_server}
184
210
  Port: #{db_port}
185
- Read/Write user: #{db_creds[:user] ? db_creds[:user] : 'unset' }
186
- Read/Write password: #{db_creds[:password] ? 'stored in keychain' : 'unset' }
211
+ Read/Write user: #{db_creds[:user] ? db_creds[:user] : 'unset'}
212
+ Read/Write password: #{db_creds[:password] ? 'stored in keychain' : 'unset'}
187
213
 
188
214
  Master Distribution Point
189
215
  Hostname: (stored in JSS)
190
216
  Port: (stored in JSS)
191
217
  Read/Write user: (stored in JSS)
192
- Read/Write password: #{dist_creds[:password] ? 'stored in keychain' : 'unset' }
218
+ Read/Write password: #{dist_creds[:password] ? 'stored in keychain' : 'unset'}
193
219
 
194
220
  Adding Packages
195
221
  Description Editor: #{editor ? editor : D3::Admin::Interactive::DFT_EDITOR}
196
222
  Build Workspace: #{wkspc ? wkspc : D3::Admin::DFT_WORKSPACE}
197
- Identifier prefix: #{pkg_id_pfx ? pkg_id_pfx : D3::Admin::DFT_PKG_ID_PREFIX}
223
+ Identifier Prefix: #{pkg_id_pfx ? pkg_id_pfx : D3::Admin::DFT_PKG_ID_PREFIX}
224
+
225
+ Package Signing (Optional)
226
+ Signing Identity: #{signing_id ? signing_id : 'N/A'}
227
+ Signing Options: #{signing_opts ? signing_opts : 'N/A'}
198
228
 
199
229
  DISPLAY
200
230
  end # display config
201
231
 
202
232
  end # module prefs
233
+
203
234
  end # module Admin
204
- end # module D3
205
235
 
236
+ end # module D3
@@ -56,7 +56,7 @@ module D3
56
56
  ### The second item is the validated input, if the check was good,
57
57
  ### or the error message if not.
58
58
  ###
59
- def validate (value, validate_method)
59
+ def validate(value, validate_method)
60
60
  return [true, value] unless validate_method
61
61
  begin
62
62
  valid_value = self.send(validate_method, value)
@@ -66,7 +66,6 @@ module D3
66
66
  end # begin
67
67
  end
68
68
 
69
-
70
69
  ### check that a given pkg id or display name exists in the JSS but not
71
70
  ### in d3, and if so, return the valid name or id
72
71
  ###
@@ -74,20 +73,18 @@ module D3
74
73
  ###
75
74
  ### @return [D3::Package] the unsaved, imported package
76
75
  ###
77
- def validate_package_for_import (pkg_to_check)
78
-
76
+ def validate_package_for_import(pkg_to_check)
79
77
  # an id, or a name?
80
78
  if pkg_to_check.to_s =~ /^\d+$/
81
79
  raise JSS::NoSuchItemError, "No package in the JSS with id #{pkg_to_check}" unless JSS::Package.all_ids.include? pkg_to_check.to_i
82
80
  raise JSS::AlreadyExistsError, "JSS Package id #{pkg_to_check} is already in d3" if D3::Package.all_ids.include? pkg_to_check.to_i
83
- return pkg_to_check.to_i
81
+ pkg_to_check.to_i
84
82
 
85
83
  else
86
84
  raise JSS::NoSuchItemError, "No package in the JSS with display-name #{pkg_to_check}" unless JSS::Package.all_names.include? pkg_to_check
87
85
  raise JSS::AlreadyExistsError, "JSS Package named #{pkg_to_check} is already in d3" if D3::Package.all_names.include? pkg_to_check
88
- return pkg_to_check
86
+ pkg_to_check
89
87
  end
90
-
91
88
  end
92
89
 
93
90
  ### Check that a given basename or edition exists in d3, and if
@@ -99,14 +96,13 @@ module D3
99
96
  ###
100
97
  ### @return [D3::Package] the matching package
101
98
  ###
102
- def validate_existing_package (pkg_to_check)
99
+ def validate_existing_package(pkg_to_check)
103
100
  # were we given an edition?
104
101
  pkgid = D3::Package.ids_to_editions.invert[pkg_to_check]
105
102
  # if not, were we given a basename?
106
103
  pkgid ||= D3::Package.basenames_to_live_ids[pkg_to_check]
107
104
  raise JSS::NoSuchItemError, "No edition or live-basename in d3 match '#{pkg_to_check}'" if pkgid.nil?
108
-
109
- return pkgid
105
+ pkgid
110
106
  end
111
107
 
112
108
  ### check that the given package name doesn't already exist
@@ -133,7 +129,7 @@ module D3
133
129
  ### @param basename[String]
134
130
  ###
135
131
  ### @return [String] the valid basename
136
- def validate_basename (basename)
132
+ def validate_basename(basename)
137
133
  raise JSS::NoSuchItemError, "There's no package in d3 with the basename '#{basename}'" unless D3::Package::Validate.basename_exist? basename.to_s
138
134
  basename.to_s
139
135
  end
@@ -145,7 +141,7 @@ module D3
145
141
  ###
146
142
  ### @return [String] the valid, unique edition
147
143
  ###
148
- def validate_edition (edition)
144
+ def validate_edition(edition)
149
145
  D3::Package::Validate.validate_edition edition
150
146
  end
151
147
 
@@ -155,7 +151,7 @@ module D3
155
151
  ###
156
152
  ### @return [String] An error message, or true if the value is ok
157
153
  ###
158
- def validate_version (vers)
154
+ def validate_version(vers)
159
155
  D3::Package::Validate.validate_version vers
160
156
  end
161
157
 
@@ -166,7 +162,7 @@ module D3
166
162
  ###
167
163
  ### @return [Integer] the valid revision
168
164
  ###
169
- def validate_revision (rev)
165
+ def validate_revision(rev)
170
166
  D3::Package::Validate.validate_revision rev
171
167
  end
172
168
 
@@ -177,14 +173,14 @@ module D3
177
173
  ###
178
174
  ### @return [Pathname] the valid, fully-expanded path
179
175
  ###
180
- def validate_source_path (src)
181
- raise JSS::InvalidDataError, "Source path cannot be empty" if src.to_s.empty?
176
+ def validate_source_path(src)
177
+ raise JSS::InvalidDataError, 'Source path cannot be empty' if src.to_s.empty?
182
178
  src = Pathname.new(src.to_s).expand_path
183
179
  raise JSS::NoSuchItemError, "'#{src}' doesn't exist" unless src.exist?
184
- return src if src.to_s.end_with?(".dmg") or src.to_s =~ /\.m?pkg$/
180
+ return src if src.to_s.end_with?('.dmg') || src.to_s =~ /\.m?pkg$/
185
181
 
186
182
  # isn't a dmg or pkg, check that its a directory to use as a pkg root
187
- raise JSS::InvalidDataError, "#{src} isn't a .dmg or .pkg, but isn't a folder,\ncan't use it for building packages." unless src.directory?
183
+ raise JSS::InvalidDataError, "#{src} isn't a .dmg or .pkg, but isn't a folder,\ncan't use it for building packages." unless src.directory?
188
184
  src
189
185
  end
190
186
 
@@ -208,10 +204,10 @@ module D3
208
204
  ###
209
205
  ### @return [String] the valid identifier
210
206
  ###
211
- def validate_package_identifier (pkgid)
212
- raise JSS::InvalidDataError, "Package Identifier must be a String" unless pkgid.is_a? String
213
- raise JSS::InvalidDataError, "Package Identifier cannot be empty" if pkgid.empty?
214
- return pkgid
207
+ def validate_package_identifier(pkgid)
208
+ raise JSS::InvalidDataError, 'Package Identifier must be a String' unless pkgid.is_a? String
209
+ raise JSS::InvalidDataError, 'Package Identifier cannot be empty' if pkgid.empty?
210
+ pkgid
215
211
  end
216
212
 
217
213
  ### Check the pkg identifier prefix
@@ -220,17 +216,27 @@ module D3
220
216
  ###
221
217
  ### @return [String] the cleaned-up identifier
222
218
  ###
223
- def validate_package_identifier_prefix (pfx)
219
+ def validate_package_identifier_prefix(pfx)
224
220
  return nil if pfx.to_s.empty?
225
- raise JSS::InvalidDataError, "Package Identifier Prefix must be a String" unless pfx.is_a? String
226
- return pfx
221
+ raise JSS::InvalidDataError, 'Package Identifier Prefix must be a String' unless pfx.is_a? String
222
+ pfx
223
+ end
224
+
225
+ ### Validate Signing Identity ?
226
+ def validate_signing_idenitity(id)
227
+ id.is_a?(String) && id
228
+ end
229
+
230
+ ### Validate Signing Options
231
+ def validate_signing_options(options)
232
+ options.is_a?(String) && options
227
233
  end
228
234
 
229
235
  ### Check the path given as a workspace for building pkgs
230
236
  ###
231
237
  ### @return [Pathname] the valid, full path to the workspace folder
232
238
  ###
233
- def validate_workspace (wkspc)
239
+ def validate_workspace(wkspc)
234
240
  wkspc = Pathname.new(wkspc).expand_path
235
241
  raise JSS::NoSuchItemError, "Workspace folder '#{wkspc}' doesn't exist" unless wkspc.exist?
236
242
  raise JSS::InvalidDataError, "Workspace folder '#{wkspc}' isn't a folder" unless wkspc.directory?
@@ -257,7 +263,7 @@ module D3
257
263
  end
258
264
 
259
265
  ### @see D3::Package::Validate.validate_groups
260
- def validate_scoped_groups (groups)
266
+ def validate_scoped_groups(groups)
261
267
  D3::Package::Validate.validate_groups groups
262
268
  end
263
269
 
@@ -282,7 +288,7 @@ module D3
282
288
  ###
283
289
  ### @see #validate_script
284
290
  ###
285
- def validate_pre_install_script (script)
291
+ def validate_pre_install_script(script)
286
292
  D3::Package::Validate.validate_script script
287
293
  end
288
294
 
@@ -290,7 +296,7 @@ module D3
290
296
  ###
291
297
  ### @see #validate_script
292
298
  ###
293
- def validate_post_install_script (script)
299
+ def validate_post_install_script(script)
294
300
  D3::Package::Validate.validate_script script
295
301
  end
296
302
 
@@ -298,7 +304,7 @@ module D3
298
304
  ###
299
305
  ### @see #validate_script
300
306
  ###
301
- def validate_pre_remove_script (script)
307
+ def validate_pre_remove_script(script)
302
308
  D3::Package::Validate.validate_script script
303
309
  end
304
310
 
@@ -306,17 +312,17 @@ module D3
306
312
  ###
307
313
  ### @see #validate_script
308
314
  ###
309
- def validate_post_remove_script (script)
315
+ def validate_post_remove_script(script)
310
316
  D3::Package::Validate.validate_script script
311
317
  end
312
318
 
313
319
  ### @see #validate_groups
314
- def validate_auto_groups (groups)
320
+ def validate_auto_groups(groups)
315
321
  D3::Package::Validate.validate_auto_groups groups
316
322
  end
317
323
 
318
324
  ### @see #validate_groups
319
- def validate_excluded_groups (groups)
325
+ def validate_excluded_groups(groups)
320
326
  D3::Package::Validate.validate_groups groups
321
327
  end
322
328
 
@@ -329,7 +335,7 @@ module D3
329
335
  ###
330
336
  ### @return [True] true if there are no groups in common
331
337
  ###
332
- def validate_non_overlapping_groups (auto, excl)
338
+ def validate_non_overlapping_groups(auto, excl)
333
339
  D3::Package::Validate.validate_non_overlapping_groups auto, excl
334
340
  end
335
341
 
@@ -340,7 +346,7 @@ module D3
340
346
  ###
341
347
  ### @return [Array] the valid OS list
342
348
  ###
343
- def validate_oses (os_list)
349
+ def validate_oses(os_list)
344
350
  D3::Package::Validate.validate_oses os_list
345
351
  end
346
352
 
@@ -351,7 +357,7 @@ module D3
351
357
  ###
352
358
  ### @return [Symbol] the valid CPU type
353
359
  ###
354
- def validate_cpu_type (type)
360
+ def validate_cpu_type(type)
355
361
  D3::Package::Validate.validate_cpu_type type
356
362
  end
357
363
 
@@ -362,7 +368,7 @@ module D3
362
368
  ###
363
369
  ### @return [String] the valid category
364
370
  ###
365
- def validate_category (cat)
371
+ def validate_category(cat)
366
372
  D3::Package::Validate.validate_category cat
367
373
  end
368
374
 
@@ -372,7 +378,7 @@ module D3
372
378
  ###
373
379
  ### @return [Array<String>]
374
380
  ###
375
- def validate_prohibiting_processes (process_names)
381
+ def validate_prohibiting_processes(process_names)
376
382
  process_names = [] if process_names.to_s =~ /^n(one)?$/i
377
383
  names_as_array = JSS.to_s_and_a(process_names)[:arrayform]
378
384
  names_as_array.map { |procname| D3::Package::Validate.validate_prohibiting_process(procname) }.compact
@@ -384,7 +390,7 @@ module D3
384
390
  ###
385
391
  ### @return [Boolean]
386
392
  ###
387
- def validate_yes_no (yn)
393
+ def validate_yes_no(yn)
388
394
  D3::Package::Validate.validate_yes_no yn
389
395
  end
390
396
 
@@ -395,7 +401,7 @@ module D3
395
401
  ###
396
402
  ### @return [Integer] the valid expiration
397
403
  ###
398
- def validate_expiration (exp)
404
+ def validate_expiration(exp)
399
405
  D3::Package::Validate.validate_expiration exp
400
406
  end
401
407
 
@@ -407,7 +413,7 @@ module D3
407
413
  ###
408
414
  ### @return [Array<Pathname>] the valid path
409
415
  ###
410
- def validate_expiration_paths (paths)
416
+ def validate_expiration_paths(paths)
411
417
  D3::Package::Validate.validate_expiration_paths paths
412
418
  end
413
419
 
@@ -418,11 +424,12 @@ module D3
418
424
  ###
419
425
  ### @return [Pathname, nil] the valid path
420
426
  ###
421
- def validate_expiration_path (path)
427
+ def validate_expiration_path(path)
422
428
  D3::Package::Validate.validate_expiration_path path
423
429
  end
424
430
 
425
-
426
431
  end # module Validate
432
+
427
433
  end # module Admin
434
+
428
435
  end # module D3