[SOLVED] apt pinning advice

If none of the more specific forums is the right place to ask

[SOLVED] apt pinning advice

Postby wasabi-warrior » 2014-02-12 02:05

Hi all,
As a disclaimer, I still consider myself a noob, but I'm willing to learn.

I run a headless Debian Wheezy server. One of the services I have installed is not at the version I need it to be, but the repo for Jessie is supposed to have it. Now I can either edit the sources list and add Jessie, run the install for that one package, and change the sources list back. However, this is not really future proof, as I plan to continue running update/upgrades against this machine for some time to come. The other concern I have is that it will automatically install recommends or required packages from Jessie, overwriting my existing, stable, packages.

So...the service itself is one package and installs 3 other packages. I dont want it to install any other packages or upgrade any of the dependencies. I've been doing quite a lot of reading, and came across apt pinning and preferences. However, it seems strongly recommended that no noobs do it. I am interested though, and dont mind giving it a try, so I'm just looking for some advice and want to know if anyone can confirm what I have found so far.

So it first seems that source.list is involved, you need to add your other source. All sources in source.list receive a default 'preference priority', unless you specifically specify the source when you run apt-get. Then there is the preferences file, supposedly in /etc/apt/preferences. I've noticed Wheezy seems to have /etc/apt/preferences.d as a directory, where you can place part files ending with .pref to specify preferences. Priority gets specified using the following format in the file:

Package: *
Pin: release a=stable
Pin-Priority: 700

Package can either be * which means all packages or a specific full package name. Pin can be release or version of package, and pin-priority is what actually sets the priority.

Thats where things get a little muddy for me. Quite a lot of the references seem to have examples where they want everything installed from testing where possible, and then fall back to stable when needed. I'm looking to use everything from wheezy, not use ANYTHING from jessie except the 4 packages I explicitly specify.

    Do I need a preferences file, or will the part files in preferences.d suffice?
    Do my sources retain their default priority if not set in said files? e.g. can I just put in my priority for jessie, and wheezy will keep using default?
    In order to ignore jessie except for my 4 packages, I *think* i need to do something along these lines:
Code: Select all
Package: *
Pin: release a=jessie
Pin-Priority: -1

Package: package-1
Pin: release a=jessie
Pin-Priority: 500

Package: package-2
Pin: release a=jessie
Pin-Priority: 500

etc.

    so that it uses default priority for my packages, and sets all other packages from jessie to be never installed even if recommended. Am I right?
    I dont know if I still need to specify wheezy to keep using default priority. What happens to sources not mentioned in any preference files?

Has anyone here used apt preferences or can more readily get their head around it? Can you tell me if I'm on the right track, or if theres something I'm missing here?

Thanks to anyone who can help.

References read so far:
https://wiki.debian.org/AptPreferences#Pinning
http://www.argon.org/~roderick/apt-pinning.html
http://www.debian.org/doc/manuals/debia ... te_version
http://www.debian.org/doc/manuals/debia ... f_archives
http://web.archive.org/web/201011130539 ... nning.html
http://carlo17.home.xs4all.nl/howto/debian.html#errata
http://man.he.net/man5/apt_preferences
http://linux.die.net/man/5/apt_preferences
Last edited by wasabi-warrior on 2014-02-12 05:40, edited 1 time in total.
User avatar
wasabi-warrior
 
Posts: 24
Joined: 2013-02-25 21:09

Re: apt pinning advice

Postby ziggybopbopdoo » 2014-02-12 02:31

What package(s) are we talking about?

I never recommend mixing stable and any other flavor, much better to go with a backport.

The best way to figure out pinning/prefs is to configure it and then check and see if it does what you want.
ziggybopbopdoo
 
Posts: 107
Joined: 2014-01-25 21:27

Re: apt pinning advice

Postby wasabi-warrior » 2014-02-12 03:08

Thanks ziggy.
Specifically, its sabnzbdplus, and the three extra packages are its themes. I'm just worried I'll stuff it up and it will overwrite other packages (unlikely if I read properly, but you never know). Wheezy contains v6 and Jessie and sid contain v7. I figure the version in Jessie is closer to stable than using any experimental or direct builds from them.

So its not as detrimental as I fear to just give it a try? Does my example listed look OK?
User avatar
wasabi-warrior
 
Posts: 24
Joined: 2013-02-25 21:09

Re: apt pinning advice

Postby wasabi-warrior » 2014-02-12 05:39

Dont mean to double post, but I like when the answer is in a separate post. I run into a completely separate issue which forced me to reverse what I had done, so I dont have a 100% success to report here, but if I continued, it looked like it would work fine. As for using jessie as the source, both jessie and testing have the same results.

you can use apt-cache policy to verify your preferences are set correctly. At the bottom it will say
Package pinned:
package-name -> version number from new repo.

So to recap:
In source.list, add a line with 'testing' instead of 'wheezy' or whatever youre using.
Make a new file in /etc/apt/preferences.d/ and make sure it ends with either no extension, or .pref
Add the following to the file:
Code: Select all
Package: *
Pin: release a=testing
Pin-Priority: -1

Package: package-exact-name
Pin: release a=testing
Pin-Priority: 500

When you want to install the new version from testing use
Code: Select all
apt-get -t testing install package-exact-name

And it will pull it from the testing repository. I cant confirm whether it pulls its required packages from testing or not still, but the priority listing makes sure that the testing repository isnt considered for a normal update and upgrade.

Hope that helps any future tinkerers. Kudos to ziggy for the reassurance.
User avatar
wasabi-warrior
 
Posts: 24
Joined: 2013-02-25 21:09

Re: [SOLVED] apt pinning advice

Postby \hbar » 2014-02-12 09:55

If you replace the pin priority with 100, then the jessie packages you manually installed with the "-t testing" option would also be updated when new versions come out on the testing repository. Other packages would still be installed from the wheezy repositories.

I guess the only disadvantage with this approach is that running apt-get update will take a bit longer because you have more repos to check.
MacBookPro5,5 - 2.53 GHz core 2 duo - Debian jessie
MacMini - Core i7 - Debian jessie
User avatar
\hbar
 
Posts: 41
Joined: 2011-04-22 12:52

Re: [SOLVED] apt pinning advice

Postby sunrat » 2014-02-13 06:36

\hbar wrote:If you replace the pin priority with 100, then the jessie packages you manually installed with the "-t testing" option would also be updated when new versions come out on the testing repository. Other packages would still be installed from the wheezy repositories.

I guess the only disadvantage with this approach is that running apt-get update will take a bit longer because you have more repos to check.

You could disable the sources for testing after installing. Then you wouldn't need pinning but it also wouldn't be upgraded automatically.
I'm not sure but order may be imporant in the preferences file. Your first entry may cancel the second one (can an expert confirm this for me?).
You can hold a package to a particular version with aptitude or apt-mark, although probably not necessary as wheezy version will never be higher than jessie.
Concerning installing a new version, apt-get will tell you if dependencies are not correct.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!
User avatar
sunrat
 
Posts: 3225
Joined: 2006-08-29 09:12
Location: Melbourne, Australia

Re: [SOLVED] apt pinning advice

Postby wasabi-warrior » 2014-02-15 02:59

Yeah, I ended up just doing it by adding/removing the sources just this once. Turned out it was a completely separate package (sickbeard) causing issues with me installing sabnzbd. It was trying to import an NZB while sab was installing, and caused it to error out. Because I was messing with pinning and different versions at the same time, I just rolled it all back, and did it manually so I could rule that out.

I can confirm that when using -t at least, the priority of -1 doesnt stop me installing packages from testing. It also appears that when using that though, it tries to pull its dependency from 'testing' as well, instead of using the available version from wheezy, regardless of the fact that I hadn't given those any other priority. I would assume from this, that using -1 for the priority means "never install automatically" and when using -t in apt-get, it means "install this package, and any requirements, from the repo specified". The only other indication was that it still told me that the program was pinned when using apt-cache policy. I would assume that it meant it would have worked automatically should I have continued down that path.

I havent played enough with it to confirm that the pinning works 100% other than ignoring the testing repo from automatic upgrades.
User avatar
wasabi-warrior
 
Posts: 24
Joined: 2013-02-25 21:09


Return to General Questions

Who is online

Users browsing this forum: No registered users and 15 guests

fashionable