Volkswagen agrees to buy rest of Porsche shares