Skip to content

Instantly share code, notes, and snippets.

@roadsideseb
Last active November 10, 2016 17:50
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 roadsideseb/82450470a2727f548dc0773d29b699da to your computer and use it in GitHub Desktop.
Save roadsideseb/82450470a2727f548dc0773d29b699da to your computer and use it in GitHub Desktop.
Various ways to install packages on OSX
#!/bin/bash
#
# Install an application or library that uses a PKG installer
# wrapped inside a DMG archive. Takes the URL of the DMG and
# optionally the name of the downloaded file locally.
#
# ./auto_install_dmg.sh https://example.com/software/download/super_genius_tool_v1.2.dmg
set -uxe
download_url=${1:-"https://google.com/"}
package_name=${2:-"downloaded_package.dmg"}
download_dir=$(mktemp -d)
filename=${download_dir}/${package_name}
echo "Installing ${package_name}"
curl -fo ${filename} ${download_url}
pushd ${download_dir}
volume_name=$(hdiutil attach ${package_name} | grep '/Volumes' | awk '{$1=$2=""; print $0}')
volume_name=$(set -f; echo $volume_name)
packages=$(ls "${volume_name}"/*.pkg)
sudo installer -pkg "${packages}" -target /
hdiutil detach "${volume_name}"
popd
rm -f ${filename}
#!/bin/bash
#
# Install a specific Python version using the official
# python.org site using the commandline. This installer
# script takes an optional version number to install the
# desired version.
#
# ./python_on_osx.sh 3.4.0
set -uxe
python_version=${1:-"3.5.2"}
package_name="python-${python_version}-macosx10.6.pkg"
filename=$(mktemp -d -t python)/${package_name}
echo "Installing version: ${python_version}"
curl -fo ${filename} https://www.python.org/ftp/python/${python_version}/${package_name}
sudo installer -pkg ${filename} -target /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment