Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If I have to two repositories listed in my sources.list or sources.list.d is there a way to tell apt which is preferred?

My exact use case is if a package is found on the intranet repository and on the remote repository I want apt to always use the intranet one. Right now it seems to pick randomly between the two.

share|improve this question
add comment

2 Answers 2

You can do it by modifying your /etc/apt/preferences file; it's commonly referred to as "APT pinning". Here are some guides with details:

share|improve this answer
1  
I read the manpage for apt_preferences. It has this line: "The APT preferences file does not affect the choice of instance, only the choice of version." It looks like APT preferences wont solve my specific use case. –  deft_code Oct 26 '10 at 17:14
    
I think apt-pinning is Debian-only due to the fact that Ubuntu doesn't differn between stable, testing, unstable... maybe for Multimedia or so... bit normally the versions should be never... –  wishi Oct 26 '10 at 22:08
add comment

It should be enough to list the intranet source first, in sources.list. According to the manual:

It is important to list sources in order of preference, with the most preferred source listed first. Typically this will result in sorting by speed from fastest to slowest (CD-ROM followed by hosts on a local network, followed by distant Internet hosts, for example).

From a cursory look at the source, sources.list is traversed first, then the files in sources.list.d in an order that you can't control.

share|improve this answer
    
That's a bummer. I wanted to distribute a package that dropped the intranet repo info in sources.list.d. But it looks like I'll have to edit the sources.list in the post-install, yuck. –  deft_code Oct 26 '10 at 23:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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