lib/u3d/installation.rb in u3d-1.0.20 vs lib/u3d/installation.rb in u3d-1.0.21
- old
+ new
@@ -19,17 +19,20 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
## --- END LICENSE BLOCK ---
require 'u3d/utils'
+require 'u3d_core/admin_tools'
+require 'fileutils'
module U3d
UNITY_DIR_CHECK = /Unity_\d+\.\d+\.\d+[a-z]\d+/
UNITY_DIR_CHECK_LINUX = /unity-editor-\d+\.\d+\.\d+[a-z]\d+\z/
+ U3D_DO_NOT_MOVE = ".u3d_do_not_move".freeze
class Installation
- attr_reader :root_path
+ attr_accessor :root_path
NOT_PLAYBACKENGINE_PACKAGES = %w[Documentation StandardAssets MonoDevelop].freeze
PACKAGE_ALIASES =
{
'Android' => [],
@@ -65,10 +68,26 @@
def packages
false
end
+ def do_not_move?
+ File.exist?(@root_path) && File.exist?(do_not_move_file_path)
+ end
+
+ def do_not_move!(dry_run: false)
+ if dry_run
+ UI.message "Would create '#{do_not_move_file_path}'"
+ else
+ begin
+ FileUtils.touch do_not_move_file_path
+ rescue Errno::EACCES => _e
+ U3dCore::AdminTools.create_file(Helper.operating_system, do_not_move_file_path)
+ end
+ end
+ end
+
def package_installed?(package)
return true if (packages || []).include?(package)
aliases = PACKAGE_ALIASES[package]
@@ -76,10 +95,16 @@
# If the exact name doesn't match then we have to suppose it's not installed
return false unless aliases
return !(aliases & packages).empty?
end
+
+ private
+
+ def do_not_move_file_path
+ File.join(@root_path, U3D_DO_NOT_MOVE)
+ end
end
class PlaybackEngineUtils
def self.list_module_configs(playbackengine_parent_path)
Dir.glob("#{playbackengine_parent_path}/PlaybackEngines/*/ivy.xml")
@@ -150,11 +175,11 @@
UI.crash! "No pattern is known for #{module_name} on Mac"
end
end
def clean_install?
- !(root_path =~ UNITY_DIR_CHECK).nil?
+ do_not_move? || !(root_path =~ UNITY_DIR_CHECK).nil?
end
private
def plist
@@ -173,10 +198,11 @@
def find_build_number(root)
known_rev_locations.each do |p|
rev = find_build_number_in("#{root}#{p}")
return rev if rev
end
+ nil
end
private
def strings(path)
@@ -255,11 +281,11 @@
UI.crash! "No pattern is known for #{module_name} on Linux"
end
end
def clean_install?
- !(root_path =~ UNITY_DIR_CHECK_LINUX).nil?
+ do_not_move? || !(root_path =~ UNITY_DIR_CHECK_LINUX).nil?
end
end
class WindowsInstallationHelper
def build_number(exe_path)
@@ -370,9 +396,9 @@
UI.crash! "No pattern is known for #{module_name} on Windows"
end
end
def clean_install?
- !(root_path =~ UNITY_DIR_CHECK).nil?
+ do_not_move? || !(root_path =~ UNITY_DIR_CHECK).nil?
end
end
end