I want to install emacs-snapshot from http://emacs.orebokech.com But there is already an emacs-snapshot in Ubuntu's repositories.

How can I specify the repository from which a package will be installed?

5 Answers 5


You can specify a repository with -t option. As an example, I have added the following repository to /etc/apt/sources.list to install Iceweasel latest release:

deb http://mozilla.debian.net/ squeeze-backports iceweasel-release

As you know there is a same package iceweasel in the official Debian repository. If I want install Iceweasel from this specific repo I run:

apt-get install -t squeeze-backports iceweasel

from apt-get manual page:

-t, --target-release, --default-release
           This option controls the default input to the policy engine, it creates a default pin at priority 990 using the specified
           release string. This overrides the general settings in /etc/apt/preferences. Specifically pinned packages are not affected by
           the value of this option. In short, this option lets you have simple control over which distribution packages will be retrieved
           from. Some common examples might be -t '2.1*', -t unstable or -t sid. Configuration Item: APT::Default-Release; see also the
           apt_preferences(5) manual page.

I think this is a better solution,

Source from:https://askubuntu.com/questions/27362/how-to-only-install-updates-from-a-specific-repository/57749#57749

  • 1
    What if you don't want to add the said source into your sources.list ? Dec 14, 2016 at 12:38

I found a workaround. First I needed to find the repositories that had the pacakage:

$ apt-cache showpkg emacs-snapshot
Package: emacs-snapshot
1:20100111-1~lenny1 (/var/lib/apt/lists/emacs.orebokech.com_dists_lenny_main_binary-amd64_Packages) (/var/lib/dpkg/status)
 Description Language: 
                 File: /var/lib/apt/lists/emacs.orebokech.com_dists_lenny_main_binary-amd64_Packages
                  MD5: 906df684c212eabe267e6b5c2e8c2032

1:20090909-1 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_karmic_universe_binary-amd64_Packages)
 Description Language: 
                 File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_karmic_universe_binary-amd64_Packages
                  MD5: 906df684c212eabe267e6b5c2e8c2032

Reverse Depends: ...

In the Versions: section. I see the versions that come from different repositories:

  • 1:20100111-1~lenny1
  • 1:20090909-1

So now we just tell apt or aptitude to install that specific version:

$ sudo aptitude install emacs-snapshot=1:20100111-1~lenny1



I still don't know how to use a specific repository. But in this case a specific version was enough.


There is a preferences file for apt. I think it is located under /etc/apt, but not 100% sure. There you can set the priority for a package from a repository to be higher than for the same package from the Ubunto repository. For the exact syntax, look up in man apt-get. Edit the file, then install as usual with apt-get, it will fetch from the highest priority origin. Just make sure beforehand that the package from that repository is compiled for your distro (e.g. a debian binary may look for dependencies in the wrong places) and for your kernel version (this changes quite often throughout the life cycle of a Ubuntu version). Else it is a matter of chance if it will work.


I ran into this issue when a package I wanted (helm), had a name that was used by both the Kubernetes package manager and also by a music VST instrument from KX Studio.

I had both repositories available in my sources list, but because KX Studio's helm had a higher version number, asking apt to install it lead to the "wrong" package being installed (since I wanted the Kubernetes package manager). This was even more of a problem because my distro kept trying to get me to "upgrade" to the wrong package even after having installed the one I wanted.

I solved the issue by adjusting by creating a /etc/apt/preferences file with the following contents:

Package: helm
Pin: origin "baltocdn.com"
Pin-Priority: 999

Read up on man apt_preferences if you want more details about other options. Note that baltocdn.com was the repository for the helm package I wanted, so you'd replace both the package name and origin with whatever you wanted. After updating apt, it no longer wished to upgrade me to the wrong package version!


In my case I added an apt-get repository for a development stream of Inkscape. Here's the steps I took to add the development version of Inkscape:

  1. List all repo sources
grep -r --include '*.list' '^deb ' /etc/apt/sources.list /etc/apt/sources.list.d/

enter image description here

  1. Choose a repo source, and list all packages (in my case the inkscape ppa)
grep -h -P -o "^Package: \K.*" /var/lib/apt/lists/ppa.launchpad.net_inkscape* | sort -u

enter image description here

  1. Install the specific package
sudo apt install -t hirsute inkscape-trunk

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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