`md5sum -c` 不适用于 Apache 的 MD5 文件格式

Bil*_*kil 5 apache md5sum

让我带你去旅行..

我试图下载和验证Apache的火花(http://www.apache.org/dist/spark/spark-1.6.0/spark-1.6.0-bin-hadoop2.6.tgz通过MD5上一个新) Debian(杰西)机器。

md5sum脚本已经存在这台机器上没有我需要做什么。

因此,我继续将 MD5 校验和(http://www.apache.org/dist/spark/spark-1.6.0/spark-1.6.0-bin-hadoop2.6.tgz.md5)下载到同一目录作为下载的 Spark,然后我执行:

md5sum -c spark-1.6.0-bin-hadoop2.6.tgz.md5
Run Code Online (Sandbox Code Playgroud)

这失败了:

md5sum: spark-1.6.0-bin-hadoop2.6.tgz.md5: no properly formatted MD5 checksum lines found
Run Code Online (Sandbox Code Playgroud)

所以我通过cat spark-1.6.0-bin-hadoop2.6.tgz.md5以下方式检查内容:

spark-1.6.0-bin-hadoop2.6.tgz: 62 4B 16 1F 67 70 A6 E0  E0 0E 57 16 AF D0 EA 0B
Run Code Online (Sandbox Code Playgroud)

这就是整个文件。对我来说看起来不错 - 也许 Spark 下载实际上很糟糕?在采取该假设之前,我将首先通过md5sum spark-1.6.0-bin-hadoop2.6.tgz以下方式查看 MD5 的内容:

624b161f6770a6e0e00e5716afd0ea0b  spark-1.6.0-bin-hadoop2.6.tgz
Run Code Online (Sandbox Code Playgroud)

嗯,这是一种完全不同的格式——但如果你仔细观察,你会发现数字和字母实际上是一样的(除了小写和没有空格)。看起来md5sumDebian 附带的 遵循不同的标准。

也许还有另一种方法可以运行此命令?让我们试试md5sum --help

Usage: md5sum [OPTION]... [FILE]...
Print or check MD5 (128-bit) checksums.
With no FILE, or when FILE is -, read standard input.

  -b, --binary         read in binary mode
  -c, --check          read MD5 sums from the FILEs and check them
      --tag            create a BSD-style checksum
  -t, --text           read in text mode (default)

The following four options are useful only when verifying checksums:
      --quiet          don't print OK for each successfully verified file
      --status         don't output anything, status code shows success
      --strict         exit non-zero for improperly formatted checksum lines
  -w, --warn           warn about improperly formatted checksum lines

      --help     display this help and exit
      --version  output version information and exit

The sums are computed as described in RFC 1321.  When checking, the input
should be a former output of this program.  The default mode is to print
a line with checksum, a character indicating input mode ('*' for binary,
space for text), and name for each FILE.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report md5sum translation bugs to <http://translationproject.org/team/>
Full documentation at: <http://www.gnu.org/software/coreutils/md5sum>
or available locally via: info '(coreutils) md5sum invocation'
Run Code Online (Sandbox Code Playgroud)

好吧,--tag似乎改变了格式。让我们试试md5sum --tag spark-1.6.0-bin-hadoop2.6.tgz

MD5 (spark-1.6.0-bin-hadoop2.6.tgz) = 624b161f6770a6e0e00e5716afd0ea0b
Run Code Online (Sandbox Code Playgroud)

确实,这是一种不同的格式,但仍然不是正确的格式..所以我查看了Apache 下载镜像页面上的说明并找到以下文本:

或者,您可以验证文件的 MD5 哈希。一个被称为md5md5sum包含在许多 unix 发行版中的unix 程序。它也可以作为GNU Textutils 的一部分使用...

所以我点击那个链接,发现 Textutils 在 2003 年被合并到 Coreutils - 所以我实际上想要md5sum来自 Coreutils 的那个。但是,您可以在md5sum --help转储的底部看到它已经来自 Coreutils。

这可能意味着我的 Coreutils 已过时。所以我会apt-get update && apt-get upgrade coreutils,但后来我发现:

Calculating upgrade... coreutils is already the newest version.
Run Code Online (Sandbox Code Playgroud)

那是一个死胡同……但是等一下,他们说“md5md5sum”!让我们看看那个铅。

md5脚本尚不存在,所以我会尝试apt-get install md5

E: Unable to locate package md5
Run Code Online (Sandbox Code Playgroud)

现在我迷路了,所以求助于谷歌和 StackOverflow 寻求帮助..现在我来了。

那么这两种不同的 MD5 文件格式有什么关系,我该如何处理这个问题(并最终验证我的 Apache Spark)?

del*_*hin 3

我相信gpg --print-md md5 spark-1.6.0-bin-hadoop2.6.tgz应该与 .md5 文件的内容匹配。

md5/sha 文件的格式存在问题,因为构建 Spark 版本的脚本用于gpg --print-md md5创建签名文件。请参阅:https://issues.apache.org/jira/browse/SPARK-5308

  • 你必须使用类似`gpg --print-md MD5 Spark-1.6.0-bin-hadoop2.6.tgz | 的东西。diff - Spark-1.6.0-bin-hadoop2.6.tgz.md5` 因为我认为没有自动方法可以做到这一点。您始终可以下载“spark-1.6.0-bin-hadoop2.6.tgz.asc”文件并执行“gpg --verify spark-1.6.0-bin-hadoop2.6.tgz.asc”之类的操作spark-1.6获取公钥后的.0-bin-hadoop2.6.tgz` (4认同)