使用私有 apt 存储库从特定发行版安装包?

使用私有 apt 存储库从特定发行版安装包?

因此我正在托管一个私人apt存储库。

层次结构如下:

├── 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

我的源文件如下所示:

deb [arch=all] https://user:[email protected]/ stable main
deb [arch=all] https://user:[email protected]/ 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发布文件内容(不带哈希值):

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发布文件内容(不带哈希值):

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

问题是,当我尝试通过stable运行以下命令进行安装时:

sudo apt-get install -t stable mypackage

它仍然安装最新的软件包unstable/main

mypackage_2.3.2_all.deb

而不是来自stable/main

mypackage_2.3.1_all.deb

我也尝试过固定(从这个答案) 下创建一个文件/etc/apt/preferences.d

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

unstable但仍然安装了更高版本。

我究竟做错了什么?

答案1

您的Release文件应该包含一个Codename标题,以允许按版本名称固定。来自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

请参阅参考Release官方 Xenial 存储库的文件

相关内容