为什么我的存储库的更高优先级在 apt 中不起作用?

Why higher priority for my repository does not works in apt?

根据手册:

       A note of caution: the keyword used here is "origin" which can be
       used to match a hostname. The following record will assign a high
       priority to all versions available from the server identified by
       the hostname "ftp.de.debian.org"

           Package: *
           Pin: origin "ftp.de.debian.org"
           Pin-Priority: 999

source link: http://manpages.ubuntu.com/manpages/zesty/man5/apt_preferences.5.html

我的输出是:

合适的偏好是:

# more /etc/apt/preferences.d/default_source_list.pref
Package: *
Pin: origin "ubuntu-repository.youseeu.com"
Pin-Priority: 999

包mysql-服务器的策略:

# apt-cache policy mysql-server
mysql-server:
  Installed: (none)
  Candidate: 5.5.57-0ubuntu0.14.04.1
  Version table:
     5.5.57-0ubuntu0.14.04.1 0
        500 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
        999 https://ubuntu-repository.youseeu.com/ysu_ubuntu14/ trusty/main amd64 Packages
     5.5.35+dfsg-1ubuntu1 0
        500 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

检查它是如何工作的:

# apt-get install -d mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
  libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  mysql-server-5.5 mysql-server-core-5.5 perl perl-base perl-modules
Suggested packages:
  libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  libsql-statement-perl libipc-sharedcache-perl tinyca mailx perl-doc
  libterm-readline-gnu-perl libterm-readline-perl-perl libb-lint-perl
  libcpanplus-dist-build-perl libcpanplus-perl libfile-checktree-perl
  liblog-message-perl libobject-accessor-perl
The following NEW packages will be installed:
  libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
  libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  mysql-server mysql-server-5.5 mysql-server-core-5.5
The following packages will be upgraded:
  perl perl-base perl-modules
3 upgraded, 12 newly installed, 0 to remove and 195 not upgraded.
Need to get 16.1 MB of archives.
After this operation, 97.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main perl amd64 5.18.2-2ubuntu1.1 [2,648 kB]
Get:2 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main perl-base amd64 5.18.2-2ubuntu1.1 [1,146 kB]
Get:3 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main perl-modules all 5.18.2-2ubuntu1.1 [2,673 kB]
Get:4 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
Get:5 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-common all 5.5.57-0ubuntu0.14.04.1 [13.0 kB]
Get:6 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main libmysqlclient18 amd64 5.5.57-0ubuntu0.14.04.1 [596 kB]
Get:7 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty/main libdbi-perl amd64 1.630-1 [879 kB]
Get:8 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main libdbd-mysql-perl amd64 4.025-1ubuntu0.1 [87.6 kB]
Get:9 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty/main libterm-readkey-perl amd64 2.31-1 [27.4 kB]
Get:10 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-core-5.5 amd64 5.5.57-0ubuntu0.14.04.1 [707 kB]
Get:11 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-5.5 amd64 5.5.57-0ubuntu0.14.04.1 [1,588 kB]
Get:12 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-core-5.5 amd64 5.5.57-0ubuntu0.14.04.1 [3,766 kB]
Get:13 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-5.5 amd64 5.5.57-0ubuntu0.14.04.1 [1,866 kB]
Get:14 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty/main libhtml-template-perl all 2.95-1 [65.5 kB]
Get:15 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server all 5.5.57-0ubuntu0.14.04.1 [11.3 kB]
Fetched 16.1 MB in 0s (21.1 MB/s)
Download complete and in download only mode

检查政策:

# apt-cache policy | head -n 20
Package files:
 100 /var/lib/dpkg/status
     release a=now
 999 https://ubuntu-repository.youseeu.com/ysu_ubuntu14/ trusty/main amd64 Packages
     release o=ysu_ubuntu14 trusty,a=trusty,n=trusty,l=ysu_ubuntu14 trusty,c=main
     origin ubuntu-repository.youseeu.com
 500 http://security.ubuntu.com/ubuntu/ trusty-security/universe Translation-en
 500 http://security.ubuntu.com/ubuntu/ trusty-security/main Translation-en
 500 http://security.ubuntu.com/ubuntu/ trusty-security/universe amd64 Packages
     release v=14.04,o=Ubuntu,a=trusty-security,n=trusty,l=Ubuntu,c=universe
     origin security.ubuntu.com
 500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
     release v=14.04,o=Ubuntu,a=trusty-security,n=trusty,l=Ubuntu,c=main
     origin security.ubuntu.com
 500 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/universe Translation-en
 500 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main Translation-en
 500 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/universe amd64 Packages
     release v=14.04,o=Ubuntu,a=trusty-updates,n=trusty,l=Ubuntu,c=universe
     origin us-east-2.ec2.archive.ubuntu.com
 500 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages

那么,为什么包 mysql-server 是从主机 us-east-2.ec2.archive.ubuntu.com 下载的?

为什么我的存储库 ubuntu-repository.youseeu.com 的更高优先级不起作用?

Several instances of the same version of a package may be available when the sources.list(5) file contains references to more than one source. In this case apt-get downloads the instance listed earliest in the sources.list(5) file. The APT preferences do not affect the choice of instance, only the choice of version. source link(Your link): http://manpages.ubuntu.com/manpages/zesty/man5/apt_preferences.5.html

所以首先apt搜索可用的版本:

apt-cache policy mysql-server mysql-server: Installed: (none) Candidate: 5.5.57-0ubuntu0.14.04.1 Version table:

 5.5.57-0ubuntu0.14.04.1 0
    500 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
    500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
    999 https://ubuntu-repository.youseeu.com/ysu_ubuntu14/ trusty/main amd64 Packages
 5.5.35+dfsg-1ubuntu1 0
    500 http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

在 3 个来源中找到版本 5.5.57,根据以下优先级忽略:

In this case apt-get downloads the instance listed earliest in the sources.list(5) file. The APT preferences do not affect the choice of instance, only the choice of version.