lib/d3/client/receipt.rb in depot3-3.0.11 vs lib/d3/client/receipt.rb in depot3-3.0.13
- old
+ new
@@ -104,11 +104,11 @@
:removable,
:pre_remove_script_id,
:post_remove_script_id,
:expiration,
:expiration_paths,
- :prohibiting_process
+ :prohibiting_processes
]
################## Class Variables #################
### The current receipts.
@@ -573,11 +573,11 @@
@apple_pkg_ids = args[:apple_pkg_ids]
@installed_at = args[:installed_at]
@removable = args[:removable]
- @prohibiting_process = args[:prohibiting_process]
+ @prohibiting_processes = args[:prohibiting_processes]
@frozen = args[:frozen]
@pre_remove_script_id = args[:pre_remove_script_id]
@post_remove_script_id = args[:post_remove_script_id]
@expiration = args[:expiration].to_i
@@ -620,11 +620,11 @@
depiloting = pilot? && skipped?
begin # ...ensure...
if uninstall_prohibited_by_process? and (not force)
- raise D3::InstallError, "#{edition} cannot be uninstalled now because '#{@prohibiting_process}' is running."
+ raise D3::InstallError, "#{edition} cannot be uninstalled now because one or more of the following processes is running: #{D3::Admin::OPTIONS[:prohibiting_processes][:display_conversion].call @prohibiting_processes}"
end
D3::Client.set_env :removing, edition
D3.log "Uninstalling #{edition}", :warn
# run a preflight if needed.
@@ -758,14 +758,15 @@
raise D3::UninstallError, "#{edition} is not a .pkg installer. Can't use Apple receipts." if @package_type == :dmg
to_delete = {}
begin
installed_apple_rcpts = `#{JSS::Composer::PKG_UTIL} --pkgs`.split("\n")
@apple_pkg_ids.each do |pkgid|
-
unless installed_apple_rcpts.include? pkgid
- raise D3::UninstallError, "No local Apple receipt for '#{pkgid}'"
+ D3.log "No local Apple receipt for '#{pkgid}', ignoring", :warn
+ next
end
+
# this gets them in reverse order, so we can
# delete files and then test for and delete empty dirs on the way
to_delete[pkgid] = `#{JSS::Composer::PKG_UTIL} --files '#{pkgid}' 2>/dev/null`.split("\n").reverse
raise D3::UninstallError, "Error querying pkg file list for '#{pkgid}'" if $CHILD_STATUS.exitstatus > 0
end # each pkgid
@@ -864,13 +865,13 @@
###
def expiration_paths= (new_val)
@expiration_paths = new_val
end
- ### Set a new prohibiting process
- def prohibiting_process=(new_val)
- @prohibiting_process = new_val
+ ### Set new prohibiting process(es)
+ def prohibiting_processes=(new_val)
+ @prohibiting_processes = new_val
end
### Update the current receipt in the receipt store
def update
D3::Client::Receipt.add_receipt(self, :replace)
@@ -1132,10 +1133,13 @@
@last_usage = all_usages.compact.max
# if never been used, last usage is the install date
@last_usage ||= @installed_at
+ # prohibiting_processes should always be an array
+ @prohibiting_processes ||= []
+
# if the install time is newer than the last usage,
# use the install time.
# this basically "resets the timer" when
# something is re-installed.
@last_usage = @installed_at if @installed_at > @last_usage
@@ -1149,31 +1153,30 @@
end # last_usage
### set the status - for rcpts, this can't be a private method
###
- ### @param new_status[Symnol] one of the valid STATUSES
+ ### @param new_status[Symbol] one of the valid STATUSES
###
### @return [Symbol] the new status
###
def status= (new_status)
raise JSS::InvalidDataError, "status must be one of :#{D3::Basename::STATUSES.join(', :')}" unless D3::Basename::STATUSES.include? new_status
@status = new_status
update
end
- ################# Provate Instance Methods #################
+ ################# Private Instance Methods #################
private
### Is there a process running that would prevent removal?
###
### @return [Boolean]
###
def uninstall_prohibited_by_process?
- return false unless @prohibiting_process
- D3.prohibited_by_process_running? @prohibiting_process
+ D3.prohibited_by_process_running? @prohibiting_processes
end #
end # class Receipt
end # class Client
end # module