Pull out profile selection code from setup_board.
Pull out profile selection code from setup_board.

This is pretty much just the profile selection code from setup_board.
Once this is installed in the chroot (separate CL) the code in
setup_board can go away and be replaced with a call to this.

I did add an additional check that the existing profile link (if it
exists) is in fact a symlink.  I chose not to clobber it if it isn't
because it could indicate a developer that has done something manual.

BUG=chromium-os:6107
TEST=The same set of tests that were run for the code in setup_board:
./cros_choose_profile --board=x86-generic --profile=asdf # error'd succesfully
./cros_choose_profile --board=x86-generic --profile=bar # correctly failed when bar did not exist or was a file
./cros_choose_profile --board=x86-generic --profile=bar # worked when bar was changed to a directory
./cros_choose_profile --board=x86-generic --profile=/asdf/foo # failed correctly, path does not exist
./cros_choose_profile --board=x86-generic --profile=/etc/make.profile # worked - path existed
./cros_choose_profile --board=x86-generic --profile=bar # empty directory bar created a warning for file 'parent' not existing
./cros_choose_profile --board tegra2 --variant seaboard # Correctly found variant profile
./cros_choose_profile --board tegra2 --variant seaboard --profile=bar # Correctly found variant profile named bar

Change-Id: I65adb953fc3851355cf8b691d5eeffbff1e3c440

Review URL: http://codereview.chromium.org/6511001

mgireesh05/dev-util,coreos/dev-util,mgireesh05/dev-util,marineam/coreos-dev-util,mgireesh05/dev-util,coreos/dev-util,coreos/dev-util,marineam/coreos-dev-util