depot3 3.0.15 → 3.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +21 -1
- data/README.md +6 -6
- data/bin/d3 +3 -3
- data/bin/d3admin +257 -293
- data/lib/d3/admin/add.rb +98 -94
- data/lib/d3/admin/interactive.rb +195 -161
- data/lib/d3/admin/options.rb +424 -412
- data/lib/d3/admin/prefs.rb +73 -42
- data/lib/d3/admin/validate.rb +50 -43
- data/lib/d3/client/auth.rb +4 -2
- data/lib/d3/client/class_methods.rb +169 -119
- data/lib/d3/client/receipt.rb +2 -2
- data/lib/d3/database.rb +167 -180
- data/lib/d3/log.rb +2 -3
- data/lib/d3/package/server_actions.rb +2 -3
- data/lib/d3/package/validate.rb +63 -70
- data/lib/d3/version.rb +1 -2
- metadata +2 -2
data/lib/d3/log.rb
CHANGED
@@ -71,9 +71,9 @@ module D3
|
|
71
71
|
|
72
72
|
### Log the lines of backtrace from the most recent exception
|
73
73
|
### but only if the current severity is :debug
|
74
|
-
def self.log_backtrace
|
74
|
+
def self.log_backtrace( e = $@ )
|
75
75
|
return unless D3::LOG.level == :debug
|
76
|
-
|
76
|
+
e.backtrace.each{|line| D3.log " #{line}", :debug }
|
77
77
|
end
|
78
78
|
|
79
79
|
|
@@ -265,4 +265,3 @@ module D3
|
|
265
265
|
# the singleton instance of our logger
|
266
266
|
LOG = D3::Log.instance
|
267
267
|
end # module D3
|
268
|
-
|
@@ -535,10 +535,9 @@ INSERT INTO #{P_TABLE[:table_name]} (
|
|
535
535
|
if local_file_path.to_s =~ PKG_RE
|
536
536
|
@apple_receipt_data = D3::Package.receipt_data_from_pkg(local_file_path)
|
537
537
|
@need_to_update_d3 = true
|
538
|
-
self.save
|
539
538
|
end # if local_file_path.to_s =~ PKG_RE
|
540
|
-
|
541
539
|
super
|
540
|
+
update
|
542
541
|
end
|
543
542
|
|
544
543
|
### Create, or re-create, the BOM index records for this
|
@@ -615,7 +614,7 @@ INSERT INTO #{P_TABLE[:table_name]} (
|
|
615
614
|
system "rm -rf '#{tmp_bom}'"
|
616
615
|
|
617
616
|
else
|
618
|
-
raise JSS::InvalidDataError, "#{@filename}
|
617
|
+
raise JSS::InvalidDataError, "#{@filename} doesn't looks like a .pkg or .dmg. Try Casper Admin to index it."
|
619
618
|
end # if filename .pkg
|
620
619
|
|
621
620
|
# If there are no bomlines (perhaps a payloadless pkg?) just return
|
data/lib/d3/package/validate.rb
CHANGED
@@ -22,7 +22,6 @@
|
|
22
22
|
###
|
23
23
|
###
|
24
24
|
|
25
|
-
|
26
25
|
###
|
27
26
|
module D3
|
28
27
|
class Package < JSS::Package
|
@@ -37,10 +36,9 @@ module D3
|
|
37
36
|
### return [void]
|
38
37
|
###
|
39
38
|
def check_for_newer_version
|
40
|
-
if D3::Client::Receipt.basenames.include? @basename
|
41
|
-
|
42
|
-
|
43
|
-
end
|
39
|
+
rcpt = D3::Client::Receipt.all[@basename] # if D3::Client::Receipt.basenames.include? @basename
|
40
|
+
return unless rcpt
|
41
|
+
raise D3::InstallError, "The installed #{rcpt.edition} (#{rcpt.status}) is the same or newer. Use --force if needed." if rcpt.id >= @id
|
44
42
|
end # check for newer version
|
45
43
|
|
46
44
|
### Check that we're not installing a deprecated pkg, and raise an exception if we are.
|
@@ -66,8 +64,8 @@ module D3
|
|
66
64
|
###
|
67
65
|
def check_for_exclusions
|
68
66
|
excl_grps = D3::Client.computer_groups & @excluded_groups
|
69
|
-
raise D3::InstallError,
|
70
|
-
|
67
|
+
raise D3::InstallError, "This machine is excluded for #{edition}. Use --force if needed." unless excl_grps.empty?
|
68
|
+
true
|
71
69
|
end # check for exclusions
|
72
70
|
|
73
71
|
### Check if this machine is OK wrt to the os limitations
|
@@ -76,9 +74,9 @@ module D3
|
|
76
74
|
### return [void]
|
77
75
|
###
|
78
76
|
def check_oses
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
my_os = `/usr/bin/sw_vers -productVersion`.chomp
|
78
|
+
raise D3::InstallError, "This machine doesn't have the correct OS to install #{self.edition}." unless JSS.os_ok? @os_requirements, my_os
|
79
|
+
true
|
82
80
|
end
|
83
81
|
|
84
82
|
### Check if this machine is OK wrt to the processor limitations
|
@@ -87,11 +85,10 @@ module D3
|
|
87
85
|
### return [void]
|
88
86
|
###
|
89
87
|
def check_cpu
|
90
|
-
|
91
|
-
|
88
|
+
my_cpu = `/usr/bin/uname -p`.chomp
|
89
|
+
raise D3::InstallError, "This machine doesn't have the correct OS to install #{self.edition}." unless JSS.processor_ok? @required_processor, my_cpu
|
92
90
|
end
|
93
91
|
|
94
|
-
|
95
92
|
### This module contains methods for validating attribute
|
96
93
|
### values in d3 Packages
|
97
94
|
###
|
@@ -113,7 +110,7 @@ module D3
|
|
113
110
|
###
|
114
111
|
### @return [Boolean] does that basename exist in d3?
|
115
112
|
###
|
116
|
-
def basename_exist?
|
113
|
+
def basename_exist?(name)
|
117
114
|
D3::Package.all_basenames.include? name
|
118
115
|
end
|
119
116
|
|
@@ -123,7 +120,7 @@ module D3
|
|
123
120
|
###
|
124
121
|
### @return [Boolean] does that edition exist in d3?
|
125
122
|
###
|
126
|
-
def edition_exist?
|
123
|
+
def edition_exist?(edition)
|
127
124
|
D3::Package.all_editions.include? edition
|
128
125
|
end
|
129
126
|
|
@@ -133,11 +130,10 @@ module D3
|
|
133
130
|
###
|
134
131
|
### @return [Boolean] does that package filename exist in d3?
|
135
132
|
###
|
136
|
-
def filename_exist?
|
133
|
+
def filename_exist?(name)
|
137
134
|
D3::Package.all_filenames.values.include? name
|
138
135
|
end
|
139
136
|
|
140
|
-
|
141
137
|
### check that the given package name doesn't already exist
|
142
138
|
###
|
143
139
|
### @see {JSS::Package.validate_package_name}
|
@@ -165,24 +161,22 @@ module D3
|
|
165
161
|
###
|
166
162
|
### @return [String] the valid, unique edition
|
167
163
|
###
|
168
|
-
def validate_edition
|
164
|
+
def validate_edition(edition)
|
169
165
|
raise JSS::AlreadyExistsError, "There's already a package in the JSS with the edition '#{edition}'" if edition_exist? edition
|
170
|
-
raise JSS::InvalidDataError, "'#{edition}' doesn't seem like a valid edition" unless edition.count(
|
166
|
+
raise JSS::InvalidDataError, "'#{edition}' doesn't seem like a valid edition" unless edition.count('-') >= 2
|
171
167
|
edition
|
172
168
|
end
|
173
169
|
|
174
|
-
|
175
|
-
|
176
170
|
### Confirm the validity of a version. Raise an exception if invalid.
|
177
171
|
###
|
178
172
|
### @param vers[String] the version to check
|
179
173
|
###
|
180
174
|
### @return [String] An error message, or true if the value is ok
|
181
175
|
###
|
182
|
-
def validate_version
|
183
|
-
raise JSS::InvalidDataError,
|
176
|
+
def validate_version(vers)
|
177
|
+
raise JSS::InvalidDataError, 'Version must be a String.' unless vers.is_a? String
|
184
178
|
raise JSS::InvalidDataError, "Version can't be empty." if vers.empty?
|
185
|
-
|
179
|
+
vers.gsub(' ', '_')
|
186
180
|
end
|
187
181
|
|
188
182
|
### Confirm the validity of a revision.
|
@@ -192,8 +186,8 @@ module D3
|
|
192
186
|
###
|
193
187
|
### @return [Integer] the valid revision
|
194
188
|
###
|
195
|
-
def validate_revision
|
196
|
-
raise JSS::InvalidDataError,
|
189
|
+
def validate_revision(rev)
|
190
|
+
raise JSS::InvalidDataError, 'Revision must be an Integer.' unless rev.to_s =~ /^\d+$/
|
197
191
|
rev.to_i
|
198
192
|
end
|
199
193
|
|
@@ -201,7 +195,7 @@ module D3
|
|
201
195
|
###
|
202
196
|
### @see #validate_script
|
203
197
|
###
|
204
|
-
def validate_pre_install_script
|
198
|
+
def validate_pre_install_script(script)
|
205
199
|
validate_script script
|
206
200
|
end
|
207
201
|
|
@@ -209,7 +203,7 @@ module D3
|
|
209
203
|
###
|
210
204
|
### @see #validate_script
|
211
205
|
###
|
212
|
-
def validate_post_install_script
|
206
|
+
def validate_post_install_script(script)
|
213
207
|
validate_script script
|
214
208
|
end
|
215
209
|
|
@@ -217,7 +211,7 @@ module D3
|
|
217
211
|
###
|
218
212
|
### @see #validate_script
|
219
213
|
###
|
220
|
-
def validate_pre_remove_script
|
214
|
+
def validate_pre_remove_script(script)
|
221
215
|
validate_script script
|
222
216
|
end
|
223
217
|
|
@@ -225,7 +219,7 @@ module D3
|
|
225
219
|
###
|
226
220
|
### @see #validate_script
|
227
221
|
###
|
228
|
-
def validate_post_remove_script
|
222
|
+
def validate_post_remove_script(script)
|
229
223
|
validate_script script
|
230
224
|
end
|
231
225
|
|
@@ -236,7 +230,7 @@ module D3
|
|
236
230
|
###
|
237
231
|
### @return [Pathname, String] the valid local path or JSS name of the script
|
238
232
|
###
|
239
|
-
def validate_script
|
233
|
+
def validate_script(script)
|
240
234
|
script = nil if script.to_s =~ /^n(one)?$/i
|
241
235
|
return nil if script.to_s.empty?
|
242
236
|
script = script.to_s.strip
|
@@ -252,21 +246,19 @@ module D3
|
|
252
246
|
return path.expand_path if path.file?
|
253
247
|
|
254
248
|
# otherwise, its a JSS Script name,return its id
|
255
|
-
if JSS::Script.all_names.include? script.to_s
|
256
|
-
return script
|
257
|
-
end
|
249
|
+
return script if JSS::Script.all_names.include? script.to_s
|
258
250
|
|
259
251
|
raise JSS::NoSuchItemError, "No local file or JSS script named '#{script}'"
|
260
252
|
end # if a fixnum
|
261
253
|
end
|
262
254
|
|
263
255
|
### @see #validate_groups
|
264
|
-
def validate_auto_groups
|
256
|
+
def validate_auto_groups(groups)
|
265
257
|
validate_groups groups, :check_for_std
|
266
258
|
end
|
267
259
|
|
268
260
|
### @see #validate_groups
|
269
|
-
def validate_excluded_groups
|
261
|
+
def validate_excluded_groups(groups)
|
270
262
|
validate_groups groups
|
271
263
|
end
|
272
264
|
|
@@ -283,12 +275,12 @@ module D3
|
|
283
275
|
###
|
284
276
|
### @return [Array] The valid groups as an array
|
285
277
|
###
|
286
|
-
def validate_groups
|
278
|
+
def validate_groups(groups, check_for_std = false)
|
287
279
|
groups = [] if groups.to_s =~ /^n(one)?$/i
|
288
280
|
group_array = JSS.to_s_and_a(groups)[:arrayform].compact
|
289
281
|
return [] if group_array.empty?
|
290
|
-
return [] if group_array.reject{|g| g =~ /^n(one)$/i }.empty? # ['n'], ['None'], case-free
|
291
|
-
return [D3::STANDARD_AUTO_GROUP] if check_for_std
|
282
|
+
return [] if group_array.reject { |g| g =~ /^n(one)$/i }.empty? # ['n'], ['None'], case-free
|
283
|
+
return [D3::STANDARD_AUTO_GROUP] if check_for_std && group_array.include?(D3::STANDARD_AUTO_GROUP)
|
292
284
|
|
293
285
|
group_array.each do |group|
|
294
286
|
raise JSS::NoSuchItemError, "No ComputerGroup named '#{group}' in the JSS" unless JSS::ComputerGroup.all_names.include? group
|
@@ -305,8 +297,8 @@ module D3
|
|
305
297
|
###
|
306
298
|
### @return [True] true if there are no groups in common
|
307
299
|
###
|
308
|
-
def validate_non_overlapping_groups
|
309
|
-
return nil unless auto
|
300
|
+
def validate_non_overlapping_groups(auto, excl)
|
301
|
+
return nil unless auto && excl
|
310
302
|
auto = JSS.to_s_and_a(auto)[:arrayform]
|
311
303
|
excl = JSS.to_s_and_a(excl)[:arrayform]
|
312
304
|
raise JSS::InvalidDataError, "Auto and Excluded group-lists can't contain groups in common." unless (auto & excl).empty?
|
@@ -320,19 +312,19 @@ module D3
|
|
320
312
|
###
|
321
313
|
### @return [Array] the valid OS list
|
322
314
|
###
|
323
|
-
def validate_oses
|
315
|
+
def validate_oses(os_list)
|
324
316
|
os_list = nil if os_list.to_s =~ /^n(one)?$/i
|
325
317
|
return [] if os_list.to_s.empty?
|
326
|
-
|
318
|
+
### if any value starts with >=, expand it
|
327
319
|
case os_list
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
320
|
+
when String
|
321
|
+
os_list = JSS.expand_min_os(os_list) if os_list =~ /^>=/
|
322
|
+
when Array
|
323
|
+
os_list.map! { |a| a =~ /^>=/ ? JSS.expand_min_os(a) : a }
|
324
|
+
os_list.flatten!
|
325
|
+
os_list.uniq!
|
326
|
+
else
|
327
|
+
raise JSS::InvalidDataError, 'os_list must be a String or an Array of strings'
|
336
328
|
end
|
337
329
|
### return the array version
|
338
330
|
JSS.to_s_and_a(os_list)[:arrayform]
|
@@ -345,11 +337,11 @@ module D3
|
|
345
337
|
###
|
346
338
|
### @return [Symbol] the valid CPU type
|
347
339
|
###
|
348
|
-
def validate_cpu_type
|
340
|
+
def validate_cpu_type(type)
|
349
341
|
type = JSS::Package::DEFAULT_PROCESSOR if type.to_s.empty?
|
350
|
-
type =
|
351
|
-
type =
|
352
|
-
type =
|
342
|
+
type = 'None' if type =~ /^n(one)?$/i
|
343
|
+
type = 'x86' if type.casecmp('intel').zero?
|
344
|
+
type = 'ppc' if type.casecmp('ppc').zero?
|
353
345
|
unless JSS::Package::CPU_TYPES.include? type
|
354
346
|
raise JSS::InvalidDataError, "CPU type must be one of: #{JSS::Package::CPU_TYPES.join ', '}"
|
355
347
|
end
|
@@ -364,9 +356,9 @@ module D3
|
|
364
356
|
###
|
365
357
|
### @return [String] the valid category name
|
366
358
|
###
|
367
|
-
def validate_category
|
359
|
+
def validate_category(cat)
|
368
360
|
cat = nil if cat.to_s =~ /^n(one)?$/i
|
369
|
-
return
|
361
|
+
return '' if cat.to_s.empty?
|
370
362
|
raise JSS::NoSuchItemError, "No category '#{cat}' in the JSS" unless JSS::Category.all_names.include? cat
|
371
363
|
cat
|
372
364
|
end
|
@@ -377,9 +369,9 @@ module D3
|
|
377
369
|
###
|
378
370
|
### @return [String]
|
379
371
|
###
|
380
|
-
def validate_prohibiting_process
|
372
|
+
def validate_prohibiting_process(process_name)
|
381
373
|
process_name = nil if process_name.to_s =~ /^n(one)?$/i
|
382
|
-
return nil if process_name.nil?
|
374
|
+
return nil if process_name.nil? || process_name.empty?
|
383
375
|
process_name.to_s
|
384
376
|
end
|
385
377
|
|
@@ -396,11 +388,11 @@ module D3
|
|
396
388
|
###
|
397
389
|
### @return [Boolean]
|
398
390
|
###
|
399
|
-
def validate_yes_no
|
391
|
+
def validate_yes_no(yn)
|
400
392
|
case yn
|
401
|
-
when
|
393
|
+
when Integer
|
402
394
|
return true if yn == 1
|
403
|
-
return false if yn
|
395
|
+
return false if yn.zero?
|
404
396
|
when String
|
405
397
|
return true if yn.strip =~ /^y(es)?$/i
|
406
398
|
return false if yn.strip =~ /^no?$/i
|
@@ -421,9 +413,9 @@ module D3
|
|
421
413
|
###
|
422
414
|
### @return [Integer] the valid expiration
|
423
415
|
###
|
424
|
-
def validate_expiration
|
416
|
+
def validate_expiration(exp)
|
425
417
|
exp ||= '0'
|
426
|
-
raise JSS::InvalidDataError,
|
418
|
+
raise JSS::InvalidDataError, 'Expiration must be a non-negative Integer.' unless exp.to_s =~ /^\d+$/
|
427
419
|
exp = 0 if exp.to_i < 0
|
428
420
|
exp.to_i
|
429
421
|
end
|
@@ -436,13 +428,13 @@ module D3
|
|
436
428
|
###
|
437
429
|
### @return [Array<Pathname>] the valid path
|
438
430
|
###
|
439
|
-
def validate_expiration_paths
|
440
|
-
return [] if paths.to_s.empty?
|
431
|
+
def validate_expiration_paths(paths)
|
432
|
+
return [] if paths.to_s.empty? || paths.to_s =~ /^n(one)?$/i
|
441
433
|
|
442
434
|
paths = paths.chomp.split(/\s*,\s*/) if paths.is_a? String
|
443
435
|
|
444
436
|
if paths.is_a? Array
|
445
|
-
return paths.map!{|p| validate_expiration_path p}
|
437
|
+
return paths.map! { |p| validate_expiration_path p }
|
446
438
|
else
|
447
439
|
return [validate_expiration_path(paths)]
|
448
440
|
end
|
@@ -456,13 +448,14 @@ module D3
|
|
456
448
|
###
|
457
449
|
### @return [Pathname] the valid path
|
458
450
|
###
|
459
|
-
def validate_expiration_path
|
451
|
+
def validate_expiration_path(path)
|
460
452
|
path = path.to_s
|
461
|
-
raise JSS::InvalidDataError,
|
453
|
+
raise JSS::InvalidDataError, 'Expiration Path must be a full path starting with /.' unless path.start_with? '/'
|
462
454
|
Pathname.new path
|
463
455
|
end
|
464
456
|
|
465
457
|
end # module Validate
|
466
458
|
|
467
|
-
end # class
|
459
|
+
end # class Package
|
460
|
+
|
468
461
|
end # module D3
|
data/lib/d3/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: depot3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-keychain
|