Walgreens Boots Alliance says it has agreed to be acquired by private equity firm Sycamore Partners as the struggling retailer looks to turn itself around after years of losing money.