dpkg/apt-get 冲突信息

dpkg/apt-get 冲突信息

当我运行 时dpkg -l,我会得到一个已安装软件包的列表,然后我会将其与我试图重现的“模型”系统进行比较。该列表中出现了几个软件包,例如emacs23,我希望删除它们。但是,当我运行 时apt-get remove emacs23,系统提示我该emacs23软件包未安装:

# apt-get -y remove emacs23
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package emacs23 is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 97 not upgraded.

跑步apt-get update没有帮助:

更新信息:

# dpkg -l emacs23
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
rc  emacs23        23.3+1-1ubuntu The GNU Emacs editor (with GTK+ user interfa

# apt-cache policy emacs23
emacs23:
  Installed: (none)
  Candidate: 23.3+1-1ubuntu9.2
  Version table:
     23.3+1-1ubuntu9.2 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     23.3+1-1ubuntu9.1 0
        500 http://security.ubuntu.com/ubuntu/ precise-security/main amd64 Packages
     23.3+1-1ubuntu9 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages

# dpkg -l | grep emacs23
rc  emacs23                          23.3+1-1ubuntu9.2                   The GNU Emacs editor (with GTK+ user interface)

我该如何解决这种明显的混乱?

答案1

man dpkg

   -l, --list [package-name-pattern...]
          List  packages  matching given pattern. If no package-name-pattern is given, list all packages in /var/lib/dpkg/status, excluding the
          ones marked as not-installed (i.e. those which have been previously purged).

这意味着dpkg-l列出所有未清除包裹,以及不是一切已安装包裹;

事实上,从man dpkg-query(作为dpkg -l前端)来看:

          Desired action:
            u = Unknown
            i = Install
            h = Hold
            r = Remove
            p = Purge

          Package status:
            n = Not-installed
            c = Config-files
            H = Half-installed
            U = Unpacked
            F = Half-configured
            W = Triggers-awaiting
            t = Triggers-pending
            i = Installed

这意味着rc该行的开头意味着:

  • r:该包的期望操作是:“删除”;
  • c:该包的状态为:仅存在配置文件;

由于您想要重现现有系统,因此rc应清除“模型”系统中未出现的所需操作/状态组合的包:

sudo apt-get purge emacs23

其副作用是,这些包裹甚至不会dpkg -l再出现。

相关内容