Barcelona said the 30-year-old has signed a deal that will run until 2030, bringing an end to one of the longest-running transfer sagas of the summer.