depot3 0.0.0a1 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +55 -1
- data/bin/d3 +323 -0
- data/bin/d3admin +1011 -0
- data/bin/d3helper +354 -0
- data/bin/puppytime +334 -0
- data/data/d3/com.pixar.d3.RepoMan.plist +23 -0
- data/data/d3/d3.conf.example +507 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftAppKit.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftCore.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftCoreData.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftCoreGraphics.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftCoreImage.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftDarwin.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftDispatch.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftFoundation.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftObjectiveC.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Info.plist +56 -0
- data/data/d3/d3RepoMan.app/Contents/MacOS/d3RepoMan +0 -0
- data/data/d3/d3RepoMan.app/Contents/PkgInfo +1 -0
- data/data/d3/d3RepoMan.app/Contents/Resources/Base.lproj/MainMenu.nib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Resources/last-foreground-times-template.plist +5 -0
- data/data/d3/d3RepoMan.app/Contents/_CodeSignature/CodeResources +214 -0
- data/data/d3/puppytime/ImageLicenses.txt +165 -0
- data/data/d3/puppytime/notification_image +1 -0
- data/data/d3/puppytime/opt_out_image +1 -0
- data/data/d3/puppytime/slideshow/2008-07-11_White_German_Shepherd_pup_chilling_at_the_Coker_Arboretum.jpg +0 -0
- data/data/d3/puppytime/slideshow/2009-04-21_APBT_pup_on_deck.jpg +0 -0
- data/data/d3/puppytime/slideshow/A_puppy_Yorkie.jpg +0 -0
- data/data/d3/puppytime/slideshow/Alert_Pug_Puppy.jpg +0 -0
- data/data/d3/puppytime/slideshow/Australian_Cattle_Dog_puppies_04.JPG +0 -0
- data/data/d3/puppytime/slideshow/Beagle_puppy_Cadet.jpg +0 -0
- data/data/d3/puppytime/slideshow/Bernese_Mountain_Dog.jpg +0 -0
- data/data/d3/puppytime/slideshow/Bloodhound_Puppy.jpg +0 -0
- data/data/d3/puppytime/slideshow/Boston_terrier_with_toy.jpg +0 -0
- data/data/d3/puppytime/slideshow/Boxer_puppy_fawn_portrai.jpg +0 -0
- data/data/d3/puppytime/slideshow/Caracal_kitten.jpg +0 -0
- data/data/d3/puppytime/slideshow/Chihuahua_&_Doberman_Pup.jpg +0 -0
- data/data/d3/puppytime/slideshow/Cuccioli_di_Margot_a_35_gg_Basenjis.jpg +0 -0
- data/data/d3/puppytime/slideshow/Dalmatian_puppy_03.jpg +0 -0
- data/data/d3/puppytime/slideshow/GoldenRetrieverPuppyDaisyParker.JPG +0 -0
- data/data/d3/puppytime/slideshow/Green_eyed_beige_Chihuahua.jpg +0 -0
- data/data/d3/puppytime/slideshow/Let_Sleeping_Dogs_Lie.jpg +0 -0
- data/data/d3/puppytime/slideshow/Meatball_-_French_Bulldog_Puppy.jpg +0 -0
- data/data/d3/puppytime/slideshow/Oola_-_9_weeks.jpg +0 -0
- data/data/d3/puppytime/slideshow/Pancho0008.JPG +0 -0
- data/data/d3/puppytime/slideshow/Pomeranian_orange-sable_Coco.jpg +0 -0
- data/data/d3/puppytime/slideshow/Pug_puppy_001.jpg +0 -0
- data/data/d3/puppytime/slideshow/Puggle_puppy_6_weeks.JPG +0 -0
- data/data/d3/puppytime/slideshow/Puli_kan.jpg +0 -0
- data/data/d3/puppytime/slideshow/Puppy_French_Bulldog.jpg +0 -0
- data/data/d3/puppytime/slideshow/Rocco_the_Bulldog.jpg +0 -0
- data/data/d3/puppytime/slideshow/Rottweiler_Face.jpg +0 -0
- data/data/d3/puppytime/slideshow/Saint_Bernard_puppy.jpg +0 -0
- data/data/d3/puppytime/slideshow/Scottish_froment.jpg +0 -0
- data/data/d3/puppytime/slideshow/Shar_pei_puppy_(age_2_months).jpg +0 -0
- data/data/d3/puppytime/slideshow/Shiba-Inu_beim_Spielen_im_Schnee.JPG +0 -0
- data/data/d3/puppytime/slideshow/Smooth-coat_Border_Collie_puppy..jpg +0 -0
- data/data/d3/puppytime/slideshow/Smooth_Dachshund_puppies.jpg +0 -0
- data/data/d3/puppytime/slideshow/Snow_dog.jpg +0 -0
- data/data/d3/puppytime/slideshow/Taylor_the_Pembroke_Welsh_Corgi.png +0 -0
- data/data/d3/puppytime/slideshow/Weim_Pups_001.jpg +0 -0
- data/data/d3/puppytime/slideshow/Westie_pups.jpg +0 -0
- data/data/d3/puppytime/slideshow/Yellow_Labrador_puppies_(4165737325).jpg +0 -0
- data/lib/d3/admin/add.rb +451 -0
- data/lib/d3/admin/auth.rb +470 -0
- data/lib/d3/admin/edit.rb +297 -0
- data/lib/d3/admin/help.rb +396 -0
- data/lib/d3/admin/interactive.rb +972 -0
- data/lib/d3/admin/options.rb +454 -0
- data/lib/d3/admin/prefs.rb +204 -0
- data/lib/d3/admin/report.rb +727 -0
- data/lib/d3/admin/state.rb +42 -0
- data/lib/d3/admin/validate.rb +413 -0
- data/lib/d3/admin.rb +42 -0
- data/lib/d3/basename.rb +217 -0
- data/lib/d3/client/auth.rb +108 -0
- data/lib/d3/client/class_methods.rb +766 -0
- data/lib/d3/client/class_variables.rb +47 -0
- data/lib/d3/client/cli.rb +187 -0
- data/lib/d3/client/environment.rb +134 -0
- data/lib/d3/client/help.rb +110 -0
- data/lib/d3/client/lists.rb +314 -0
- data/lib/d3/client/receipt.rb +1173 -0
- data/lib/d3/client.rb +45 -0
- data/lib/d3/configuration.rb +319 -0
- data/lib/d3/constants.rb +60 -0
- data/lib/d3/database.rb +488 -0
- data/lib/d3/exceptions.rb +44 -0
- data/lib/d3/log.rb +271 -0
- data/lib/d3/package/aliases.rb +80 -0
- data/lib/d3/package/attributes.rb +97 -0
- data/lib/d3/package/class_methods.rb +817 -0
- data/lib/d3/package/class_variables.rb +46 -0
- data/lib/d3/package/client_actions.rb +293 -0
- data/lib/d3/package/constants.rb +58 -0
- data/lib/d3/package/constructor.rb +191 -0
- data/lib/d3/package/getters.rb +164 -0
- data/lib/d3/package/mixins.rb +39 -0
- data/lib/d3/package/private_methods.rb +227 -0
- data/lib/d3/package/questions.rb +95 -0
- data/lib/d3/package/server_actions.rb +683 -0
- data/lib/d3/package/setters.rb +326 -0
- data/lib/d3/package/validate.rb +448 -0
- data/lib/d3/package.rb +51 -0
- data/lib/d3/puppytime/pending_puppy.rb +108 -0
- data/lib/d3/puppytime/puppy_queue.rb +274 -0
- data/lib/d3/puppytime.rb +68 -0
- data/lib/d3/state.rb +105 -0
- data/lib/d3/utility.rb +325 -0
- data/lib/d3/version.rb +1 -1
- metadata +162 -9
@@ -0,0 +1,448 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
|
26
|
+
module D3
|
27
|
+
class Package < JSS::Package
|
28
|
+
|
29
|
+
### General validation checks for the package as a whole,
|
30
|
+
### For individual attribute validation, see the
|
31
|
+
### D3::Package::Validate module.
|
32
|
+
|
33
|
+
### Check that there's not a newer version of this thing alreay installed
|
34
|
+
### Raise an exception if so.
|
35
|
+
###
|
36
|
+
### return [void]
|
37
|
+
###
|
38
|
+
def check_for_newer_version
|
39
|
+
if D3::Client::Receipt.basenames.include? @basename
|
40
|
+
rcpt = D3::Client::Receipt.all[@basename]
|
41
|
+
raise D3::InstallError, "The installed #{rcpt.edition} (#{rcpt.status}) is the same or newer. Use --force if needed." if rcpt.id >= @id
|
42
|
+
end
|
43
|
+
end # check for newer version
|
44
|
+
|
45
|
+
### Check that we're not installing a deprecated pkg, and raise an exception if we are.
|
46
|
+
###
|
47
|
+
### return [void]
|
48
|
+
###
|
49
|
+
def check_for_deprecated
|
50
|
+
raise D3::InstallError, "#{edition} is deprecated. Use --force if needed." if deprecated?
|
51
|
+
end
|
52
|
+
|
53
|
+
### Check that we're not trying to install a skipped pkg, and raise an exception if we are.
|
54
|
+
###
|
55
|
+
### return [void]
|
56
|
+
###
|
57
|
+
def check_for_skipped
|
58
|
+
raise D3::InstallError, "#{edition} was skipped. Use --force if needed." if skipped?
|
59
|
+
end
|
60
|
+
|
61
|
+
### Check if this machine is in an excluded group.
|
62
|
+
### Raise an exception if so.
|
63
|
+
###
|
64
|
+
### return [void]
|
65
|
+
###
|
66
|
+
def check_for_exclusions
|
67
|
+
excl_grps = D3::Client.computer_groups & @excluded_groups
|
68
|
+
raise D3::InstallError, "This machine is excluded for #{desired_pkg.edition}. Use --force if needed." unless excl_grps.empty?
|
69
|
+
return true
|
70
|
+
end # check for exclusions
|
71
|
+
|
72
|
+
### Check if this machine is OK wrt to the os limitations
|
73
|
+
### Raise an exception if not
|
74
|
+
###
|
75
|
+
### return [void]
|
76
|
+
###
|
77
|
+
def check_oses
|
78
|
+
my_os = `/usr/bin/sw_vers -productVersion`.chomp
|
79
|
+
raise D3::InstallError, "This machine doesn't have the correct OS to install #{self.edition}." unless JSS.os_ok? @os_requirements, my_os
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
|
83
|
+
### Check if this machine is OK wrt to the processor limitations
|
84
|
+
### Raise an exception if not
|
85
|
+
###
|
86
|
+
### return [void]
|
87
|
+
###
|
88
|
+
def check_cpu
|
89
|
+
my_cpu = `/usr/bin/uname -p`.chomp
|
90
|
+
raise D3::InstallError, "This machine doesn't have the correct OS to install #{self.edition}." unless JSS.processor_ok? @required_processor, my_cpu
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
### This module contains methods for validating attribute
|
95
|
+
### values in d3 Packages
|
96
|
+
###
|
97
|
+
### Each method takes an argument, and either raises an exception
|
98
|
+
### if the argument isn't valid for its destination, or
|
99
|
+
### converts it to the proper type for its destination.
|
100
|
+
###
|
101
|
+
### For example, the {#validate_groups} takes either a comma-seprated String
|
102
|
+
### or an Array of computer group names, converts the String to an Array
|
103
|
+
### if needed, and then confirms that each group exists in the JSS
|
104
|
+
### If they all do, the Array is returned.
|
105
|
+
###
|
106
|
+
module Validate
|
107
|
+
extend self
|
108
|
+
|
109
|
+
### Check the existence of a basename in d3.
|
110
|
+
###
|
111
|
+
### @param name[String] the basename to check
|
112
|
+
###
|
113
|
+
### @return [Boolean] does that basename exist in d3?
|
114
|
+
###
|
115
|
+
def basename_exist? (name)
|
116
|
+
D3::Package.all_basenames.include? name
|
117
|
+
end
|
118
|
+
|
119
|
+
### Check the existence of an edition in d3.
|
120
|
+
###
|
121
|
+
### @param name[String] the edition to check
|
122
|
+
###
|
123
|
+
### @return [Boolean] does that edition exist in d3?
|
124
|
+
###
|
125
|
+
def edition_exist? (edition)
|
126
|
+
D3::Package.all_editions.include? edition
|
127
|
+
end
|
128
|
+
|
129
|
+
### Check the existence of a filename in the JSS.
|
130
|
+
###
|
131
|
+
### @param name[String] the name to check
|
132
|
+
###
|
133
|
+
### @return [Boolean] does that package filename exist in d3?
|
134
|
+
###
|
135
|
+
def filename_exist? (name)
|
136
|
+
D3::Package.all_filenames.values.include? name
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
### check that the given package name doesn't already exist
|
141
|
+
###
|
142
|
+
### @see {JSS::Package.validate_package_name}
|
143
|
+
###
|
144
|
+
def validate_package_name(name)
|
145
|
+
raise JSS::AlreadyExistsError, "There's already a package in the JSS with the name '#{name}'" if JSS::Package.all_names.include? name
|
146
|
+
name
|
147
|
+
end
|
148
|
+
|
149
|
+
### check that the given filename doesn't already exist
|
150
|
+
###
|
151
|
+
### @param name[String] the name to check
|
152
|
+
###
|
153
|
+
### @return [String] the valid new file name
|
154
|
+
###
|
155
|
+
def validate_filename(name)
|
156
|
+
raise JSS::AlreadyExistsError, "There's already a package in the JSS with the filename '#{name}'" if self.filename_exist? name
|
157
|
+
name
|
158
|
+
end
|
159
|
+
|
160
|
+
### Check if an edition exists and raise an exception if so
|
161
|
+
### Also check that it contains at least two hyphens
|
162
|
+
###
|
163
|
+
### @param edition[String] the edition to check
|
164
|
+
###
|
165
|
+
### @return [String] the valid, unique edition
|
166
|
+
###
|
167
|
+
def validate_edition (edition)
|
168
|
+
raise JSS::AlreadyExistsError, "There's already a package in the JSS with the edition '#{edition}'" if edition_exist? edition
|
169
|
+
raise JSS::InvalidDataError, "'#{edition}' doesn't seem like a valid edition" unless edition.count("-") >= 2
|
170
|
+
edition
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
### Confirm the validity of a version. Raise an exception if invalid.
|
176
|
+
###
|
177
|
+
### @param vers[String] the version to check
|
178
|
+
###
|
179
|
+
### @return [String] An error message, or true if the value is ok
|
180
|
+
###
|
181
|
+
def validate_version (vers)
|
182
|
+
raise JSS::InvalidDataError, "Version must be a String." unless vers.is_a? String
|
183
|
+
raise JSS::InvalidDataError, "Version can't be empty." if vers.empty?
|
184
|
+
return vers.gsub(" ", "_")
|
185
|
+
end
|
186
|
+
|
187
|
+
### Confirm the validity of a revision.
|
188
|
+
### Raise an exception if invalid.
|
189
|
+
###
|
190
|
+
### @param rev[Integer] the revision to check
|
191
|
+
###
|
192
|
+
### @return [Integer] the valid revision
|
193
|
+
###
|
194
|
+
def validate_revision (rev)
|
195
|
+
raise JSS::InvalidDataError, "Revision must be an Integer." unless rev.to_s =~ /^\d+$/
|
196
|
+
rev.to_i
|
197
|
+
end
|
198
|
+
|
199
|
+
### Check the validity of a pre_install script
|
200
|
+
###
|
201
|
+
### @see #validate_script
|
202
|
+
###
|
203
|
+
def validate_pre_install_script (script)
|
204
|
+
validate_script script
|
205
|
+
end
|
206
|
+
|
207
|
+
### Check the validity of a post_install script
|
208
|
+
###
|
209
|
+
### @see #validate_script
|
210
|
+
###
|
211
|
+
def validate_post_install_script (script)
|
212
|
+
validate_script script
|
213
|
+
end
|
214
|
+
|
215
|
+
### Check the validity of a pre_remove script
|
216
|
+
###
|
217
|
+
### @see #validate_script
|
218
|
+
###
|
219
|
+
def validate_pre_remove_script (script)
|
220
|
+
validate_script script
|
221
|
+
end
|
222
|
+
|
223
|
+
### Check the validity of a pre_remove script
|
224
|
+
###
|
225
|
+
### @see #validate_script
|
226
|
+
###
|
227
|
+
def validate_post_remove_script (script)
|
228
|
+
validate_script script
|
229
|
+
end
|
230
|
+
|
231
|
+
### Check the validity of a script, either Pathname, JSS id, or JSS name
|
232
|
+
### Raise an exception if not valid
|
233
|
+
###
|
234
|
+
### @param script[Pathname, Integer, String] the script to check
|
235
|
+
###
|
236
|
+
### @return [Pathname, String] the valid local path or JSS name of the script
|
237
|
+
###
|
238
|
+
def validate_script (script)
|
239
|
+
script = nil if script.to_s =~ /^n(one)?$/i
|
240
|
+
return nil if script.to_s.empty?
|
241
|
+
script = script.to_s.strip
|
242
|
+
|
243
|
+
if script =~ /^\d+$/
|
244
|
+
script = script.to_i
|
245
|
+
return JSS::Script.map_all_ids_to(:name)[script] if JSS::Script.all_ids.include? script
|
246
|
+
raise JSS::NoSuchItemError, "No JSS script with id '#{script}'"
|
247
|
+
|
248
|
+
else
|
249
|
+
# if its a file path, return it fully expanded
|
250
|
+
path = Pathname.new script
|
251
|
+
return path.expand_path if path.file?
|
252
|
+
|
253
|
+
# otherwise, its a JSS Script name,return its id
|
254
|
+
if JSS::Script.all_names.include? script.to_s
|
255
|
+
return script
|
256
|
+
end
|
257
|
+
|
258
|
+
raise JSS::NoSuchItemError, "No local file or JSS script named '#{script}'"
|
259
|
+
end # if a fixnum
|
260
|
+
end
|
261
|
+
|
262
|
+
### @see #validate_groups
|
263
|
+
def validate_auto_groups (groups)
|
264
|
+
validate_groups groups, :check_for_std
|
265
|
+
end
|
266
|
+
|
267
|
+
### @see #validate_groups
|
268
|
+
def validate_excluded_groups (groups)
|
269
|
+
validate_groups groups
|
270
|
+
end
|
271
|
+
|
272
|
+
### Confirm the existence of a list of Computer Group names
|
273
|
+
### (String or Array) and return them as an Array
|
274
|
+
###
|
275
|
+
### If "n", "", "none" or nil are passed, an empty array is returned.
|
276
|
+
###
|
277
|
+
### Raise an exception if any group is not valid.
|
278
|
+
###
|
279
|
+
### @param groups[String, Array<String>]
|
280
|
+
###
|
281
|
+
### @param check_for_std[Boolean] should we check for the D3::STANDARD_AUTO_GROUP?
|
282
|
+
###
|
283
|
+
### @return [Array] The valid groups as an array
|
284
|
+
###
|
285
|
+
def validate_groups (groups, check_for_std = false)
|
286
|
+
groups = [] if groups.to_s =~ /^n(one)?$/i
|
287
|
+
group_array = JSS.to_s_and_a(groups)[:arrayform].compact
|
288
|
+
return [] if group_array.empty?
|
289
|
+
return [] if group_array.reject{|g| g =~ /^n(one)$/i }.empty? # ['n'], ['None'], case-free
|
290
|
+
return [D3::STANDARD_AUTO_GROUP] if check_for_std and group_array.include?(D3::STANDARD_AUTO_GROUP)
|
291
|
+
|
292
|
+
group_array.each do |group|
|
293
|
+
raise JSS::NoSuchItemError, "No ComputerGroup named '#{group}' in the JSS" unless JSS::ComputerGroup.all_names.include? group
|
294
|
+
end
|
295
|
+
group_array
|
296
|
+
end
|
297
|
+
|
298
|
+
### Make sure auto and excluded groups don't have any
|
299
|
+
### members in common, raise an exception if they do.
|
300
|
+
###
|
301
|
+
### @param auto[Array] the array of auto groups
|
302
|
+
###
|
303
|
+
### @param excl[Array] the array of excluded groups
|
304
|
+
###
|
305
|
+
### @return [True] true if there are no groups in common
|
306
|
+
###
|
307
|
+
def validate_non_overlapping_groups (auto, excl)
|
308
|
+
return nil unless auto and excl
|
309
|
+
auto = JSS.to_s_and_a(auto)[:arrayform]
|
310
|
+
excl = JSS.to_s_and_a(excl)[:arrayform]
|
311
|
+
raise JSS::InvalidDataError, "Auto and Excluded group-lists can't contain groups in common." unless (auto & excl).empty?
|
312
|
+
true
|
313
|
+
end
|
314
|
+
|
315
|
+
### Check the validity of a list of OSes
|
316
|
+
### Raise an exception if not valid
|
317
|
+
###
|
318
|
+
### @param [String,Array] Array or comma-separated list of OSes to check
|
319
|
+
###
|
320
|
+
### @return [Array] the valid OS list
|
321
|
+
###
|
322
|
+
def validate_oses (os_list)
|
323
|
+
os_list = nil if os_list.to_s =~ /^n(one)?$/i
|
324
|
+
return [] if os_list.to_s.empty?
|
325
|
+
### if any value starts with >=, expand it
|
326
|
+
case os_list
|
327
|
+
when String
|
328
|
+
os_list = JSS.expand_min_os(os_list) if os_list =~ /^>=/
|
329
|
+
when Array
|
330
|
+
os_list.map!{|a| a =~ /^>=/ ? JSS.expand_min_os(a) : a }
|
331
|
+
os_list.flatten!
|
332
|
+
os_list.uniq!
|
333
|
+
else
|
334
|
+
raise JSS::InvalidDataError, "os_list must be a String or an Array of strings"
|
335
|
+
end
|
336
|
+
### return the array version
|
337
|
+
JSS.to_s_and_a(os_list)[:arrayform]
|
338
|
+
end
|
339
|
+
|
340
|
+
### Check the validity of a CPU type
|
341
|
+
### Raise an exception if not valid
|
342
|
+
###
|
343
|
+
### @param [Symbol] the CPU type to check
|
344
|
+
###
|
345
|
+
### @return [Symbol] the valid CPU type
|
346
|
+
###
|
347
|
+
def validate_cpu_type (type)
|
348
|
+
type = JSS::Package::DEFAULT_CPU_TYPE if type.to_s.empty?
|
349
|
+
type = "None" if type =~ /^n(one)?$/i
|
350
|
+
type = "x86" if type.casecmp('intel') == 0
|
351
|
+
type = "ppc" if type.casecmp('ppc') == 0
|
352
|
+
unless JSS::Package::CPU_TYPES.include? type
|
353
|
+
raise JSS::InvalidDataError, "CPU type must be one of: #{JSS::Package::CPU_TYPES.join ', '}"
|
354
|
+
end
|
355
|
+
type
|
356
|
+
end
|
357
|
+
|
358
|
+
### Check the validity of a category name
|
359
|
+
### Raise an exception if not valid.
|
360
|
+
### nil and empty strings are acceptable to unset the category.
|
361
|
+
###
|
362
|
+
### @param cat[String] the category to check
|
363
|
+
###
|
364
|
+
### @return [String] the valid category name
|
365
|
+
###
|
366
|
+
def validate_category (cat)
|
367
|
+
cat = nil if cat.to_s =~ /^n(one)?$/i
|
368
|
+
return "" if cat.to_s.empty?
|
369
|
+
raise JSS::NoSuchItemError, "No category '#{cat}' in the JSS" unless JSS::Category.all_names.include? cat
|
370
|
+
cat
|
371
|
+
end
|
372
|
+
|
373
|
+
### Check the offered prohibiting process pattern
|
374
|
+
###
|
375
|
+
### @param match_string[String] the data entered by the user
|
376
|
+
###
|
377
|
+
### @return [String, nil] the regexp used to do the match
|
378
|
+
###
|
379
|
+
def validate_prohibiting_process (match_string)
|
380
|
+
match_string = nil if match_string.to_s =~ /^n(one)?$/i
|
381
|
+
return nil if match_string.nil? or match_string.empty?
|
382
|
+
match_string.to_s
|
383
|
+
end
|
384
|
+
|
385
|
+
### check the validity of a yes/no,true/false,1/0 input value
|
386
|
+
###
|
387
|
+
### TrueClass, "true", "y","yes", and 1 are true
|
388
|
+
###
|
389
|
+
### FalseClass, nil, "false", "n", "no", and 0 are false
|
390
|
+
###
|
391
|
+
### (Strings are case-insensitive)
|
392
|
+
### Anything else raises an exception.
|
393
|
+
###
|
394
|
+
### @param type[String,Boolean,Integer] the value to check
|
395
|
+
###
|
396
|
+
### @return [Boolean]
|
397
|
+
###
|
398
|
+
def validate_yes_no (yn)
|
399
|
+
case yn
|
400
|
+
when Fixnum
|
401
|
+
return true if yn == 1
|
402
|
+
return false if yn == 0
|
403
|
+
when String
|
404
|
+
return true if yn.strip =~ /^y(es)?$/i
|
405
|
+
return false if yn.strip =~ /^no?$/i
|
406
|
+
when TrueClass
|
407
|
+
return true
|
408
|
+
when FalseClass
|
409
|
+
return false
|
410
|
+
when nil
|
411
|
+
return false
|
412
|
+
end
|
413
|
+
raise JSS::InvalidDataError, "Value must be one of: 'yes', 'y', 'true', '1', 'no', 'n', 'false', '0'"
|
414
|
+
end
|
415
|
+
|
416
|
+
### Confirm the validity of an expiration.
|
417
|
+
### Raise an exception if invalid.
|
418
|
+
###
|
419
|
+
### @param exp[Integer] the expiration to check
|
420
|
+
###
|
421
|
+
### @return [Integer] the valid expiration
|
422
|
+
###
|
423
|
+
def validate_expiration (exp)
|
424
|
+
exp ||= '0'
|
425
|
+
raise JSS::InvalidDataError, "Expiration must be a non-negative Integer." unless exp.to_s =~ /^\d+$/
|
426
|
+
exp = 0 if exp.to_i < 0
|
427
|
+
exp.to_i
|
428
|
+
end
|
429
|
+
|
430
|
+
### Confirm the validity of an expiration path.
|
431
|
+
### any string that starts with a / is valid.
|
432
|
+
###
|
433
|
+
### @param path[Pathname, String] the path to check
|
434
|
+
###
|
435
|
+
### @return [Pathname, nil] the valid path
|
436
|
+
###
|
437
|
+
def validate_expiration_path (path)
|
438
|
+
path = path.to_s
|
439
|
+
return nil if path.empty?
|
440
|
+
raise JSS::InvalidDataError, "Expiration Path must be a full path starting with /." unless path.start_with? "/"
|
441
|
+
Pathname.new path
|
442
|
+
end
|
443
|
+
|
444
|
+
|
445
|
+
end # module Validate
|
446
|
+
|
447
|
+
end # class package
|
448
|
+
end # module D3
|
data/lib/d3/package.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
module D3
|
26
|
+
|
27
|
+
###
|
28
|
+
### Package - A JSS::Package that can be installed and maintained by d3
|
29
|
+
###
|
30
|
+
class Package < JSS::Package
|
31
|
+
module Validate
|
32
|
+
end # module validate
|
33
|
+
end # class package
|
34
|
+
|
35
|
+
end # modle D3
|
36
|
+
|
37
|
+
require "d3/package/mixins"
|
38
|
+
require "d3/package/constants"
|
39
|
+
require "d3/package/class_variables"
|
40
|
+
require "d3/package/class_methods"
|
41
|
+
require "d3/package/attributes"
|
42
|
+
require "d3/package/constructor"
|
43
|
+
require "d3/package/validate"
|
44
|
+
require "d3/package/setters"
|
45
|
+
require "d3/package/getters"
|
46
|
+
require "d3/package/questions"
|
47
|
+
require "d3/package/server_actions"
|
48
|
+
require "d3/package/client_actions"
|
49
|
+
require "d3/package/private_methods"
|
50
|
+
require "d3/package/aliases"
|
51
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
|
26
|
+
module D3
|
27
|
+
module PuppyTime
|
28
|
+
|
29
|
+
###
|
30
|
+
### PendingPuppy - a d3 pkg awaiting installation during puppytime.
|
31
|
+
###
|
32
|
+
### We don't need much data about the pkg to be installed
|
33
|
+
### These are required in the args:
|
34
|
+
### :basename
|
35
|
+
### :version
|
36
|
+
### :revision
|
37
|
+
### :admin
|
38
|
+
### :status
|
39
|
+
### These are optional:
|
40
|
+
### :force - use force when installing
|
41
|
+
###
|
42
|
+
class PendingPuppy
|
43
|
+
|
44
|
+
################# Mixin Modules #################
|
45
|
+
|
46
|
+
# The D3::Basename module provides common attributes and methods related to
|
47
|
+
# d3's use of 'basenames'
|
48
|
+
include D3::Basename
|
49
|
+
|
50
|
+
################# Attributes #################
|
51
|
+
|
52
|
+
### @return [Boolean] was this puppy queued with force?
|
53
|
+
attr_reader :force
|
54
|
+
|
55
|
+
### @return [Time] when was this puppy added to the queue
|
56
|
+
attr_accessor :queued_at
|
57
|
+
|
58
|
+
### @return [Integer] the expiration period for this app
|
59
|
+
attr_reader :custom_expiration
|
60
|
+
|
61
|
+
################# Constructor #################
|
62
|
+
|
63
|
+
###
|
64
|
+
###
|
65
|
+
###
|
66
|
+
def initialize (args = {})
|
67
|
+
raise JSS::MissingDataError, "Puppies need a :basename" unless args[:basename]
|
68
|
+
raise JSS::MissingDataError, "Puppies need a :version" unless args[:version]
|
69
|
+
raise JSS::MissingDataError, "Puppies need a :revision" unless args[:revision]
|
70
|
+
raise JSS::MissingDataError, "Puppies need an :admin" unless args[:admin]
|
71
|
+
raise JSS::MissingDataError, "Puppies need an :status" unless args[:status]
|
72
|
+
|
73
|
+
@basename = args[:basename]
|
74
|
+
@version = args[:version]
|
75
|
+
@revision = args[:revision]
|
76
|
+
@admin = args[:admin]
|
77
|
+
@custom_expiration = args[:custom_expiration]
|
78
|
+
@status = args[:status]
|
79
|
+
|
80
|
+
@id = D3::Package.ids_to_editions.invert[edition]
|
81
|
+
|
82
|
+
raise JSS::InvalidDataError, "Edition #{edition} doesn't exist in d3." unless @id
|
83
|
+
|
84
|
+
@force = args[:force]
|
85
|
+
end # init
|
86
|
+
|
87
|
+
### Install this puppy
|
88
|
+
def install
|
89
|
+
|
90
|
+
begin # for ensure
|
91
|
+
|
92
|
+
install_args = {:puppywalk => true, :admin => @admin, :force => @force}
|
93
|
+
install_args[:expiration] = @custom_expiration if @custom_expiration
|
94
|
+
|
95
|
+
# install it - this will remove it from the queue if successful
|
96
|
+
D3::Package.new(:edition => edition).install(install_args)
|
97
|
+
ensure
|
98
|
+
# but we need to remove it even if not successfull, so it doesn't
|
99
|
+
# keep trying and failing (and reminding the users)
|
100
|
+
D3::PuppyTime::PuppyQueue.instance - self
|
101
|
+
end
|
102
|
+
end # install
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
end #class PendingPuppy
|
107
|
+
end # module puppytime
|
108
|
+
end #module D3
|