require 'travis/build/appliances/base'

module Travis
  module Build
    module Appliances
      class DisableSshRoaming < Base
        def apply
          sh.cmd %(mkdir -p $HOME/.ssh)
          sh.cmd %(chmod 0700 $HOME/.ssh)
          sh.cmd %(touch $HOME/.ssh/config)
          sh.cmd %(echo -e "Host *\n  UseRoaming no\n" | cat - $HOME/.ssh/config > $HOME/.ssh/config.tmp && mv $HOME/.ssh/config.tmp $HOME/.ssh/config)
        end
      end
    end
  end
end

require 'travis/build/appliances/base'

module Travis
  module Build
    module Appliances
      class DisableSshRoaming < Base
        def apply
          sh.cmd <<-EOF
if [ $(sw_vers -productVersion | cut -d . -f 2) -lt 12 ]; do
  mkdir -p $HOME/.ssh
  chmod 0700 $HOME/.ssh
  touch $HOME/.ssh/config
  echo -e "Host *\n  UseRoaming no\n" | cat - $HOME/.ssh/config > $HOME/.ssh/config.tmp && mv $HOME/.ssh/config.tmp $HOME/.ssh/config
fi
          EOF
        end
      end
    end
  end
end

Fix an error where Sierra builds can't use git
Fix an error where Sierra builds can't use git

Due to the CVE earlier this year regarding "Roaming" mode in SSH, Apple
has decided it's a good idea to just completely take out SSH roaming
entirely, starting in macOS 10.12. Defining an invalid directive in the
SSH configuration breaks Git, so we need to not set that directive.

The "if OS minor version is < 12" syntax is weird, but is used elsewhere
in the repo just the same way.
