获取软件包信息

有些基于APT系统的前端程序,能十分方便地获得系统软件包列表,列表包括可安 装或已安装的软件包,还可以显示某软件包属于哪个section,它的优先级是多少, 它的说明文档等等。

但是…在此我们想的学习如何使用APT本身来完成。你如何找出你想要安装的软件 包的名称?

我们完成这个任务的方法有很多。我们从apt-cache开始,APT系统使用 这个程序来维护它的数据库。下面我们通过一些实际操作来对它做个概览。

  1. 获得软件包名称

# apt-cache search idle
idle - IDE for Python using Tkinter (default version)
idle-python2.7 - IDE for Python (v2.7) using Tkinter
idle-python3.4 - IDE for Python (v3.4) using Tkinter
idle3 - IDE for Python using Tkinter (default version)
libkidletime4 - library to provide information about idle time
libkutils4 - dummy transitional library
llvm-3.4 - Modular compiler and toolchain technologies
llvm-3.4-dev - Modular compiler and toolchain technologies, libraries and headers
llvm-3.4-doc - Modular compiler and toolchain technologies, documentation
……

通过上面的操作,我们找到了几个相关的软件包,以及有关的简单描述。如果想进一步的了解某个软件包的详细信息。可以运行:

# apt-cache show idle
Package: idle
Priority: optional
Section: python
Installed-Size: 54
Maintainer: Ubuntu Developers ubuntu-devel-discuss@lists.ubuntu.com
Original-Maintainer: Matthias Klose doko@debian.org
Architecture: all
Source: python-defaults
Version: 2.7.5-5ubuntu3
Replaces: python (<< 2.7.3-1~)
Depends: python (>= 2.7.5-5ubuntu3), python-tk, idle-python2.7
Breaks: python (<< 2.7.3-1~)
Filename: pool/main/p/python-defaults/idle_2.7.5-5ubuntu3_all.deb
Size: 3114
MD5sum: c18627e5a82c87a441cc1b8a3c278240
SHA1: 44525cf376f81a06da8374e0f4309e7756efd181
SHA256: 8776508df7c4df3f3e71d608596cd4c27470e9b7dacfde86361320c63e6d3ab8
Description-en: IDE for Python using Tkinter (default version)
IDLE is an Integrated Development Environment for Python.
IDLE is written using Tkinter and therefore quite platform-independent.
.
This package is a dependency package, which depends on Debian’s default

屏幕中显示出这个软件包的详细信息及其用途的完整描述。
2. 使用dpkg查找安装包名称
另外一个定位安装包的方法是知道软件包的某个关键文件的名称。例如,你编译时需要某个“*.h”头文件,查找提供该文件的软件包,可以运行:

# dpkg -S stdio.h
perl: /usr/lib/perl/5.18.2/CORE/nostdio.h
syslinux-common: /usr/lib/syslinux/com32/include/stdio.h
libc6-dev:amd64: /usr/include/x86_64-linux-gnu/bits/stdio.h
libc6-dev:amd64: /usr/include/stdio.h

或者

# dpkg -S /usr/include/stdio.h
libc6-dev:amd64: /usr/include/stdio.h

  1. 如何“按需”安装软件包
    你真正编译某段程序时,突然,停住了,然后一条错误的信息告诉你没有它需要的头文件。这时你可以使用auto-apt来帮助你。它会首先询问你是否需要安装安装包,然后挂起编译进程,安装好软件包后在恢复编译进程。
    你所要做的就是:
    # auto-apt run command此处的command 对应的是上面运行过程中出现“找不到头文件”的问题命令。例如:
    # auto-apt run ./config
    一会儿,它就会告诉你所需要的安装包并跳转到apt-get处理。如果你真正运行X,就会出现一个图形界面提示窗口。
    另外,为了提高效率auto-apt所使用的数据库需要实时更新。可调用auto-apt update auto-apt updatedbauto-apt updat-locale来完成更新。

摘录于:APT HOWTO (Obsolete Documentation) —第 5 章 - 获取软件包信息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值