apt源代码包中depcache.cc中的“自动源”是什么意思?

apt源代码包中depcache.cc中的“自动源”是什么意思?

在浏览 apt 包管理器的源代码时,我想找出pkgDepCache::Policy::GetCandidateVer函数的内部逻辑。

pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator const &Pkg)
{
   /* Not source/not automatic versions cannot be a candidate version 
      unless they are already installed */
   VerIterator Last(*(pkgCache *)this,0);

   for (VerIterator I = Pkg.VersionList(); I.end() == false; ++I)
   {
      if (Pkg.CurrentVer() == I)
     return I;

      for (VerFileIterator J = I.FileList(); J.end() == false; ++J)
      {
     if ((J.File()->Flags & Flag::NotSource) != 0)
        continue;

     /* Stash the highest version of a not-automatic source, we use it
        if there is nothing better */
     if ((J.File()->Flags & Flag::NotAutomatic) != 0 ||
         (J.File()->Flags & Flag::ButAutomaticUpgrades) != 0)

      ...

什么是“自动版本“ 和 ”自动源“ 这里?

答案1

apt 的源(例如 apt 中给出的源sources.list)可以有一个Release文件,该文件指定源的各种属性。例如,ReleaseUbuntu 16.04 的移植文件

Origin: Ubuntu
Label: Ubuntu
Suite: xenial-backports
Version: 16.04
Codename: xenial
Date: Wed, 06 Sep 2017 14:06:49 UTC
Architectures: amd64 arm64 armhf i386 powerpc ppc64el s390x
Components: main restricted universe multiverse
Description: Ubuntu Xenial Backports
NotAutomatic: yes
ButAutomaticUpgrades: yes
MD5Sum:
 f1647057d0c93fc58961ea0d03f5e524           244120 Contents-powerpc

请注意此处看到的最后几个字段。这些字段与该代码中测试的字段相同。自动源是NotAutomatic不是 yes。这些字段用于按 apt 为源分配默认优先级。从man apt_preferences

   If the target release has been specified then APT uses the following
   algorithm to set the priorities of the versions of a package. Assign:

   priority 1
       to the versions coming from archives which in their Release files
       are marked as "NotAutomatic: yes" but not as "ButAutomaticUpgrades:
       yes" like the Debian experimental archive.

   priority 100
       to the version that is already installed (if any) and to the
       versions coming from archives which in their Release files are
       marked as "NotAutomatic: yes" and "ButAutomaticUpgrades: yes" like
       the Debian backports archive since squeeze-backports.

您可以在手册页中阅读有关 apt 如何使用这些优先级的更多信息。

现在,在第一条评论中,“不是源”是指软件包版本不是sources.list来自 apt 源(例如中的条目)。这将是一个已安装的版本,因此信息来自(您可以检查已安装软件包/var/lib/dpkg/status的输出以查看此信息)。“非自动版本”来自如上所述标记的源。此类源在第二条注释中被称为“非自动”。apt-cache policyNotAutomatic

相关内容