Fix Rootdir determination

This is a partial backport of I15c1707eb6a62c74a0021a48b89ae15f03fcfea8

Change-Id: Ia4c490e2e2cd0851bb378f1db4116a955a6ad845
Fixes-Bug: #1241198
Merge "Fix Rootdir determination" into stable/havana