diff --git a/planemo/shed_lint.py b/planemo/shed_lint.py index ec9c749c5..a303af5ba 100644 --- a/planemo/shed_lint.py +++ b/planemo/shed_lint.py @@ -69,6 +69,11 @@ def lint_repository(ctx, realized_repository, **kwds): lint_tool_dependencies_xsd, path, ) + lint_ctx.lint( + "lint_tool_dependencies_sha256sum", + lint_tool_dependencies_sha256sum, + path, + ) lint_ctx.lint( "lint_tool_dependencies_actions", lint_tool_dependencies_actions, @@ -190,6 +195,33 @@ def lint_tool_dependencies_urls(path, lint_ctx): lint_urls(root, lint_ctx) +def lint_tool_dependencies_sha256sum(path, lint_ctx): + tool_dependencies = os.path.join(path, "tool_dependencies.xml") + if not os.path.exists(tool_dependencies): + lint_ctx.info("No tool_dependencies.xml, skipping.") + return + + root = ET.parse(tool_dependencies).getroot() + + count = 0 + for action in root.findall(".//action"): + assert action.tag == "action" + if action.attrib.get('type', '') not in ['download_by_url', 'download_file']: + continue + url = action.text.strip() + checksum = action.attrib.get('sha256sum', '') + if not checksum: + lint_ctx.warn("Missing checksum for %s" % url) + elif len(checksum) != 64 or not set("0123456789abcdef").issuperset(checksum.lower()): + lint_ctx.error("Invalid checksum %r for %s" % (checksum, url)) + else: + # TODO - See planned --verify option to check it matches + # lint_ctx.info("SHA256 checkum listed for %s" % url) + count += 1 + if count: + lint_ctx.info("Found %i download action(s) with SHA256 checksums" % count) + + def lint_tool_dependencies_xsd(path, lint_ctx): tool_dependencies = os.path.join(path, "tool_dependencies.xml") if not os.path.exists(tool_dependencies): diff --git a/tests/data/repos/package_1/tool_dependencies.xml b/tests/data/repos/package_1/tool_dependencies.xml index 7dfe8f1e3..d79e055ae 100644 --- a/tests/data/repos/package_1/tool_dependencies.xml +++ b/tests/data/repos/package_1/tool_dependencies.xml @@ -4,35 +4,35 @@ - http://depot.galaxyproject.org/package/linux/i386/samtools/samtools-0.1.16-linux-i386.tgz + http://depot.galaxyproject.org/package/linux/i386/samtools/samtools-0.1.16-linux-i386.tgz . $INSTALL_DIR - http://depot.galaxyproject.org/package/linux/x86_64/samtools/samtools-0.1.16-linux-x86_64.tgz + http://depot.galaxyproject.org/package/linux/x86_64/samtools/samtools-0.1.16-linux-x86_64.tgz . $INSTALL_DIR - http://depot.galaxyproject.org/package/darwin/i386/samtools/samtools-0.1.16-Darwin-i386.tgz + http://depot.galaxyproject.org/package/darwin/i386/samtools/samtools-0.1.16-Darwin-i386.tgz . $INSTALL_DIR - http://depot.galaxyproject.org/package/darwin/x86_64/samtools/samtools-0.1.16-Darwin-x86_64.tgz + http://depot.galaxyproject.org/package/darwin/x86_64/samtools/samtools-0.1.16-Darwin-x86_64.tgz . $INSTALL_DIR - http://depot.galaxyproject.org/package/source/samtools/samtools-0.1.16.tar.bz2 + http://depot.galaxyproject.org/package/source/samtools/samtools-0.1.16.tar.bz2 sed -i.bak 's/-lcurses/-lncurses/' Makefile make diff --git a/tests/tool_dependencies_good_1.xml b/tests/tool_dependencies_good_1.xml index 7dfe8f1e3..d79e055ae 100644 --- a/tests/tool_dependencies_good_1.xml +++ b/tests/tool_dependencies_good_1.xml @@ -4,35 +4,35 @@ - http://depot.galaxyproject.org/package/linux/i386/samtools/samtools-0.1.16-linux-i386.tgz + http://depot.galaxyproject.org/package/linux/i386/samtools/samtools-0.1.16-linux-i386.tgz . $INSTALL_DIR - http://depot.galaxyproject.org/package/linux/x86_64/samtools/samtools-0.1.16-linux-x86_64.tgz + http://depot.galaxyproject.org/package/linux/x86_64/samtools/samtools-0.1.16-linux-x86_64.tgz . $INSTALL_DIR - http://depot.galaxyproject.org/package/darwin/i386/samtools/samtools-0.1.16-Darwin-i386.tgz + http://depot.galaxyproject.org/package/darwin/i386/samtools/samtools-0.1.16-Darwin-i386.tgz . $INSTALL_DIR - http://depot.galaxyproject.org/package/darwin/x86_64/samtools/samtools-0.1.16-Darwin-x86_64.tgz + http://depot.galaxyproject.org/package/darwin/x86_64/samtools/samtools-0.1.16-Darwin-x86_64.tgz . $INSTALL_DIR - http://depot.galaxyproject.org/package/source/samtools/samtools-0.1.16.tar.bz2 + http://depot.galaxyproject.org/package/source/samtools/samtools-0.1.16.tar.bz2 sed -i.bak 's/-lcurses/-lncurses/' Makefile make