Project

General

Profile

Apt Pinning » History » Version 3

laforge, 07/20/2024 08:14 AM
add alternative method using l=

1 1 laforge
h1. Apt Pinning
2
3 2 fixeria
When adding multiple package repositories (such as our [[Latest_Builds]] or [[Nightly_Builds]]) to your package manager, the situation might arise that multiple repositories offer a package.
4 1 laforge
5
This happens, for example, if your distribution offers one (typically older) version of osmo-bsc, while the osmocom feeds offer a newer version.  _Usually_ it works as our versions are higher, but sometimes package names change, or other aspects of the packages change, making the automatic guess not what you'd want.
6
7
_apt pinning_ is what you can use to help the apt package manager on Debian/Unbuntu based GNU/Linux distributions figuring out *which* of the packages to install in case there are multiple different repositories providing a package of the same name.
8
9
h2. Example of apt-pinning always preferring osmocom packages over upstream
10
11 2 fixeria
Create a file @/etc/apt/preferences.d/osmocom@ with the following content
12 1 laforge
13
<pre>
14
Package: *
15
Pin: release o=obs://osmocom/osmocom:nightly/Raspbian_10
16
Pin-Priority: 1001
17
</pre>
18
19 2 fixeria
Of course you'd have to adjust the @nightly@ vs @latest@ and use the correct distribution (the above example is for nightly feeds on Raspbian 10).
20 1 laforge
21 3 laforge
An alternative approach rendering he same results would be:
22
<pre>
23
Package: *
24
Pin: release l=osmocom:nightly
25
Pin-Priority: 1001
26
</pre>
27
(of course make sure you use @osmocom:latest@ or @osmocom:nightly@ as applicable)
28
29 1 laforge
When you now use @apt-cache policy@ to list the priorities you should get something like:
30
<pre>
31
root@raspi:~# apt-cache policy
32
Package files:
33
 100 /var/lib/dpkg/status
34
     release a=now
35
 500 http://archive.raspberrypi.org/debian buster/main armhf Packages
36
     release o=Raspberry Pi Foundation,a=oldstable,n=buster,l=Raspberry Pi Foundation,c=main,b=armhf
37
     origin archive.raspberrypi.org
38
1001 https://downloads.osmocom.org/packages/osmocom:/nightly/Raspbian_10 ./ Packages
39
     release o=obs://osmocom/osmocom:nightly/Raspbian_10,n=Raspbian_10,l=osmocom:nightly,c=
40
     origin downloads.osmocom.org
41
 500 http://raspbian.raspberrypi.org/raspbian buster/rpi armhf Packages
42
     release o=Raspbian,a=oldstable,n=buster,l=Raspbian,c=rpi,b=armhf
43
     origin raspbian.raspberrypi.org
44
 500 http://raspbian.raspberrypi.org/raspbian buster/non-free armhf Packages
45
     release o=Raspbian,a=oldstable,n=buster,l=Raspbian,c=non-free,b=armhf
46
     origin raspbian.raspberrypi.org
47
 500 http://raspbian.raspberrypi.org/raspbian buster/contrib armhf Packages
48
     release o=Raspbian,a=oldstable,n=buster,l=Raspbian,c=contrib,b=armhf
49
     origin raspbian.raspberrypi.org
50
 500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
51
     release o=Raspbian,a=oldstable,n=buster,l=Raspbian,c=main,b=armhf
52
     origin raspbian.raspberrypi.org
53
</pre>
54
55
Note the line with the osmocom repo has the highest priority (1001).  You're now all good: Packages from the osmocom repo will always be preferred over upstream raspbian packages.
Add picture from clipboard (Maximum size: 48.8 MB)