元包是自己不安装任何东西,但依赖于其他包的包。如何列出系统上已安装的元软件包?
答案1
我用了:
apt-cache search . | grep -i "metapackage\|meta-package"
结合:
dpkg --get-selections
在以下脚本中:
awk 'BEGIN{
FS=" - ";
findmeta="apt-cache search . | grep -i \"metapackage\|meta-package\"";
while ((findmeta | getline) > 0) meta[$1]=$2;
FS=" ";
findinstalled="dpkg --get-selections";
while ((findinstalled | getline) > 0) {
if ($1 in meta) print $1" - "meta[$1]
}
}'
一行:
awk 'BEGIN{FS=" - ";findmeta="apt-cache search . | grep -i \"metapackage\|meta-package\""; while ((findmeta | getline) > 0) meta[$1]=$2; FS=" "; findinstalled="dpkg --get-selections"; while ((findinstalled | getline) > 0) {if ($1 in meta) print $1" - "meta[$1]}}'
结果示例:
emacs - GNU Emacs editor (metapackage)
exim4 - metapackage to ease Exim MTA (v4) installation
linux-headers-amd64 - Header files for Linux amd64 configuration (meta-package)
linux-image-amd64 - Linux for 64-bit PCs (meta-package)
xfce4 - Meta-package for the Xfce Lightweight Desktop Environment
xserver-xorg-input-all - X.Org X server -- input driver metapackage
答案2
"metapackage"
尝试以下命令,该命令列出了输出中其部分字段中包含该字符串的每个已安装软件包的名称apt-cache show
:
apt-cache show $(dpkg-query -Wf '${Package}\n') |
awk '$1 == "Package:" { pkg = $2 };
$1 == "Section:" && $2 ~ /metapackage/ { print pkg }'