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,314 @@
|
|
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
|
+
### client/lists.rb
|
27
|
+
###
|
28
|
+
### Methods related to the display of lists via the d3 client tool
|
29
|
+
###
|
30
|
+
|
31
|
+
module D3
|
32
|
+
class Client < JSS::Client
|
33
|
+
|
34
|
+
### list installed d3 items.
|
35
|
+
### The arg can be used to limit what's listed
|
36
|
+
### and can be one of :all, :manual, :pilot, :frozen.
|
37
|
+
### (anything other than :manual, :pilot, or :frozen
|
38
|
+
### is treated as :all)
|
39
|
+
###
|
40
|
+
### @param what_to_list[Symbol] one of :all, :manual, :pilot, :frozen.
|
41
|
+
### defaults to :all
|
42
|
+
###
|
43
|
+
### @return [void]
|
44
|
+
###
|
45
|
+
def self.list_installed (what_to_list = :all)
|
46
|
+
|
47
|
+
case what_to_list
|
48
|
+
when :manual then
|
49
|
+
title = "Manually installed packages (not-uninstallable<, frozen^)"
|
50
|
+
kind = "manually installed "
|
51
|
+
when :pilots then
|
52
|
+
title = "Packages being piloted on this machine (not-uninstallable<, frozen^)"
|
53
|
+
kind = "pilot "
|
54
|
+
when :frozen then
|
55
|
+
title = "Packages frozen on this machine (not-uninstallable<)"
|
56
|
+
kind = "frozen "
|
57
|
+
else
|
58
|
+
title = "All packages installed by d3 (not-uninstallable<, frozen^)"
|
59
|
+
kind = ""
|
60
|
+
end # case show
|
61
|
+
|
62
|
+
colheaders = %w{Basename Vers-Rev Status Installed By}
|
63
|
+
|
64
|
+
lines = []
|
65
|
+
|
66
|
+
D3::Client::Receipt.all.keys.sort.each do |bn|
|
67
|
+
|
68
|
+
# its a d3 installer
|
69
|
+
rcpt = D3::Client::Receipt.all[bn]
|
70
|
+
|
71
|
+
if what_to_list == :manual
|
72
|
+
next unless rcpt.manual?
|
73
|
+
end # if manual
|
74
|
+
|
75
|
+
if what_to_list == :pilots
|
76
|
+
next unless rcpt.pilot?
|
77
|
+
end
|
78
|
+
|
79
|
+
if what_to_list == :frozen
|
80
|
+
next unless rcpt.frozen?
|
81
|
+
end
|
82
|
+
|
83
|
+
basename = rcpt.basename
|
84
|
+
basename += "<" unless rcpt.removable?
|
85
|
+
basename += "^" if rcpt.frozen? and (not what_to_list == :frozen)
|
86
|
+
date = rcpt.installed_at.strftime "%Y-%m-%d"
|
87
|
+
|
88
|
+
lines << [basename, "#{rcpt.version}-#{rcpt.revision}", rcpt.status, date, rcpt.admin]
|
89
|
+
|
90
|
+
end # installed_pkgs.each
|
91
|
+
|
92
|
+
if lines.empty?
|
93
|
+
puts "No #{kind}receipts on this computer"
|
94
|
+
else
|
95
|
+
D3.less_text D3.generate_report(lines, :title => title, :header_row => colheaders)
|
96
|
+
end
|
97
|
+
end # list_all_installed
|
98
|
+
|
99
|
+
### list all manually installed pkgs
|
100
|
+
###
|
101
|
+
def self.list_manual
|
102
|
+
self.list_installed :manual
|
103
|
+
end
|
104
|
+
|
105
|
+
### list all installed pilots
|
106
|
+
###
|
107
|
+
def self.list_pilots
|
108
|
+
self.list_installed :pilots
|
109
|
+
end
|
110
|
+
|
111
|
+
### list all frozen pkgs
|
112
|
+
###
|
113
|
+
def self.list_frozen
|
114
|
+
self.list_installed :frozen
|
115
|
+
end
|
116
|
+
|
117
|
+
### list_pending_puppies
|
118
|
+
###
|
119
|
+
def self.list_pending_puppies
|
120
|
+
if D3::PUPPY_Q.q.empty?
|
121
|
+
puts "# There are no puppies in the queue"
|
122
|
+
return nil
|
123
|
+
end
|
124
|
+
|
125
|
+
title = "Puppy packages awaiting logout"
|
126
|
+
colheaders = %w{Edition Status Queued-at By}
|
127
|
+
lines = []
|
128
|
+
|
129
|
+
# loop through the puppies in the queue
|
130
|
+
D3::PUPPY_Q.q.values.each do | pup|
|
131
|
+
lines << [pup.edition, pup.status, (pup.queued_at.strftime "%b %d %Y %H:%M:%S"), pup.admin]
|
132
|
+
end # do pup
|
133
|
+
D3.less_text D3.generate_report(lines, :title => title, :header_row => colheaders)
|
134
|
+
|
135
|
+
end # list pending pups
|
136
|
+
|
137
|
+
### list currently available packages to stdout via 'less'
|
138
|
+
###
|
139
|
+
### @return [void]
|
140
|
+
###
|
141
|
+
def self.list_available(force = false)
|
142
|
+
|
143
|
+
# If using force, show all live pkgs
|
144
|
+
if force or D3.forced?
|
145
|
+
ids_to_show = D3::Package.live_ids
|
146
|
+
title = "All live packages in d3 (* = installed, ^ = puppies)"
|
147
|
+
|
148
|
+
# otherwise, only those available to this machine based on
|
149
|
+
# excluded_groups.
|
150
|
+
# (the intersection of all live, with all available to this machine,
|
151
|
+
# the latter of which includes non-live)
|
152
|
+
else
|
153
|
+
ids_to_show = D3::Package.live_ids & D3::Client.available_pkg_ids
|
154
|
+
title = "Live packages available for this machine (* = installed, ^ = puppies)"
|
155
|
+
end # if force
|
156
|
+
|
157
|
+
header = ["Basename", "Vers-Rev" , "Auto-installed on" ]
|
158
|
+
|
159
|
+
my_rcpt_ids = D3::Client::Receipt.all.values.map{|r| r.id}
|
160
|
+
|
161
|
+
lines = []
|
162
|
+
ids_to_show.each do |id|
|
163
|
+
pkg = D3::Package.package_data[id]
|
164
|
+
bn = pkg[:basename]
|
165
|
+
bn += "*" if my_rcpt_ids.include? id
|
166
|
+
bn += "^" if pkg[:reboot]
|
167
|
+
auto_grps = pkg[:auto_groups].empty? ? "-" : pkg[:auto_groups].join(',')
|
168
|
+
lines << [bn, "#{pkg[:version]}-#{pkg[:revision]}", auto_grps ]
|
169
|
+
end
|
170
|
+
lines.sort_by! {|l| l[0]}
|
171
|
+
D3.less_text D3.generate_report(lines, header_row: header, title: title)
|
172
|
+
|
173
|
+
return true
|
174
|
+
|
175
|
+
end # list_avail
|
176
|
+
|
177
|
+
### list the files installed by one or more installers
|
178
|
+
###
|
179
|
+
def self.list_files(pkgs)
|
180
|
+
self.connect_for_reports
|
181
|
+
pkgs.each do |pkg_to_match|
|
182
|
+
begin
|
183
|
+
found_pkg = D3::Package.find_package pkg_to_match
|
184
|
+
unless found_pkg
|
185
|
+
puts "Skipping '#{pkg_to_match}': no matching edition in d3"
|
186
|
+
next
|
187
|
+
end
|
188
|
+
puts "Querying for files installed by '#{found_pkg.edition}'..."
|
189
|
+
|
190
|
+
# because this is just a list of single strings
|
191
|
+
# and doesn't need column formatting,
|
192
|
+
# and mostly because it can be tens of thousands
|
193
|
+
# of lines long, we're not using 'generate_report"
|
194
|
+
# and just building a huge string to display.
|
195
|
+
file_list = "# Files installed by #{found_pkg.edition}\n"
|
196
|
+
file_list += "#==========================================================================\n"
|
197
|
+
file_list += found_pkg.installed_files.join("\n")
|
198
|
+
|
199
|
+
D3.less_text file_list
|
200
|
+
|
201
|
+
rescue JSS::MissingDataError, JSS::InvalidDataError
|
202
|
+
D3.log "Skipping #{item_to_match}:\n #{$!}", :error
|
203
|
+
D3.log_backtrace
|
204
|
+
end # begin
|
205
|
+
end # isntallers.each
|
206
|
+
end # list files
|
207
|
+
|
208
|
+
### find out which editions install one or more given files
|
209
|
+
###
|
210
|
+
def self.query_files (paths)
|
211
|
+
self.connect_for_reports
|
212
|
+
paths.each do |path|
|
213
|
+
puts "Querying for packages that install '#{path}'..."
|
214
|
+
path = path.chomp "/" # remove trailing slashes on dirs
|
215
|
+
query = <<-ENDQ
|
216
|
+
SELECT pkgs.package_id
|
217
|
+
FROM #{D3::Package::P_TABLE[:table_name]} pkgs
|
218
|
+
JOIN #{D3::Package::PKG_CONTENTS_TABLE} contents
|
219
|
+
ON pkgs.#{D3::Package::P_FIELDS[:id][:field_name]} = contents.#{D3::Package::P_FIELDS[:id][:field_name]}
|
220
|
+
WHERE contents.file = '#{Mysql.quote path}'
|
221
|
+
ENDQ
|
222
|
+
search_results = JSS::DB_CNX.db.query query
|
223
|
+
ids = []
|
224
|
+
search_results.each{|id| ids << id[0].to_i}
|
225
|
+
search_results.free
|
226
|
+
if ids.empty?
|
227
|
+
puts "# Nothing in d3 installs '#{path}'"
|
228
|
+
else
|
229
|
+
title = "Packages that install '#{path}'"
|
230
|
+
colheader = %w{Edition Status Installed}
|
231
|
+
lines = []
|
232
|
+
ids.each do |id|
|
233
|
+
begin
|
234
|
+
pkg = D3::Package.new id: id
|
235
|
+
lines << [pkg.edition, pkg.status.to_s, (pkg.installed? ? "yes" : "no")]
|
236
|
+
rescue
|
237
|
+
D3.log "Couldn't get pkg for id #{id}", :error
|
238
|
+
end # begin
|
239
|
+
end
|
240
|
+
D3.less_text D3.generate_report(lines, header_row: colheader, title: title)
|
241
|
+
|
242
|
+
end # if ids.empty?
|
243
|
+
end # paths each path
|
244
|
+
end # def query files
|
245
|
+
|
246
|
+
### Display the details about one or more pkgs and/or receipts on the local machine
|
247
|
+
###
|
248
|
+
### @param pkgs[String,Array<String>] the pkgs to list details for.
|
249
|
+
###
|
250
|
+
### @return [void]
|
251
|
+
###
|
252
|
+
def self.list_details(pkgs)
|
253
|
+
pkgs = [pkgs] if pkgs.is_a? String
|
254
|
+
pkgs.each do |item_to_match|
|
255
|
+
begin
|
256
|
+
|
257
|
+
# package details
|
258
|
+
server_pkg = D3::Package.find_package(item_to_match)
|
259
|
+
if server_pkg
|
260
|
+
puts "### Found package on the server matching '#{item_to_match}'\n"
|
261
|
+
puts server_pkg.formatted_details
|
262
|
+
else
|
263
|
+
puts "### No package on the server matched '#{item_to_match}'"
|
264
|
+
puts "### (doesn't exist, or basename has no live editions)"
|
265
|
+
end
|
266
|
+
|
267
|
+
# receipt details
|
268
|
+
rcpt = D3::Client::Receipt.find_receipt item_to_match
|
269
|
+
if rcpt
|
270
|
+
puts
|
271
|
+
if server_pkg
|
272
|
+
if rcpt.edition == server_pkg.edition
|
273
|
+
puts "### Found matching receipt for edition '#{server_pkg.edition}'\n"
|
274
|
+
else
|
275
|
+
puts "### Found receipt for different edition: '#{rcpt.edition}'\n"
|
276
|
+
end # if rcpt.edition == server_pkg.edition
|
277
|
+
|
278
|
+
else # no svr pkg
|
279
|
+
puts "### Found receipt matching '#{item_to_match}'\n"
|
280
|
+
end # if svr pkg
|
281
|
+
|
282
|
+
puts rcpt.formatted_details
|
283
|
+
|
284
|
+
else # no rcpt
|
285
|
+
puts "### No receipt matched '#{item_to_match}'"
|
286
|
+
end # if rcpt
|
287
|
+
|
288
|
+
rescue
|
289
|
+
D3.log "An error occured getting the details of #{item_to_match}:\n #{$!}", :error
|
290
|
+
D3.log_backtrace
|
291
|
+
next
|
292
|
+
end # begin
|
293
|
+
|
294
|
+
end # args.each
|
295
|
+
end # list details
|
296
|
+
|
297
|
+
### Reconnect to both the API and DB with a much larger timeout, and
|
298
|
+
### using an alternate DB server if one is defined.
|
299
|
+
###
|
300
|
+
### @return [Hash<String>] the hostnames of the connected JSS & MySQL servers
|
301
|
+
###
|
302
|
+
def self.connect_for_reports
|
303
|
+
jss_ro_user = D3::CONFIG.client_jss_ro_user
|
304
|
+
jss_ro_user ||= JSS::CONFIG.api_username
|
305
|
+
|
306
|
+
db_ro_user = D3::CONFIG.client_db_ro_user
|
307
|
+
db_ro_user ||= JSS::CONFIG.db_username
|
308
|
+
|
309
|
+
D3.connect_for_reports jss_ro_user, get_ro_pass(:jss), db_ro_user, get_ro_pass(:db)
|
310
|
+
end # connect for report
|
311
|
+
|
312
|
+
end # class
|
313
|
+
end # module D3
|
314
|
+
|