在终端中安装之前如何了解有关软件包的信息


53

我想知道如何在安装之前在终端中获取有关软件包的信息,apt-get install以便我可以根据说明决定是否安装它。

谢谢并恭祝安康!

Answers:


62

采用

 apt-cache show PACKAGE

在安装后查看说明和有关软件包的其他信息

 dpkg -L package_name

查看软件包包含的文件。


1
第二个提示是列出包装内容,即。文件对我不起作用。它总是说,dpkg-query: package 'package_name' is not installed所以它不能用于在安装之前检查文件。该apt-file实用程序似乎是一个更可行的选择,尽管我现在还无法参考自己的经验。
2016年

dpkg -L并不总是有效,例如aide-xen将报告未安装。
Mike Q

10

对于类似的任务,包管理系统ATP(高级包工具)提供了几种解决方案(https://en.wikipedia.org/wiki/Advanced_Packaging_Tool)。


apt-cache showpkg package_name

从这里获取的描述https://linux.die.net/man/8/apt-cache

showpkg显示有关命令行上列出的软件包的信息。其余参数是程序包名称。列出了列出的每个软件包的可用版本和反向依赖关系,以及每个版本的正向依赖关系。前向(正常)依赖关系是有问题的程序包所依赖的程序包;反向依存关系是那些依赖于所讨论的软件包的软件包。因此,必须满足程序包的前向依存关系,而不必满足反向依存关系。例如,apt-cache showpkg libreadline2将产生类似于以下内容的输出

$ apt-cache showpkg javacc
Package: javacc
Versions: 
5.0-5 (/var/lib/apt/lists/ftp.ru.debian.org_debian_dists_jessie_main_binary-amd64_Packages) (/var/lib/apt/lists/httpredir.debian.org_debian_dists_jessie_main_binary-am)
 Description Language: 
                 File: /var/lib/apt/lists/ftp.ru.debian.org_debian_dists_jessie_main_binary-amd64_Packages
                  MD5: 61505d89a764133cbd782b370c93fe98
 Description Language: en
                 File: /var/lib/apt/lists/ftp.ru.debian.org_debian_dists_jessie_main_i18n_Translation-en
                  MD5: 61505d89a764133cbd782b370c93fe98


Reverse Depends: 
  ant-optional,javacc
  ant-optional,javacc
  libjavacc-maven-plugin-java,javacc
  javacc-doc,javacc
  ant-optional,javacc
Dependencies: 
5.0-5 - default-jre-headless (16 (null)) java1-runtime-headless (16 (null)) java2-runtime-headless (0 (null)) javacc-doc (0 (null)) 
Provides: 
5.0-5 - 
Reverse Provides: 

apt-cache show package_name

显示命名软件包的软件包记录。

$ apt-cache show javacc
Package: javacc
Version: 5.0-5
Installed-Size: 380
Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
Architecture: all
Depends: default-jre-headless | java1-runtime-headless | java2-runtime-headless
Suggests: javacc-doc
Description-en: Parser generator for use with Java
 Java Compiler-Compiler (JavaCC) is (according to sun)
 "the most popular parser generator" for use with Java [tm]
 applications.
 .
 A parser generator is a tool that reads a grammar specification
 and converts it to a Java program that can recognize matches to
 the grammar. In addition to the parser generator itself, JavaCC
 provides other standard capabilities related to parser
 generation such as tree building (via a tool called JJTree
 included with JavaCC), actions, debugging, etc.
Description-md5: 61505d89a764133cbd782b370c93fe98
Homepage: http://javacc.java.net
Tag: devel::code-generator, devel::lang:java, implemented-in::java,
 interface::commandline, role::program, scope::utility
Section: java
Priority: optional
Filename: pool/main/j/javacc/javacc_5.0-5_all.deb
Size: 284722
MD5sum: b1efd2defeba45cd97a48541235e6255
SHA1: c5e4b1991be06ec56e6d1a5b916c714068e5bf6b
SHA256: 757f9566d488858285c23c2ac12e05168af38953cf034f6e44123c2a88cb7c83

apt-cache策略package_name

这是为了帮助调试与首选项文件有关的问题。没有任何参数,它将打印出每个源的优先级。否则,它将打印出有关命名包优先级选择的详细信息。

$ apt-cache policy javacc
javacc:
  Installed: (none)
  Candidate: 5.0-5
  Version table:
     5.0-5 0
        500 http://ftp.ru.debian.org/debian/ jessie/main amd64 Packages
        500 http://httpredir.debian.org/debian/ jessie/main amd64 Packages

apt-cache麦迪逊package_name

apt-cache的madison命令尝试模仿Debian档案管理工具madison的输出格式和功能的子集。它以表格格式显示软件包的可用版本。与原始的madison不同,它只能显示有关APT已为其检索软件包列表(APT :: Architecture)的体系结构的信息。

$ apt-cache madison javacc
    javacc |      5.0-5 | http://ftp.ru.debian.org/debian/ jessie/main amd64 Packages
    javacc |      5.0-5 | http://httpredir.debian.org/debian/ jessie/main amd64 Packages
    javacc |      5.0-5 | http://ftp.ru.debian.org/debian/ jessie/main Sources

apt-cache showsrc package_name

显示与给定包名称匹配的所有源包记录。显示所有版本,以及所有声明该名称为Binary的记录。

$ apt-cache showsrc javacc
Package: javacc
Binary: javacc, javacc-doc
Version: 5.0-5
Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
Uploaders: Emmanuel Bourg <ebourg@apache.org>
Build-Depends: ant, debhelper (>= 7), cdbs (>= 0.4.5.3), default-jdk
Build-Depends-Indep: ant-optional, libxalan2-java, docbook-to-man, junit, maven-repo-helper
Architecture: all
Standards-Version: 3.9.4
Format: 3.0 (quilt)
Files:
 6715506605c7a4e750309b7ef645ec86 1397 javacc_5.0-5.dsc
 edf47d357c6f36458474a1b537b88a12 711183 javacc_5.0.orig.tar.gz
 b3308a9aefeca4318a0838b2a3213cea 7893 javacc_5.0-5.debian.tar.gz
Vcs-Browser: http://anonscm.debian.org/viewvc/pkg-java/trunk/javacc
Vcs-Svn: svn://anonscm.debian.org/pkg-java/trunk/javacc
Checksums-Sha1:
 f4a4ea175ce87af588c713eaab8caeaefc64183f 1397 javacc_5.0-5.dsc
 f6e12a183579a67528f351282251560faf4737db 711183 javacc_5.0.orig.tar.gz
 4aebf3cadecd96f304f80786f07473574569dc02 7893 javacc_5.0-5.debian.tar.gz
Checksums-Sha256:
 4a61f89f984809964e3d63d159998ff29c951765a046ac87dca32b21eb54f99b 1397 javacc_5.0-5.dsc
 aab2c3e2f37648b9e708e6bad4c8b544cba63b66f1791907e6e3f89609b27150 711183 javacc_5.0.orig.tar.gz
 66418d91dc6c6d45d941181d08150d272d3db57a944f3ce61847e5e1ec7c0659 7893 javacc_5.0-5.debian.tar.gz
Homepage: http://javacc.java.net
Package-List: 
 javacc deb java optional
 javacc-doc deb doc optional
Directory: pool/main/j/javacc
Priority: source
Section: java

apt-cache取决于package_name

显示软件包具有的每个依赖关系的列表以及可以满足该依赖关系的所有其他可能的软件包。

$ apt-cache depends javacc
javacc
 |Depends: default-jre-headless
 |Depends: <java1-runtime-headless>
    gcj-4.8-jre-headless
    gcj-4.9-jre-headless
    gcj-jre-headless
  Depends: <java2-runtime-headless>
    default-jre-headless
    gcj-4.8-jre-headless
    gcj-4.9-jre-headless
    gcj-jre-headless
    openjdk-7-jre-headless
    openjdk-8-jre-headless
  Suggests: javacc-doc

测试环境

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.6 (jessie)
Release:    8.6
Codename:   jessie
setivolkylany$/media/setivolkylany/WorkDisk/Private$ uname -a
Linux localhost 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux

基于https://linux.die.net/man/8/apt-cachehttp://manpages.ubuntu.com/manpages/zesty/man8/apt-cache.8.html


0

对于那些只想了解软件包基本信息的人:

apt-cache search ^package-name$
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.