Debian: script to manipulate apt sources quickly from the command line
I’m one of those who just uses the command line to manage packages, and since I don’t use synaptic, it makes no sense to have the application ‘Software Preferences’ installed, which all in all pulls in a lot of packages.
But sometimes it’s tiresome to open an editor to enable or disable sources, or throw some sed command to change the line, which is anyway some typing. And it’s worse if you want to enable or disable several repositories at once.
So I created a bash script, aptsources (pretty unoriginal), to deal with repositories’ files under the directory ‘/etc/apt/sources.list.d/’. It doesn’t touch the file ‘/etc/apt/sources.list’ file at all, as it’s the file I edit the least. I have most Debian’s distributions entries uncommented (squeeze, sid, etc), with the use of apt-pinning.
The script allows to enable, disable, remove and add files under that directory. It also sets launchpad’s ppa repositories (Note and disclaimer: Ubuntu packages are not binary compatible!) with a syntax similar to add-apt-repository, allowing to set as an argument the Ubuntu version you think your Debian system is closer to. Thanks to Anant Shirvastava, as this function uses the code in his script. It also does backup, shows content, etc…
You can only specify one parameter a time, but some of them (--enable, --disable, --source
) accept multiple arguments.
This is:
# aptsources --enable wine zeitgeist
would enable (uncomment) the ‘deb’ lines (not the ‘deb-src’ ones) in the files ‘wine.list’ and ‘zeitgeist.list’ at once.
One handy feature of the script is listing repos grouping them as enabled or disabled.
omar~$ aptsources -l
Enabled: cardapio docky multimedia synapse
Disabled: awn burg codeblocks getdeb hadret mpd-sound-menu notify-osd orta playdeb translate ufw-gtk vineyard wine zeitgeist
The script doesn’t run “exotic” commands, and it’s very easy to read. I stopped posting it here cause it got too big. You can download it from github. Click on the “Download” button and you will get a compressed archive with the latest version. You can install the script to ‘/usr/local/bin’ and bash-completion feature with aptsources.sh -i
. I still enhance with small things so you better come back once or twice :)
Play with it and I hope it’s useful for more people than just me.
Enjoy!
linux is for fascists and pederasts!!!
fucking nerds sucks!!!
Daniel
January 10, 2011 at 12:20 am
First of all Thanks for the credit link.
I am excited in using your script and happy that my code served your purpose.
Anant Shrivastava
January 10, 2011 at 8:11 am
Thanks for your comment Anant, and I’m glad you find it useful :)
elric80
January 10, 2011 at 4:32 pm
Excelente ;-)
Un saludo.
Yoyo
January 11, 2011 at 8:29 pm
Gracias :) Además de otras cosas, acabo de añadir un fichero para bash_completion, que agiliza bastante las cosas.
Si tienes alguna idea, escríbela aquí :)
elric80
January 20, 2011 at 12:40 am