Debian/Ubuntu Linux apt-get如何不升级某些软件包

时间:2019-11-20 08:53:08  来源:igfitidea点击:

在使用apt-get命令进行系统升级时,如何不升级某些软件包?
我们可以将它们加入黑名单中。
运行apt-get upgrade时,将忽略加入黑名单的软件包。

dpkg命令语法

将Debian/Ubuntu软件包列入黑名单,执行以下命令:

echo "packageName hold" | dpkg --set-selections
echo "lighttpd hold" | dpkg --set-selections

要删除软件包并再次安装/升级:

echo "packageName install” | dpkg --set-selections
echo "lighttpd install” | dpkg --set-selections

使用/etc/apt/apt.conf.d/01autoremove

另一种不升级软件包的方法是:

编辑文件/etc/apt/apt.conf.d/01autoremove

# vi /etc/apt/apt.conf.d/01autoremove

输出示例:

APT
{
  NeverAutoRemove
  {
        "^firmware-linux.*";
        "^linux-firmware$";
        "^linux-image.*";
        "^kfreebsd-image.*";
        "^linux-restricted-modules.*";
        "^linux-ubuntu-modules-.*";
  };

  Never-MarkAuto-Sections
  {
        "metapackages";
        "restricted/metapackages";
        "universe/metapackages";
        "multiverse/metapackages";
        "oldlibs";
        "restricted/oldlibs";
        "universe/oldlibs";
        "multiverse/oldlibs";
  };
};

在Never-MarkAuto-Sections添加不自动升级的软件:

Never-MarkAuto-Sections
  {
        "metapackages";
        "restricted/metapackages";
        "universe/metapackages";
        "multiverse/metapackages";
        "oldlibs";
        "restricted/oldlibs";
        "universe/oldlibs";
        "multiverse/oldlibs";
        "php5-cgi*";
  };