Ajitabh Pandey's Soul & Syntax

Exploring systems, souls, and stories – one post at a time

Tag: Apt

  • Apt Pinning in Raspbian

    Quite sometime back I wrote a blog entry on apt-pinning to mix multiple repositories in debian and prioritize them. Recently, I felt the need to do the same on my raspberry pi.

    I use rsnapshot to backup remote systems. Rsnapshot has an associated perl script which is meant to send beautiful reports via email at the end of the backup. The script in the version which came with raspbian was broken (1.3.1-4+deb8u1) and I needed 1.4.2-1, which is available in Debian Stretch.

    Following my earlier post, I performed the following steps to perform the installation of the required version without impacting the rest of the system. As you can see that the priority of Jessie is higher than that of Stretch, which will ensure that the system does not get messed up when you do an upgrade.

    # Create the preferences file for jessie and stretch as shown below
    $ sudo vi /etc/apt/preferences.d/jessie.pref
    Package: *
    Pin: release n=jessie
    Pin-Priority: 900
    
    $ sudo vi /etc/apt/preferences.d/stretch.pref
    Package: *
    Pin: release a=stretch
    Pin-Priority: 750
    
    # Define the package sources for both jessie and stretch
    $ sudo vi /etc/apt/sources.list.d/jessie.list
    deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
    
    $ sudo vi /etc/apt/sources.list.d/stretch.list
    deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi
    
    # Refresh the cache and sources list
    $ sudo apt-get update
    
    # Install the desired package by specifying the repository from which 
    # it has to be installed
    $ sudo apt-get install rsnapshot -t stretch

    Please be careful before performing these steps in a production system.

  • Apt Pinning

    I normally stick with Debian Stable on my laptop. But atleast there was one package which I needed out of testing or unstable, git. So I thought of using the Debian backports repository. I followed the instructions to use the backports repository and came through this very good APT Pinning document. This is how I installed git on my laptop.

    I added the following line to my /etc/apt/source.list file

    # Debian backports
    deb http://www.backports.org/debian/ sarge-backports main contrib non-free

    and the following to my /etc/apt/preferences file. I needed to create this file as I was not using multiple repositories before, so I had to make all the entries. However, only the middle entry which pins the priority of the sarge-backports repository is required. If most of the time stable is preferred then the priority of stable has to be higher than that of sarge-backports. The last pinning which specifies the priority of -10 to other Debian releases is just a proactive measure to make sure that if I add a new Debian repository to the /etc/apt/sources.list file then I need to specify a pinning preference explicitly in this file, else it will have the priority of -10 which is lowest or no priority at all.

    # Debian stable has a higher priority than the
    # backports repository
    Package: *
    Pin: release o=Debian,a=stable
    Pin-Priority: 900
    Package: *
    Pin: release a=sarge-backports
    Pin-Priority: 200
    Package: *
    Pin: release o=Debian
    Pin-Priority: -10