Conditionally comment out and uncomment repositories, ensuring `apt update` is run only when necessary.