Mar*_*cio 5 package-management apt dpkg package-info
给定两台机器:
哪个工具最好输出一个“集合”,类似diff安装包的视图:
$ ssh server-a dpkg --get-selections | grep '\binstall$' | cut -f 1 > server-a.txt
$ ssh server-b dpkg --get-selections | grep '\binstall$' | cut -f 1 > server-b.txt
Run Code Online (Sandbox Code Playgroud)使用shell 的“设置操作”来生成想要的结果:
$ comm -12 <(sort server-a.txt) <(sort server-b.txt) > both.txt
$ comm -23 <(sort server-a.txt) <(sort server-b.txt) > only-server-a.txt
$ comm -13 <(sort server-a.txt) <(sort server-b.txt) > only-server-b.txt
Run Code Online (Sandbox Code Playgroud)查看每组中有多少个包:
$ wc -l *.txt
2238 both.txt
948 only-server-a.txt
89 only-server-b.txt
3186 server-a.txt
2327 server-b.txt
8788 total
Run Code Online (Sandbox Code Playgroud)我刚刚编写了这个脚本,它也比较了包版本(如果你不需要版本,那么 ændrük 发布的内容更好):
https://github.com/lepe/scripts/blob/master/compare_ubuntu_apt.pl
用法:
1)在两台电脑上生成包列表,如:
apt --installed list | tail -n+2 > that_server.lst
Run Code Online (Sandbox Code Playgroud)
2)执行perl脚本:
./compare_ubuntu_apt.pl this_server.lst that_server.lst
Run Code Online (Sandbox Code Playgroud)
结果:(示例)
----------------------------------
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5588 次 |
| 最近记录: |