如何获取有关 deb 包存档的信息?

如何获取有关 deb 包存档的信息?

如何获取有关.deb包存档的信息?

例如:包信息、版本、安装大小、架构、描述和许可.deb包存档中的信息等?

答案1

您可以使用dpkg-deb用于操作 Debian 软件包存档 (.deb) 的命令。

来自联机帮助页:-

-I, --info archive [control-file-name...]
              Provides information about a binary package archive.

              If  no  control-file-names are specified then it will print a summary of the contents of the package as
              well as its control file.

              If any control-file-names are specified then dpkg-deb will print them in the order they were specified;
              if  any  of  the components weren't present it will print an error message to stderr about each one and
              exit with status 2.

用法示例:-

$ dpkg-deb -I intltool_0.50.2-2_all.deb 
 new debian package, version 2.0.
 size 52040 bytes: control archive=1242 bytes.
     831 bytes,    19 lines      control              
    1189 bytes,    18 lines      md5sums              
 Package: intltool
 Version: 0.50.2-2
 Architecture: all
 Maintainer: Ubuntu Developers <[email protected]>
 Original-Maintainer: Debian GNOME Maintainers <[email protected]>
 Installed-Size: 239
 Depends: gettext (>= 0.10.36-1), patch, automake | automaken, perl (>= 5.8.1), libxml-parser-perl, file
 Provides: xml-i18n-tools
 Section: devel
 Priority: optional
 Multi-Arch: foreign
 Homepage: https://launchpad.net/intltool
 Description: Utility scripts for internationalizing XML
  Automatically extracts translatable strings from oaf, glade, bonobo
  ui, nautilus theme and other XML files into the po files.
  .
  Automatically merges translations from po files back into .oaf files
  (encoding to be 7-bit clean). The merging mechanism can also be
  extended to support other types of XML files.

您可以通过以下方式列出内容dpkg-deb -c:-

用法示例:

$ dpkg-deb -c libnotify-bin_0.7.6-1ubuntu3_i386.deb 
drwxr-xr-x root/root         0 2014-02-22 05:24 ./
drwxr-xr-x root/root         0 2014-02-22 05:24 ./usr/
drwxr-xr-x root/root         0 2014-02-22 05:24 ./usr/bin/
-rwxr-xr-x root/root      9764 2014-02-22 05:24 ./usr/bin/notify-send
drwxr-xr-x root/root         0 2014-02-22 05:24 ./usr/share/
drwxr-xr-x root/root         0 2014-02-22 05:24 ./usr/share/man/
drwxr-xr-x root/root         0 2014-02-22 05:24 ./usr/share/man/man1/
-rw-r--r-- root/root       773 2014-02-22 05:24 ./usr/share/man/man1/notify-send.1.gz
drwxr-xr-x root/root         0 2014-02-22 05:24 ./usr/share/doc/
drwxr-xr-x root/root         0 2014-02-22 05:25 ./usr/share/doc/libnotify-bin/
-rw-r--r-- root/root      1327 2011-07-31 03:11 ./usr/share/doc/libnotify-bin/copyright
lrwxrwxrwx root/root         0 2014-02-22 05:25 ./usr/share/doc/libnotify-bin/AUTHORS -> ../libnotify4/AUTHORS
lrwxrwxrwx root/root         0 2014-02-22 05:25 ./usr/share/doc/libnotify-bin/NEWS.gz -> ../libnotify4/NEWS.gz
lrwxrwxrwx root/root         0 2014-02-22 05:25 ./usr/share/doc/libnotify-bin/changelog.Debian.gz -> ../libnotify4/changelog.Debian.gz

获取许可信息:-

大部分档案版权信息可从/usr/share/doc/<pkgname>/copyright

例子 :-

$ dpkg-deb -c gparted_0.18.0-1_i386.deb | grep -i copyright
-rw-r--r-- root/root      1067 2011-12-08 00:34 ./usr/share/doc/gparted/copyright

您可以从中提取-x并查找执照根据它被释放。

这里:-

$ cat /usr/share/doc/gparted/copyright | grep -i ^license -A 5
License:

   This package is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 dated June, 1991.

如需更多信息,请运行man dpkg-deb

答案2

您可以用来dpkg -f (archive) (field name)执行此操作。

例子:

dpkg -f archive.deb Version
dpkg -f archive.deb Package

要获取可能的字段名称:

dpkg --info archive.deb

答案3

灵感来自https://sleeplessbeastie.eu/2018/03/05/how-to-display-dependency-for-deb-package/:

如果您被困在不同的系统上而无法访问 dpkg/dpkg-deb,快速破解方法是使用 binutils 中的 ar 和 tar 的组合来提取必要的文件/信息。这可以通过 conda 安装;例如对于 win-64:

conda install -c msys2 m2w64-binutils
conda install -c msys2 m2-tar

提取控制文件信息的示例:

ar -x <input_file.deb> control.tar.gz
tar --to-stdout --gzip --extract --file control.tar.gz ./control

提取许可证信息的示例(另请参阅 Pandya 的回答)

ar -x gparted_0.18.0-1_i386.deb data.tar.bz2
tar --to-stdout --bzip2 --extract --file data.tar.bz2 ./usr/share/doc/gparted/copyright

如果您不确定 .deb 中的内容,您可以使用

ar -t <input_file.deb>

列出包文件中的所有文件

相关内容