I’ve been using an apt cache on my server at home. It’s great as it means I don’t have to download new software 3-5 times. However it comes with a slight drawback.
My cache in only accessible on my home network. So when I’m at uni I can’t access it without going to System > Administration > Software Sources. Manually disabling all the apt cache sources and enable all the internet ones. This get’s tedious immediately.
Solution: create 2 sources.list files and a script to swap them.
All the information about the software sources are stored in /etc/apt/sources.list file. When you use the “Software Sources” interface it modifies this file. So we can copy it to preserve settings:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.swap
Now all we have to do is create a script in ~/bin to swap between the two.
gksu mv /etc/apt/sources.list /etc/apt/sources.list.tmp
gksu mv /etc/apt/sources.list.swap /etc/apt/sources.list
gksu mv /etc/apt/sources.list.tmp /etc/apt/sources.list.swap
Now all I need to do is to swap the two souces is type
chmod +x ~/bin/swap-sources
Now set up with your cache. Run
swap-sources and then set it up with the internet. Now everytime you run
it will swap between the two settings.