Skip to content

Commit

Permalink
don't bundle codesign, prompt user to install xcode commandline tools
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed May 22, 2014
1 parent 9734451 commit 5adef81
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 12 deletions.
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ cp -Rf "$BUILT_PRODUCTS_DIR/asepsisTest" "$TEST"
cp -Rf "$BUILT_PRODUCTS_DIR/DesktopServicesPrivWrapper.framework/Versions/A/DesktopServicesPrivWrapper" "$WRAPPER"
cp -Rf "$BUILT_PRODUCTS_DIR/AsepsisUpdater.app" "$UPDATER"
cp "$PROJECT_DIR/install_name_tool" "$TARGET"
cp "$PROJECT_DIR/codesign" "$TARGET"

install_name_tool -change "/System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv" "/System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A_/DesktopServicesPriv" "$WRAPPER"

Expand Down
11 changes: 9 additions & 2 deletions ctl/cmd/install.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
def cmd_install(options)
# prevent installing on future OS versions
os_version_check()

$forced_exit_code = 0

ctl = "\"#{ASEPSISCTL_SYMLINK_SOURCE_PATH}\""
sys!("#{ctl} create_symlink")
Expand All @@ -12,7 +14,12 @@ def cmd_install(options)
sys!("#{ctl} install_updater")

# remove (possibly) scheduled uninstall (pathological case when someone uninstalls and installs without restart)
sys("sudo rm \"/Library/LaunchDaemons/com.binaryage.asepsis.uninstall.plist\"") if File.exists? "/Library/LaunchDaemons/com.binaryage.asepsis.uninstall.plist"
sys!("sudo rm \"/Library/LaunchDaemons/com.binaryage.asepsis.uninstall.plist\"") if File.exists? "/Library/LaunchDaemons/com.binaryage.asepsis.uninstall.plist"

say "Asepsis installation done, it is effective for newly launched processes, you should reboot your computer"
if $forced_exit_code==0 then
say "Asepsis installation done, it is effective for newly launched processes, you should reboot your computer."
else
say_red "Asepsis installation encountered some failures, please inspect the command output."
exit 1
end
end
6 changes: 4 additions & 2 deletions ctl/cmd/install_wrapper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
def cmd_install_wrapper(options)
force = options[:force]

codesign_check()

# prevent installing on future OS versions
os_version_check() unless force

Expand Down Expand Up @@ -40,9 +42,9 @@ def cmd_install_wrapper(options)
sys("sudo cp -a \"#{DS_LIB_FOLDER}\" \"#{DS_LIB_RELOCATED_FOLDER}\"")
sys("sudo \"#{RESOURCES_PATH}/install_name_tool\" -id \"#{DS_LIB_RELOCATED_FOLDER}/DesktopServicesPriv\" \"#{DS_LIB_RELOCATED_FOLDER}/DesktopServicesPriv\"")
# apply code signatures only under Mavericks and higher
sys("sudo \"#{RESOURCES_PATH}/codesign\" --force --sign - \"#{DS_LIB_RELOCATED_FOLDER}/DesktopServicesPriv\"") unless lions?
sys("sudo /usr/bin/codesign --force --sign - \"#{DS_LIB_RELOCATED_FOLDER}/DesktopServicesPriv\"") unless lions?
sys("sudo cp \"#{DS_WRAPPER_SOURCE_PATH}\" \"#{DS_LIB_FOLDER}/DesktopServicesPriv\"")
# since 10.9.3 it is important to codesing in-place after copying the file, see https://github.com/binaryage/asepsis/issues/13
sys("sudo \"#{RESOURCES_PATH}/codesign\" --force --sign - \"#{DS_LIB_FOLDER}\"") unless lions?
sys("sudo /usr/bin/codesign --force --sign - \"#{DS_LIB_FOLDER}\"") unless lions?
sys("sudo rm -rf \"#{DS_LIB_FOLDER}/_CodeSignature\"")
end
12 changes: 10 additions & 2 deletions ctl/cmd/uninstall.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
def cmd_uninstall(options)
ctl = "\"#{ASEPSISCTL_SYMLINK_SOURCE_PATH}\""

$forced_exit_code = 0

sys!("#{ctl} uninstall_wrapper")
sys!("#{ctl} kill_daemon")
sys!("#{ctl} uninstall_daemon")
Expand All @@ -8,7 +11,12 @@ def cmd_uninstall(options)
sys!("#{ctl} uninstall_updater")

# install launchd "runonce" task to finish the uninstallation after reboot
sys("sudo cp \"#{RESOURCES_PATH}/com.binaryage.asepsis.uninstall.plist\" \"/Library/LaunchDaemons\"")
sys!("sudo cp \"#{RESOURCES_PATH}/com.binaryage.asepsis.uninstall.plist\" \"/Library/LaunchDaemons\"")

say "Asepsis uninstallation done, reboot your computer"
if $forced_exit_code==0 then
say "Asepsis uninstallation done, reboot your computer."
else
say_red "Asepsis uninstallation done, but with some failures, please inspect the command output."
exit 1
end
end
15 changes: 13 additions & 2 deletions ctl/lib/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def say(what)
puts colorize("34", what)
end

def say_red(what)
puts colorize("31", what)
end

def sys(cmd)
out(cmd)
$stdout.flush
Expand All @@ -24,11 +28,13 @@ def sys(cmd)
def sys!(cmd)
out(cmd)
$stdout.flush
system(cmd)
if not system(cmd) then
$forced_exit_code = 1
end
end

def die(message, code=1)
puts message
say_red message
exit code
end

Expand Down Expand Up @@ -75,6 +81,11 @@ def lions?
$?==0
end

def codesign_check()
res = `which codesignx`.strip
die("Asepsis requires working codesign command for this operation. Please install codesign to /usr/bin/codesign.\nInstall Xcode command-line tools: http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x") if res.size==0
end

def os_version_check()
`sw_vers -productVersion|grep '10\\.\\(7\\|8\\|9\\)'`
die("Asepsis #{ASEPSISCTL_VERSION} can be only installed under OS X versions 10.7, 10.8 and 10.9\nCheck out http://asepsis.binaryage.com for updated version.") if $?!=0
Expand Down
7 changes: 7 additions & 0 deletions installer/check-codesign-present.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [ -z `which codesign` ]; then
xcode-select --install
exit 1
fi
exit 0
46 changes: 46 additions & 0 deletions installer/installer.pkgproj
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,47 @@
<key>STATE</key>
<true/>
</dict>
<dict>
<key>BEHAVIOR</key>
<integer>3</integer>
<key>DICTIONARY</key>
<dict>
<key>IC_REQUIREMENT_SCRIPT_ARGUMENTS</key>
<array/>
<key>IC_REQUIREMENT_SCRIPT_COMPARATOR</key>
<integer>0</integer>
<key>IC_REQUIREMENT_SCRIPT_EMBED</key>
<true/>
<key>IC_REQUIREMENT_SCRIPT_PATH</key>
<dict>
<key>PATH</key>
<string>installer/check-codesign-present.sh</string>
<key>PATH_TYPE</key>
<integer>3</integer>
</dict>
<key>IC_REQUIREMENT_SCRIPT_VALUE</key>
<integer>0</integer>
</dict>
<key>IC_REQUIREMENT_CHECK_TYPE</key>
<integer>0</integer>
<key>IDENTIFIER</key>
<string>fr.whitebox.Packages.requirement.scripts</string>
<key>MESSAGE</key>
<array>
<dict>
<key>LANGUAGE</key>
<string>English</string>
<key>SECONDARY_VALUE</key>
<string></string>
<key>VALUE</key>
<string>Please install Xcode command-line tools first. Asepsis requires working "codesign" command. You should see a separate dialog or read this article http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x.</string>
</dict>
</array>
<key>NAME</key>
<string>Codesign requirement</string>
<key>STATE</key>
<true/>
</dict>
</array>
<key>POSTINSTALL_PATH</key>
<dict/>
Expand Down Expand Up @@ -922,6 +963,11 @@
<string>/Users/darwin/code/asepsis</string>
</dict>
</dict>
<key>SHARED_GLOBAL_DATA</key>
<dict>
<key>IC_REQUIREMENT_JAVASCRIPT_SHARED_SOURCE_CODE</key>
<string></string>
</dict>
<key>TYPE</key>
<integer>0</integer>
<key>VERSION</key>
Expand Down
4 changes: 1 addition & 3 deletions installer/script_asepsis_post
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
/Library/Application\ Support/Asepsis/ctl/asepsisctl uninstall_kext

# perform inplace re-installation
/Library/Application\ Support/Asepsis/ctl/asepsisctl install

exit 0
/Library/Application\ Support/Asepsis/ctl/asepsisctl install
Empty file modified installer/script_asepsis_pre
100644 → 100755
Empty file.
Binary file removed packager/codesign
Binary file not shown.

0 comments on commit 5adef81

Please sign in to comment.