4

So I'm hosting a private apt repository.

The hierarchy looks like this:

├── stable
│   ├── main
│   │   └── binary-all
│   │       ├── Packages
│   │       └── mypackage_2.3.1_all.deb
│   ├── Release
│   └── Release.gpg
└── unstable
    ├── main
    │   └── binary-all
    │       ├── Packages
    │       └── mypackage_2.3.2_all.deb
    ├── rc
    │   └── binary-all
    │       ├── Packages
    │       └── mypackage_2.3.2_all.deb
    ├── Release
    └── Release.gpg

My source file looks like this:

deb [arch=all] https://user:pass@my.apt-server.com/ stable main
deb [arch=all] https://user:pass@my.apt-server.com/ unstable main rc

apt-cache policy mypackage

mypackage:
  Installed: (none)
  Candidate: 2.3.2
  Version table:
     2.3.2 500
        500 https://my.apt-server.com unstable/main all Packages
        500 https://my.apt-server.com unstable/rc all Packages
     2.3.1 500
        500 https://my.apt-server.com stable/main all Packages

stable release file content (without the hashes):

Date: Wed, 12 Oct 2016 09:29:19 UTC
MD5Sum:
                 0 Release
               707 main/binary-all/Packages
SHA1:
                 0 Release
               707 main/binary-all/Packages
SHA256:
                 0 Release
               707 main/binary-all/Packages
SHA512:
                 0 Release
               707 main/binary-all/Packages

unstable release file content (without the hashes):

Date: Wed, 12 Oct 2016 09:29:27 UTC
MD5Sum:
                 0 Release
               709 main/binary-all/Packages
               705 rc/binary-all/Packages
SHA1:
                 0 Release
               709 main/binary-all/Packages
               705 rc/binary-all/Packages
SHA256:
                 0 Release
               709 main/binary-all/Packages
               705 rc/binary-all/Packages
SHA512:
                 0 Release
               709 main/binary-all/Packages
               705 rc/binary-all/Packages

The problem is, when I try to install from stable by running the command:

sudo apt-get install -t stable mypackage

it still installs the latest package from unstable/main

mypackage_2.3.2_all.deb

and not the package from stable/main

mypackage_2.3.1_all.deb

I also tried pinning (from this answer) by creating a file under /etc/apt/preferences.d with:

Package: *
Pin: release n=unstable
Pin-Priority: 50

but still a higher version from unstable is installed.

What am I doing wrong?

Alexis Wilke
  • 2,707
Urban48
  • 143
  • 5
  • 1
    2.3.2 is higher than 2.3.1, and you don't define an apt policy anywhere on your computer for which repository is higher priority than the other. Without a priority policy defined it will use whichever is the higher version number. (I am on mobile but will write an answer when I am at a computer, if nobody else does) – Thomas Ward Oct 12 '16 at 10:17
  • @ThomasWard but i thought -t option sets a high priority. (apt-get manual) "it creates a default pin at priority 990" – Urban48 Oct 12 '16 at 12:02
  • If you look at the apt-cache policy output it directly contradicts the manual. While it may be true it will not respect that for updates and upgrade processes unless you update the pinning priorities to specify specific origin repos and such are a low priority. I still don't have a computer right now to write up an answer though. – Thomas Ward Oct 12 '16 at 12:37
  • What's the name of your file in /etc/apt/preferences.d? – fkraiem Oct 12 '16 at 13:35
  • @fkraiem, I tried with unstable and repo – Urban48 Oct 12 '16 at 13:37
  • @Urban48 Both should work... What are the contents of your Release files? (Just the headers, the MD5 sums are not important here.) – fkraiem Oct 12 '16 at 13:39
  • @fkraiem, i updated the question – Urban48 Oct 12 '16 at 13:47

1 Answers1

2

Your Release files should contain a Codename header to allow pinning by release name. From man apt_preferences:

The Release file is normally found in the directory .../dists/dist-name: for
example, .../dists/stable/Release, or .../dists/wheezy/Release. It consists of a
single multi-line record which applies to all of the packages in the directory
tree below its parent. Unlike the Packages file, nearly all of the lines in a
Release file are relevant for setting APT priorities:

[...]

the Codename: line
    names the codename to which all the packages in the directory tree belong.
    For example, the line "Codename: jessie" specifies that all of the packages
    in the directory tree below the parent of the Release file belong to a
    version named jessie. Specifying this value in the APT preferences file would
    require the line:

        Pin: release n=jessie

See for reference the Release file of the official Xenial repository.

fkraiem
  • 12,555
  • 4
  • 35
  • 40
  • it worked, i created a config files for unstable and stable for with a content: APT::FTPArchive::Release { Codename "stable"; Components "main"; }; (and Codename "unstable" for the unstable config), and ran apt-ftparchive with -c to generate the Release file with the Codename. after that apt-get install -t stable ... worked – Urban48 Oct 12 '16 at 14:08