Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • alistair23/pmaports
  • exkc/pmaports
  • fossdd/pmaports
  • JustSoup321/pmaports
  • Eisenbahnfan/pmaports
  • raihan2000/pmaports
  • sleirsgoevy/pmaports
  • Adrian/pmaports
  • adamthiede/pmaports
  • jianhua/pmaports
  • knuxify/pmaports
  • Arnavion/pmaports
  • barni2000/pmaports
  • longnoserob/pmaports
  • smankusors/pmaports
  • Aren/pmaports
  • langfingaz/pmaports
  • sicelo/pmaports
  • kouta-kun/pmaports
  • craftyguy/pmaports
  • rdacayan/pmaports
  • rmader/pmaports
  • Haui111/pmaports
  • jakko/pmaports
  • dujem/pmaports
  • methanal/pmaports
  • WeirdTreeThing/pmaports
  • MightyM17/pmaports
  • sertonix/pmaports
  • amessier/pmaports
  • akemnade/pmaports
  • setotau/pmaports
  • kevinwidjaja21/pmaports
  • NekoCWD/pmaports
  • ollieparanoid/pmaports
  • manoedinata/pmaports
  • Drakulix/pmaports
  • grimler/pmaports
  • benpicco/pmaports
  • Frieder.Hannenheim/pmaports
  • andrisas/pmaports
  • EspiDev/pmaports
  • maze42/pmaports
  • anjandev/pmaports
  • danct12/pmaports
  • ijiki16/pmaports
  • jja2000/pmaports
  • fancsali/pmaports
  • bolilingmeng89006/pmaports
  • Minecrell/pmaports
  • chipiguay/pmaports
  • cherrypicker/pmaports
  • fortuna-mainline/pmaports
  • pevik/pmaports
  • Patriot-06/pmaports
  • JoseskVolpe/pmaports
  • verdre/pmaports
  • proycon/pmaports
  • AutumnSpark1226/pmaports
  • PsychoGame/pmaports
  • fraolt/pmaports
  • VaporGame/pmaports
  • pugzarecute/pmaports
  • CalcProgrammer1/pmaports
  • hexaheximal/pmaports
  • dabao1955/pmaports
  • HenriDellal/pmaports
  • semfault/pmaports
  • strobo5/pmaports
  • andrewgigena/pmaports
  • Athozus/pmaports
  • 1peter10/pmaports
  • vixalien/pmaports
  • Tooniis/pmaports
  • adomerle/pmaports
  • bjorn3/pmaports
  • StacyHarper/pmaports
  • Jack_Kekzoz/pmaports
  • Ceddicedced/pmaports
  • Justin_Zobel/pmaports
  • airtower-luna/pmaports
  • f-izzo/pmaports
  • cosmo/pmaports
  • 9lore/pmaports
  • postmarketOS/pmaports
  • Johnnynator/pmaports
  • iAboothahir/pmaports
  • N1kroks/pmaports
  • neuschaefer/pmaports
  • DylanVanAssche/pmaports
  • yehiashamaa987/pmaports
  • Operachi/pmaports
  • faveoled/pmaports
  • ilpianista/pmaports
  • johkra/pmaports
  • HDDTHR/pmaports
  • zsoltiv/pmaports
  • Justin/pmaports
  • Kaloyan501/pmaports_huawei_p8_lite_2015_fix
  • joelselvaraj/pmaports
  • rontti/pmaports
  • dsankouski/pmaports
  • StandaSK/pmaports
  • paricbat/pmaports
  • asdfugil/pmaports
  • komaru-yml/pmaports
  • MasterPlexus/pmaports
  • Felix/pmaports
  • ayakael/pmaports
  • feisuzhu/pmaports
  • AJ-RR/pmaports
  • SzczurekYT/pmaports
  • mediaberry/pmaports
  • justsomeguy/pmaports
  • Augis154/pmaports
  • hrdl/pmaports
  • sib0ndt/pmaports
  • 19atlas/pmaports
  • vipaoL/pmaports
  • wannjanjic/pmaports
  • dh/pmaports
  • LogicalErzor/pmaports
  • halamix2/pmaports
  • Shamilkv34/pmaports
  • Cogitri/pmaports
  • fallenritemonk/pmaports
  • user0-07161/pmaports
  • rock3tsprocket/pmaports
  • ellyq/pmaports
  • rodent/pmaports
  • mkorpershoek/pmaports
  • candrew/pmaports
  • fallaciousreasoning/pmaports
  • chalkin/pmaports
  • ungeskriptet/pmaports
  • r00t/pmaports
  • panpanpanpan/pmaports
  • celiffe/pmaports
  • davidfurey/pmaports
  • kidd/pmaports
  • tpikonen/pmaports
  • camelCaseNick/pmaports
  • ermine/pmaports
  • lgh/pmaports
  • sajattack/pmaports
  • StephanieBread/pmaports
  • M0Rf30/pmaports
  • notfound405/pmaports
  • samueldr/pmaports
  • r10nw7fd3/pmaports
  • treid998/pmaports-merge
  • denysvitali/pmaports
  • rodriguezst/pmaports
  • puppiestdoggo1/pmaports
  • donihalim/pmaports
  • EDKPiepaint/pmaports-apple-tonga-test
  • SanyaPilot/pmaports
  • spyraks/pmaports
  • HAKANKOKCU/pmaports
  • omar-mahboubi/pmaports
  • eliassouza/pmaports
161 results
Show changes
Commits on Source (995)
Showing
with 546 additions and 180 deletions
......@@ -11,12 +11,4 @@ if [ "$(id -u)" = 0 ]; then
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
# Wrap pmbootstrap to use this repository for --aports
pmaports="$(cd "$(dirname "$0")"/..; pwd -P)"
_pmbootstrap="$(command -v pmbootstrap)"
pmbootstrap() {
"$_pmbootstrap" --aports="$pmaports" "$@"
}
.ci/lib/apkbuild_linting.py
......@@ -43,7 +43,7 @@ update_linux_next() {
# shellcheck source=/dev/null
pkgver=$(. device/testing/linux-next/APKBUILD; echo "$pkgver")
curl -s "https://gitlab.com/linux-kernel/linux-next/-/tags?format=atom" | grep -oP "(?<=<title>)[^<]+" | tail -n +2 > /tmp/tags
curl -s https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/refs/tags/ | grep -oE "<a href='.*'>(.*)</a>.*\.tar\.gz</a>" | awk -F'[<>]' '{print $3}' > /tmp/tags
latest=$(grep -v "v" < /tmp/tags | head -n1)
if [ -z "$latest" ]; then
......@@ -71,6 +71,7 @@ update_linux_next() {
echo "Updating linux-next from $pkgver to $new_pkgver..."
sed -i -e "s/pkgver=$pkgver/pkgver=$new_pkgver/" device/testing/linux-next/APKBUILD
sed -i -e "s/^pkgrel=.*/pkgrel=0/" device/testing/linux-next/APKBUILD
# Update the checksums
pmbootstrap checksum linux-next
......
image: alpine:latest
stages:
- build
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "parent_pipeline"
{% if archs|length == 0 %}
# Needed because gitlab fails if no jobs are created, e.g: nothing should be
# built: https://gitlab.com/gitlab-org/gitlab/-/issues/368248
placeholder:
stage: build
script:
- 'true'
{% endif %}
.build:
stage: build
interruptible: true
before_script:
# upgrade is mostly needed for "qemu" runners that run edge based on a VM
# The other build jobs run natively in docker on latest alpine stable and
# those should always have whatever we need
- apk upgrade -U
- .ci/lib/gitlab_prepare_ci.sh
after_script:
- cp -r /home/pmos/.local/var/pmbootstrap/packages/ packages/ || true
- .ci/lib/move_logs.sh $CI_PROJECT_DIR
artifacts:
expire_in: 1 week
paths:
- packages/
timeout: 10 h
{% if ('x86_64' in archs) %}
build-x86_64:
extends: .build
script:
- .ci/build-x86_64.sh
{% endif %}
{% if ('x86' in archs) %}
build-x86:
extends: .build
script:
- .ci/build-x86.sh
{% endif %}
{% if ('aarch64' in archs) %}
build-aarch64:
extends: .build
tags: [arm64]
script:
- .ci/build-aarch64.sh
{% endif %}
{% if ('armv7' in archs) %}
build-armv7:
extends: .build
tags: [qemu]
script:
- .ci/build-armv7.sh
{% endif %}
{% if ('armhf' in archs) %}
build-armhf:
extends: .build
tags: [qemu]
script:
- .ci/build-armhf.sh
{% endif %}
{% if ('riscv64' in archs) %}
build-riscv64:
extends: .build
tags: [qemu]
script:
- .ci/build-riscv64.sh
{% endif %}
#!/bin/sh -e
# Description: verify CODEOWNERS file is sane
# https://postmarketos.org/pmb-ci
# TODO Future improvements:
# * Check that all devices in main/community have someone in CODEOWNERS
# * Check that GitLab user actually exists (e.g. deleted account, account with
# changed user name)
if grep -q " " CODEOWNERS; then
echo
echo "ERROR: Found space indentation in CODEOWNERS."
echo "ERROR: Please indent with tab characters."
grep " " CODEOWNERS
echo
exit 1
fi
fail=0
tmppipe=$(mktemp -u)
mkfifo "$tmppipe"
grep -v "^#" CODEOWNERS | cut -d' ' -f1 > "$tmppipe" &
while IFS= read -r line; do
[ -z "$line" ] && continue
# Check if entry generally exists
# shellcheck disable=SC2086
ls $line >/dev/null 2>&1 || { fail=1; echo "Non-existing: $line"; }
# Check that directories end with a slash
# shellcheck disable=SC2086
if test -d "$(ls -d $line)"; then
echo "$line" | grep -q '/$' || { fail=1; echo "Missing trailing slash: $line"; }
fi
done < "$tmppipe"
rm "$tmppipe"
if [ "$fail" = 1 ]; then
echo
echo "ERROR: Invalid CODEOWNERS entries, see above."
echo
exit 1
fi
......@@ -24,23 +24,6 @@ def build_strict(packages, arch):
"--arch", arch, ] + list(packages))
def verify_checksums(packages, arch):
# Only do this with one build-{arch} job
arch_verify = "x86_64"
if arch != arch_verify:
print(f"NOTE: doing checksum verification in build-{arch_verify} job,"
" not here.")
return
if len(packages) == 0:
print("no packages changed, not doing any checksums verification")
return
common.run_pmbootstrap(["build_init"])
common.run_pmbootstrap(["--details-to-stdout", "checksum", "--verify"] +
list(packages))
if __name__ == "__main__":
# Architecture to build for (as in build-{arch})
if len(sys.argv) != 2:
......@@ -93,31 +76,31 @@ if __name__ == "__main__":
# No packages: skip build
if len(packages) == 0:
print(f"no packages changed, which can be built for {arch}")
sys.exit(0)
else:
verify_only = common.commit_message_has_string("[ci:skip-build]")
if verify_only:
# [ci:skip-build]: verify checksums and stop
print("WARNING: not building changed packages ([ci:skip-build])!")
print("verifying checksums: " + ", ".join(packages))
verify_checksums(packages, arch)
else:
# Build packages
print(f"building in strict mode for {arch}: {', '.join(packages)}")
build_strict(packages, arch)
build_strict(packages, arch)
# Build packages in extra-repos/systemd
# FIXME: this should probably be more generic, if other repos are added later?
if systemd_pkgs:
common.run_pmbootstrap(["config", "systemd", "always"])
verify_only = common.commit_message_has_string("[ci:skip-build]")
if verify_only:
# [ci:skip-build]: verify checksums
print("WARNING: not building changed packages for extra-repos/systemd: ([ci:skip-build])!")
print("verifying checksums: " + ", ".join(systemd_pkgs))
verify_checksums(systemd_pkgs, arch)
else:
# Build packages
print(f"building in strict mode for {arch}, from extra-repos/systemd: {', '.join(systemd_pkgs)}")
build_strict(systemd_pkgs, arch)
# To fix the ERROR: Chroot 'native' is for the 'edge' channel, but you are on the
# 'systemd-edge' channel. Run 'pmbootstrap zap' to delete your chroots and try again.
# To do this automatically, run 'pmbootstrap config auto_zap_misconfigured_chroots yes'.
common.run_pmbootstrap(["config", "auto_zap_misconfigured_chroots", "yes"])
# filter out packages that can't be built for arch
# (Iterate over copy of `systemd_pkgs`, because we modify it in this loop)
for package in systemd_pkgs.copy():
apkbuild_path = pmb.helpers.pmaports.find(package, True, True, with_extra_repos="enabled")
apkbuild = pmb.parse._apkbuild.apkbuild(pathlib.Path(apkbuild_path, "APKBUILD"))
if not pmb.helpers.pmaports.check_arches(apkbuild["arch"], arch):
print(f"(extra-repos/systemd) {package}: not enabled for {arch}, skipping")
systemd_pkgs.remove(package)
# No packages: skip build
if len(systemd_pkgs) == 0:
print(f"no packages changed, which can be built for {arch}")
sys.exit(0)
build_strict(systemd_pkgs, arch)
......@@ -41,7 +41,9 @@ def add_upstream_git_remote():
def commit_message_has_string(needle):
return needle in run_git(["show", "-s", "--format=full", "HEAD"])
base_commit = get_base_commit()
return needle in run_git(["log", "--pretty=format:%B", f"{base_commit}..HEAD"])
def run_pmbootstrap(parameters):
......@@ -86,12 +88,10 @@ def get_upstream_branch():
return ret
def get_changed_files(removed=True):
""" Get all changed files and print them, as well as the branch and the
commit that was used for the diff.
:param removed: also return removed files (default: True)
:returns: set of changed files
"""
def get_base_commit() -> str:
"""Get the base commit that can be compared with HEAD to get all commits in the
given branch/merge request."""
branch_upstream = f"upstream/{get_upstream_branch()}"
commit_head = run_git(["rev-parse", "HEAD"])[:-1]
commit_upstream = run_git(["rev-parse", branch_upstream])[:-1]
......@@ -107,6 +107,17 @@ def get_changed_files(removed=True):
commit = run_git(["merge-base", branch_upstream, "HEAD"])[:-1]
print("comparing HEAD with: " + commit)
return commit
def get_changed_files(removed=True):
""" Get all changed files and print them, as well as the branch and the
commit that was used for the diff.
:param removed: also return removed files (default: True)
:returns: set of changed files
"""
commit = get_base_commit()
# Changed files
ret = set()
print("changed file(s):")
......
#!/usr/bin/env python3
# Copyright 2025 Pablo Correa Gomez
# SPDX-License-Identifier: GPL-3.0-or-later
from pathlib import Path
import shutil
import sys
from jinja2 import Template
import add_pmbootstrap_to_import_path
import pmb.parse
import pmb.helpers.logging
from pmb.core.arch import Arch
# Same dir
import common
if __name__ == "__main__":
# Needs input to output if we should create the jobs
if len(sys.argv) != 3:
print("usage: generate_build_jobs.py TEMPLATE CHILD_PIPELINE")
print(sys.argv)
sys.exit(1)
template = sys.argv[1]
child_pipeline = sys.argv[2]
# pmb logging has to be initialized for later pmb commands to work, setting
# to /dev/null since we don't care about the output. Later this could
# be changed to a file and added as a CI artifact if we need to debug
# something.
pmb.logging.init(Path("/dev/null"), False)
archs = set()
# Get and print modified packages
common.add_upstream_git_remote()
for file in common.get_changed_files():
path = Path(file)
if path.name != "APKBUILD":
continue
elif not path.exists():
continue # APKBUILD was deleted
apkbuild = pmb.parse.apkbuild(path)
archs.update(apkbuild["arch"])
if common.commit_message_has_string("[ci:skip-build]"):
print("User requested skipping build, not creating child pipeline file")
archs = set()
# This ignores things like !armv7, that could be a follow-up optimization
if 'noarch' in archs or 'all' in archs:
archs = set([str(arch) for arch in Arch.supported()])
print(archs)
with open(template) as f:
rendered = Template(f.read()).render(archs=archs)
with open(child_pipeline, "w") as fw:
fw.write(rendered)
#!/bin/sh
# Unit testing framework for shell scripts
# Invoke with the path to a tests/ subdir of a package and the
# package name as arguments. Or source it with the following
# variables set:
# * results_dir - second argument to the test script
set -e
# Colors :D
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
BLUE="\e[34m"
BOLDBLUE="\e[1;34m"
RESET="\e[0m"
testlib_path="$(realpath "$0")"
_test_assert_failed=""
_test_testn=1
_test_passedn=0
_test_failedn=0
_test_current_test=""
_test_statefile="$(mktemp)"
# Set by each test
results_dir="${results_dir:-}"
test_log() {
# ash supports echo -e
# shellcheck disable=SC3037
echo -e "$*" >&2
}
test_info() {
# shellcheck disable=SC3037
echo -e "${BLUE}$*${RESET}" >&2
}
test_debug() {
# shellcheck disable=SC3037
echo -e "${YELLOW}$*${RESET}" >&2
}
assert_strequal() {
# $1: first string
# $2: second string
if [ -z "$1" ] || [ -z "$2" ]; then
test_log "ERROR: assert_equal: not enough arguments given"
exit 1
fi
if [ "$1" != "$2" ]; then
_test_assert_failed="$1 != $2"
test_log " ❌ $_test_assert_failed"
return
fi
test_log " ✅ $1 == $2"
}
assert_equal() {
# $1: name of variable
# $2: value to compare
if [ -z "$1" ] || [ -z "$2" ]; then
test_log "ERROR: assert_equal: not enough arguments given"
exit 1
fi
val="$(eval echo "\$$1")"
if [ "$val" != "$2" ]; then
_test_assert_failed="\$$1 != $2 (got $val)"
test_log " ❌ $_test_assert_failed"
return
fi
test_log " ✅ \$$1 == $2"
}
assert_unset() {
if [ -z "$1" ]; then
test_log "ERROR: assert_unset: not enough arguments given"
exit 1
fi
val="$(eval echo \$"$1")"
if [ -n "$val" ]; then
_test_assert_failed="\$$1 should be unset (has value '$val')"
test_log " ❌ $_test_assert_failed"
return
fi
test_log " ✅ \$$1 is unset"
}
# Log some expression and evaluate it
logeval() {
eval "$*"
test_log "${YELLOW}+ $*${RESET}"
}
# Start a test. Shell scripts involved in the test should be sourced AFTER calling this function!
start_test() {
if [ -n "$_test_current_test" ]; then
test_log "ERROR: multiple calls to start_test without calling end_test first!"
test_log "Current test: $_test_current_test"
exit 1
fi
test_log "==> Test $_test_testn: $1"
_test_current_test="$1"
set > "$_test_statefile"
}
# End a test and reset the environment.
end_test() {
local msg
local save_assert_failed
# Restore environment
save_assert_failed="$_test_assert_failed"
# Splitting is intentional
# shellcheck disable=SC2046
unset $(set | grep "='" | cut -d= -f1 | grep -vE "(PATH|IFS|TERM|LANG|HOME|PWD|SHELL|USER|save_assert_failed|_test_statefile)" )
# shellcheck disable=SC1090
. "$_test_statefile"
_test_assert_failed="$save_assert_failed"
if [ -n "$_test_assert_failed" ]; then
msg="${RED}Failed! ❌ ${_test_assert_failed}${RESET}"
echo "Test $_test_testn: $_test_assert_failed" >> "$results_dir/failed"
_test_failedn=$((_test_failedn+1))
echo "$_test_failedn" > "$results_dir/failedn"
unset _test_assert_failed
else
msg="${GREEN}Passed!${RESET}"
_test_passedn=$((_test_passedn+1))
echo "$_test_passedn" > "$results_dir/passedn"
fi
test_log "<== Test $_test_testn: $msg $_test_current_test\n"
_test_testn=$((_test_testn+1))
_test_current_test=""
}
# Call at the end of each testsuite shell script
end_testsuite() {
if [ -n "$_test_current_test" ]; then
test_log "${RED}ERROR: end_testsuite called without calling end_test first!${RESET}"
test_log "${RED}Current test: $_test_current_test${RESET}"
exit 1
fi
if [ -f "$results_dir/failed" ]; then
exit 1
fi
exit 0
}
run_tests() {
local failed test_results_base
local test name total passedn failedn t_passed t_failed
test_results_base="$(mktemp -d)"
test_log "Running tests for $2"
# FIXME: yeah this isn't quite the best way to iterate the files
# shellcheck disable=SC2010
for name in $(ls "$1" | grep "\.sh$"); do
test="$1/$name"
mkdir "$test_results_base/$name"
echo 0 > "$test_results_base/$name/passedn"
echo 0 > "$test_results_base/$name/failedn"
test_log
test_log "${BOLDBLUE}# Test suite ${name}${RESET}"
$test "$testlib_path" "$test_results_base/$name" || failed="$failed $name"
t_passed=$(cat "$test_results_base/$name/passedn")
t_failed=$(cat "$test_results_base/$name/failedn")
passedn=$((passedn+t_passed))
failedn=$((failedn+t_failed))
total=$((total+t_passed+t_failed))
done
if [ -n "$failed" ]; then
test_log
test_log "Some tests failed:"
for test in $failed; do
test_log "❌ $test"
test_log " ${RED}$(cat "$test_results_base/$test/failed")${RESET}"
done
fi
if [ $passedn -lt $total ]; then
test_log "[${RED}$passedn/$total tests passed${RESET}]"
else
test_log "[${GREEN}$passedn/$total tests passed!${RESET}]"
fi
test_log
if [ -n "$failed" ]; then exit 1; else exit 0; fi
}
# FIXME: probably not the best way to determine if this was sourced
if [ $# -gt 0 ]; then
run_tests "$1" "$2"
fi
#!/usr/bin/env python3
# Copyright 2025 Pablo Correa Gomez
# SPDX-License-Identifier: GPL-3.0-or-later
import os
import sys
# Same dir
import common
# pmbootstrap
import add_pmbootstrap_to_import_path
import pmb.core
from pmb.core.context import get_context
def verify_checksums(packages):
if len(packages) == 0:
print("no packages changed, not doing any checksums verification")
return
print("verifying checksums: " + ", ".join(packages))
common.run_pmbootstrap(["build_init"])
common.run_pmbootstrap(["--details-to-stdout", "checksum", "--verify"] +
list(packages))
if __name__ == "__main__":
# Get and print modified packages
common.add_upstream_git_remote()
packages = common.get_changed_packages()
# Load context
sys.argv = ["pmbootstrap.py", "chroot"]
args = pmb.parse.arguments()
context = get_context()
# Get set of all buildable packages for the enabled repos, for skipping unbuildable
# aports later. We might be given a changed aport from e.g. extra-repos/systemd when
# that repo is not enabled
buildable_pkgs = set()
for path in pmb.core.pkgrepo.pkgrepo_iter_package_dirs():
buildable_pkgs.add(os.path.basename(path))
# To store a list of packages from extra-repos/systemd for special handling
# later:
systemd_pkgs = list()
# Filter out packages are not found in enabled repos
# (Iterate over copy of packages, because we modify it in this loop)
for package in packages.copy():
if package not in buildable_pkgs:
print(f"{package}: not in current repo, skipping")
packages.remove(package)
# FIXME: this should probably be more generic, if other repos are added
# later?
# This just tosses the package into the list of packages to try
# building later w/ systemd enabled, and assumes it'll be found
# there.
print(f"{package}: adding to list of packages to check in systemd repo")
systemd_pkgs.append(package)
continue
# No packages: skip build
if len(packages) == 0:
print("no packages to check for the current repo")
else:
verify_checksums(packages)
# FIXME: this should probably be more generic, if other repos are added later?
if systemd_pkgs:
common.run_pmbootstrap(["config", "systemd", "always"])
# To fix the ERROR: Chroot 'native' is for the 'edge' channel, but you are on the
# 'systemd-edge' channel. Run 'pmbootstrap zap' to delete your chroots and try again.
# To do this automatically, run 'pmbootstrap config auto_zap_misconfigured_chroots yes'.
common.run_pmbootstrap(["config", "auto_zap_misconfigured_chroots", "yes"])
# No packages: skip build
if len(systemd_pkgs) == 0:
print("no packages to check for the systemd repo")
else:
verify_checksums(systemd_pkgs)
......@@ -15,18 +15,15 @@ fi
# Shell: shellcheck
sh_files="
./main/mdss-fb-init-hack/mdss-fb-init-hack.sh
./main/postmarketos-base/rootfs-usr-lib-firmwareload.sh
./main/postmarketos-base-ui/rootfs-usr-lib-NetworkManager-dispatcher.d-50-dns-filter.sh
./main/postmarketos-base-ui/rootfs-usr-lib-NetworkManager-dispatcher.d-50-tethering.sh
./main/postmarketos-installkernel/installkernel-pmos
./main/postmarketos-initramfs/init.sh
./main/postmarketos-initramfs/init_functions.sh
./main/postmarketos-mkinitfs-hook-debug-shell/setup_usb_storage.sh
./main/postmarketos-mkinitfs-hook-netboot/netboot.sh
./main/ttyescape/*.post-install
./main/unl0kr/unlock.sh
./main/msm-firmware-loader/*.post-install
./device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.sh
./device/community/soc-qcom/call_audio_idle_suspend_workaround.sh
$(find . -path './main/postmarketos-ui-*/*.sh')
$(find . -path './main/postmarketos-ui-*/*.pre-install')
......@@ -41,10 +38,11 @@ sh_files="
$(find . -path './main/postmarketos-mvcfg/*.sh')
$(find . -path './.ci/**.sh')
$(find . -path '**/tests/*.sh')
"
for file in $sh_files; do
echo "Test with shellcheck: $file"
cd "$DIR/$(dirname "$file")"
shellcheck -e SC1008 -e SC3043 -x "$(basename "$file")"
shellcheck -S warning -e SC1008 -e SC3043 -x "$(basename "$file")"
done
......@@ -14,9 +14,6 @@ import pmb.parse._apkbuild
from pmb.core.pkgrepo import pkgrepo_default_path, pkgrepo_iglob, pkgrepo_relative_path
from pmb.core.arch import Arch
# Cache for codeowners_parse
codeowners_parsed = {}
# Don't complain if these nicknames are the only maintainers of an APKBUILD,
# because they are actually a group of people
gitlab_groups = [
......@@ -47,8 +44,7 @@ def test_aports_device():
if "postmarketos-base" == dependency or "postmarketos-base>" in dependency:
depend_flag = True
if not depend_flag:
raise RuntimeError("Missing 'postmarketos-base' in depends of " +
path)
raise RuntimeError(f"Missing 'postmarketos-base' in depends of {path}")
# Depends: Must not have specific packages
for depend in apkbuild["depends"]:
......@@ -61,7 +57,7 @@ def test_aports_device():
raise RuntimeError("wrong architecture, please change to arch=\""
f"{deviceinfo.arch}\": {path}")
if "!archcheck" not in apkbuild["options"]:
raise RuntimeError("!archcheck missing in options= line: " + path)
raise RuntimeError(f"!archcheck missing in options= line: {path}")
def test_aports_device_kernel():
......@@ -103,72 +99,12 @@ def test_aports_device_kernel():
f" <https://postmarketos.org/devicepkg>): {path}")
def codeowners_parse():
global codeowners_parsed
pattern_prev = None
aports = pkgrepo_default_path()
with open(aports / "CODEOWNERS") as h:
for line in h:
line = line.rstrip()
if not line or line.startswith("#"):
continue
pattern_nicks = line.split()
assert len(pattern_nicks) > 1, f"CODEOWNERS line without nicks: {line}"
pattern = pattern_nicks[0]
if pattern.endswith("/"):
pattern += "*"
nicks = []
for word in pattern_nicks[1:]:
if word.startswith("@"):
nicks += [word]
codeowners_parsed[pattern] = nicks
if pattern_prev:
assert pattern_prev <= pattern, "CODEOWNERS: please order entries alphabetically"
pattern_prev = pattern
def require_enough_codeowners_entries(path, maintainers):
"""
:param path: full path to an APKBUILD (e.g. /home/user/…/APKBUILD)
:param maintainers: list of one or more maintainers
"""
_, path = pkgrepo_relative_path(path)
nicks = set()
for pattern, pattern_nicks in codeowners_parsed.items():
if fnmatch.fnmatch(path, pattern):
for nick in pattern_nicks:
nicks.add(nick)
print(f"{path}:")
print(f" APKBUILD: {maintainers}")
print(f" CODEOWNERS: {nicks}")
if len(nicks) < len(maintainers):
for nick in nicks:
if nick in gitlab_groups:
print(f" -> {nick} is a group")
return
assert len(nicks) >= len(maintainers), \
f"{path}: make sure that each maintainer is listed in CODEOWNERS!"
# @pytest.mark.xfail # Not all aports have been updated yet
def test_aports_maintained():
"""
Ensure that aports in /device/{main,community} have "Maintainer:" and
"Co-Maintainer:" (only required for main) listed in their APKBUILDs. Also
check that at least as many are listed in CODEOWNERS.
"Co-Maintainer:" (only required for main) listed in their APKBUILDs.
"""
codeowners_parse()
for path in pkgrepo_iglob("device/main/*/APKBUILD"):
if 'firmware-' in path.parent.name:
......@@ -176,14 +112,12 @@ def test_aports_maintained():
maintainers = pmb.parse._apkbuild.maintainers(path)
assert maintainers and len(maintainers) >= 2, \
f"{path} in main needs at least 1 Maintainer and 1 Co-Maintainer"
require_enough_codeowners_entries(path, maintainers)
for path in pkgrepo_iglob("device/community/*/APKBUILD"):
if 'firmware-' in path.parent.name:
continue
maintainers = pmb.parse._apkbuild.maintainers(path)
assert maintainers, f"{path} in community needs at least 1 Maintainer"
require_enough_codeowners_entries(path, maintainers)
def test_aports_unmaintained():
......
......@@ -10,6 +10,7 @@ expected_directories = [
"device/community",
"device/main",
"device/testing",
"extra-repos/systemd",
"main",
"modem",
"non-free",
......
......@@ -25,6 +25,7 @@ def test_aports_firmware():
"firmware-samsung-maguro", # Depends on firmware-aosp-broadcom-wlan
"firmware-xiaomi-ferrari", # Depends on soc-qcom-msm8916
"firmware-xiaomi-willow", # Doesn't build, source link is dead (pma#1212)
"firmware-samsung-i9105p", # Depends on firmware-aosp-broadcom-wlan
]
for path in pkgrepo_iglob("**/firmware-*/APKBUILD", recursive=True):
......
......@@ -23,6 +23,9 @@ def test_aports_kernel():
apkbuild = pmb.parse.apkbuild(path)
aport_name = os.path.basename(os.path.dirname(path))
if aport_name == "linux-pam":
continue # This package isn't a linux kernel!
if "pmb:cross-native" not in apkbuild["options"]:
raise RuntimeError(f"{aport_name}: \"pmb:cross-native\" missing in"
" options= line")
......
......@@ -105,7 +105,8 @@ def test_aports_unreferenced_files():
if os.path.basename(rel_file_path) not in sources_chk \
and rel_file_path not in apkbuild["install"] \
and rel_file_path not in subpackage_installs \
and rel_file_path not in trigger_sources:
and rel_file_path not in trigger_sources \
and not rel_file_path.startswith("tests/"):
raise RuntimeError(f"{apkbuild_path}: found unreferenced file: {rel_file_path}")
......
#!/bin/sh -e
# Description: run unit-tests for packages
# https://postmarketos.org/pmb-ci
#
# This script only exists to allow running unit-tests locally.
# In actual CI the package tests/ subdir has it's own YAML
# fine defining a job which calls testlib for that package.
# This way we can run all the package unit-tests locally but
# have them be individual jobs in GitLab.
if [ "$(id -u)" = 0 ]; then
set -x
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
find . -type d -name "tests" | while read -r testdir; do
pkg="$(basename "$(dirname "$testdir")")"
.ci/lib/testlib.sh "$testdir" "$pkg"
done
#!/bin/sh -e
# Description: verify checksums of modified packages
# Options: native
# Use 'native' because it requires running pmbootstrap.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
wget "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
sh ./install_pmbootstrap.sh
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
export PYTHONUNBUFFERED=1
.ci/lib/verify_checksums.py
......@@ -12,3 +12,8 @@ indent_style = tab
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
# Forked from Alpine
[extra-repos/systemd/networkmanager/networkmanager.rules]
indent_style = space
indent_size = 4
......@@ -65,7 +65,7 @@ is_symlink() {
# available in git tree and checksums are correct.
check_local_sources() {
local apkbuild="$1"
local startdir="${apkbuild%/*}"
local startdir="$2"
local status=0
local checksum_act checksum_exp content filename line sources
......@@ -109,11 +109,21 @@ check_file_size() {
fi
}
cleanup() {
[ -f "$_staged" ] && rm "$_staged"
}
trap cleanup EXIT
for apkbuild in $(changed_files '**/APKBUILD'); do
check_local_sources "$apkbuild"
_staged="$(mktemp)"
git show ":$apkbuild" >"$_staged"
check_local_sources "$_staged" "${apkbuild%/*}"
cleanup
done
for path in $(changed_files); do
check_file_size "$path"
done
trap - EXIT
......@@ -37,13 +37,30 @@ prepend_msg() {
[ -z "$SOURCE" ] || exit 0
lcp=$(git diff-index --name-only --cached HEAD | longest_common_prefix)
prefix=""
case "$lcp" in
device/*/*) prepend_msg "$(echo "$lcp" | cut -d/ -f3): ";;
# Multiple packages touched for same device category
# More logic could be added to detect if they all belong to same device
device/*) ;;
[^.]*/*) prepend_msg "$(echo "$lcp" | cut -d/ -f1-2): ";;
extra-repos/systemd/systemd/*)
prefix="systemd"
;;
extra-repos/systemd/*)
prefix="systemd/$(echo "$lcp" | cut -d/ -f3)"
;;
device/*/*)
prefix="$(echo "$lcp" | cut -d/ -f3)"
;;
device/*)
# Multiple packages touched for same device category. More
# logic could be added to detect if they all belong to same
# device.
;;
[^.]*/*)
prefix="$(echo "$lcp" | cut -d/ -f1-2)"
;;
esac
if [ -n "$prefix" ]; then
prepend_msg "$prefix: "
fi
exit 0