There are two ways:
- Pinning -> this is more a permanent solution, you can remix it into something adhoc and it's detailed at the end.
- Using aweso... err aptitude!
Lets say the package is from some origin, lets call this
ppa.launchpad.net. So, how to tell aptitude to install the package form that origin:
sudo aptitude install '?narrow(nameofthepackage, ?origin(ppa.launchpad.net))'
You can change
and. Also, you can use other selectors like version string, etc.
A complete reference of all the features of aptitude here:
This requires that you write the preference file before hand and you should add pretty options arguments:
You must write your pinning file:
Pin: origin ppa.launchpad.net
Now with apt-get:
sudo apt-get install -o Dir::Etc::Preferences=/path/to/pinningFile somepackage