license_depends_compat.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <tools/ccanlint/ccanlint.h>
  2. #include <ccan/foreach/foreach.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <fcntl.h>
  6. #include <unistd.h>
  7. #include <limits.h>
  8. #include <errno.h>
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11. #include <err.h>
  12. #include <ccan/talloc/talloc.h>
  13. #include <ccan/str/str.h>
  14. #include <ccan/str_talloc/str_talloc.h>
  15. static void check_license_depends_compat(struct manifest *m,
  16. unsigned int *timeleft,
  17. struct score *score)
  18. {
  19. struct manifest *i;
  20. score->pass = true;
  21. /* If our license is unknown, we can't know the answer. */
  22. if (m->license == LICENSE_UNKNOWN) {
  23. score->score = score->total = 0;
  24. return;
  25. }
  26. list_for_each(&m->deps, i, list) {
  27. struct doc_section *d = find_license_tag(i);
  28. i->license = which_license(d);
  29. if (i->license != LICENSE_UNKNOWN
  30. && !license_compatible[m->license][i->license]) {
  31. score_file_error(score, i->info_file, 0,
  32. "Dependency ccan/%s has"
  33. " incompatible license '%s'",
  34. i->basename,
  35. licenses[i->license].name);
  36. score->pass = false;
  37. }
  38. }
  39. if (score->pass)
  40. score->score = score->total;
  41. }
  42. struct ccanlint license_depends_compat = {
  43. .key = "license_depends_compat",
  44. .name = "CCAN dependencies don't contain incompatible licenses",
  45. .check = check_license_depends_compat,
  46. .needs = "license_exists depends_exist"
  47. };
  48. REGISTER_TEST(license_depends_compat);