2021-02-08 17:53:21 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright 2021 Oliver Smith
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import glob
|
|
|
|
import pytest
|
|
|
|
import sys
|
|
|
|
import os
|
2024-01-03 11:04:02 +00:00
|
|
|
import re
|
|
|
|
from pathlib import Path
|
2021-02-08 17:53:21 +00:00
|
|
|
|
|
|
|
import add_pmbootstrap_to_import_path
|
|
|
|
import pmb.parse
|
|
|
|
|
|
|
|
|
|
|
|
def test_aports_kernel(args):
|
|
|
|
"""
|
|
|
|
Various tests performed on the /**/linux-* aports.
|
|
|
|
"""
|
2021-06-24 17:11:17 +00:00
|
|
|
|
|
|
|
for path in glob.iglob(f"{args.aports}/**/linux-*/APKBUILD", recursive=True):
|
2021-11-27 14:08:36 +00:00
|
|
|
apkbuild = pmb.parse.apkbuild(path)
|
2021-06-24 17:10:48 +00:00
|
|
|
aport_name = os.path.basename(os.path.dirname(path))
|
2021-02-08 17:53:21 +00:00
|
|
|
|
|
|
|
if "pmb:cross-native" not in apkbuild["options"]:
|
2021-06-24 17:10:48 +00:00
|
|
|
raise RuntimeError(f"{aport_name}: \"pmb:cross-native\" missing in"
|
|
|
|
" options= line")
|
|
|
|
|
|
|
|
# cross-compilers should not be in makedepends
|
|
|
|
for ccc in ["gcc-armv7", "gcc-armhf", "gcc-aarch64",
|
|
|
|
"gcc4-armv7", "gcc4-armhf", "gcc4-aarch64",
|
|
|
|
"gcc6-armv7", "gcc6-armhf", "gcc6-aarch64"]:
|
|
|
|
if ccc in apkbuild["makedepends"]:
|
|
|
|
raise RuntimeError(f"{aport_name}: Cross-compiler ({ccc}) should"
|
|
|
|
" not be explicitly specified in makedepends!"
|
|
|
|
" pmbootstrap installs cross-compiler"
|
|
|
|
" automatically.")
|
2021-07-19 21:06:08 +00:00
|
|
|
|
2022-09-11 19:15:37 +00:00
|
|
|
# check some options only for main and community devices
|
2021-07-19 21:06:08 +00:00
|
|
|
for dir in ["main", "device/main", "device/community"]:
|
|
|
|
if path.startswith(f"{args.aports}/{dir}"):
|
2022-09-11 19:15:37 +00:00
|
|
|
if "pmb:kconfigcheck-community" not in apkbuild["options"]:
|
|
|
|
raise RuntimeError(f"{aport_name}: \"pmb:kconfigcheck-community\" missing in"
|
|
|
|
" options= line, required for all community/main devices.")
|
2024-01-03 11:04:02 +00:00
|
|
|
|
|
|
|
# check for postmarketos-installkernel in makedepends when installing kernel with make
|
|
|
|
if bool(re.search("make z?install", Path(path).read_text(encoding="utf-8"))):
|
|
|
|
if "postmarketos-installkernel" not in apkbuild["makedepends"]:
|
|
|
|
raise RuntimeError(f"{aport_name}: \"postmarketos-installkernel\" missing in"
|
|
|
|
" makedepends, required when using make install/zinstall.")
|