diff options
-rw-r--r-- | lib/spack/docs/packaging_guide.rst | 28 | ||||
-rw-r--r-- | lib/spack/spack/cmd/md5.py | 92 | ||||
-rw-r--r-- | lib/spack/spack/cmd/sha256.py | 40 |
3 files changed, 0 insertions, 160 deletions
diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst index ac89f9724a..a8971f64a9 100644 --- a/lib/spack/docs/packaging_guide.rst +++ b/lib/spack/docs/packaging_guide.rst @@ -652,34 +652,6 @@ use: #. If all else fails and ``@develop`` is the only matching version, it will be used. -^^^^^^^^^^^^^ -``spack md5`` -^^^^^^^^^^^^^ - -If you have one or more files to checksum, you can use the ``spack md5`` -command to do it: - -.. code-block:: console - - $ 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:: console - - $ 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 -released, is tedious. See ``spack checksum`` below for an automated -version of this process. .. _cmd-spack-checksum: diff --git a/lib/spack/spack/cmd/md5.py b/lib/spack/spack/cmd/md5.py deleted file mode 100644 index 824e88373c..0000000000 --- a/lib/spack/spack/cmd/md5.py +++ /dev/null @@ -1,92 +0,0 @@ -############################################################################## -# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC. -# Produced at the Lawrence Livermore National Laboratory. -# -# This file is part of Spack. -# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. -# LLNL-CODE-647188 -# -# For details, see https://github.com/spack/spack -# Please also see the NOTICE and LICENSE files for our notice and the LGPL. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License (as -# published by the Free Software Foundation) version 2.1, February 1999. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and -# conditions of the GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -############################################################################## -import argparse -import hashlib -import os -from six.moves.urllib.parse import urlparse - -import llnl.util.tty as tty -import spack.util.crypto -from spack.stage import Stage, FailedDownloadError - -description = "calculate md5 checksums for files/urls" -section = "packaging" -level = "long" - - -def setup_parser(subparser): - setup_parser.parser = subparser - subparser.add_argument('files', nargs=argparse.REMAINDER, - help="files/urls to checksum") - - -def compute_checksum(url, algo): - algo = getattr(hashlib, algo) - - if not os.path.isfile(url): - with Stage(url) as stage: - stage.fetch() - value = spack.util.crypto.checksum(algo, stage.archive_file) - else: - value = spack.util.crypto.checksum(algo, url) - return value - - -def normalized(files): - for p in files: - result = urlparse(p) - value = p - if not result.scheme: - value = os.path.abspath(p) - yield value - - -def do_checksum(parser, args, algo): - if not args.files: - setup_parser.parser.print_help() - return 1 - - urls = [x for x in normalized(args.files)] - results = [] - for url in urls: - try: - checksum = compute_checksum(url, algo) - results.append((checksum, url)) - except FailedDownloadError as e: - tty.warn("Failed to fetch %s" % url) - tty.warn("%s" % e) - except IOError as e: - tty.warn("Error when reading %s" % url) - tty.warn("%s" % e) - - # Dump the hashes last, without interleaving them with downloads - checksum = 'checksum' if len(results) == 1 else 'checksums' - tty.msg("%d %s %s:" % (len(results), algo, checksum)) - for checksum, url in results: - print("{0} {1}".format(checksum, url)) - - -def md5(parser, args): - do_checksum(parser, args, 'md5') diff --git a/lib/spack/spack/cmd/sha256.py b/lib/spack/spack/cmd/sha256.py deleted file mode 100644 index 9b9b962e46..0000000000 --- a/lib/spack/spack/cmd/sha256.py +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################## -# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC. -# Produced at the Lawrence Livermore National Laboratory. -# -# This file is part of Spack. -# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. -# LLNL-CODE-647188 -# -# For details, see https://github.com/spack/spack -# Please also see the NOTICE and LICENSE files for our notice and the LGPL. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License (as -# published by the Free Software Foundation) version 2.1, February 1999. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and -# conditions of the GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -############################################################################## -import argparse -from spack.cmd.md5 import do_checksum - -description = "calculate sha256 checksums for files/urls" -section = "packaging" -level = "long" - - -def setup_parser(subparser): - setup_parser.parser = subparser - subparser.add_argument('files', nargs=argparse.REMAINDER, - help="files/urls to checksum") - - -def sha256(parser, args): - do_checksum(parser, args, 'sha256') |