Install brew under Lion?

To give an early Macbook Air from 2010 some useful tasks, a package manager is needed. The basic requirement is always Xcode 4.6.3 (from 2013) while also the command line tools are necessary.

Using some code from an earlier script I wrote

curl "$DMGURL" -o "$XC"
curl "$DMGURL" -o "$TOOLS"

Then install Xcode, then Commandline Tools as an untrusted package.

TMPMOUNT=`/usr/bin/mktemp -d /tmp/clitools.XXXX`
hdiutil attach "$TOOLS" -mountpoint "$TMPMOUNT" -nobrowse
sudo installer -allowUntrusted -pkg "$(find $TMPMOUNT -name '*.mpkg')" -target /
hdiutil detach "$TMPMOUNT"
rm -rf "$TMPMOUNT"
rm "$TOOLS"

So far so good. Then I installed

/usr/bin/ruby -e "$(curl -fsSL"

and run several “brew update” and “brew doctor” which failed due to SSL errors. Only macport worked perfect and compiled all my sources (fswatch….).