Skip to content

Instantly share code, notes, and snippets.

@joakimk
Created November 22, 2009 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joakimk/240491 to your computer and use it in GitHub Desktop.
Save joakimk/240491 to your computer and use it in GitHub Desktop.
# Installer script for the Android development environment on MacOSX.
# This code is Public Domain. Have fun.
# Made by @joakimk.
DOWNLOAD_DIR = "~/Downloads/android"
INSTALL_DIR = "/usr/local/android"
system "mkdir -p #{DOWNLOAD_DIR}"
def check(part)
print part.gsub(/_/, ' ').capitalize + " y/n: "; STDOUT.flush
eval("def #{part}?; #{gets.chomp == 'y'}; end")
end
def run(commands)
system commands.flatten.join(" && ")
end
def api_install_commands(api, platform)
[
"cd #{INSTALL_DIR}/add-ons",
"sudo wget http://dl-ssl.google.com/android/repository/#{api}",
"sudo unzip #{api}",
"sudo rm #{api}",
"cd #{INSTALL_DIR}/platforms",
"sudo wget http://dl-ssl.google.com/android/repository/#{platform}",
"sudo unzip #{platform}",
"sudo rm #{platform}"
]
end
check("install_android_sdk")
check("install_eclipse")
check("install_textmate_plugin")
run [ "cd #{DOWNLOAD_DIR}",
"wget http://ftp.ing.umu.se/mirror/eclipse/technology/epp/downloads/release/galileo/SR1/eclipse-java-galileo-SR1-macosx-cocoa.tar.gz",
"tar xvfz eclipse-java-galileo-SR1-macosx-cocoa.tar.gz &> /dev/null",
"sudo mv eclipse /Applications" ] if install_eclipse?
run [ "mkdir -p '#{ENV['home']}/Library/Application Support/TextMate/Bundles'",
"cd '#{ENV['home']}/Library/Application Support/TextMate/Bundles'",
"git clone git://github.com/geoffb/android-tmbundle.git Android.tmbundle",
"osascript -e 'tell app \"TextMate\" to reload bundles'" ] if install_textmate_plugin?
run [ "cd #{DOWNLOAD_DIR}",
"wget http://dl.google.com/android/android-sdk_r3-mac.zip",
"unzip android-sdk_r3-mac.zip &> /dev/null",
"sudo mv android-sdk-mac #{INSTALL_DIR}",
api_install_commands("google_apis-3-r03.zip", "android-1.5_r03-mac_x86.zip"),
api_install_commands("google_apis-4-r01.zip", "android-1.6_r01-mac_x86.zip"),
api_install_commands("google_apis-5_r01.zip", "android-2.0_r01-macosx.zip"),
"sudo mkdir -p /tmp/android",
"sudo chmod 1777 /tmp/android",
"sudo chmod 755 #{INSTALL_DIR}" ] if install_android_sdk?
if install_android_sdk?
puts
puts "ANDROID SDK:"
puts "- !! This script bypasses the license dialogs when installing the API/Platforms, you can find the license at: !!"
puts "- !! http://developer.android.com/sdk/terms.html (you accept it by using the SDK!) !!"
puts "- Add to PATH: #{INSTALL_DIR}/tools"
puts "- Examples for creating 'AVDs':"
puts ' android create avd --target 4 --name "Android-1.5"'
puts ' android create avd --target 5 --name "Android-1.6"'
puts ' android create avd --target 6 --name "Android-2.0"'
puts "- Getting started with Android Dev: http://developer.android.com/guide/tutorials/hello-world.html"
end
if install_eclipse?
puts
puts "ECLIPSE:"
puts "Eclipse can be found under /Applications/eclipse"
puts "- Follow http://developer.android.com/sdk/eclipse-adt.html to install the eclipse ADT plugin (follow the instructions for Eclipse 3.5 (Galileo))"
end
if install_textmate_plugin?
puts
puts "TEXTMATE:"
puts "- More info about the textmate bundle at: http://github.com/geoffb/android-tmbundle"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment