3

我需要显示一个 Linux 软件包列表,这些软件包的版本在“构建机器”和各种“开发人员机器”之间可能会随着时间的推移与构建 VM 不同。

我可以通过执行“dpkg -l”来获得安装在黄金 VM 上的软件包与其他机器上的包的文本转储,然后在两个列表上执行“diff”或“awk grep”之类的操作,但我想知道是否已经有一个工具比我为这项工作编写脚本做得更好。

你们是怎么做到的?

让-皮埃尔

4

1 回答 1

8

我刚刚编写了这个脚本,它还比较了包版本:

https://github.com/lepe/scripts/blob/master/compare_ubuntu_apt.pl

用法:

1)在两台计算机上生成包列表,如:

apt --installed list | tail -n+2 > that_server.lst

2)执行perl脚本:

./compare_ubuntu_apt.pl this_server.lst that_server.lst

结果:(示例)

----------------------------------
 DIFFERENCES 
----------------------------------
 @ apparmor : 2.8.95~2430-0ubuntu5.2 -> 2.8.95~2430-0ubuntu5.3
 @ apt : 1.0.1ubuntu2.8 -> 1.0.1ubuntu2.10
 @ apt-transport-https : 1.0.1ubuntu2.8 -> 1.0.1ubuntu2.10
 @ apt-utils : 1.0.1ubuntu2.8 -> 1.0.1ubuntu2.10
 @ base-files : 7.2ubuntu5.2 -> 7.2ubuntu5.3
 @ bash-completion : 1:2.1-4 -> 1:2.1-4ubuntu0.1
----------------------------------
 MISSING IN this_server.lst
----------------------------------
 + acl : 2.2.52-1
 + acpid : 1:2.0.21-1ubuntu2
 + apport : 2.14.1-0ubuntu3.11
 + apport-symptoms : 0.20
 + at : 3.1.14-1ubuntu1
 + at-spi2-core : 2.10.2.is.2.10.1-0ubuntu1
 + attr : 1:2.4.47-1ubuntu1
 + autotools-dev : 20130810.1
----------------------------------
 MISSING IN that_server.lst
----------------------------------
 - apcupsd : 3.14.10-2build1
 - apcupsd-doc : 3.14.10-2build1
 - beep : 1.3-3
 - btrfs-tools : 3.12-1
 - discover : 2.1.2-5.2ubuntu1
于 2015-09-04T05:45:46.837 回答