防止在执行“dpkg --set-selections”后软件包被删除

防止在执行“dpkg --set-selections”后软件包被删除

我正在尝试安装另一台主机上安装的所有软件包。

  • 来自主机 = Ubuntu 12.04 LTS
  • 主机 = Ubuntu 12.04 LTS

dpkg --get-selections > packages.txt我在“旧”系统上运行过。要将它们导入到较新的系统,我运行了: dpkg --set-selections < packages.txt。这似乎运行良好。

但是当我尝试安装它们时;apt-get告诉我它要删除以下软件包:

 e2fsprogs libblkid1 (due to e2fsprogs) libuuid1 (due to e2fsprogs) util-linux (due to e2fsprogs) hostname mount libmount1 (due to mount) acpid adduser aptitude console-setup cron dmsetup dselect e2fsprogs eject grub-common
  grub-gfxpayload-lists grub-pc grub-pc-bin grub2-common hostname ifupdown initramfs-tools
  initscripts kbd keyboard-configuration libblkid1 libdevmapper1.02.1 libmount1 libuuid1 libxapian22
  linux-image-3.2.0-49-virtual linux-image-virtual linux-virtual module-init-tools mount mountall
  netbase ntpdate openssh-client openssh-server passwd plymouth procps resolvconf rsync rsyslog
  tasksel tasksel-data ubuntu-minimal udev upstart ureadahead util-linux

问题是;我看到几个我不想卸载/删除的“必需”包。有没有类似的命令apt-get upgrade --only-install?或者有没有解决方法只安装包?

答案1

--get-selections正确的方法是在导入列表之前解析输出。现在要纠正这种情况,应该应用一些解决方法:

在“旧”系统上:

dpkg --get-selections | grep -v 'deinstall` > packages.txt

这将为您提供仅安装的软件包的列表。现在在目标系统中:

sudo dpkg --clear-selections
sudo dpkg --set-selections < packages.txt

现在让我们修复上一个命令的混乱:

将以下内容保存到某个文件中,我们称之为packages.fix

e2fsprogs install 
libblkid1 install 
libuuid1 install 
util-linux install 
hostname install 
mount install 
libmount1 install 
acpid install 
adduser install 
aptitude install 
console-setup install 
cron install 
dmsetup install 
dselect install 
e2fsprogs install 
eject install 
grub-common install 
grub-gfxpayload-lists install 
grub-pc install 
grub-pc-bin install 
grub2-common install 
hostname install 
ifupdown install 
initramfs-tools install 
initscripts install 
kbd install 
keyboard-configuration install 
libblkid1 install 
libdevmapper1.02.1 install 
libmount1 install 
libuuid1 install 
libxapian22 install 
linux-image-3.2.0-49-virtual install 
linux-image-virtual install 
linux-virtual install 
module-init-tools install 
mount install 
mountall install 
netbase install 
ntpdate install 
openssh-client install 
openssh-server install 
passwd install 
plymouth install 
procps install 
resolvconf install 
rsync install 
rsyslog install 
tasksel install 
tasksel-data install 
ubuntu-minimal install 
udev install 
upstart install 
ureadahead install 
util-linux install

现在让我们sudo dpkg --set-selections < packages.fix继续你的操作,现在应该没问题了。

相关内容