Skip to content

Commit

Permalink
Merge pull request #1509 from adamjstewart/docs/md5
Browse files Browse the repository at this point in the history
Update documentation for spack md5
  • Loading branch information
tgamblin committed Aug 12, 2016
2 parents e1c2ea5 + c815aed commit 483e411
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
21 changes: 16 additions & 5 deletions lib/spack/docs/packaging_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,25 @@ to use based on the hash length.
``spack md5``
^^^^^^^^^^^^^^^^^^^^^^

If you have a single file to checksum, you can use the ``spack md5``
command to do it. Here's how you might download an archive and get a
checksum for it:
If you have one or more files to checksum, you can use the ``spack md5``
command to do it:

.. code-block:: sh
$ curl -O http://exmaple.com/foo-8.2.1.tar.gz'
$ spack md5 foo-8.2.1.tar.gz
$ spack md5 foo-8.2.1.tar.gz foo-8.2.2.tar.gz
==> 2 MD5 checksums:
4136d7b4c04df68b686570afa26988ac foo-8.2.1.tar.gz
1586b70a49dfe05da5fcc29ef239dce0 foo-8.2.2.tar.gz
``spack md5`` also accepts one or more URLs and automatically downloads
the files for you:

.. code-block:: sh
$ spack md5 http://example.com/foo-8.2.1.tar.gz
==> Trying to fetch from http://example.com/foo-8.2.1.tar.gz
######################################################################## 100.0%
==> 1 MD5 checksum:
4136d7b4c04df68b686570afa26988ac foo-8.2.1.tar.gz
Doing this for lots of files, or whenever a new package version is
Expand Down
5 changes: 3 additions & 2 deletions lib/spack/spack/cmd/md5.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
def setup_parser(subparser):
setup_parser.parser = subparser
subparser.add_argument('files', nargs=argparse.REMAINDER,
help="Files to checksum.")
help="Files/urls to checksum.")


def compute_md5_checksum(url):
Expand Down Expand Up @@ -67,6 +67,7 @@ def md5(parser, args):
tty.warn("%s" % e)

# Dump the MD5s at last without interleaving them with downloads
tty.msg("%d MD5 checksums:" % len(results))
checksum = 'checksum' if len(results) == 1 else 'checksums'
tty.msg("%d MD5 %s:" % (len(results), checksum))
for checksum, url in results:
print "%s %s" % (checksum, url)

0 comments on commit 483e411

Please sign in to comment.