Advance Auto Parts Inc., one of the biggest retailers of automotive aftermarket parts, agreed to acquire one of its major competitors, General Parts International Inc., which operates the CarQuest and WorldPac brands, for $2.04 billion in an all-cash transaction.