2020-01-06 17:25:27 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import common
|
2020-03-14 11:22:08 +00:00
|
|
|
import os.path
|
2020-01-06 17:25:27 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
common.add_upstream_git_remote()
|
2020-03-14 11:22:08 +00:00
|
|
|
apkbuilds = {file for file in common.get_changed_files(removed=False)
|
|
|
|
if os.path.basename(file) == "APKBUILD"}
|
|
|
|
if len(apkbuilds) < 1:
|
2020-01-06 17:25:27 +00:00
|
|
|
print("No APKBUILDs to lint")
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
issues = []
|
2020-03-14 11:22:08 +00:00
|
|
|
for apkbuild in apkbuilds:
|
|
|
|
if apkbuild.startswith("temp/") or apkbuild.startswith("cross/"):
|
|
|
|
print(f"NOTE: Skipping linting of {apkbuild}")
|
2020-01-06 17:25:27 +00:00
|
|
|
continue
|
|
|
|
|
2020-04-06 21:06:11 +00:00
|
|
|
package = os.path.basename(os.path.dirname(apkbuild))
|
|
|
|
result = common.run_pmbootstrap(["-q", "lint", package], output_return=True)
|
|
|
|
if len(result) > 0:
|
|
|
|
issues.append([apkbuild, result])
|
2020-01-06 17:25:27 +00:00
|
|
|
|
|
|
|
if len(issues) > 0:
|
|
|
|
print("Linting issues found:")
|
|
|
|
for issue in issues:
|
|
|
|
print(issue[0] + ": " + issue[1])
|
|
|
|
|
|
|
|
sys.exit(1)
|