mac_install() {
- local prg="$1"
+ local prg="$1"; shift
# Aliases
case "$prg" in
;;
xcode)
- prg="http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_macOS_10.12_for_Xcode_8.1/Command_Line_Tools_macOS_10.12_for_Xcode_8.1.dmg"
+ #echo "$prg"; return
+ local os=$(mac_version)
+ local vers="8.2_beta_2"
+ open "http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_macOS_${os}_for_Xcode_${vers}/Command_Line_Tools_macOS_${os}_for_Xcode_${vers}.dmg"
;;
virtualbox)
;;
macport)
- prg=$(getexp_url 'https?://distfiles.macports.org/MacPorts/MacPorts[^"\s]+pkg' https://www.macports.org/install.php)
+ prg=$(getexp_url 'https?://.*'$(mac_version_name)'[^"\s]+pkg' https://www.macports.org/install.php)
;;
esac
+ #echo ">$prg"; return
# Install
case "$prg" in
""|-h|--help)
*)
local MOUNTDIR=$(echo `sudo hdiutil mount "$prg" | tail -1 | awk '{$1=$2=""; print $0}'` | xargs -0 echo)
- if [[ -n $(find "${MOUNTDIR}" -mindepth 0 -maxdepth 1 -name '*.pkg') ]]; then
- sudo installer -verbose -pkg "${MOUNTDIR}/"*.pkg -target /
- elif [[ -n $(find "${MOUNTDIR}" -mindepth 0 -maxdepth 1 -name '*.app') ]]; then
- sudo cp -rv "${MOUNTDIR}/"*.app /Applications/
- else
- read -p "Can not find *.pkg. Press a key to unmount ${MOUNTDIR}"
- fi
+ if [ -n "$MOUNTDIR" ]; then
+
+ if [[ -n $(find "${MOUNTDIR}" -mindepth 0 -maxdepth 1 -name '*.pkg') ]]; then
+ sudo installer -verbose -pkg "${MOUNTDIR}/"*.pkg -target /
+ elif [[ -n $(find "${MOUNTDIR}" -mindepth 0 -maxdepth 1 -name '*.app') ]]; then
+ sudo cp -rv "${MOUNTDIR}/"*.app /Applications/
+ else
+ read -p "Can not find *.pkg. Press a key to unmount ${MOUNTDIR}"
+ fi
- sudo hdiutil detach "${MOUNTDIR}"
+ sudo hdiutil detach "${MOUNTDIR}"
+ fi
;;
esac
}
+mac_version() {
+ sw_vers -productVersion | cut -d '.' -f 1,2
+}
+
+mac_version_name() {
+ case $(mac_version) in
+ 10.5) echo Leopard;;
+ 10.6) echo SnowLeopard;;
+ 10.7) echo Lion ;;
+ 10.8) echo MountainLion ;;
+ 10.9) echo Mavericks ;;
+ 10.10) echo Yosemite ;;
+ 10.11) echo ElCapitan ;;
+ 10.12) echo Sierra ;;
+ esac
+}
+
mac_pkg_list_files() {
#sudo pkgutil --only-dirs --files com.puppetlabs.puppet-agent|grep /puppet
sudo pkgutil --only-files --files $@
netstat -nr $@ | perl -pe'/^Internet6/&&last'
}
+mac_port_reinstall() {
+ port -qv installed > /tmp/myports.txt
+ port echo requested | cut -d ' ' -f 1 > /tmp/requested.txt
+ port -f uninstall installed
+ port selfupdate
+ port clean all
+ curl -s https://svn.macports.org/repository/macports/contrib/restore_ports/restore_ports.tcl | sh /tmp/myports.txt
+ rm /tmp/myports.txt
+}
;;esac # Darwin only ! <<<