From 4258964f427ea6d11fa2163858b1f33d74e0e7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Py=C4=87?= Date: Mon, 7 Mar 2022 16:40:51 +0100 Subject: [PATCH 1/2] Stop moving Xcode with sudo --- lib/xcode/install.rb | 16 ++++++++-------- lib/xcode/install/uninstall.rb | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/xcode/install.rb b/lib/xcode/install.rb index 0eefb978..d9c19839 100644 --- a/lib/xcode/install.rb +++ b/lib/xcode/install.rb @@ -233,9 +233,9 @@ def install_dmg(dmg_path, suffix = '', switch = true, clean = true) xcode_orig_path = File.join(Dir.pwd, 'Xcode.app') xcode_beta_path = File.join(Dir.pwd, 'Xcode-beta.app') if Pathname.new(xcode_orig_path).exist? - `sudo -p "#{prompt}" mv "#{xcode_orig_path}" "#{xcode_path}"` + `mv "#{xcode_orig_path}" "#{xcode_path}"` elsif Pathname.new(xcode_beta_path).exist? - `sudo -p "#{prompt}" mv "#{xcode_beta_path}" "#{xcode_path}"` + `mv "#{xcode_beta_path}" "#{xcode_path}"` else out = <<-HELP No `Xcode.app(or Xcode-beta.app)` found in XIP. Please remove #{dmg_path} if you @@ -260,14 +260,14 @@ def install_dmg(dmg_path, suffix = '', switch = true, clean = true) return end - `sudo -p "#{prompt}" ditto "#{source}" "#{xcode_path}"` + `ditto "#{source}" "#{xcode_path}"` `umount "/Volumes/Xcode"` end xcode = InstalledXcode.new(xcode_path) unless xcode.verify_integrity - `sudo rm -rf #{xcode_path}` + `rm -rf #{xcode_path}` return end @@ -276,8 +276,8 @@ def install_dmg(dmg_path, suffix = '', switch = true, clean = true) xcode.install_components if switch - `sudo rm -f #{SYMLINK_PATH}` unless current_symlink.nil? - `sudo ln -sf #{xcode_path} #{SYMLINK_PATH}` unless SYMLINK_PATH.exist? + `rm -f #{SYMLINK_PATH}` unless current_symlink.nil? + `ln -sf #{xcode_path} #{SYMLINK_PATH}` unless SYMLINK_PATH.exist? `sudo xcode-select --switch #{xcode_path}` puts `xcodebuild -version` @@ -330,8 +330,8 @@ def rm_list_cache def symlink(version) xcode = installed_versions.find { |x| x.version == version } - `sudo rm -f #{SYMLINK_PATH}` unless current_symlink.nil? - `sudo ln -sf #{xcode.path} #{SYMLINK_PATH}` unless xcode.nil? || SYMLINK_PATH.exist? + `rm -f #{SYMLINK_PATH}` unless current_symlink.nil? + `ln -sf #{xcode.path} #{SYMLINK_PATH}` unless xcode.nil? || SYMLINK_PATH.exist? end def symlinks_to diff --git a/lib/xcode/install/uninstall.rb b/lib/xcode/install/uninstall.rb index ec6c46f0..70deb973 100644 --- a/lib/xcode/install/uninstall.rb +++ b/lib/xcode/install/uninstall.rb @@ -25,7 +25,7 @@ def run installed_path = @installer.installed_versions.find { |x| x.version == @version } return if installed_path.nil? || installed_path.path.nil? - `sudo rm -rf #{installed_path.path}` + `rm -rf #{installed_path.path}` return unless @installer.symlinks_to == installed_path.path newest_version = @installer.installed_versions.last From 514dcf2eb9e393a2c1795d01b40734abdf63b3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Py=C4=87?= Date: Tue, 8 Mar 2022 10:12:56 +0100 Subject: [PATCH 2/2] Removed unused variable --- lib/xcode/install.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/xcode/install.rb b/lib/xcode/install.rb index d9c19839..3edc90f0 100644 --- a/lib/xcode/install.rb +++ b/lib/xcode/install.rb @@ -225,7 +225,6 @@ def seedlist end def install_dmg(dmg_path, suffix = '', switch = true, clean = true) - prompt = "Please authenticate for Xcode installation.\nPassword: " xcode_path = "/Applications/Xcode#{suffix}.app" if dmg_path.extname == '.xip'