From b805fb2145030019cdc82e52d55fa175d395336f Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sat, 3 Dec 2016 18:25:08 +0000 Subject: [PATCH] mac_install, mac_version* --- etc/profile.d/mac.sh | 55 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/etc/profile.d/mac.sh b/etc/profile.d/mac.sh index f5c68c98..4749e8db 100644 --- a/etc/profile.d/mac.sh +++ b/etc/profile.d/mac.sh @@ -108,7 +108,7 @@ mac_pkg_list_todel() { mac_install() { - local prg="$1" + local prg="$1"; shift # Aliases case "$prg" in @@ -127,7 +127,10 @@ mac_install() { ;; 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) @@ -135,10 +138,11 @@ mac_install() { ;; 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) @@ -152,20 +156,40 @@ mac_install() { *) 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 $@ @@ -181,4 +205,13 @@ mac_routes() { 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 ! <<< -- 2.47.3