I want to add a repository to apt-get (without potentially messing up /etc/apt/sources.list) through the user of a script. This script may run multiple times so I can't just append the entry each time. Is there any way I can add a single file in a directory with entries?

I know you can do this for yum, but I'm not sure if it's possible for apt-get. Please let me know if I need to add more info.

link|improve this question

feedback

2 Answers

up vote 5 down vote accepted

You can place files in /etc/apt/sources.list.d. This is described in the man page for sources.list (type man sources.list). The man page says:

SOURCES.LIST.D

The /etc/apt/sources.list.d directory provides a way to add sources.list entries in separate files. The format is the same as for the regular sources.list file. File names need to end with .list and may only contain letters (a-z and A-Z), digits (0-9), underscore (_), hyphen (-) and period (.) characters. Otherwise they will be silently ignored.

link|improve this answer
Thanks, this is exactly what I needed. – Daisetsu Jan 24 '11 at 21:19
feedback

You could try:

add-apt-repository <REPOSITORY LINE>

The repository line would just be what you would append to the sources.list or a PPA repository. Check out the manpage here, or execute:

man add-apt-repository
link|improve this answer
1  
From a quick look at the man file for add-apt-repository it looks like it simply appends the line to the sources.list file, it doens't mention if it checks, so this is just the same as "echo line >> sources.list" which I already had. Thanks for responding though. – Daisetsu Jan 24 '11 at 21:20
@Daisetsu I know it does, I thought you just felt uncomfortable manually editing the file! Must've misunderstood! Great you got an answer that worked for you though! – BloodPhilia Jan 24 '11 at 21:33
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.