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)
|
|
|
|
|
2021-08-30 09:09:02 +00:00
|
|
|
packages = []
|
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
|
2021-08-30 09:09:02 +00:00
|
|
|
packages.append(os.path.basename(os.path.dirname(apkbuild)))
|
2021-10-24 07:05:02 +00:00
|
|
|
if len(packages) < 1:
|
|
|
|
print("No APKBUILDs to lint")
|
|
|
|
sys.exit(0)
|
2020-01-06 17:25:27 +00:00
|
|
|
|
2021-08-30 09:09:02 +00:00
|
|
|
result = common.run_pmbootstrap(["-q", "lint"] + packages, output_return=True)
|
2020-01-06 17:25:27 +00:00
|
|
|
|
2021-08-30 09:09:02 +00:00
|
|
|
if len(result) > 0:
|
2020-01-06 17:25:27 +00:00
|
|
|
print("Linting issues found:")
|
2021-08-30 09:09:02 +00:00
|
|
|
print(result)
|
2020-01-06 17:25:27 +00:00
|
|
|
sys.exit(1)
|