diff --git a/.gitignore b/.gitignore index bacbfb6..8aaefaf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ -/grafana-pcp-0.0.7.tar.gz -/grafana-pcp-deps-0.0.7.tar.xz +/grafana-pcp-*.tar.gz +/grafana-pcp-*.rpm +/grafana-pcp-deps-*.tar.xz +/grafana-pcp-*/ +/noarch/ +.build-*.log diff --git a/check_npm_dependencies.py b/check_npm_dependencies.py new file mode 100755 index 0000000..f736653 --- /dev/null +++ b/check_npm_dependencies.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +import sys +import tarfile +import json + +def read_spec_provides(spec_path): + with open(spec_path) as f: + for line in f: + if line.startswith('Provides:'): + yield line.strip() + +def read_node_deps(source_archive_path): + root_dir = source_archive_path[:-len('.tar.gz')] + with tarfile.open(source_archive_path) as tar: + f = tar.extractfile('{}/package.json'.format(root_dir)) + package_json = json.load(f) + return list(package_json['devDependencies'].keys()) + list(package_json['dependencies'].keys()) + +def read_node_deps_versions(dep_bundle_path, dependencies): + with tarfile.open(dep_bundle_path) as tar: + for dependency in dependencies: + f = tar.extractfile('node_modules/{}/package.json'.format(dependency)) + package_json = json.load(f) + yield 'Provides: bundled(nodejs-{}) = {}'.format(package_json["name"], package_json["version"]) + +if __name__ == '__main__': + if len(sys.argv) != 4: + print('usage: {} specfile source-archive dependency-bundle'.format(sys.argv[0])) + sys.exit(1) + + provides = list(read_spec_provides(sys.argv[1])) + dependencies = sorted(read_node_deps(sys.argv[2])) + actual_provides = list(read_node_deps_versions(sys.argv[3], dependencies)) + + if provides == actual_provides: + print("Dependencies are up-to-date with the specfile.") + sys.exit(0) + else: + print("Dependencies don't match, please update the specfile:") + print ('\n'.join(actual_provides)) + sys.exit(1) diff --git a/grafana-pcp.rpmlintrc b/grafana-pcp.rpmlintrc new file mode 100644 index 0000000..2bccc80 --- /dev/null +++ b/grafana-pcp.rpmlintrc @@ -0,0 +1,6 @@ +addFilter("W: spelling-error %description -l en_US datasources -> .*") +addFilter("W: spelling-error %description -l en_US pmseries -> .*") +addFilter("W: spelling-error %description -l en_US bpftrace -> .*") + +addFilter("W: strange-permission create_dependency_bundle.sh 755") +addFilter("W: invalid-url Source1: grafana-pcp-deps-.*")