Compare commits

..
Author SHA1 Message Date
Caleb Connolly 5cb1d710e1 DONTMERGE: boot-deploy: feat/multiple-kernels
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-17 05:11:14 +01:00
Caleb Connolly 7cda3728d8 WIP: linux-next: keep old versions on upgrade
Add pre and post-upgrade scripts which keep the old kernel, modules,
dtbs, and release file.

This allows for the kernel package to be upgraded while preserving the
old version, so if the upgrade causes a regression the user can switch
back.

This will need to be heavily refactored, documented and made generic.

Most likely the upgrade scripts will be moved to some -dev package and
the kernel package APKBUILD will simply source a script to create the
pre/post-upgrade scripts.

For this to work, the kernel release directory
(/usr/share/kernel/something/) has to follow the format
<flavour>-<pkgver>-r<pkgrel> since the scripts rely on this to map the
package version to the kernel suffix.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-17 05:07:11 +01:00
Caleb Connolly dd9811a545 postmarketos-mkinitfs: run for each kernel release
Rather than running mkinitfs once (and assume there is only one kernel
version installed) run it for each release.

This depends on https://gitlab.postmarketos.org/postmarketOS/postmarketos-mkinitfs/-/merge_requests/59
as well as
https://gitlab.postmarketos.org/postmarketOS/boot-deploy/-/merge_requests/74

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-17 04:59:40 +01:00
Caleb Connolly 505b29b104 linux-next: use _outdir
Recent changes to the kernels build infrastructure (currently just in
next?) break some unintentional assumptions in pmbootstrap build
--envkernel.

Specifically, that we used to mount the .output directory as the "src"
directory and rely on the fact that the kernel lets you run make from
here. But this doesn't work anymore because the Makefile points to an
absolute path on the host.

For now this is half fix half workaround.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-17 03:09:44 +01:00
8817 changed files with 265509 additions and 803414 deletions

No files matched your search

+13 -3
View File
@@ -1,12 +1,22 @@
#!/bin/sh -e
# Description: run apkbuild-lint on modified APKBUILDs
# Options: with-dot-git
# Options: native
# Use 'native' because it requires git commit history.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
apk add atools git python3
exec su "${TESTUSER:-build}" -c "sh -e $0"
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
# 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
+5 -7
View File
@@ -3,16 +3,15 @@
if [ "$(id -u)" = 0 ]; then
set -x
apk add git openssh-keygen grep curl
wget "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/main/install_pmbootstrap.sh"
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
git config --global --add safe.directory "$CI_PROJECT_DIR"
git config --global user.name "postmarketOS CI"
# The username for the bot associated with the access token
# e.g. project_226_bot_bfa19b84bf7f559c8ff7438a01fd29b9
git config --global user.email "$PMAPORTS_TOKEN_BOT@noreply.gitlab.postmarketos.org"
# pmaports
git config --global user.email "project_226_bot_a365eaa0c380d1bee0af03adf42ebea3@noreply.gitlab.postmarketos.org"
# Configure SSH key for signing
mkdir -p ~/.ssh
@@ -43,7 +42,7 @@ update_linux_next() {
# shellcheck source=/dev/null
pkgver=$(. device/testing/linux-next/APKBUILD; echo "$pkgver")
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
curl -s "https://gitlab.com/linux-kernel/linux-next/-/tags?format=atom" | grep -oP "(?<=<title>)[^<]+" | tail -n +2 > /tmp/tags
latest=$(grep -v "v" < /tmp/tags | head -n1)
if [ -z "$latest" ]; then
@@ -71,7 +70,6 @@ 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
@@ -89,7 +87,7 @@ update_linux_next() {
git remote add gitlab https://pmos-ci:"$PMAPORTS_PUSH_TOKEN"@gitlab.postmarketos.org/postmarketOS/pmaports.git
git fetch gitlab
git checkout --track gitlab/main
git checkout --track gitlab/master
for pkg in $PKGS; do
case "$pkg" in
-20
View File
@@ -1,20 +0,0 @@
#!/bin/sh -e
# Copyright 2025 Pablo Correa Gomez
# SPDX-License-Identifier: GPL-3.0-or-later
# Description: create documentation with antora
# Options: with-dot-git
# Artifacts: build/site
# https://postmarketos.org/pmb-ci
# Install dependencies
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add py3-pip make git
apk add dint --allow-untrusted --repository=https://mirror.postmarketos.org/postmarketos/main
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
cd docs/
make venv
make
-141
View File
@@ -1,141 +0,0 @@
image: registry.alpinelinux.org/img/alpine:3.24
stages:
- build
- hardware tests
variables:
CI_TRON_TEMPLATE_PROJECT: &ci-tron-template-project postmarketOS/ci-common
CI_TRON_JOB_TEMPLATE_PROJECT_URL: $CI_SERVER_URL/$CI_TRON_TEMPLATE_PROJECT
CI_TRON_JOB_TEMPLATE_COMMIT: &ci-tron-template-commit 1c70e34b7a610cda1d7f048f6b50ca9c10f52995
include:
- project: *ci-tron-template-project
ref: *ci-tron-template-commit
file: '/ci-tron/common.yml'
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "parent_pipeline"
.build:
# Create jobs, but do not run them unless this is
# overriden in jobs that extend it
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
- mkdir -p keys
- cp /home/pmos/.local/var/pmbootstrap/config_apk_keys/pmos@local*.pub keys/ || true
- .ci/lib/move_logs.sh $CI_PROJECT_DIR
artifacts:
expire_in: 1 week
paths:
- packages/
- keys/
timeout: 10 h
build:
extends: .build
parallel:
matrix:
{% for arch in archs %}
- ARCH: {{ arch }}
TAG: {{ archtag[arch] }}
{% endfor %}
{% if archs|length == 0 %}
- ARCH: placeholder
TAG: shared
{% endif %}
tags:
- $TAG
script:
# Needed because gitlab fails if no jobs are ran:
# - https://gitlab.com/gitlab-org/gitlab/-/issues/368248
{% if archs|length == 0 %}
- 'true'
{% else %}
- .ci/build-$ARCH.sh
{% endif %}
# Hardware testing
# Define here all the gitlab-ci snippets that could be common between the
# different packages
# Extends from this job if the target device needs a kernel and initramfs to
# boot. This will not work if your device uses boot images.
.device-boot-flow-separate-artifacts:
variables:
CI_TRON_KERNEL__URL: "glartifact://${CI_TRON__PMB_BUILD_JOB}/${CI_TRON__PMB_EXPORT_PATH}/vmlinuz"
CI_TRON_INITRAMFS__INITRAMFS__URL: "glartifact://${CI_TRON__PMB_BUILD_JOB}/${CI_TRON__PMB_EXPORT_PATH}/initramfs"
# Extends from this job if the target device boots using fastboot and boot images
.device-boot-flow-fastboot-image:
variables:
CI_TRON_FASTBOOT__BOOT_IMAGE__URL: "glartifact://${CI_TRON__PMB_BUILD_JOB}/${CI_TRON__PMB_EXPORT_PATH}/boot.img"
# Include all the devices that need and can to be tested
{% for device in devices_under_test %}
prepare-{{ device.name }}:
stage: hardware tests
extends:
.pmos-ci-tron-build-boot-artifacts
{%- if device.has_kernel_variants %}
# Build all the boot artifacts for all the supported kernel variants in
# different jobs, but hide them behind a single job name so as not to pollute
# the pipeline.
parallel:
matrix:
- KERNEL_VARIANT:
{%- for kernel in device.kernel_variants %}
- {{ kernel }}
{%- endfor %}
{%- endif %}
needs:
- job: "build"
parallel:
matrix:
- ARCH: "{{ device.arch }}"
TAG: "{{ archtag[device.arch] }}"
variables:
DEVICE_NAME: {{ device.name }}
# NOTE: All the packages that may influence testing should have an
# `install-if postmarketos-mkinitfs-hook-ci`, so no need to add them here
INSTALL_PACKAGES: {{ device.pkgname }} {% if device.has_kernel_variants %}{{ device.pkgname }}-kernel-${KERNEL_VARIANT} {% endif %}postmarketos-mkinitfs-hook-ci
.test-{{ device.name }}:
stage: hardware tests
{%- if device.has_kernel_variants %}
# Test all the kernels in different jobs, but hide them behind a single
# job name so as not to pollute the pipeline.
parallel:
matrix:
- KERNEL_VARIANT:
{%- for kernel in device.kernel_variants %}
- {{ kernel }}
{%- endfor %}
{%- endif %}
dependencies: []
needs:
- job: 'prepare-{{ device.name }}'
artifacts: false
{%- if device.has_kernel_variants %}
parallel:
matrix:
- KERNEL_VARIANT: $[[ matrix.KERNEL_VARIANT ]]
{%- endif %}
variables:
CI_TRON__PMB_BUILD_JOB: "prepare-{{ device.name }}{% if device.has_kernel_variants %}: [$KERNEL_VARIANT]{% endif %}"
# Include the gitlab ci yml fragment, as found in
# `device/$category/device-$devicename/gitlab-ci.yml.j2` which defines the jobs
{{ device.gitlab_ci_fragment }}
{% endfor %}
-1
View File
@@ -1 +0,0 @@
lib/build_changed_aports.sh
-1
View File
@@ -1 +0,0 @@
lib/build_changed_aports.sh
-20
View File
@@ -1,20 +0,0 @@
#!/bin/sh -e
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
# Description: check pkgver/pkgrel bumps, amount of changed pkgs etc
# Options: native
# Use 'native' because it requires running pmbootstrap.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
# In .gitlab-ci.yml currently .ci/pytest.sh runs before this and
# already downloads and runs install_pmbootstrap.sh.
if ! [ -e install_pmbootstrap.sh ]; then
wget "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/main/install_pmbootstrap.sh"
sh ./install_pmbootstrap.sh
fi
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
.ci/lib/check_changed_versions.py
-29
View File
@@ -1,29 +0,0 @@
#!/bin/sh -e
# Description: Ensure that we're not depending on a too new pmbootstrap version.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add coreutils curl jq
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
pmbootstrap_min_age_days="30"
pmbootstrap_min_version_field="$(grep pmbootstrap_min_version= pmaports.cfg)"
pmbootstrap_min_version="${pmbootstrap_min_version_field#*=}"
tag_date=$(curl -s "https://gitlab.postmarketos.org/api/v4/projects/postmarketOS%2Fpmbootstrap/repository/tags/$pmbootstrap_min_version" \
| jq -r ".created_at")
tag_age_timestamp=$(date -d "$tag_date" +"%s")
acceptable_age_timestamp=$(date -d "$pmbootstrap_min_age_days days ago" +"%s")
echo "NOTE: pmbootstrap versions must be at least $pmbootstrap_min_age_days days old to be the minimum required version"
if [ "$tag_age_timestamp" -ge "$acceptable_age_timestamp" ]; then
echo "ERROR: pmbootstrap version '$pmbootstrap_min_version' is too new!"
exit 1
else
echo "PASS: pmbootstrap version '$pmbootstrap_min_version' is acceptable"
exit 0
fi
+43
View File
@@ -0,0 +1,43 @@
#!/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
Executable
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh -e
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
# Description: check pkgver/pkgrel bumps, amount of changed pkgs etc
# Options: native
# Use 'native' because it requires git commit history.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
# In .gitlab-ci.yml currently .ci/pytest.sh runs before this and
# already downloads and runs install_pmbootstrap.sh.
if ! [ -e install_pmbootstrap.sh ]; then
wget "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
sh ./install_pmbootstrap.sh
fi
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
.ci/lib/check_changed_aports_versions.py
-13
View File
@@ -1,13 +0,0 @@
#!/bin/sh -e
# Description: Validate and lint deviceinfo files
# Options: with-dot-git
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
apk add git python3
apk add dint --allow-untrusted --repository=https://mirror.postmarketos.org/postmarketos/main
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
.ci/lib/deviceinfo_linting.py
+1 -89
View File
@@ -1,7 +1,4 @@
#!/bin/sh -e
# shellcheck shell=busybox
# Description: check various bad patterns with grep
# https://postmarketos.org/pmb-ci
@@ -9,7 +6,7 @@ exit_code=0
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add git grep
apk -q add grep
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
@@ -97,89 +94,4 @@ if grep -qEr '^deviceinfo_kernel_cmdline.*[\"\s]console=null' -- device/; then
exit_code=1
fi
# Disallow installation of files to /etc/modules-load.d and /etc/modprobe.d
if grep -qr '/etc/modules-load.d' --exclude-dir='device-samsung-golden-downstream' -- *; then
echo "ERROR: Please replace '/etc/modules-load.d' with '/usr/lib/modules-load.d' in the following files:"
grep --color=always -r '/etc/modules-load.d' --exclude-dir='device-samsung-golden-downstream' -- *
exit_code=1
fi
# n900 is excluded because the string is in a comment linking to a repo.
# No other non-archived devices should be excluded.
if grep -qr '/etc/modprobe.d' --exclude-dir='archived' \
--exclude-dir='device-nokia-n900' -- *; then
echo "ERROR: Please replace '/etc/modprobe.d' with '/usr/lib/modprobe.d' in the following files:"
grep --color=always -r '/etc/modprobe.d' --exclude-dir='device-nokia-n900' \
--exclude-dir='archived' -- *
exit_code=1
fi
# Disallow maintainer comments.
if grep -qr '# Maintainer:' -- *; then
echo 'ERROR: Please use maintainer variables of the form maintainer="..." instead of maintainer comments of the form # Maintainer: ...'
grep --color=always -r '# Maintainer:' -- *
exit_code=1
fi
if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
# Find all moved or new kernel APKBUILDs in main, community or testing
MOVED_OR_NEW_MAINLINE_KERNEL_PACKAGES=$(git show --pretty="" --name-only --diff-filter=AR "$CI_MERGE_REQUEST_DIFF_BASE_SHA"..HEAD | grep "device/\(main\|community\|testing\)/linux-.*/APKBUILD" || true)
if [ -n "$MOVED_OR_NEW_MAINLINE_KERNEL_PACKAGES" ]; then
if [ -n "$(grep -L LLVM=1 $MOVED_OR_NEW_MAINLINE_KERNEL_PACKAGES || true)" ]; then
echo "ERROR: An added or moved close-to-mainline kernel package is not being built with LLVM."
echo "See https://postmarketos.org/edge/2025/11/11/kernels-llvm/ for more details"
grep --color=always -L LLVM=1 $MOVED_OR_NEW_MAINLINE_KERNEL_PACKAGES
exit_code=1
fi
fi
# Find all moved, added, or generally modified kernel APKBUILDs
MODIFIED_KERNEL_PACKAGES=$(git show --pretty="" --name-only --diff-filter=AMR "$CI_MERGE_REQUEST_DIFF_BASE_SHA"..HEAD | grep "device/\(main\|community\|testing\|downstream\)/linux-.*/APKBUILD" || true)
if [ -n "$MODIFIED_KERNEL_PACKAGES" ]; then
# Disallow installing kernel modules outside /usr/
_bad_module_path_packages=""
for package in $MODIFIED_KERNEL_PACKAGES; do
# Check for INSTALL_MOD_PATH being set
if grep -qr 'INSTALL_MOD_PATH="$pkgdir"' "$package"; then
# Check if INSTALL_MOD_PATH is set to install to usr
if ! grep -qr 'INSTALL_MOD_PATH="$pkgdir"/usr' "$package"; then
# If INSTALL_MOD_PATH doesn't include usr, add package to list and
# setup failure
_bad_module_path_packages="$_bad_module_path_packages $package"
_module_error=1
fi
fi
done
# Fail with error and pretty print bad packages for logging
if [ -n "$_module_error" ]; then
echo "ERROR: Please set INSTALL_MOD_PATH to '\"\$pkgdir\"/usr'."
for package in $_bad_module_path_packages; do
printf "$package\n"
done
exit_code=1
fi
fi
# Disallow adding packages without a maintainer set
NEW_APKBUILDS=$(git show --pretty="" --name-only --diff-filter=A "$CI_MERGE_REQUEST_DIFF_BASE_SHA"..HEAD | grep APKBUILD || true)
if [ -n "$NEW_APKBUILDS" ]; then
if [ -n "$(grep -L '^maintainer="[^"]\+"$' $NEW_APKBUILDS || true)" ]; then
echo "ERROR: A new package does not have a maintainer set."
grep --color=always -L '^maintainer="[^"]\+"$' $NEW_APKBUILDS
exit_code=1
fi
fi
# Get latest commit message in MR
case "$CI_COMMIT_DESCRIPTION" in
*"[ci:skip-grep]"*)
echo "WARNING: not checking packages with grep"
echo " ([ci:skip-grep])!"
exit_code=0
;;
esac
fi
exit "$exit_code"
+2 -2
View File
@@ -6,11 +6,11 @@
if [ "$(id -u)" = 0 ]; then
set -x
wget "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/main/install_pmbootstrap.sh"
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/kconfig.py
.ci/lib/check_changed_kernels.py
+1
View File
@@ -0,0 +1 @@
../testcases/add_pmbootstrap_to_import_path
+7 -61
View File
@@ -2,79 +2,25 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import common
import os
import os.path
import sys
import subprocess
import tomllib
custom_valid_options = [
"!pmb:crossdirect",
"!pmb:kconfigcheck",
"pmb:cross-native",
"pmb:cross-native2",
"pmb:drm",
"pmb:generic-kernel",
"pmb:strict",
"pmb:systemd",
"pmb:systemd-never",
]
def get_kconfigcheck_categories() -> list [str]:
with open("kconfigcheck.toml", "rb") as kconfigcheck_config:
kconfigcheck_data = tomllib.load(kconfigcheck_config)
kconfigcheck_categories = []
for category_name in kconfigcheck_data:
if category_name == "aliases":
for alias_name in kconfigcheck_data["aliases"]:
kconfigcheck_categories.append(f"pmb:kconfigcheck-{alias_name}")
else:
kconfigcheck_categories.append(category_name)
return [item.replace("category:", "pmb:kconfigcheck-") for item in kconfigcheck_categories]
if __name__ == "__main__":
if common.commit_message_has_string("[ci:skip-apkbuild-lint]"):
print("WARNING: not linting deviceinfo files ([ci:skip-apkbuild-lint])")
exit(0)
kconfigcheck_categories = get_kconfigcheck_categories()
custom_valid_options += kconfigcheck_categories
os.environ["CUSTOM_VALID_OPTIONS"] = " ".join(custom_valid_options)
apkbuilds = {file for file in common.get_changed_files()
common.add_upstream_git_remote()
apkbuilds = {file for file in common.get_changed_files(removed=False)
if os.path.basename(file) == "APKBUILD"}
if len(apkbuilds) < 1:
print("No APKBUILDs to lint")
sys.exit(0)
apkbuilds_filtered = []
packages = []
for apkbuild in apkbuilds:
if apkbuild.startswith("temp/") or apkbuild.startswith("cross/"):
print(f"NOTE: Skipping linting of {apkbuild}")
continue
apkbuilds_filtered.append(apkbuild)
if len(apkbuilds_filtered) < 1:
packages.append(os.path.basename(os.path.dirname(apkbuild)))
if len(packages) < 1:
print("No APKBUILDs to lint")
sys.exit(0)
print("Running apkbuild-lint...")
print("")
ret = 0
for apkbuild in apkbuilds_filtered:
try:
cmd = ["apkbuild-lint", apkbuild]
subprocess.run(cmd, text=True, check=True)
except subprocess.CalledProcessError as exception:
ret = exception.returncode
print("")
if ret == 0:
print("Success")
sys.exit(ret)
common.run_pmbootstrap(["-q", "lint"] + packages)
+45 -27
View File
@@ -9,6 +9,7 @@ import pathlib
import common
# pmbootstrap
import add_pmbootstrap_to_import_path
import pmb.core
import pmb.parse
import pmb.parse._apkbuild
@@ -18,15 +19,28 @@ from pmb.core.context import get_context
def build_strict(packages, arch):
common.run_pmbootstrap(["build_init"])
# We set the timeout to 1 hour because linking the Linux kernel with
# ThinLTO on our aarch64 runners takes slightly over 30 minutes
common.run_pmbootstrap(["--details-to-stdout", "--no-ccache",
"--timeout", "3600",
"build",
common.run_pmbootstrap(["--details-to-stdout", "--no-ccache", "build",
"--strict", "--force",
"--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:
@@ -35,7 +49,11 @@ if __name__ == "__main__":
arch = sys.argv[1]
# Get and print modified packages
packages = common.get_changed_packages(skip_archived=True)
common.add_upstream_git_remote()
packages = common.get_changed_packages()
# Package count sanity check
common.get_changed_packages_sanity_check(len(packages))
# Load context
sys.argv = ["pmbootstrap.py", "chroot"]
@@ -75,31 +93,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)
build_strict(packages, arch)
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 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"])
# 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)
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)
+1 -2
View File
@@ -1,12 +1,11 @@
#!/bin/sh -e
# Description: build modified packages for this architecture
# Options: native slow
# 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/main/install_pmbootstrap.sh"
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
+205
View File
@@ -0,0 +1,205 @@
#!/usr/bin/env python3
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import pathlib
import tempfile
import sys
import subprocess
# Same dir
import common
# pmbootstrap
import add_pmbootstrap_to_import_path # noqa
import pmb.parse
import pmb.parse.version
import pmb.helpers.logging
from pmb.core.context import get_context
def get_package_contents(package, revision, check=True):
# Redirect stderr to /dev/null, so git doesn't complain about files not
# existing in upstream branch for new packages
stderr = None
if not check:
stderr = subprocess.DEVNULL
# Run something like "git show upstream/master:main/hello-world/APKBUILD"
pmaports_dir = common.get_pmaports_dir()
pattern = pmaports_dir + "/**/" + package + "/APKBUILD"
path = glob.glob(pattern, recursive=True)[0][len(pmaports_dir + "/"):]
apkbuild_content = common.run_git(["show", revision + ":" + path], check,
stderr)
if not apkbuild_content:
return None
# Save APKBUILD to a temporary path and parse it from there. (Not the best
# way to do things, but good enough for this CI script.)
with tempfile.TemporaryDirectory() as tempdir:
with open(tempdir + "/APKBUILD", "w", encoding="utf-8") as handle:
handle.write(apkbuild_content)
parsed = pmb.parse.apkbuild(pathlib.Path(tempdir, "APKBUILD"),
False, False)
return parsed
def get_package_version(package, revision, check=True):
""" returns version in the format "{pkgver}-r{pkgrel}", or None if no
matching package is found """
parsed = get_package_contents(package, revision, check)
if parsed is None:
return None
return parsed["pkgver"] + "-r" + parsed["pkgrel"]
def version_compare_operator(result):
""" :param result: return value from pmb.parse.version.compare() """
if result == -1:
return "<"
elif result == 0:
return "=="
elif result == 1:
return ">"
raise RuntimeError("Unexpected version_compare_operator input: " + result)
def exit_with_error_message():
branch = common.get_upstream_branch()
print()
print("ERROR: Modified package(s) don't have an increased version or a")
print("new package has a nonzero pkgrel!")
print()
print("This can happen if you added a new package with a nonzero")
print("pkgrel, or if you did not change the pkgver/pkgrel")
print("variables in the APKBUILDs. Or you did change them, but the")
print(f"packages have been updated in the official '{branch}' branch, and")
print("now your versions are not higher anymore.")
print()
print("Your options:")
print("a) If you made changes to the packages, and did not increase the")
print(" pkgrel/pkgver: increase them now, and force push your branch.")
print(" => https://postmarketos.org/howto-bump-pkgrel-pkgver")
print("b) If you had already increased the package versions, rebase on")
print(f" '{branch}', increase the versions again and then force push:")
print(" => https://postmarketos.org/rebase")
print("c) If you made a change, that does not require rebuilding the")
print(" packages, such as only changing the arch=... line: you can")
print(" disable this check by adding '[ci:skip-vercheck]' to the")
print(" latest commit message, then force push.")
print()
print("Thank you and sorry for the inconvenience.")
exit(1)
def check_versions(packages):
error = False
# Get relevant commits: compare HEAD against upstream branch or HEAD~1
# (the latter if this CI check is running on upstream branch). Note that
# for the common.get_changed_files() code, we don't check against
# upstream branch HEAD, but against the latest common ancestor. This is not
# desired here, since we already know what packages changed, and really
# want to check if the version was increased towards *current* upstream
# branch HEAD.
commit = f"upstream/{common.get_upstream_branch()}"
if common.run_git(["rev-parse", "HEAD"]) == common.run_git(["rev-parse",
commit]):
print(f"NOTE: {commit} is on same commit as HEAD, comparing"
" HEAD against HEAD~1.")
commit = "HEAD~1"
for package in packages:
# Get versions, skip new packages
head = get_package_version(package, "HEAD")
upstream = get_package_version(package, commit, False)
if not upstream:
if head.rpartition('r')[2] != "0":
print(f"- {package}: {head} (HEAD) (new package) [ERROR]")
error = True
else:
print(f"- {package}: {head} (HEAD) (new package)")
continue
# Check pkgver follows expected format for device packages
pkgver = head.rpartition('-r')[0]
if package.startswith('device-') and not pkgver.isdigit():
print(f" - {package}: invalid pkgver \"{pkgver}\""
"See: https://wiki.postmarketos.org/wiki/Packaging#device_packages_and_other_packages_without_sources")
error = True
# Additional checks for device packages
if package.startswith('device-'):
head_parsed = get_package_contents(package, "HEAD", False)
upstream_parsed = get_package_contents(package, commit, False)
# checksums did not change
if head_parsed["sha512sums"] == upstream_parsed["sha512sums"]:
# Check that pkgver did not change
if head_parsed["pkgver"] != upstream_parsed["pkgver"]:
print(f" - {package}: pkgver should not change when package source checksums did not change."
"See: https://wiki.postmarketos.org/wiki/Packaging#device_packages_and_other_packages_without_sources")
error = True
# We do not check for a bumped pkgrel, because not everything
# needs it, e.g: pmb_recommends
# checksums changed
else:
# Check that pkgrel was reset to 0
if head_parsed["pkgrel"] != "0":
print(f" - {package}: pkgrel should be 0 when package source checksums change."
"See: https://wiki.postmarketos.org/wiki/Packaging#device_packages_and_other_packages_without_sources")
error = True
# Check that pkgver was changed
if head_parsed["pkgver"] == upstream_parsed["pkgver"]:
print(f" - {package}: pkgver should change when package source checksums change."
"See: https://wiki.postmarketos.org/wiki/Packaging#device_packages_and_other_packages_without_sources")
error = True
# Compare head and upstream versions
result = pmb.parse.version.compare(head, upstream)
if result != 1:
error = True
# Print result line ("- hello-world: 1-r2 (HEAD) > 1-r1 (HEAD~1)")
formatstr = "- {}: {} (HEAD) {} {} ({})"
if result != 1:
formatstr += " [ERROR]"
operator = version_compare_operator(result)
print(formatstr.format(package, head, operator, upstream, commit))
if error:
exit_with_error_message()
if __name__ == "__main__":
# Get and print modified packages
common.add_upstream_git_remote()
packages = common.get_changed_packages()
print(f"Changed packages: {packages}")
# Verify modified package count
common.get_changed_packages_sanity_check(len(packages))
if len(packages) == 0:
print("no aports changed in this branch")
exit(0)
# Potentially skip this check
if common.commit_message_has_string("[ci:skip-vercheck]"):
print("WARNING: not checking for changed package versions"
" ([ci:skip-vercheck])!")
exit(0)
# Initialize args (so we can use pmbootstrap's APKBUILD parsing)
sys.argv = ["pmbootstrap.py", "chroot"]
args = pmb.parse.arguments()
context = get_context()
# pmb.helpers.logging.init(args)
pmb.helpers.logging.init(context.log, args.verbose, context.details_to_stdout)
# Verify package versions
print("checking changed package versions...")
check_versions(packages)
+98
View File
@@ -0,0 +1,98 @@
#!/usr/bin/env python3
# Copyright 2024 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import tempfile
import sys
import subprocess
# Same dir
import common
def check_kconfig(pkgnames):
last_failed = None
for i in range(len(pkgnames)):
pkgname = pkgnames[i]
print(f" ({i+1}/{len(pkgnames)}) {pkgname}")
p = subprocess.run(["pmbootstrap", "kconfig", "check", "--keep-going", pkgname],
check=False)
if p.returncode:
last_failed = pkgname
return last_failed
def check_kconfig_all():
p = subprocess.run(["pmbootstrap", "kconfig", "check", "--keep-going"], check=False)
return p.returncode == 0
def show_error(last_failed):
print("")
print("---")
print("")
print("Please adjust your kernel config. This is required for getting your"
" patch merged.")
print("")
print("Edit your kernel config:")
print(f" pmbootstrap kconfig edit {last_failed}")
print("")
print("Test this kernel config again:")
print(f" pmbootstrap kconfig check {last_failed}")
print("")
print("Run this check again (on all kernels you modified):")
print(" pmbootstrap ci kconfig")
print("")
print("---")
print("")
def show_error_all():
print("")
print("---")
print("")
print("Please adjust the failed kernel configs. This is required for")
print("getting your patch merged.")
print("")
print("If a kernel in the testing category failed, and fixing is too much")
print("effort, remove 'pmb:kconfigcheck-community' from the APKBUILD.")
print("")
print("Edit a kernel config:")
print(" pmbootstrap kconfig edit <PACKAGE NAME>")
print("")
print("Test a specific kernel config again:")
print(" pmbootstrap kconfig check <PACKAGE NAME>")
print("")
print("Run this check again (on all kernels you modified):")
print(" pmbootstrap ci kconfig")
print("")
print("---")
print("")
if __name__ == "__main__":
common.add_upstream_git_remote()
if "kconfigcheck.toml" in common.get_changed_files():
print("kconfigcheck.toml changed -> checking all kernels")
if not check_kconfig_all():
show_error_all()
exit(1)
exit(0)
pkgnames = common.get_changed_kernels()
print(f"Changed kernels: {pkgnames}")
if len(pkgnames) == 0:
print("No kernels changed in this branch")
exit(0)
last_failed = check_kconfig(pkgnames)
if last_failed:
show_error(last_failed)
exit(1)
-196
View File
@@ -1,196 +0,0 @@
#!/usr/bin/env python3
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import pathlib
import tempfile
import sys
import subprocess
# Same dir
import common
# pmbootstrap
import pmb.parse
import pmb.parse.version
import pmb.helpers.logging
from pmb.core.context import get_context
def get_package_contents(package, revision, check=True):
# Redirect stderr to /dev/null, so git doesn't complain about files not
# existing in upstream branch for new packages
stderr = None
if not check:
stderr = subprocess.DEVNULL
# Run something like "git show upstream/main:main/hello-world/APKBUILD"
pmaports_dir = common.get_pmaports_dir()
pattern = pmaports_dir + "/**/" + package + "/APKBUILD"
path = glob.glob(pattern, recursive=True)[0][len(pmaports_dir + "/"):]
apkbuild_content = common.run_git(["show", revision + ":" + path], check,
stderr)
if not apkbuild_content:
return None
# Save APKBUILD to a temporary path and parse it from there. (Not the best
# way to do things, but good enough for this CI script.)
with tempfile.TemporaryDirectory() as tempdir:
with open(tempdir + "/APKBUILD", "w", encoding="utf-8") as handle:
handle.write(apkbuild_content)
parsed = pmb.parse.apkbuild(pathlib.Path(tempdir, "APKBUILD"),
False, False)
return parsed
def get_package_version(package, revision, check=True):
""" returns version in the format "{pkgver}-r{pkgrel}", or None if no
matching package is found """
parsed = get_package_contents(package, revision, check)
if parsed is None:
return None
return parsed["pkgver"] + "-r" + parsed["pkgrel"]
def version_compare_operator(result):
""" :param result: return value from pmb.parse.version.compare() """
if result == -1:
return "<"
elif result == 0:
return "=="
elif result == 1:
return ">"
raise RuntimeError("Unexpected version_compare_operator input: " + result)
def exit_with_error_message():
branch = common.get_upstream_branch()
print()
print("ERROR: Modified package(s) don't have an increased version or a")
print("new package has a nonzero pkgrel!")
print()
print("This can happen if you added a new package with a nonzero")
print("pkgrel, or if you did not change the pkgver/pkgrel")
print("variables in the APKBUILDs. Or you did change them, but the")
print(f"packages have been updated in the official '{branch}' branch, and")
print("now your versions are not higher anymore.")
print()
print("Your options:")
print("a) If you made changes to the packages, and did not increase the")
print(" pkgrel/pkgver: increase them now, and force push your branch.")
print(" => https://postmarketos.org/howto-bump-pkgrel-pkgver")
print("b) If you had already increased the package versions, rebase on")
print(f" '{branch}', increase the versions again and then force push:")
print(" => https://postmarketos.org/rebase")
print("c) If you made a change, that does not require rebuilding the")
print(" packages, such as only changing the arch=... line: you can")
print(" disable this check by adding '[ci:skip-vercheck]' to the")
print(" latest commit message, then force push.")
print()
print("Thank you and sorry for the inconvenience.")
exit(1)
def check_versions(packages):
error = False
# Get relevant commits: compare HEAD against upstream branch or HEAD~1
# (the latter if this CI check is running on upstream branch). Note that
# for the common.get_changed_files() code, we don't check against
# upstream branch HEAD, but against the latest common ancestor. This is not
# desired here, since we already know what packages changed, and really
# want to check if the version was increased towards *current* upstream
# branch HEAD.
common.run_git(["remote", "add", "upstream",
"https://gitlab.postmarketos.org/postmarketOS/pmaports.git"], False)
common.run_git(["fetch", "-q", "upstream"])
commit = f"upstream/{common.get_upstream_branch()}"
if common.run_git(["rev-parse", "HEAD"]) == common.run_git(["rev-parse",
commit]):
print(f"NOTE: {commit} is on same commit as HEAD, comparing"
" HEAD against HEAD~1.")
commit = "HEAD~1"
# Exclude linux-next from pkgrel checks, as it is updated automatically.
#
# Without this, .ci/commits.sh complains about the following:
# ERROR: Modified package(s) don't have an increased version or a new
# package has a nonzero pkgrel!
if "linux-next" in packages:
packages.remove("linux-next")
for package in packages:
# Get versions, skip new packages
head = get_package_version(package, "HEAD")
upstream = get_package_version(package, commit, False)
if not upstream:
if head.rpartition('r')[2] != "0":
print(f"- {package}: {head} (HEAD) (new package) [ERROR]")
error = True
else:
print(f"- {package}: {head} (HEAD) (new package)")
continue
# Check pkgver follows expected format for device packages
pkgver = head.rpartition('-r')[0]
if package.startswith('device-') and not pkgver.isdigit():
print(f" - {package}: invalid pkgver \"{pkgver}\""
"See: https://docs.postmarketos.org/pmaports/main/packaging-guidelines.html#package-versioning-pkgver-pkgrel")
error = True
# Additional checks for device packages
if package.startswith('device-'):
head_parsed = get_package_contents(package, "HEAD", False)
upstream_parsed = get_package_contents(package, commit, False)
# Check that pkgrel was reset to 0 when pkgver was changed
if head_parsed["pkgver"] != upstream_parsed["pkgver"] and head_parsed["pkgrel"] != "0":
print(f" - {package}: pkgrel should be 0 when pkgver changes."
"See: https://docs.postmarketos.org/pmaports/main/packaging-guidelines.html#package-versioning-pkgver-pkgrel")
error = True
# Compare head and upstream versions
result = pmb.parse.version.compare(head, upstream)
if result != 1:
error = True
# Print result line ("- hello-world: 1-r2 (HEAD) > 1-r1 (HEAD~1)")
formatstr = "- {}: {} (HEAD) {} {} ({})"
if result != 1:
formatstr += " [ERROR]"
operator = version_compare_operator(result)
print(formatstr.format(package, head, operator, upstream, commit))
if error:
exit_with_error_message()
if __name__ == "__main__":
# Get and print modified packages
packages = common.get_changed_packages()
if len(packages) == 0:
print("no aports changed in this branch")
exit(0)
print(f"Changed packages: {packages}")
# Potentially skip this check
if common.commit_message_has_string("[ci:skip-vercheck]"):
print("WARNING: not checking for changed package versions"
" ([ci:skip-vercheck])!")
exit(0)
# Initialize args (so we can use pmbootstrap's APKBUILD parsing)
sys.argv = ["pmbootstrap.py", "chroot"]
args = pmb.parse.arguments()
context = get_context()
# pmb.helpers.logging.init(args)
pmb.helpers.logging.init(context.log, args.verbose, context.details_to_stdout)
# Verify package versions
print("checking changed package versions...")
check_versions(packages)
+21 -34
View File
@@ -2,20 +2,20 @@
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
from pathlib import Path
import argparse
import glob
import os
import sys
import urllib.request
# Same dir
import common
def get_devices() -> list[str]:
def get_devices():
""":returns: list of all devices"""
ret = []
pmaports = Path(__file__).resolve().parents[2]
for path in pmaports.glob("device/*/device-*/"):
device = path.name.split("device-", 1)[1]
pmaports = (os.path.realpath(os.path.join(os.path.dirname(__file__) +
"/../..")))
for path in glob.glob(pmaports + "/device/*/device-*/"):
device = os.path.dirname(path).split("device-", 1)[1]
# -downstream suffix is used when packaging the downstream kernel for
# devices that have a working mainline kernel. Those are usually
@@ -28,7 +28,7 @@ def get_devices() -> list[str]:
return sorted(ret)
def get_wiki_devices_html(path: Path | None) -> dict[str, str]:
def get_wiki_devices_html(path):
""":param path: to a local file with the saved content of the devices wiki
page or None to download a fresh copy
:returns: HTML of the page, split into booting and not booting:
@@ -41,9 +41,8 @@ def get_wiki_devices_html(path: Path | None) -> dict[str, str]:
content = handle.read()
else:
# Download wiki page
url = "https://wiki.postmarketos.org/wiki/Devices"
with urllib.request.urlopen(url) as f:
content = f.read().decode("utf-8")
url = "http://wiki.postmarketos.org/wiki/Devices"
content = urllib.request.urlopen(url).read().decode("utf-8")
# Split into booting and not booting
split = content.split("<span class=\"mw-headline\" id=\"Non-booting_devices\">")
@@ -54,16 +53,14 @@ def get_wiki_devices_html(path: Path | None) -> dict[str, str]:
return {"booting": split[0], "not_booting": split[1]}
def get_wiki_renamed_devices_html() -> str:
def get_wiki_renamed_devices_html():
""":returns: HTML of the page"""
# Download wiki page
url = "https://wiki.postmarketos.org/wiki/Renamed_Devices"
with urllib.request.urlopen(url) as f:
res: bytes = f.read()
return res.decode("utf-8")
url = "http://wiki.postmarketos.org/wiki/Renamed_Devices"
return urllib.request.urlopen(url).read().decode("utf-8")
def check_device(device: str, html: dict[str, str], is_booting: bool) -> bool:
def check_device(device, html, is_booting):
""":param is_booting: require the device to be in the booting section, not
just anywhere in the page (i.e. in the not booting
table).
@@ -85,34 +82,24 @@ def check_device(device: str, html: dict[str, str], is_booting: bool) -> bool:
return False
def main() -> int:
def main():
# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument("--booting", help="devices must be in the upper table,"
" being in the 'not booting' table below is not"
" enough (all devices in pmaports main and stable"
" enough (all devices in pmaports master and stable"
" branches and should be in the upper table)",
action="store_true")
parser.add_argument("--path", help="instead of downloading the devices"
" page from the wiki, use a local HTML file",
type=Path, default=None)
parser.add_argument("--all", help="check all devices (default: check only"
" devices changed from branch point)",
action="store_true")
default=None)
args = parser.parse_args()
# Check all devices
html = get_wiki_devices_html(args.path)
html["renamed"] = get_wiki_renamed_devices_html()
error = False
devices = []
if args.all:
devices = get_devices()
else:
devices = common.get_changed_devices(skip_archived=True)
# remove 'device-' prefix
devices = [d[7:] for d in devices]
devices = [d.removesuffix("-downstream") for d in devices]
for device in devices:
for device in get_devices():
if not check_device(device, html, args.booting):
error = True
@@ -139,8 +126,8 @@ def main() -> int:
print("wiki as well and make sure to add it here:")
print("https://postmarketos.org/renamed")
return 1
print("*** Wiki check successful!")
else:
print("*** Wiki check successful!")
return 0
+73 -61
View File
@@ -7,12 +7,19 @@
import configparser
import os
import subprocess
from functools import cache
import sys
cache = {}
@cache
def get_pmaports_dir():
return os.path.realpath(os.path.join(os.path.dirname(__file__) + "/../.."))
global cache
if "pmaports_dir" in cache:
return cache["pmaports_dir"]
ret = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/../.."))
cache["pmaports_dir"] = ret
return ret
def run_git(parameters, check=True, stderr=None):
@@ -26,17 +33,15 @@ def run_git(parameters, check=True, stderr=None):
return None
def add_upstream_git_remote():
""" Add a remote pointing to postmarketOS/pmaports. """
run_git(["remote", "add", "upstream",
"https://gitlab.postmarketos.org/postmarketOS/pmaports.git"], False)
run_git(["fetch", "-q", "upstream"])
def commit_message_has_string(needle):
base_commit = get_base_commit()
return needle in run_git(["log", "--pretty=format:%B", f"{base_commit}..HEAD"])
def all_committed_by_merge_bot():
base_commit = get_base_commit()
commit_emails = run_git(["log", "--pretty=format:%ce", f"{base_commit}..HEAD"]).splitlines()
bot_email = os.getenv("PMOS_MERGE_BOT_EMAIL", "merge-bot@postmarketos.org")
return all(bot_email == ce for ce in commit_emails)
return needle in run_git(["show", "-s", "--format=full", "HEAD"])
def run_pmbootstrap(parameters):
@@ -45,10 +50,9 @@ def run_pmbootstrap(parameters):
subprocess.run(cmd, universal_newlines=True, check=True)
@cache
def get_upstream_branch():
""" Use pmaports.cfg from current branch (e.g. "v20.05_fix-ci") and
channels.cfg from main to retrieve the upstream branch.
channels.cfg from master to retrieve the upstream branch.
:returns: branch name, e.g. "v20.05" """
@@ -56,6 +60,10 @@ def get_upstream_branch():
if target_branch := os.environ.get("CI_MERGE_REQUEST_TARGET_BRANCH_NAME"):
return target_branch
global cache
if "upstream_branch" in cache:
return cache["upstream_branch"]
# Get channel (e.g. "stable") from pmaports.cfg
# https://postmarketos.org/pmaports.cfg
pmaports_dir = get_pmaports_dir()
@@ -65,7 +73,7 @@ def get_upstream_branch():
# Get branch_pmaports (e.g. "v20.05") from channels.cfg
# https://postmarketos.org/channels.cfg
channels_cfg_str = run_git(["show", "upstream/main:channels.cfg"])
channels_cfg_str = run_git(["show", "upstream/master:channels.cfg"])
channels_cfg = configparser.ConfigParser()
channels_cfg.read_string(channels_cfg_str)
assert channel in channels_cfg, \
@@ -73,23 +81,17 @@ def get_upstream_branch():
" This appears to be an old branch, consider recreating your change" \
" on top of master."
return channels_cfg[channel]["branch_pmaports"]
ret = channels_cfg[channel]["branch_pmaports"]
cache["upstream_branch"] = ret
return ret
@cache
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."""
commit = os.getenv("CI_MERGE_REQUEST_DIFF_BASE_SHA")
if commit is not None:
return commit
# Add a remote pointing to postmarketOS/pmaports
run_git(["remote", "add", "upstream",
"https://gitlab.postmarketos.org/postmarketOS/pmaports.git"], False)
run_git(["fetch", "-q", "upstream"])
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
"""
branch_upstream = f"upstream/{get_upstream_branch()}"
commit_head = run_git(["rev-parse", "HEAD"])[:-1]
commit_upstream = run_git(["rev-parse", branch_upstream])[:-1]
@@ -105,17 +107,6 @@ def get_base_commit() -> str:
commit = run_git(["merge-base", branch_upstream, "HEAD"])[:-1]
print("comparing HEAD with: " + commit)
return commit
def get_changed_files(removed=False):
""" 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):")
@@ -131,22 +122,50 @@ def get_changed_files(removed=False):
return ret
def get_changed_packages(skip_archived: bool = False):
def get_changed_packages_sanity_check(count):
for mark in ["[ci:ignore-count]", "[ci:skip-build]"]:
if commit_message_has_string(mark):
print("NOTE: package count sanity check skipped (" + mark + ").")
return
if count <= 10:
return
branch = get_upstream_branch()
print(f"""
ERROR: Too many packages have changed!
This is a sanity check, so we don't end up building packages that
have not been modified. CI won't run for more than three hours
anyway.
Your options:
a) If you *did not* modify everything listed above, then rebase
your branch on the official postmarketOS/pmaports.git {branch}
branch. Feel free to ask in the chat for help if you need any.
b) If you *did* modify all these packages, and you assume that
they will build within one hour: skip this sanity check by
adding '[ci:ignore-count]' to the commit message of the last
commit in the merge request (then force push).
c) If you *did* modify all these packages, and you are sure that
they won't build in time, please add '[ci:skip-build]' to the
commit message (then force push). Make sure that all packages
build with 'pmbootstrap build --strict'!
Thank you and sorry for the inconvenience.
""")
sys.exit(1)
def get_changed_packages():
ret = set()
for file in get_changed_files(removed=True):
for file in get_changed_files():
dirname, filename = os.path.split(file)
# Skip files:
# * in the root dir of pmaports (e.g. README.md)
# * path with a dot (e.g. .ci/, device/.shared-patches/)
# * documentation
if (
not dirname
or file.startswith(".")
or "/." in file
or skip_archived and dirname.startswith("device/archived")
or dirname == "docs"
):
if not dirname or file.startswith(".") or "/." in file:
continue
if filename != "APKBUILD":
@@ -175,16 +194,9 @@ def get_changed_packages(skip_archived: bool = False):
return ret
def get_changed_kernels(skip_archived: bool = False):
def get_changed_kernels():
ret = []
for pkgname in get_changed_packages(skip_archived):
for pkgname in get_changed_packages():
if pkgname.startswith("linux-"):
ret += [pkgname]
return ret
def get_changed_devices(skip_archived: bool = False):
ret = []
for pkgname in get_changed_packages(skip_archived):
if pkgname.startswith("device-"):
ret += [pkgname]
return ret
-28
View File
@@ -1,28 +0,0 @@
#!/usr/bin/env python3
# Copyright 2025 Stefan Hansson
# SPDX-License-Identifier: GPL-3.0-or-later
import common
import glob
import os.path
import subprocess
import sys
if __name__ == "__main__":
if common.commit_message_has_string("[ci:skip-dint]"):
print("WARNING: not linting deviceinfo files ([ci:skip-dint])")
exit(0)
if "deviceinfo_schema.toml" in common.get_changed_files():
print("deviceinfo_schema.toml changed -> checking all deviceinfo files")
pmaports_dir = common.get_pmaports_dir()
deviceinfo_files = set(glob.glob(pmaports_dir + "/device/*/*/deviceinfo"))
else:
# only lint deviceinfo files in the devices repo
deviceinfo_files = {file for file in common.get_changed_files()
if os.path.basename(file) == "deviceinfo" and file.startswith("device/")}
try:
subprocess.run(["dint", "check", *deviceinfo_files], text=True, check=True)
except subprocess.CalledProcessError as exception:
sys.exit(exception.returncode)
-223
View File
@@ -1,223 +0,0 @@
#!/usr/bin/env python3
# Copyright 2025 Pablo Correa Gomez
# SPDX-License-Identifier: GPL-3.0-or-later
import argparse
from functools import cached_property
from pathlib import Path
from typing import Self
import sys
import traceback
from jinja2 import Template
import pmb.parse
from pmb.parse.deviceinfo import Deviceinfo
from pmb.types import Apkbuild
import pmb.helpers.devices
import pmb.helpers.logging
import pmb.helpers.package
from pmb.core.arch import Arch
# Same dir
import common
class Device:
def __init__(self, codename: str):
self.codename = codename
self.full_path = pmb.helpers.devices.find_path(codename)
def __repr__(self):
return f"Device({self.codename})"
@property
def name(self):
return self.full_path.name.removeprefix("device-")
@cached_property
def gitlab_ci_fragment(self) -> str | None:
fragment_path = self.full_path / "gitlab-ci.yml.j2"
try:
fragment_tmpl = fragment_path.read_text()
except Exception:
return None
return Template(fragment_tmpl).render(device=self)
@cached_property
def pmaports_path(self) -> Path:
# Find the root of pmaports
pmaports_root = self.full_path.parent
while (not (pmaports_root / "pmaports.cfg").exists() and
pmaports_root != pmaports_root.root):
pmaports_root = pmaports_root.parent
assert pmaports_root != pmaports_root.root
return self.full_path.relative_to(pmaports_root)
@cached_property
def apkbuild(self) -> Apkbuild:
return pmb.parse.apkbuild(self.full_path)
@property
def pkgname(self) -> str:
return self.apkbuild['pkgname']
@property
def arch(self) -> Arch:
return Arch(self.apkbuild['arch'][0])
@property
def testing_dependencies(self) -> set[str]:
# TODO: Source this from the APKBUILD
return {"postmarketos-mkinitfs-hook-ci"}
@cached_property
def package_dependencies(self) -> set[str]:
# HACK: Work around a bug in depends_recurse which prevents listing all the dependencies
# Bug: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2623
return {"postmarketos-initramfs"}
# return pmb.helpers.package.depends_recurse(pkgname=self.pkgname,
# arch=self.arch)
@cached_property
def dependencies(self) -> set[str]:
return self.package_dependencies | self.testing_dependencies
@cached_property
def kernel_variants(self) -> list[str]:
kernels = []
subpackage_prefix = f"device-{self.codename}-kernel-"
for subpkgname in self.apkbuild.get('subpackages', []):
if not subpkgname.startswith(subpackage_prefix):
continue
kernel_name = subpkgname.removeprefix(subpackage_prefix)
# Ignore `none` kernels as they are not bootable
if kernel_name != "none":
kernels.append(kernel_name)
return kernels
@cached_property
def deviceinfo(self) -> dict[str, Deviceinfo] | Deviceinfo:
# NOTE: deviceinfo files that have different values per kernel are
# currently unsupported due to a gitlab-ci issue which prevents us
# from having a per-kernel list of variables that would be selected
# using `.extends`:
# https://gitlab.com/gitlab-org/gitlab/-/issues/299423
return Deviceinfo(self.full_path / "deviceinfo", None)
@property
def has_kernel_variants(self):
return len(self.kernel_variants) > 0
@classmethod
def supported_devices(cls) -> dict[Path, Self]:
# NOTE: Not sure I like relying on pmboostrap just to avoid listing
# devices ourselves, but since we need it to parse the APKBUILD, then
# let's avoid duplicating the logic?
supported_devices = {}
for vendor in pmb.helpers.devices.list_vendors():
for device in pmb.helpers.devices.list_codenames(vendor):
try:
dev = cls(device.codename)
# Ignore devices that do not have a gitlab ci fragment,
# since adding that fragment is how we mark them as DUTs
if not dev.gitlab_ci_fragment:
continue
supported_devices[dev.pmaports_path] = dev
except Exception:
traceback.print_exc()
return supported_devices
class ArchTagSet(set):
def update(self, iterable):
supported_arches = Arch.supported_binary()
# This ignores things like !armv7, that could be a follow-up optimization
if 'noarch' in iterable or 'all' in iterable:
iterable = [arch for arch in supported_arches]
super().update([Arch(arch) for arch in iterable if Arch(arch) in supported_arches])
if __name__ == "__main__":
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("--template", default=".ci/build-jobs.yaml.j2", help="Jinja2 input template")
parser.add_argument("--output", default=".ci/build-jobs.yaml", help="output pipeline")
args = parser.parse_args()
# 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)
# Load context
sys.argv = ["pmbootstrap.py", "chroot"]
_ = pmb.parse.arguments()
# Get the list of supported devices
supported_devices = Device.supported_devices()
print(f"Supported devices: {[d for d in supported_devices.values()]}")
archs = ArchTagSet()
devices_under_test = set()
packages_modified = set()
# Get and print modified packages
for file in common.get_changed_files():
path = Path(file)
# Check if the modified's file parent folder is one of a supported dev
if device := supported_devices.get(path.parent):
devices_under_test.add(device)
if path.name != "APKBUILD":
continue
apkbuild = pmb.parse.apkbuild(path)
packages_modified.add(apkbuild['pkgname'])
archs.update(apkbuild["arch"])
# Add all the devices found in CI that depend on the package that got
# modified
for device in supported_devices.values():
if apkbuild['pkgname'] in device.dependencies:
devices_under_test.add(device)
skip = False
if common.commit_message_has_string("[ci:skip-build]"):
print("User requested skipping build, skipping build")
skip = True
if common.all_committed_by_merge_bot():
print("All commits in branch committed by merge bot, skipping build")
skip = True
if skip:
archs = ArchTagSet()
devices_under_test = set()
print(f"Architectures to build: {archs}")
print(f"Devices under test: {devices_under_test}")
with open(args.template) as f:
rendered = Template(f.read()).render(
archs=archs,
devices_under_test=devices_under_test,
packages_modified=packages_modified,
archtag={
Arch.x86_64: "shared",
Arch.x86: "shared",
Arch.aarch64: "aarch64",
Arch.armv7: "armv7",
Arch.armhf: "armhf",
Arch.riscv64: "qemu",
Arch.ppc64le: "ppc64le",
Arch.loongarch64: "loongarch64",
},
)
with open(args.output, "w") as fw:
fw.write(rendered)
-96
View File
@@ -1,96 +0,0 @@
#!/usr/bin/env python3
# Copyright 2024 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import subprocess
# Same dir
import common
def check_kconfig(pkgnames):
last_failed = None
for i in range(len(pkgnames)):
pkgname = pkgnames[i]
print(f" ({i+1}/{len(pkgnames)}) {pkgname}")
p = subprocess.run(["pmbootstrap", "kconfig", "check", "--keep-going", pkgname],
check=False)
if p.returncode:
last_failed = pkgname
return last_failed
def check_kconfig_all():
p = subprocess.run(["pmbootstrap", "kconfig", "check", "--keep-going"], check=False)
return p.returncode == 0
def show_error(last_failed):
print("")
print("---")
print("")
print("Please adjust your kernel config. This is required for getting your"
" patch merged.")
print("")
print("Edit your kernel config:")
print(f" pmbootstrap kconfig edit {last_failed}")
print("")
print("Test this kernel config again:")
print(f" pmbootstrap kconfig check {last_failed}")
print("")
print("Run this check again (on all kernels you modified):")
print(" pmbootstrap ci kconfig")
print("")
print("---")
print("")
def show_error_all():
print("")
print("---")
print("")
print("Please adjust the failed kernel configs. This is required for")
print("getting your patch merged.")
print("")
print("If a kernel in the testing category failed, and fixing is too much")
print("effort, remove 'pmb:kconfigcheck-community' from the APKBUILD.")
print("")
print("Edit a kernel config:")
print(" pmbootstrap kconfig edit <PACKAGE NAME>")
print("")
print("Test a specific kernel config again:")
print(" pmbootstrap kconfig check <PACKAGE NAME>")
print("")
print("Run this check again (on all kernels you modified):")
print(" pmbootstrap ci kconfig")
print("")
print("---")
print("")
if __name__ == "__main__":
if "kconfigcheck.toml" in common.get_changed_files():
print("kconfigcheck.toml changed -> checking all kernels")
if not check_kconfig_all():
show_error_all()
exit(1)
exit(0)
pkgnames = common.get_changed_kernels(skip_archived=True)
print(f"Changed kernels: {pkgnames}")
if len(pkgnames) == 0:
print("No kernels changed in this branch")
exit(0)
elif common.commit_message_has_string("[ci:skip-kconfigcheck]"):
print("WARNING: not checking kernel configs ([ci:skip-kconfigcheck])")
exit(0)
last_failed = check_kconfig(pkgnames)
if last_failed:
show_error(last_failed)
exit(1)
-283
View File
@@ -1,283 +0,0 @@
#!/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)"
_test_original_pwd=""
_test_temp_root=""
# 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
}
create_test_root() {
_test_original_pwd="$(pwd)"
_test_temp_root="$(mktemp -d)"
cd "$_test_temp_root"
}
cleanup_test_root() {
if [ -n "$_test_original_pwd" ]; then
cd "$_test_original_pwd"
fi
if [ -n "$_test_temp_root" ] && [ -d "$_test_temp_root" ]; then
rm -rf "$_test_temp_root"
fi
_test_original_pwd=""
_test_temp_root=""
}
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"
}
assert_exists() {
# $1: filename to test
if [ -z "$1" ]; then
test_log "ERROR: assert_exists: not enough arguments given"
exit 1
fi
if ! [ -e "$1" ]; then
_test_assert_failed="\$$1 should exist but does not"
test_log " ❌ $_test_assert_failed"
return
fi
test_log " ✅ \$$1 exists"
}
assert_not_exists() {
if [ -z "$1" ]; then
test_log "ERROR: assert_not_exists: not enough arguments given"
exit 1
fi
if [ -e "$1" ]; then
_test_assert_failed="\$$1 should NOT exist but does"
test_log " ❌ $_test_assert_failed"
return
fi
test_log " ✅ \$$1 does not exist"
}
assert_contains() {
# $1: string to search in
# $2: substring to find
if [ -z "$1" ] || [ -z "$2" ]; then
test_log "ERROR: assert_contains: not enough arguments given"
exit 1
fi
case "$1" in
*"$2"*)
test_log " ✅ '$2' found in '$1'"
;;
*)
_test_assert_failed="'$2' not found in '$1'"
test_log " ❌ $_test_assert_failed"
return
;;
esac
}
assert_not_contains() {
# $1: string to search in
# $2: substring that should not be found
if [ -z "$1" ] || [ -z "$2" ]; then
test_log "ERROR: assert_not_contains: not enough arguments given"
exit 1
fi
case "$1" in
*"$2"*)
_test_assert_failed="'$2' found in '$1' but should not be"
test_log " ❌ $_test_assert_failed"
return
;;
*)
test_log " ✅ '$2' not found in '$1'"
;;
esac
}
# 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
-91
View File
@@ -1,91 +0,0 @@
#!/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 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
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()
archived = set()
for path in pmb.core.pkgrepo.pkgrepo_iter_package_dirs():
# Store archived packages for matching later
if os.path.split(os.path.split(path)[0])[1] == 'archived':
archived.add(os.path.basename(path))
continue
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 or are in archived
# (Iterate over copy of packages, because we modify it in this loop)
for package in packages.copy():
if package not in buildable_pkgs:
# Specifically handle archived since it could include packages
# who's sources are dead
if package in archived:
print(f"{package}: archived, skipping")
packages.remove(package)
continue
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)
-16
View File
@@ -1,16 +0,0 @@
#!/bin/sh -e
# Description: static type checking for python scripts
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add py3-argcomplete py3-pip py3-pytest
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
set -x
pip install --break-system-packages --no-warn-script-location mypy
# Need to change directory for pyproject.toml to be picked up.
cd .ci
python -m mypy .
-2
View File
@@ -1,2 +0,0 @@
[tool.mypy]
disable_error_code = ["import-not-found"]
+15 -5
View File
@@ -3,12 +3,12 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Description: lint with various python tests
# Options: native
# Use 'native' because it requires running pmbootstrap.
# Use 'native' because it requires pmbootstrap.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
wget "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/main/install_pmbootstrap.sh"
wget "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
sh ./install_pmbootstrap.sh pytest
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
@@ -26,7 +26,17 @@ pmbootstrap work_migrate
pmbootstrap config aports "$pmaports"
pmbootstrap -q shutdown
# Needed to import "common"
export PYTHONPATH="$PYTHONPATH:.ci/lib"
# Make sure we have a valid device (pmbootstrap#1128)
device="$(pmbootstrap config device)"
deviceinfo="$pmaports/device/*/device-$device/deviceinfo"
# shellcheck disable=SC2086
if ! [ -e $deviceinfo ]; then
echo "ERROR: Could not find deviceinfo file for selected device '$device'."
echo "Expected path: $deviceinfo"
echo "Maybe you have switched to a branch where your device does not exist?"
echo "Use 'pmbootstrap config device qemu-amd64' to switch to a valid device."
exit 1
fi
# Run testcases
pytest -vv --tb=native "$pmaports/.ci/testcases" "$@"
pytest -vv -x --tb=native "$pmaports/.ci/testcases" "$@"
+1 -1
View File
@@ -11,4 +11,4 @@ fi
set -x
# shellcheck disable=SC2046
ruff check $(find .ci -name '*.py')
ruff check --ignore E501,F401,E722,W605 $(find .ci -name '*.py')
+7 -10
View File
@@ -15,21 +15,18 @@ 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-duranium/rootfs-usr-bin-duranium-set-channel
./main/postmarketos-duranium/rootfs-usr-libexec-duranium-first-boot
./main/postmarketos-duranium/rootfs-usr-libexec-duranium-usb-gadget-setup
./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/postmarketos-ui-os-installer/rootfs-usr-bin-pmos_setup.sh
./main/postmarketos-usb-moded/rootfs-usr-lib-systemd-system-generators-umtprd-config-generator
./main/ttyescape/*.post-install
./main/unl0kr/unlock.sh
./device/community/soc-qcom/call_audio_idle_suspend_workaround.sh
./device/testing/device-apple-mac-aarch64/*.sh
./extra-repos/systemd/postmarketos-base-systemd/rootfs-usr-libexec-systemd-apk-trigger
./main/msm-firmware-loader/*.post-install
./device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.sh
$(find . -path './main/postmarketos-ui-*/*.sh')
$(find . -path './main/postmarketos-ui-*/*.pre-install')
@@ -41,13 +38,13 @@ sh_files="
$(find . -name '*.trigger')
$(find . -path './main/devicepkg-dev/*.sh')
$(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 -S warning -e SC1008 -e SC3043 -x "$(basename "$file")"
shellcheck -e SC1008 -e SC3043 -x "$(basename "$file")"
done
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import shutil
import sys
import os
import importlib
import importlib.util
from site import getsitepackages
def path_pmbootstrap():
""" Find the pmbootstrap installation folder, so we can import the Python
code from there.
returns: pmbootstrap installation folder
"""
# This variable is set by pmbootstrap 1.52 and later
# If it's undefined, try to find 'pmbootstrap' in path
bin = os.environ.get("PMBOOTSTRAP_CMD") or shutil.which("pmbootstrap")
if not bin:
print("ERROR: 'pmbootstrap' not found in $PATH")
sys.exit(1)
# Resolve the symlink and verify the folder
directory = os.path.dirname(os.path.realpath(bin))
if os.path.exists(directory + "/pmb/__init__.py"):
return directory
directories = getsitepackages()
for directory in directories:
if os.path.exists(directory + "/pmb/__init__.py"):
return directory
# Symlink not set up properly
print("ERROR: unable to find path to pmbootstrap.py. Try setting 'PMBOOTSTRAP_CMD'.")
sys.exit(1)
# Check if pmb module can be imported
if importlib.util.find_spec("pmb") is None:
# Add pmbootstrap dir to import path
sys.path.append(os.path.realpath(path_pmbootstrap()))
+3 -1
View File
@@ -3,11 +3,14 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from pathlib import Path
import add_pmbootstrap_to_import_path
import pmb.parse
from pmb.helpers.args import init as init_args
from pmb.types import PmbArgs
import pmb.config
from pmb.core.pkgrepo import pkgrepo_default_path
import pytest
import sys
import os
@pytest.fixture(scope="session", autouse=True)
@@ -24,7 +27,6 @@ def args(request):
args.offline = False
args.action = "init"
args.cross = False
args.ccache = False
args.log = None
init_args(args)
+83 -11
View File
@@ -2,12 +2,21 @@
# Copyright 2024 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import fnmatch
import glob
import os
import pytest
import sys
import add_pmbootstrap_to_import_path
import pmb.parse
import pmb.parse._apkbuild
from pmb.core.pkgrepo import pkgrepo_default_path, pkgrepo_iglob
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 = [
@@ -38,7 +47,8 @@ def test_aports_device():
if "postmarketos-base" == dependency or "postmarketos-base>" in dependency:
depend_flag = True
if not depend_flag:
raise RuntimeError(f"Missing 'postmarketos-base' in depends of {path}")
raise RuntimeError("Missing 'postmarketos-base' in depends of " +
path)
# Depends: Must not have specific packages
for depend in apkbuild["depends"]:
@@ -51,7 +61,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(f"!archcheck missing in options= line: {path}")
raise RuntimeError("!archcheck missing in options= line: " + path)
def test_aports_device_kernel():
@@ -93,12 +103,72 @@ 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.
"Co-Maintainer:" (only required for main) listed in their APKBUILDs. Also
check that at least as many are listed in CODEOWNERS.
"""
codeowners_parse()
for path in pkgrepo_iglob("device/main/*/APKBUILD"):
if 'firmware-' in path.parent.name:
@@ -106,21 +176,23 @@ 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_archived():
def test_aports_unmaintained():
"""
Ensure that aports in /device/archived have an "Archived:" comment
that describes why the aport is archived.
Ensure that aports in /device/unmaintained have an "Unmaintained:" comment
that describes why the aport is unmaintained.
"""
for path in pkgrepo_iglob("device/archived/*/APKBUILD"):
archived = pmb.parse._apkbuild.archived(path)
assert archived, f"{path} should have an Archived: " +\
"comment that describes why the package is archived"
for path in pkgrepo_iglob("device/unmaintained/*/APKBUILD"):
unmaintained = pmb.parse._apkbuild.unmaintained(path)
assert unmaintained, f"{path} should have an Unmaintained: " +\
"comment that describes why the package is unmaintained"
+35 -5
View File
@@ -2,12 +2,33 @@
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import os
import pytest
import re
import sys
import add_pmbootstrap_to_import_path
import pmb.parse
from pmb.core.pkgrepo import pkgrepo_iglob
def deviceinfo_obsolete(info):
"""
Test for obsolete options used in the deviceinfo file. They must still be
defined in pmbootstrap's config/__init__.py.
"""
obsolete_options = [
"usb_rndis_function",
"weston_pixman_type",
]
for option in obsolete_options:
if getattr(info, option, None):
raise RuntimeError(f"option {option} is obsolete, please rename"
" or remove it (see reasons for removal of at"
" https://postmarketos.org/deviceinfo)")
def test_deviceinfo():
"""
Parse all deviceinfo files successfully and run checks on the parsed data.
@@ -15,7 +36,7 @@ def test_deviceinfo():
# Iterate over all devices
last_exception = None
count = 0
pattern = re.compile("^deviceinfo_[a-zA-Z0-9_]*=\".*\"(\\s*# .*)?$")
pattern = re.compile("^deviceinfo_[a-zA-Z0-9_]*=\".*\"$")
for folder in pkgrepo_iglob("device/*/device-*"):
device = folder.name.split("-", 1)[1]
@@ -26,25 +47,34 @@ def test_deviceinfo():
try:
for line in lines:
# Require space after # for comments
if line.startswith("#") and not line.startswith("# "):
raise RuntimeError("Comment style: please change '#' to"
f" '# ': {line}")
# Skip empty lines and comments
if not line or line.startswith("# "):
continue
# Variable can not be empty
if '=""' in line:
raise RuntimeError("Please remove the empty variable: " + line)
# Check line against regex (can't use multiple lines etc.)
if not pattern.match(line) or line.endswith("\\\""):
raise RuntimeError("Line looks invalid, maybe missing"
" quotes/multi-line string/malformed"
f" inline comment? {line}")
" quotes/multi-line string/comment next"
f" to line instead of above? {line}")
# Successful deviceinfo parsing / obsolete options
info = pmb.parse.deviceinfo(device)
deviceinfo_obsolete(info)
# deviceinfo_name must start with manufacturer
name = info.name
manufacturer = info.manufacturer
if not name.startswith(manufacturer) and \
not name.startswith("Google") and \
not name.startswith("Jolla"):
not name.startswith("Google"):
raise RuntimeError("Please add the manufacturer in front of"
" the deviceinfo_name, e.g.: '" +
manufacturer + " " + name + "'")
+6 -12
View File
@@ -8,10 +8,8 @@ expected_directories = [
"cross",
"device/archived",
"device/community",
"device/downstream",
"device/main",
"device/testing",
"extra-repos/systemd",
"main",
"modem",
"non-free",
@@ -46,20 +44,20 @@ def test_executable_files():
"m0755` or a variation thereof.")
# Make sure files belong to a package (below a directory with APKBUILD)
# Make sure files are either:
# - in root directory (README.md)
# - hidden (.ci/, device/.shared-patches/)
# - or belong to a package (below a directory with APKBUILD)
def test_files_belong_to_package():
# Walk directories and set package_dir when we find an APKBUILD
# This allows matching files in subdirectories to the package directory.
package_dir = None
for dirpath, dirs, files in os.walk("."):
# Skip "hidden" directories (.ci/, device/.shared-patches/)
# Skip "hidden" directories
dirs[:] = [d for d in dirs if not d.startswith(".")]
# Ignore files in root directory (README.md)
# Ignore files in root directory
if dirpath == '.':
continue
# Ignore files under docs/
if dirpath.startswith('./docs'):
continue
# Switched to another directory?
if package_dir and not dirpath.startswith(package_dir + os.sep):
@@ -70,9 +68,5 @@ def test_files_belong_to_package():
"both contain an APKBUILD"
package_dir = dirpath
# Skip specific ".gitlab-ci.yml" files outside of usual structure
if dirpath in ["./cross"]:
files[:] = [f for f in files if f != ".gitlab-ci.yml"]
assert not files or package_dir, "Found files that do not belong to any package: " \
f"{dirpath}/{files}"
+3 -2
View File
@@ -2,10 +2,12 @@
# Copyright 2021 Johannes Marbach
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import os
import add_pmbootstrap_to_import_path
import pmb.parse
from pmb.core.pkgrepo import pkgrepo_iglob
from pmb.core.pkgrepo import pkgrepo_default_path, pkgrepo_iglob
def test_aports_firmware():
@@ -23,7 +25,6 @@ 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):
+5
View File
@@ -6,8 +6,13 @@
version in all packages. We scan all packages, categorize them by URL
and then compare the versions of all packages in each category. """
import glob
import logging
import os
import pytest
import sys
import add_pmbootstrap_to_import_path
import pmb.config
import pmb.parse
from pmb.core.pkgrepo import pkgrepo_iter_package_dirs
+5 -3
View File
@@ -2,9 +2,14 @@
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import pytest
import sys
import os
import re
from pathlib import Path
import add_pmbootstrap_to_import_path
import pmb.parse
from pmb.core.pkgrepo import pkgrepo_iglob, pkgrepo_relative_path
@@ -18,9 +23,6 @@ def test_aports_kernel():
apkbuild = pmb.parse.apkbuild(path)
aport_name = os.path.basename(os.path.dirname(path))
if aport_name == "linux-pam-pmos":
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")
+24 -24
View File
@@ -1,9 +1,13 @@
#!/usr/bin/env python3
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import logging
import re
import os
import pytest
import sys
import add_pmbootstrap_to_import_path
import pmb.parse
import pmb.parse._apkbuild
from pmb.core.pkgrepo import pkgrepo_iter_package_dirs, pkgrepo_relative_path
@@ -40,29 +44,25 @@ def apkbuild_check_provides(path, apkbuild, version, pkgname, subpkgname=None):
# already replaces the variables, so we check against the inserted
# values here.
if not provide.endswith(f"={version}"):
# Valid version strings, per the APKBUILD reference, are fine. This regex
# attempts to detect those.
pattern = r'^\d+(\.\d+)*[a-z]?(_(?:alpha|beta|pre|rc|cvs|svn|git|hg|p)\d*)*-r\d+$'
[provide_no_ver, provide_ver] = provide.split("=", 1)
if not re.match(pattern, provide_ver):
error = f"error in , provide_ver{path}:\n"
if subpkgname:
error += f"in subpackage:\n {subpkgname}\n"
else:
error += f"in package:\n {pkgname}\n"
error += f"broken provides entry:\n {provide_no_ver}\n"
error += "\n"
error += "This provides entry needs to be changed to"
error += f" '{provide_no_ver}=$pkgver-r$pkgrel'"
error += " (do not replace the variables, without '').\n"
error += "\n"
error += "If you know what you are doing and didn't add the"
error += " version on purpose, you also need to set a"
error += " provider_priority (pma#1766).\n"
error += "Reference:"
error += " https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#provides"
error += f"\nVERSION: {provide_no_ver}"
ret += [error]
provide_no_ver = provide.split("=", 1)[0]
error = f"error in {path}:\n"
if subpkgname:
error += f"in subpackage:\n {subpkgname}\n"
else:
error += f"in package:\n {pkgname}\n"
error += f"broken provides entry:\n {provide_no_ver}\n"
error += "\n"
error += "This provides entry needs to be changed to"
error += f" '{provide_no_ver}=$pkgver-r$pkgrel'"
error += " (do not replace the variables, without '').\n"
error += "\n"
error += "If you know what you are doing and didn't add the"
error += " version on purpose, you also need to set a"
error += " provider_priority (pma#1766).\n"
error += "Reference:"
error += " https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#provides"
ret += [error]
return ret
+5 -6
View File
@@ -6,7 +6,10 @@
import glob
import logging
import os
import pytest
import sys
import add_pmbootstrap_to_import_path
import pmb.parse
import pmb.parse._apkbuild
import pmb.parse.apkindex
@@ -96,17 +99,13 @@ def test_aports_unreferenced_files():
for file in glob.iglob(dirname + "/**", recursive=True):
rel_file_path = os.path.relpath(file, dirname)
# Skip APKBUILDs and directories
if rel_file_path in ["APKBUILD", "gitlab-ci.yml.j2"] or os.path.isdir(file):
continue
# Skip kernel fragments in linux-* packages
if os.path.basename(rel_file_path).endswith(".config") and apkbuild["pkgname"].startswith("linux-"):
if rel_file_path == "APKBUILD" or os.path.isdir(file):
continue
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 not rel_file_path.startswith("tests/"):
and rel_file_path not in trigger_sources:
raise RuntimeError(f"{apkbuild_path}: found unreferenced file: {rel_file_path}")
-25
View File
@@ -1,25 +0,0 @@
#!/usr/bin/env python3
# Copyright 2025 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import logging
import os
import pmb.parse
from pmb.core.context import get_context
from pathlib import Path
def test_systemd_stage0_version():
"""Ensure systemd-stage0 and systemd have the same pkgver."""
# Don't clutter output with verbose APKBUILD parsing messages
logging.getLogger().setLevel(logging.DEBUG)
config = get_context().config
pma_systemd = os.path.join(config.aports[0], "extra-repos/systemd")
sd0 = pmb.parse.apkbuild(Path(os.path.join(pma_systemd, "systemd-stage0/APKBUILD")))
sd1 = pmb.parse.apkbuild(Path(os.path.join(pma_systemd, "systemd/APKBUILD")))
assert sd0["pkgver"] == sd1["pkgver"], (
f"systemd-stage0 pkgver ({sd0['pkgver']}) doesn't match systemd pkgver ({sd1['pkgver']})!"
)
+14 -18
View File
@@ -2,10 +2,14 @@
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
from pathlib import Path
import glob
import pytest
import sys
import os
import common
import add_pmbootstrap_to_import_path
import pmb.parse
from pmb.core.pkgrepo import pkgrepo_iglob
def test_aports_ui():
@@ -13,25 +17,18 @@ def test_aports_ui():
Raise an error if package in _pmb_recommends is not found
"""
pmaports_cfg = pmb.config.pmaports.read_config()
for arch in pmaports_cfg["supported_arches"].split(","):
for path in common.get_changed_files():
path = Path(path)
if path.name != "APKBUILD":
continue
if not path.parent.name.startswith("postmarketos-ui"):
continue
for path in pkgrepo_iglob("main/postmarketos-ui-*/APKBUILD"):
apkbuild = pmb.parse.apkbuild(path)
# Skip if arch isn't enabled
if not pmb.helpers.package.check_arch(apkbuild["pkgname"], arch, False):
continue
for package in apkbuild["_pmb_recommends"]:
depend = pmb.helpers.package.get(
package, arch, must_exist=False, try_other_arches=False
)
if depend is None:
depend = pmb.helpers.package.get(package,
arch, must_exist=False)
if depend is None or not pmb.helpers.package.check_arch(package, arch):
raise RuntimeError(f"{path}: package '{package}' from"
f" _pmb_recommends not found for arch '{arch}'")
@@ -39,9 +36,8 @@ def test_aports_ui():
if f"{apkbuild['pkgname']}-extras" in apkbuild["subpackages"]:
apkbuild = apkbuild["subpackages"][f"{apkbuild['pkgname']}-extras"]
for package in apkbuild["_pmb_recommends"]:
depend = pmb.helpers.package.get(
package, arch, must_exist=False, try_other_arches=False
)
if depend is None:
depend = pmb.helpers.package.get(package,
arch, must_exist=False)
if depend is None or not pmb.helpers.package.check_arch(package, arch):
raise RuntimeError(f"{path}: package '{package}' from _pmb_recommends "
f"of -extras subpackage is not found for arch '{arch}'")
-19
View File
@@ -1,19 +0,0 @@
#!/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
-16
View File
@@ -1,16 +0,0 @@
#!/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/main/install_pmbootstrap.sh"
sh ./install_pmbootstrap.sh
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
export PYTHONUNBUFFERED=1
.ci/lib/verify_checksums.py
+1 -3
View File
@@ -7,11 +7,9 @@
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add \
git \
python3
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
set -x
# shellcheck disable=SC2068
.ci/lib/check_devices_in_wiki.py --booting $@
.ci/lib/check_devices_in_wiki.py --booting
+1 -13
View File
@@ -7,20 +7,8 @@
# Top-most EditorConfig file.
root = true
[{**.{ini,sh,rules,nft},**/APKBUILD,CODEOWNERS}]
[{**.{md,ini,sh,rules,nft},**/APKBUILD,CODEOWNERS}]
indent_style = tab
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
[**.md]
# No indent_size since space size has meaning in markdown
indent_style = space
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
+21 -9
View File
@@ -5,6 +5,10 @@
#
set -eu
# Maximal allowed size (in bytes) of a file.
FILE_SIZE_LIMIT=262144 # 256 kiB
if ! command -v sha512sum >/dev/null; then
# macOS / BSDs (?) don't have sha512sum, but shasum.
alias sha512sum='shasum -a 512'
@@ -61,7 +65,7 @@ is_symlink() {
# available in git tree and checksums are correct.
check_local_sources() {
local apkbuild="$1"
local startdir="$2"
local startdir="${apkbuild%/*}"
local status=0
local checksum_act checksum_exp content filename line sources
@@ -91,17 +95,25 @@ check_local_sources() {
return $status
}
cleanup() {
[ -f "$_staged" ] && rm "$_staged"
# Checks if the file ($1) being committed is not bigger than FILE_SIZE_LIMIT.
check_file_size() {
local path="$1"
local size
size=$(git cat-file -s ":$path")
if [ $size -gt $FILE_SIZE_LIMIT ]; then
local size_kb=$(( size / 1024 ))
error "file \"$path\" is quite big ($(( size / 1024 )) kiB), better put a remote url in source="
return 1
fi
}
trap cleanup EXIT
for apkbuild in $(changed_files '**/APKBUILD'); do
_staged="$(mktemp)"
git show ":$apkbuild" >"$_staged"
check_local_sources "$_staged" "${apkbuild%/*}"
cleanup
check_local_sources "$apkbuild"
done
trap - EXIT
for path in $(changed_files); do
check_file_size "$path"
done
+5 -28
View File
@@ -37,36 +37,13 @@ prepend_msg() {
[ -z "$SOURCE" ] || exit 0
lcp=$(git diff-index --name-only --cached HEAD | longest_common_prefix)
prefix=""
case "$lcp" in
extra-repos/systemd/systemd/*)
prefix="systemd"
;;
extra-repos/systemd/*)
prefix="systemd/$(echo "$lcp" | cut -d/ -f3)"
;;
device/*/*)
prefix="$(echo "$lcp" | cut -d/ -f3)"
;;
docs/*.adoc)
prefix="docs/$(basename $lcp .adoc)"
;;
docs/*)
prefix="docs"
;;
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)"
;;
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): ";;
esac
if [ -n "$prefix" ]; then
prepend_msg "$prefix: "
fi
exit 0
+2 -6
View File
@@ -65,9 +65,8 @@ instance/
# Scrapy stuff:
.scrapy
# Documentation
public
docs/packaging/device-packages/deviceinfo-reference.md
# Sphinx documentation
docs/_build/
# PyBuilder
target/
@@ -119,6 +118,3 @@ ENV/
# Allow having untracked packages in aports using a custom-something directory
/custom-*/
# child pipeline
.ci/build-jobs.yaml
+57 -148
View File
@@ -2,46 +2,38 @@
# global settings
image: alpine:latest
before_script: &global_before_scripts
- apk upgrade -U
after_script:
- .ci/lib/move_logs.sh $CI_PROJECT_DIR
stages:
- lint
- prepare
- build
- autoupdate
- test
- deploy
variables:
# Default of 20 is pretty small, sometimes MRs have >20 commits in them. 100
# seems like a reasonable balance. If this is too low, git merge-base (from ci/
# common.py) can fail
GIT_DEPTH: 100
# So that anything that runs install_pmbootstrap and tries to import pmb module
# can find it.
PYTHONPATH: "/tmp/pmbootstrap"
# This defines the rules for when a pipeline should run.
workflow:
rules:
# Don't run branch pipeline if an MR is open (only the MR pipeline will run)
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
when: never
# Run for merge requests
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
# Some things have to run in the default branch
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# Run scheduled pipeline for autoupdate or manually triggered pipeline
- if: $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"
# Some packages have their own yaml files defining tests. All of these should contain
# only jobs which extend the .package-test job!
include: "**/.gitlab-ci.yml"
# device documentation
wiki:
stage: lint
rules:
- if: &mr_rule $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_REF_PROTECTED == "false"
changes:
- .ci/**/*
- .ci/build-jobs.yaml.j2
- .gitlab-ci.yml
- device/*/device-*/*
script:
@@ -52,42 +44,32 @@ wiki:
ruff:
stage: lint
rules:
- if: *mr_rule
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_REF_PROTECTED == "false"
changes:
- .ci/*
- .ci/*/*
- .ci/build-jobs.yaml.j2
- .gitlab-ci.yml
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/ruff.sh
# testcases typechecking
mypy:
stage: lint
rules:
- if: *mr_rule
changes:
- .ci/**/*
- .gitlab-ci.yml
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/mypy.sh
# shellcheck and various grep checks
shellcheck-grep:
stage: lint
image: alpine:edge
rules:
- if: *mr_rule
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_REF_PROTECTED == "false"
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/shellcheck.sh
- .ci/grep.sh
- .ci/codeowners.sh
editor-config:
stage: lint
image: alpine:edge
rules:
- if: *mr_rule
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_REF_PROTECTED == "false"
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/ec.sh
@@ -96,11 +78,11 @@ editor-config:
pytest-commits:
stage: lint
rules:
- if: *mr_rule
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_REF_PROTECTED == "false"
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/pytest.sh
- .ci/check-changed-versions.sh
- .ci/commits.sh
artifacts:
when: on_failure
paths:
@@ -111,58 +93,27 @@ pytest-commits:
# APKBUILD linting
aport-lint:
# alpine:latest doesn't have the most recent atools-go, which means we would
# miss some linting rules that were added upstream. Use alpine:edge instead.
image: alpine:edge
stage: lint
rules:
- if: *mr_rule
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_REF_PROTECTED == "false"
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/apkbuild-lint.sh
allow_failure: true
# deviceinfo linting
dint:
stage: lint
rules:
- if: *mr_rule
changes:
- .ci/**/*
- .gitlab-ci.yml
- device/*/device-*/deviceinfo
- deviceinfo_schema.toml
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/dint.sh
allow_failure:
exit_codes:
- 2 # returned by dint on non-fatal warning
# kernel kconfig check
kernel-kconfig:
stage: lint
rules:
- if: *mr_rule
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_REF_PROTECTED == "false"
changes:
- kconfigcheck.toml
allow_failure: true
- if: *mr_rule
changes:
- device/*/linux-*/config-*
- main/linux-*/config-*
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/kconfig.sh
# Verify checksums
verify-checksums:
stage: lint
rules:
- if: *mr_rule
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/verify-checksums.sh
# MR settings
# (Checks for "Allow commits from members who can merge to the target branch")
mr-settings:
@@ -170,91 +121,57 @@ mr-settings:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
before_script:
- *global_before_scripts
- apk -q add python3
script:
- wget -q "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/main/check_mr_settings.py"
- wget -q "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/master/check_mr_settings.py"
- python3 ./check_mr_settings.py
pmbootstrap minimum version:
stage: lint
# build changed aports
.build:
stage: build
rules:
- if: *mr_rule
changes:
- .ci/check-pmbootstrap-min-version.sh
- .gitlab-ci.yml
- pmaports.cfg
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/check-pmbootstrap-min-version.sh
# Calculate build of changed aports using a dynamic downstream pipelines:
# https://docs.gitlab.com/ci/pipelines/downstream_pipelines/#dynamic-child-pipelines
# For those to work, we need two jobs:
# * First one (this one) that generates a valid yaml file with the job yaml as
# an artifact
# * Second one (build-jobs) that has a "trigger" key with the yaml file from
# which to trigger pipelines
# To avoid reworking the whole CI file, for now we are re-using this same file
# to trigger the downstream pipeline. In that case, $CI_PIPELINE_SOURCE will
# be set to "parent_pipeline", and only the jobs that extend .build will run
generate-build-jobs:
stage: prepare
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_REF_PROTECTED == "false"
before_script:
- *global_before_scripts
- .ci/lib/gitlab_prepare_ci.sh
needs: []
script:
- wget "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/main/install_pmbootstrap.sh"
- sh ./install_pmbootstrap.sh py3-jinja2
# HACK: Make the pmb library happy to use the currently-cloned pmaports repo
- mkdir -p /root/.local/var/pmbootstrap/cache_git/ && ln -s $PWD /root/.local/var/pmbootstrap/cache_git/pmaports
- .ci/lib/generate_build_jobs.py
after_script:
- cp -r /home/pmos/.local/var/pmbootstrap/packages/ packages/ || true
artifacts:
expire_in: 1 week
paths:
- .ci/build-jobs.yaml
rules:
- if: *mr_rule
- packages/
timeout: 10 h
build-jobs:
stage: build
trigger:
include:
- artifact: .ci/build-jobs.yaml
job: generate-build-jobs
strategy: depend
forward:
# So that we don't have to duplicate GIT_DEPTH
pipeline_variables: true
rules:
- if: *mr_rule
build-docs:
stage: build
before_script:
- adduser -D build
build-x86_64:
extends: .build
script:
- .ci/build-docs.sh
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- .ci/build-docs.sh
- deviceinfo_schema.toml
- docs/**
- .ci/build-x86_64.sh
deploy-docs:
stage: deploy
trigger:
project: postmarketOS/docs.postmarketos.org
strategy: depend
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PROJECT_NAMESPACE == "postmarketOS"
changes:
- deviceinfo_schema.toml
- docs/**
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
build-x86:
extends: .build
script:
- .ci/build-x86.sh
build-aarch64:
extends: .build
script:
- .ci/build-aarch64.sh
build-armv7:
extends: .build
script:
- .ci/build-armv7.sh
build-armhf:
extends: .build
script:
- .ci/build-armhf.sh
build-riscv64:
extends: .build
script:
- .ci/build-riscv64.sh
auto-update:
stage: autoupdate
@@ -274,11 +191,3 @@ auto-update:
- log.txt
- log_testsuite_pmaports.txt
- pmbootstrap.cfg
# Template for package test jobs defined per-package
.package-test:
stage: test
rules:
- if: *mr_rule
before_script:
- .ci/lib/gitlab_prepare_ci.sh
+3 -8
View File
@@ -26,23 +26,18 @@
<!--
Replace space inside `[ ]` with `x` to fill the checkbox
-->
* [ ] edge (`main` branch)
* [ ] `v25.12`
* [ ] `v26.06`
* [ ] edge (`master` branch)
* [ ] `v24.06`
* [ ] I confirm that the issue still is present after running `sudo apk upgrade -a`
### On what environment did you encounter the issue?
#### Environments
* [ ] COSMIC
* [ ] GNOME Shell on Mobile
* [ ] Phosh (*Please attach the debug information of the Mobile settings app, see [this video](https://peertube.debian.social/w/4GwDjCJNcAmp8cb7dqXz1T) or use `phosh-mobile-settings -d`*)
* [ ] Phosh
* [ ] Plasma Mobile
* [ ] Sxmo (Wayland/Sway) **Please post the output of `sxmo_version.sh`**
* [ ] Other: **Please fill out**
### Which init system are you using?
* [ ] OpenRC
* [ ] systemd
### How did you get postmarketOS image?
* [ ] from https://images.postmarketos.org
* [ ] I built it using pmbootstrap
@@ -1,15 +0,0 @@
<!-- Use this template to kick off the discussion for a package with (presumably)
inactive maintainers and the future for the maintainership of the package.
-->
### Information
* Package name:
* Maintainers of the package:
* MR that had no maintainer response, if applicable:
If the maintainers don't reply within two weeks of opening this issue, the
package is considered orphaned and, in the case of device packages, the devices
will be moved to the archived category.
/label ~maintainership-status
@@ -1,25 +0,0 @@
<!-- Use this template to notify community kernel maintainers that their
kernels are out-of-date and start the timer for moving them to testing.
Please title the issue:
Current community kernels not meeting version requirement (yyyy-mm-dd)
-->
Hi, as per our
[device categorization requirements for the community category](https://docs.postmarketos.org/pmaports/main/device-categorization.html#community),
devices in the community category may not use a kernel version older than 6
months.
As of today (yyyy-mm-dd), the following kernels do not meet this requirement:
* kernel-pkgname: kernel-pkgver, version-release-date (maintainers: @ ...)
This issue is an attempt to notify you (the maintainers) of the situation so
that you can update the packages. As per the rules, you have two weeks to
update the packages or reply with a request for more time, up to one month
of time from the moment this issue is opened. If that time passes and the
devices still no longer meet the requirements, they will be moved to testing.
/label ~"device-category::community"
/label ~kernel
/label ~"type::policy"
-29
View File
@@ -1,29 +0,0 @@
<!--
This template is for marking a postmarketOS stable release as EOL.
Name this issue "vYY.MM EOL".
-->
When the release has reached its EOL date:
- [ ] `postmarketos-base-ui`: let it depend on
`postmarketos-release-upgrade-notification` and bump pkgrel
- [ ] ensure it builds locally with pmbootstrap
- [ ] push it to the branch
- [ ] make sure bpo built and released the updated packages
- [ ] drop the old release from
[monitoring](https://gitlab.postmarketos.org/postmarketOS/monitoring)
- [ ] drop the "oldold -> old" release check from
[postmarketos-release-upgrade](https://gitlab.postmarketos.org/postmarketOS/postmarketos-release-upgrade/)
CI
- [ ] bpo: configure images so they don't get built for the old release anymore
- [ ] bpo: configure branches so we don't try to build packages for old
branches anymore
- e.g. on startup all branches are checked for new packages, we should keep
the amount of branches that get checked minimal
- [ ] pmaports.git channels.cfg: change description:
- "Old release (unsupported)"
- [ ] Update the [Releases](https://docs.postmarketos.org/pmaports/main/releases.html) page
- Move the release from active to old
- [ ] Consider removing images for the previous releases to save disk space
(people can build their own images with pmbootstrap if needed)
@@ -1,234 +0,0 @@
<!--
This template is for creating a new postmarketOS stable release.
Name this issue "vYY.MM Infrastructure".
-->
Person in charge of the release (doesn't have to do all the work, but has to
push it forward):
<!-- Put your usename here and assign yourself to this issue -->
### 0. Preparation
- [ ] Create the gitlab milestone for the release
- [ ] Add this infrastructure issue to the milestone
- [ ] Update the
[timeline](https://docs.postmarketos.org/policies-and-processes/development/releases/current-timeline.html)
for the next release
### 1. Pre-Build phase
This phase is to get some extra time for building packages. The branch will be rebased once in the branch phase.
#### Requirements
- [ ] Alpine's main repository must be built and published
- [ ] Alpine's community repository must be built and published
<small>Without this, bpo won't be able to build packages but steps before
that can be done already.</small>
#### pmbootstrap: adjust config
- [ ] Update `pmb/config/__init__.py:apk_tools_min_version`. This should be a
trivial change, push it directly to main.
- [ ] (can be done later, at start of test phase) make a new [pmbootstrap
release](https://wiki.postmarketos.org/wiki/Pmbootstrap_release) <small>bpo
uses the main branch, so it will be fine without a release, however users
will want to try out the new release and may not run main.</small>
#### pmaports: create branch and initial changes
- [ ] `git checkout -b vYY.MM main`
- [ ] Create a `=== Branch vYY.MM from main ===` commit
- Remove channels.cfg (should only be in main)
- Adjust `pmaports.cfg`: Change `channel=edge` to `channel=vYY.MM`
- Adjust `pmaports.cfg`: Change `supported_arches` to `x86_64,aarch64,armv7`
- Delete `.ci/build-*` scripts for other arches
<small>`pmbootstrap ci` reads these</small>
- [ ] `git push`
- [ ] Ensure the branch is protected in the
[repository settings](https://gitlab.postmarketos.org/postmarketOS/pmaports/-/settings/repository)
#### pmaports: update main branch
- [ ] `git checkout main`
- [ ] Add the new branch to
[channels.cfg](https://wiki.postmarketos.org/wiki/Channels.cfg_reference):
- [Example](https://gitlab.postmarketos.org/postmarketOS/pmaports/-/commit/c43571ceaf9b8155519bc9fb760bdeccd96e7e9c)
- Check if you need to set `branch_aports=master` initially if the stable
branch does not exist yet.
- [ ] `git push`
#### pmaports: update os-release / remove packages / aportgen
- [ ] `git checkout vYY.MM`
- [ ] Update `postmarketos-base`:
- [ ] Set version info for `/usr/lib/os-release` in
`main/postmarketos-base/rootfs-usr-lib-os-release`
(`PRETTY_NAME="postmarketOS vYY.MM"`, `VERSION_ID="vYY.MM"`,
`VERSION="vYY.MM"`)
- `pmbootstrap pkgrel_bump postmarketos-base`
- `pmbootstrap config mirrors.pmaports none`
- `pmbootstrap config mirrors.systemd none`
- `pmbootstrap checksum postmarketos-base`
- `git commit -s` (`Remove packages that we don't have in stable`)
- [ ] Remove packages:
- `cross/*-armhf` and other unsupported arches in cross dir (keep `gcc-x86` and `musl-dev-x86`, `systemd-boot-x86`)
- `gcc4*` and `gcc6*` from main and cross dirs
- `device/downstream`, `device/archived`
- `extra-repos/systemd/postmarketos-repo-nightly`
- [ ] Run `pmbootstrap aportgen` for packages in cross:
- `cd cross; PMB_APK_FORCE_MISSING_REPOSITORIES=1 pmbootstrap aportgen musl-* grub-efi-x86`
- `git commit -s` (`cross: regenerate for vYY.MM`)
- [ ] `git push`
#### bpo: adjust config
- [ ] Add the branch to the
[build.postmarketos.org](https://gitlab.postmarketos.org/postmarketOS/build.postmarketos.org)
config in `bpo/config/const/__init__.py:branches` below `branches["main"]`,
so it builds with lower priority than main until it's released. Set `ignore_errors` to `True`.
- [ ] Make a merge request, wait until CI passes, merge it (or if you can directly push to main that's also fine since it's a trivial change)
- [ ] Roll it out/ask somebody who can do that
- [ ] Restart bpo, it will start building `x86_64` packages
#### Bootstrap of binary packages
- [ ] Fix all failing `x86_64` packages (Remember: patches need to go through
edge first, then get backported to the stable branch!)
- Try to get build fixes merged to edge quickly, ask for reviews in
#postmarketos-devel, and consider merging trivial fixes right after they
pass CI.
- Devices in testing and archived categories that don't build: consider
trying to fix them, or just delete them from the branch
- [ ] Wait until all packages for `x86_64` (main repository, we don't need to
wait for the systemd repository before continuing) are built and
published
- [ ] Enable arm repositories in the BPO config
- [ ] Get all packages to build without errors
#### Wallpaper poll
- [ ] Team meeting: make a short list of 4 wallpapers from [the
pool](https://gitlab.postmarketos.org/postmarketOS/artwork/-/tree/main/wallpapers/2024)
- [ ] Make a poll on the wallpapers on mastodon
([example](https://fosstodon.org/@postmarketOS/113624366198561582))
- Make sure to thank the wallpaper authors (usually dikasp) for the amazing
work on the wallpapers
- Put the names of the wallpapers on top of the wallpapers for easier voting
and as alt text
- Create a comment with poll options
#### Adjust CI
- [ ] Make sure pmaports.git CI runs through on the new branch (run
`pmbootstrap ci`). Examples of why it might fail:
- One postmarketos-ui package has a package from alpine testing in their
_pmb_recommends.
- Remove the UI if it is not used much (can bring it back on demand) or
fork the package to the new branch
- Consider fixing it in edge, so we don't run into this with the next
release
- [ ] Adjust
[upstream-compat](https://gitlab.postmarketos.org/postmarketOS/continuous-testing/upstream-compat)
to run on the new release and make sure it passes
([example](https://gitlab.postmarketos.org/postmarketOS/continuous-testing/upstream-compat/-/merge_requests/10))
#### Adjust release upgrade script
- [ ] Add the new release to `upgrade.sh` in [postmarketos-release-upgrade](https://gitlab.postmarketos.org/postmarketOS/postmarketos-release-upgrade/)
- [ ] Bump `SCRIPT_VERSION`, tag a new release
- [ ] Package it for edge (make MR), backport it to the new release, but NOT to
the old release yet (otherwise users may upgrade by accident, without
realizing that the new version is not out yet!)
- [ ] Adjust CI of postmarketos-release-upgrade to test the new release too
(`git grep` for the previous release to see what needs to be adjusted)
#### Update the wallpaper
- [ ] Set the wallpaper that won in the poll in edge, backport this change to
the stable release branch
### 2. Branch phase
#### Rebase on main
- [ ] `git checkout vYY.MM`
- [ ] `git rebase -i origin/main`
- [ ] Temporarily enable force-push for the `vYY.MM` branch
- [ ] `git push --force-with-lease`
- [ ] Disable force-push for the `vYY.MM` branch again
#### Update BPO config
- [ ] Update bpo's images config to build images for the new branch for all
devices in community and main
- [ ] bpo: configure the new branch to be not WIP anymore
- [ ] Roll-out bpo changes
#### pmb release done?
- [ ] Ensure that a pmbootstrap release been made with the apk-tools min
version change
#### aports stable branch set?
* [ ] Check if a stable branch exists in `aports` for the new release, and that
it is being used in `channels.cfg` (might still be set to `master` if it
did not exist during the Pre-Branch phase).
### 3. Test phase
- [ ] Create an issue in pmaports with a checklist of devices and UIs in main
and community (see previous issue for reference)
- Tag the testers of each device and UI
- Ask to verify that the images work as expected
- Release upgrade script: when coming from the previous release, grab it from
main: `wget https://gitlab.postmarketos.org/postmarketOS/postmarketos-release-upgrade/-/raw/main/upgrade.sh`
- [ ] Announce the new phase in the testing chat - and ask them to do the
testing within one week, as in the timeline.
- Prioritize merging fixes from maintainers (they do the heavy lifting in the
testing and fixing phase, see timetable)
- Make sure to properly cherry pick fixes from MRs to edge, if they are
intended for the upcoming release
- [ ] Add new version to the pmaports gitlab issue template (.gitlab dir)
### 4. Release phase
- [ ] Did a reasonable amount of devices get tested? (we may consider dropping
devices that were not tested)
- [ ] Make sure all fixes are in
- [ ] Make sure new images are generated *with* the fixes (unless it's a fix
for something that doesn't impact the experience much and is fine to get with
the first update after installing)
- [ ] Announce the new phase in the testing chat, together with the planned
date of blog post release (and testing)
#### Write blog post
- [ ] Write a blog post for the new release in `postmarketos.org.git`:
- Look at the previous release blog post and try to make the new one
consistent with it
- Highlight major changes since the last release
(see the release notes issue)
- Mention new devices, and total list of devices
- Count devices that have their own wiki page as separate device
- E.g. OnePlus 6, 6T are two devices (two wiki pages), but variants of
"Samsung Galaxy A3 (2015)" are one device (one wiki page)
- Don't count/list devices for which we don't build images (e.g.
qemu-amd64)
- Adjust the homepage config to point to the new release in the downloads
page
- update `config/download.py`:
- `latest_release`
- update devices and categories. only list the ones where we actually build images.
- Add some cool photos
- Submit the blog post as MR to postmarketos.org.git.
- Let the blog post MR close the current release notes issue.
- Ask for reviews.
#### Release!
- [ ] Backport the new postmarketos-release-upgrade version that allows
upgrading to the new release, to the previous release (don't do this before
the release is tested and ready! During the testing phase, we can use
postmarketos-release-upgrade from main directly: `wget
https://gitlab.postmarketos.org/postmarketOS/postmarketos-release-upgrade/-/raw/main/upgrade.sh`)
- [ ] Add the branch to pkgs.postmarketos.org
- [ ] Merge the blog post
- [ ] Edit channels.cfg, change descriptions:
- New release: "Latest release / Recommended for best stability"
- Old release: "Old release (supported until YYYY-MM-DD)" (one month from date of the release)
- [ ] Create a milestone for the next release
- [ ] Create an issue for the next release notes and attach it to that milestone
- [ ] Update the [Releases](https://docs.postmarketos.org/pmaports/main/releases.html) page
- Move the new release to the list of active releases, link to the blog post
- Update the announcement and title for the release
- Add a new upcoming release below
- [ ] Update [Template:Latest stable release](https://wiki.postmarketos.org/wiki/Template:Latest_stable_release) on the wiki with the new version
- [ ] Update "Default description template for issues" in pmaports (.gitlab dir)
- In "On what postmarketOS version did you encounter the issue?", change:
- previous release: add " (supported until YYYY-MM-DD)"
- add the new release
- [ ] Put a reminder in recurring-admin-tasks to drop support for the old release
-7
View File
@@ -1,7 +0,0 @@
Casey Connolly <casey.connolly@linaro.org> <caleb.connolly@linaro.org>
Casey Connolly <kcxt@postmarketos.org> <caleb@postmarketos.org>
Achill Gilgenast <achill@achill.org> <fossdd@pwned.life>
Aelin <aelin@postmarketos.org> <adrian@postmarketos.org>
Aelin <aelin@postmarketos.org> <adrian@travitia.xyz>
Stefan Hansson <newbyte@postmarketos.org> <newbie13xd@gmail.com>
Stefan Hansson <newbyte@postmarketos.org> <newbyte@postmarketos.org>
+14
View File
@@ -0,0 +1,14 @@
{
"subject_format": {
"pass": [
"^(([a-z]+\\/[a-z\\-0-9*{}]+),?)+: [A-Za-z\\/\\-0-9*{}\\(\\)\\.,_&:=' ]+( \\(MR \\d+\\)|)$",
"^CI: [a-z-0-9*{}\\(\\)\\.,_ ][A-Za-z\\/\\-0-9*{}\\(\\)\\.,_ ]+( \\(MR \\d+\\)|)$",
"^mrhlpr.json: [a-z-0-9*{}\\(\\)\\.,_ ][A-Za-z\\/\\-0-9*{}\\(\\)\\.,_ ]+( \\(MR \\d+\\)|)$",
"^pmaports.cfg: [a-z-0-9*{}\\(\\)\\.,_ ][A-Za-z\\/\\-0-9*{}\\(\\)\\.,_ ]+( \\(MR \\d+\\)|)$"
],
"unknown": [
"^[a-z-0-9_.*{}\\/]+: [a-z-0-9*{}\\(\\)\\.,_ ][A-Za-z\\/\\-0-9*{}\\(\\)\\.,_ ]+( \\(MR \\d+\\)|)$"
]
}
}
-1
View File
@@ -1 +0,0 @@
https://postmarketos.org/funding.json
+143
View File
@@ -0,0 +1,143 @@
# https://docs.gitlab.com/ee/user/project/code_owners.html
# Put groups like @sdm845-mainline into test_device.py:gitlab_groups.
# Order lines alphabetically!
device/*/*-amlogic-s905*/ @funderscore
device/*/*-arrow-db410c/ @Minecrell
device/*/*-asus-me176c/ @Minecrell
device/*/*-ayn-odin/ @jenneron
device/*/*-bq-paella/ @Minecrell
device/*/*-bq-tenshi/ @fossdd
device/*/*-google-gru/ @jenneron
device/*/*-google-kukui/ @jenneron @binarycraft
device/*/*-google-oak/ @jenneron @adamthiede
device/*/*-google-trogdor/ @jenneron
device/*/*-google-veyron/ @jenneron
device/*/*-google-x64cros/ @jenneron @JustSoup321 @alpernebbi
device/*/*-htc-golfu/ @Newbyte
device/*/*-htc-m8qlul/ @Newbyte
device/*/*-kobo-clara/ @akemnade
device/*/*-lenovo-21bx/ @craftyguy @jane400
device/*/*-lenovo-a6000/ @jenneron @Minecrell
device/*/*-lenovo-a6010/ @jenneron @Minecrell
device/*/*-librecomputer-lafrite/ @funderscore
device/*/*-librecomputer-lepotato/ @funderscore
device/*/*-librecomputer-solitude/ @Newbyte @funderscore
device/*/*-motorola-harpia/ @Minecrell
device/*/*-nokia-n900/ @sicelo @Danct12
device/*/*-pine64-pinebookpro/ @QC8086
device/*/*-pine64-pinephone/ @craftyguy @milesalan @proycon @anjandev @StacyHarper @Arnavion @PsychoGame
device/*/*-pine64-pinephonepro/ @PsychoGame
device/*/*-pine64-rockpro64/ @PureTryOut
device/*/*-purism-librem5/ @craftyguy @alistair23 @Newbyte
device/*/*-qcom-msm8916/ @Minecrell @TravMurav
device/*/*-qcom-sdm670/ @flamingradian
device/*/*-qcom-sdm845/ @sdm845-mainline
device/*/*-qcom-sm6350/ @z3ntu
device/*/*-samsung-a3/ @Mis012 @TravMurav @Minecrell
device/*/*-samsung-a5/ @Minecrell @minlexx
device/*/*-samsung-e7/ @wonderfulShrineMaidenOfParadise
device/*/*-samsung-espresso10/ @MightyM17
device/*/*-samsung-espresso7/ @MightyM17 @antoni.aloytorrens
device/*/*-samsung-grandmax/ @wonderfulShrineMaidenOfParadise
device/*/*-samsung-gt510/ @TravMurav
device/*/*-samsung-gt58/ @TravMurav
device/*/*-samsung-j5/ @wonderfulShrineMaidenOfParadise
device/*/*-samsung-j5x/ @wonderfulShrineMaidenOfParadise
device/*/*-samsung-serranove/ @Minecrell
device/*/*-tolino-shine2hd/ @akemnade
device/*/*-videostrong-kii-pro/ @funderscore
device/*/*-wileyfox-crackling/ @TravMurav @Minecrell
device/*/*-xiaomi-beryllium/ @joelselvaraj
device/*/*-xiaomi-daisy/ @joelselvaraj @alikates
device/*/*-xiaomi-markw/ @vipaoL
device/*/*-xiaomi-mido/ @barni2000
device/*/*-xiaomi-scorpio/ @Tooniis
device/*/*-xiaomi-tissot/ @jiaxyga @barni2000
device/*/*-xiaomi-vince/ @M0Rf30
device/*/*-xiaomi-wt88047/ @Minecrell
device/*/*-xiaomi-ysl/ @barni2000
device/*/alsa-ucm-conf-cros/ @WeirdTreeThing
device/*/alsa-ucm-conf-qcom-sdm670/ @flamingradian
device/*/device-fairphone-*/ @z3ntu
device/*/device-generic-x86_64/ @craftyguy @ollieparanoid
device/*/device-google-nyan-big/ @jenneron
device/*/device-google-nyan-blaze/ @jenneron
device/*/device-google-peach-pi/ @jenneron
device/*/device-google-peach-pit/ @jenneron
device/*/device-google-sargo/ @flamingradian
device/*/device-google-snow/ @jenneron
device/*/device-huawei-plank/ @gtrxAC
device/*/device-lg-judyln/ @Newbyte
device/*/device-lg-judyp/ @jenneron
device/*/device-microsoft-surface-rt/ @jenneron @jethrob
device/*/device-nvidia-tegra-armv7/ @clamor-s @okias @mschwalm @nokun
device/*/device-odroid-xu4/ @Grimler
device/*/device-oneplus-enchilada/ @calebccff
device/*/device-oneplus-fajita/ @calebccff
device/*/device-postmarketos-trailblazer/ @calebccff
device/*/device-qcom-msm8909/ @wonderfulShrineMaidenOfParadise
device/*/device-qemu-aarch64/ @Minecrell @ollieparanoid
device/*/device-qemu-amd64/ @Minecrell @ollieparanoid
device/*/device-qemu-riscv64/ @Minecrell @z3ntu
device/*/device-qualcomm-sdm845/ @calebccff
device/*/device-raspberry-pi3/ @fossdd
device/*/device-samsung-chagallwifi/ @Grimler
device/*/device-samsung-coreprimevelte/ @legolivesmatter @balejk
device/*/device-samsung-j5y17lte/ @andrisas
device/*/device-samsung-klimtlte/ @Grimler
device/*/device-samsung-lt01/ @knuxify
device/*/device-samsung-m0/ @Newbyte
device/*/device-samsung-manta/ @jenneron @alexmrqt
device/*/device-shift-axolotl/ @amartinz @calebccff @dylanvanassche
device/*/device-solidrun-cubox/ @longnoserob
device/*/firmware-google-sargo/ @flamingradian
device/*/firmware-google-veyron-brcm/ @jenneron
device/*/firmware-odroid-xu4/ @Grimler
device/*/firmware-oneplus-sdm845/ @calebccff
device/*/firmware-powervr-gx6250/ @jenneron
device/*/kobo-epdc-extractor/ @akemnade
device/*/linux-google-nyan/ @jenneron
device/*/linux-google-veyron/ @jenneron
device/*/linux-huawei-plank/ @gtrxAC
device/*/linux-next/ @calebccff
device/*/linux-postmarketos-allwinner/ @Arnavion @PsychoGame
device/*/linux-postmarketos-amlogic/ @funderscore @exkc
device/*/linux-postmarketos-exynos4/ @Newbyte @Grimler @knuxify
device/*/linux-postmarketos-exynos5/ @jenneron @Grimler
device/*/linux-postmarketos-grate/ @clamor-s @jenneron @jethrob
device/*/linux-postmarketos-imx-ereader/ @akemnade
device/*/linux-postmarketos-marvell-dove/ @longnoserob
device/*/linux-postmarketos-mediatek-mt8173/ @jenneron @adamthiede
device/*/linux-postmarketos-mediatek-mt8183/ @jenneron @binarycraft
device/*/linux-postmarketos-omap/ @MightyM17 @Sicelo
device/*/linux-postmarketos-qcom-msm8939/ @Newbyte
device/*/linux-postmarketos-qcom-msm8953/ @M0Rf30 @Ultra-azu @barni2000
device/*/linux-postmarketos-qcom-msm8996/ @Tooniis
device/*/linux-postmarketos-qcom-sc7180/ @jenneron
device/*/linux-postmarketos-rockchip/ @QC8086
device/*/linux-postmarketos-stericsson/ @Newbyte
device/*/linux-samsung-chagallwifi/ @Grimler
device/*/linux-samsung-coreprimevelte/ @legolivesmatter @balejk
device/*/linux-samsung-j5y17lte/ @andrisas
device/*/linux-samsung-klimtlte/ @Grimler
device/*/oem-amd/ @craftyguy
device/*/oem-intel/ @craftyguy
device/*/oem-nvidia/ @craftyguy
device/*/soc-mediatek-mt8183/ @jenneron
device/*/soc-qcom-msm8953/ @barni2000
device/*/soc-qcom-msm8996/ @Tooniis
device/*/soc-qcom-sc7180/ @jenneron
device/*/soc-rockchip-rk3399/ @jenneron
device/*/soc-samsung-exynos4412/ @Newbyte
device/*/u-boot-librem5/ @craftyguy @alistair23 @Newbyte
device/*/u-boot-pinebookpro/ @QC8086
device/*/u-boot-pinephone/ @Arnavion @PsychoGame
device/*/wl1251-cal/ @Danct12
main/postmarketos*gnome*/ @pabloyoyoista @Newbyte
main/postmarketos-initramfs/ @calebccff @craftyguy
main/postmarketos-ui-i3wm/ @fossdd
main/postmarketos-ui-phosh/ @pabloyoyoista @Newbyte
main/postmarketos-ui-plasma-mobile/ @PureTryOut
main/shutdown-clear-rtc-wakealarm/ @Arnavion
main/ttyescape/ @calebccff
+9 -22
View File
@@ -1,4 +1,4 @@
# Commit Style
# Policy for commits in pmaports
This document defines policy for organising and titling commits for
inclusion in pmaports.
@@ -16,9 +16,9 @@ target device.
## General policy
We follow
[Alpine's aports commit style](https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/COMMITSTYLE.md)
with some minor exceptions and additions.
We follow Alpine's aports commit style with some minor exceptions
and additions. Alpine's commit style can be found here:
https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/COMMITSTYLE.md
## Exceptions
@@ -31,29 +31,16 @@ subfolders of the device directory. As such, commits changing
packages inside of the device directory should omit the directory
prefix, for example:
device-pine64-pinephone: description of change
device-pine64-pinephone: description of change
Or:
soc-qcom-msm8996: description of change
soc-qcom-msm8996: description of change
If the commit only makes device-specific changes, the
commit title can opt to use the following format:
manufacturer-codename: description of change
### Changes to packages inside of the systemd directory
We also shorten the prefixes for packages in `extra-repos/systemd`.
When the `systemd` package itself gets changed, use `systemd: ` as
prefix. For example:
systemd: add triggers for reloading/restarting services
When another package inside the systemd directory gets changed, use
`systemd/$pkgname: ` as prefix. For example:
systemd/cups: restart on upgrade
manufacturer-codename: description of change
### Moving devices between categories
@@ -61,11 +48,11 @@ As we do not include directory prefixes in device-related commits,
Alpine's commit style for moving packages does not apply. Instead,
we do the following:
manufacturer-codename: move from category to category
manufacturer-codename: move from category to category
For example:
samsung-m0: move from testing to community
samsung-m0: move from testing to community
## Additions
+2 -18
View File
@@ -1,25 +1,9 @@
# postmarketOS aports repository
This repository contains the APKBUILD files for postmarketOS-specific packages, along with the required patches and scripts, if any.
There are many more packages defined in the [Alpine Linux aports](https://gitlab.alpinelinux.org/alpine/aports/) on which these packages depend.
# postmarketOS aports
Helpful resources:
* [Issues](https://gitlab.postmarketos.org/postmarketOS/pmaports/-/work_items)
* [How to create a package](https://wiki.postmarketos.org/wiki/Create_a_package)
* [APKBUILD reference](https://wiki.alpinelinux.org/wiki/APKBUILD_Reference)
* [pmaports commit style](./COMMITSTYLE.md)
* [Approval rules](docs/merge-requests/approval-rules.md)
* [Alpine Linux aports](https://gitlab.alpinelinux.org/alpine/aports/)
* [Alpine Linux package search](https://pkgs.alpinelinux.org/packages)
* [postmarketOS package search](https://pkgs.postmarketos.org/packages)
## Git Hooks
You can find some useful git hooks in the `.githooks` directory.
To use them, run the following command after cloning this repository:
```sh
git config --local core.hooksPath .githooks
```
* [postmarketOS commit style](./COMMITSTYLE.md)
+2 -26
View File
@@ -4,36 +4,12 @@ recommended=edge
[edge]
description=Rolling release / Most devices / Occasional breakage: https://postmarketos.org/edge
branch_pmaports=main
branch_pmaports=master
branch_aports=master
mirrordir_alpine=edge
[v26.06]
description=Upcoming stable release (DO NOT USE)
branch_pmaports=v26.06
branch_aports=3.24-stable
mirrordir_alpine=v3.24
[v25.12]
description=Latest release / Recommended for best stability
branch_pmaports=v25.12
branch_aports=3.23-stable
mirrordir_alpine=v3.23
[v25.06]
description=Old release (unsupported)
branch_pmaports=v25.06
branch_aports=3.22-stable
mirrordir_alpine=v3.22
[v24.12]
description=Old release (unsupported)
branch_pmaports=v24.12
branch_aports=3.21-stable
mirrordir_alpine=v3.21
[v24.06]
description=Old release (unsupported)
description=Latest release / Recommended for best stability
branch_pmaports=v24.06
branch_aports=3.20-stable
mirrordir_alpine=v3.20
-21
View File
@@ -1,21 +0,0 @@
cross-gcc-tests:
extends: .package-test
tags: [qemu]
before_script:
- wget "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/main/install_pmbootstrap.sh"
- sh ./install_pmbootstrap.sh
script:
- su pmos -c "pmbootstrap build gcc-aarch64"
- su pmos -c "pmbootstrap build --arch=aarch64 hello-world --force"
- su pmos -c "pmbootstrap build --arch=aarch64 iskey --force"
- su pmos -c "pmbootstrap build --arch=aarch64 pbsplash --force"
- su pmos -c "pmbootstrap build --arch=aarch64 gcc-x86_64"
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- cross/gcc-x86_64/APKBUILD
artifacts:
when: always
paths:
- log.txt
expire_in: 1 week
+43
View File
@@ -0,0 +1,43 @@
# This package gets installed in the native and foreign arch chroots.
# It creates files like /usr/lib/arch-bin-masquerade/armhf/gcc, which
# point in the native chroot to the armhf-cross-compiler, and in the
# armhf chroot to /usr/bin/gcc. That way compilation works fine, even
# when distcc gets the absolute path to the compiler passed (ccache does
# that).
pkgname=arch-bin-masquerade
pkgver=2
pkgrel=0
pkgdesc="Wrappers for ccache + distcc (native and foreign chroots)"
url="https://postmarketOS.org"
arch="all"
license="MIT"
options="!check !tracedeps pmb:cross-native"
package() {
# Architectures and binaries
_archs="x86_64 armhf armv7 aarch64"
_bins="c++ cc cpp g++ gcc"
# Iterate over architectures
for _arch in $_archs; do
# Create the arch-specific bin folder
_hostspec="$(arch_to_hostspec $_arch)"
_bindir="$pkgdir/usr/lib/arch-bin-masquerade/$_arch"
mkdir -p "$_bindir"
cd "$_bindir"
# Iterate over binaries and create wrappers
for _bin in $_bins; do
{
echo "#!/bin/sh"
if [ "$_arch" == "$CARCH" ]; then
echo "exec /usr/bin/${_bin} \"\$@\""
else
echo "exec /usr/bin/${_hostspec}-${_bin} \"\$@\""
fi
} > "$_bin"
chmod +x "$_bin"
done
done
}
+36
View File
@@ -0,0 +1,36 @@
# Automatically generated aport, do not edit!
# Generator: pmbootstrap aportgen busybox-static-aarch64
# Stub for apkbuild-lint
if [ -z "$(type -t arch_to_hostspec)" ]; then
arch_to_hostspec() { :; }
fi
pkgname=busybox-static-aarch64
pkgver=1.37.0
pkgrel=7
_arch="aarch64"
_mirror="http://dl-4.alpinelinux.org/alpine/"
url="http://busybox.net"
license="GPL2"
arch="x86_64"
options="!check !strip"
pkgdesc="Statically linked Busybox for $_arch"
_target="$(arch_to_hostspec $_arch)"
source="
busybox-static-$pkgver-r$pkgrel-$_arch-edge.apk::$_mirror/edge/main/$_arch/busybox-static-$pkgver-r$pkgrel.apk
"
package() {
mkdir -p "$pkgdir/usr/$_target"
cd "$pkgdir/usr/$_target"
tar -xf $srcdir/busybox-static-$pkgver-r$pkgrel-$_arch-edge.apk
rm .PKGINFO .SIGN.*
}
sha512sums="
9d0fd2ad11f7b2f9fbb3d5e71a2a7f113187648f61c269bee7b6b7ef0976d181d6a7588638382415b7eb2cc3934d0ef62080d4462acfc97c4c7b056003d333d4 busybox-static-1.37.0-r7-aarch64-edge.apk
"
+36
View File
@@ -0,0 +1,36 @@
# Automatically generated aport, do not edit!
# Generator: pmbootstrap aportgen busybox-static-armhf
# Stub for apkbuild-lint
if [ -z "$(type -t arch_to_hostspec)" ]; then
arch_to_hostspec() { :; }
fi
pkgname=busybox-static-armhf
pkgver=1.37.0
pkgrel=7
_arch="armhf"
_mirror="http://dl-4.alpinelinux.org/alpine/"
url="http://busybox.net"
license="GPL2"
arch="x86_64"
options="!check !strip"
pkgdesc="Statically linked Busybox for $_arch"
_target="$(arch_to_hostspec $_arch)"
source="
busybox-static-$pkgver-r$pkgrel-$_arch-edge.apk::$_mirror/edge/main/$_arch/busybox-static-$pkgver-r$pkgrel.apk
"
package() {
mkdir -p "$pkgdir/usr/$_target"
cd "$pkgdir/usr/$_target"
tar -xf $srcdir/busybox-static-$pkgver-r$pkgrel-$_arch-edge.apk
rm .PKGINFO .SIGN.*
}
sha512sums="
c89807c048cd58a5994c8162685669d0e49752f7284adc427d017355bbfd43f5a686617be42abd2b470c15869225a03f31a6231ee4dbb03fc6b27d6c920b5208 busybox-static-1.37.0-r7-armhf-edge.apk
"
+36
View File
@@ -0,0 +1,36 @@
# Automatically generated aport, do not edit!
# Generator: pmbootstrap aportgen busybox-static-armv7
# Stub for apkbuild-lint
if [ -z "$(type -t arch_to_hostspec)" ]; then
arch_to_hostspec() { :; }
fi
pkgname=busybox-static-armv7
pkgver=1.37.0
pkgrel=7
_arch="armv7"
_mirror="http://dl-4.alpinelinux.org/alpine/"
url="http://busybox.net"
license="GPL2"
arch="x86_64"
options="!check !strip"
pkgdesc="Statically linked Busybox for $_arch"
_target="$(arch_to_hostspec $_arch)"
source="
busybox-static-$pkgver-r$pkgrel-$_arch-edge.apk::$_mirror/edge/main/$_arch/busybox-static-$pkgver-r$pkgrel.apk
"
package() {
mkdir -p "$pkgdir/usr/$_target"
cd "$pkgdir/usr/$_target"
tar -xf $srcdir/busybox-static-$pkgver-r$pkgrel-$_arch-edge.apk
rm .PKGINFO .SIGN.*
}
sha512sums="
56e0b396ced0a0afab2f5b50156b87707e3511a2e24c52c9688a20791fad20f11869b5b06bb6c7d407ffec3e4e06ea3100876e3d32efae678fc5a0fe6b57715a busybox-static-1.37.0-r7-armv7-edge.apk
"
+3 -3
View File
@@ -2,10 +2,10 @@
# compiling packages in the native chroot (e.g. kernel packages), the
# cross-compiler does not get called directly, but wrapped through
# ccache, which can then cache the results.
maintainer=""
pkgname=ccache-cross-symlinks
pkgver=3
pkgrel=3
pkgrel=0
pkgdesc="Enable ccache for cross-compilers with symlinks"
url="https://ccache.samba.org/"
arch="noarch"
@@ -15,7 +15,7 @@ options="!check"
package() {
# Keep in sync with pmb.config.build_device_architectures
local _archs="armhf armv7 aarch64 x86_64 x86 riscv64 ppc64le loongarch64"
local _archs="armhf armv7 aarch64 x86_64 x86"
local _bins="c++ cc cpp g++ gcc clang clang++"
mkdir -p "$pkgdir/usr/lib/ccache/bin"
+17 -63
View File
@@ -1,4 +1,5 @@
# https://docs.postmarketos.org/pmbootstrap/cross_compiling.html
# Maintainer: Oliver Smith <ollieparanoid@postmarketos.org>
# https://wiki.postmarketos.org/wiki/Pmbootstrap:_Cross_Compiling
#
# Wrapper for the "crossdirect" compilation method.
# pmbootstrap mounts the native chroot in the foreign arch (e.g. armhf) chroot
@@ -11,33 +12,26 @@
# -> /native/usr/bin/rustc --target=armv6-alpine-linux-musleabihf ...
#
# When building packages in the armhf chroot, PATH will get prepended with
# "/native/usr/lib/crossdirect/armhf". The end game is of course invoking
# programs such as cross compilers and archivers from the native chroot,
# running at native speed, whenever they get called from the foreign arch
# chroot. See crossdirect.c for implementation details of the C version (llvm,
# fakeroot, rpath). The rust version and redirect for archivers are implemented
# as simple shell wrappers.
maintainer="Oliver Smith <ollieparanoid@postmarketos.org>"
# "/native/usr/lib/crossdirect/armhf". The end game is of course invoking the
# cross compiler from the native chroot, running at native speed, whenever
# calling the compiler from the foreign arch chroot. See crossdirect.c for
# implementation details of the C version (llvm, fakeroot, rpath). The rust
# version is implemented as simple shell wrappers.
pkgname=crossdirect
pkgver=5.3.1
pkgrel=1
pkgdesc="Wrappers to launch native programs (e.g. cross compilers) in foreign chroots"
pkgver=5.2.0
pkgrel=0
pkgdesc="Wrappers to launch native cross compilers in foreign chroots"
url="https://postmarketOS.org"
arch="all"
license="MIT"
options="!check"
source="
cargo.sh
crossdirect.c
exec_native.sh
rust-qemu-linker.sh
rustc.sh
"
source="cargo.sh crossdirect.c rustc.sh rust-qemu-linker.sh"
build() {
cd "$srcdir"
# Architectures and binaries
_archs="x86_64 armhf armv7 aarch64 loongarch64 ppc64le riscv64"
_archs="x86_64 armhf armv7 aarch64"
for _arch in $_archs; do
[ "$_arch" == "$CARCH" ] && continue
_hostspec="$(arch_to_hostspec $_arch)"
@@ -54,38 +48,8 @@ build() {
package() {
# Architectures and binaries
_archs="
aarch64
armhf
armv7
loongarch64
ppc64le
riscv64
x86_64
"
_bin_compilers="
c++
cc
clang
clang++
cpp
g++
gcc
"
_bin_archivers="
bzip2
gunzip
gzip
lzip
lzma
lzop
pigz
unlzma
unpigz
unxz
unzip
xz
"
_archs="x86_64 armhf armv7 aarch64"
_bins="c++ cc cpp g++ gcc clang clang++"
# Rust wrappers
install -Dm755 "$srcdir/rust-qemu-linker.sh" \
@@ -93,9 +57,6 @@ package() {
install -Dm755 "$srcdir/cargo.sh" "$pkgdir/usr/lib/crossdirect/cargo.sh"
install -Dm755 "$srcdir/rustc.sh" "$pkgdir/usr/lib/crossdirect/rustc.sh"
# For archivers
install -Dm755 "$srcdir/exec_native.sh" -t "$pkgdir/usr/lib/crossdirect/"
# Iterate over architectures
for _arch in $_archs; do
[ "$_arch" == "$CARCH" ] && continue
@@ -109,17 +70,11 @@ package() {
cp "$srcdir/crossdirect-$_arch" "./"
# GCC: create compiler symlinks
for _bin in $_bin_compilers; do
for _bin in $_bins; do
ln -s "crossdirect-$_arch" "$_bin"
ln -s "crossdirect-$_arch" "$_hostspec-$_bin"
done
# Archivers
for _bin in $_bin_archivers; do
ln -s ../exec_native.sh "$_bin"
done
# Rust
ln -s ../cargo.sh cargo
ln -s ../rustc.sh rustc
done
@@ -128,7 +83,6 @@ package() {
sha512sums="
0f4b48f250425dc57f63955fc8b38477d23db793bee367c3fbe03c3d2a559ba576434d07518310db4cae9d90d501af4051b80038b10fae94b980e537fc9374ad cargo.sh
b2e602b7fc95ed403d29f0d754879d5f773c39ee33e726bb10cff17b3c088406dac84f2ca6d8ad563c64370007d98af805d6ee9cd4a06fe3d4c61c0cb90c5c0c crossdirect.c
73e2b5d2d8ef7c6002b3a787d14945586991493b8d81f59e5c0beda0d3b290543e1fdc6f288da726c5dd121c0861d2a894410b7b749a537df0df5b409e102330 exec_native.sh
ea9bf8db3810d03d0a7395057f3d6e57f7127d87c55deaedc171c255288f5f3cc6fbcc680a5a1b92786cf573875d5dc22521173799fe2639acc97d0715ff905b rust-qemu-linker.sh
de2aa6929bbff5db9132673e667f4525b333d062cb1f7a0597dd924de9e5c7215a9f8e2e6263b6fb5ace06f2c4b64f4ebfd0ede9b78add07c2cd08ec8613e98f rustc.sh
ea9bf8db3810d03d0a7395057f3d6e57f7127d87c55deaedc171c255288f5f3cc6fbcc680a5a1b92786cf573875d5dc22521173799fe2639acc97d0715ff905b rust-qemu-linker.sh
"
-27
View File
@@ -1,27 +0,0 @@
#!/bin/sh -e
# Execute the binary from the native chroot if it is installed there. This is
# done for archiver tools such as unxz, so they don't need to go through QEMU.
BASENAME="$(basename "$0")"
if [ -n "$LD_PRELOAD" ]; then
# The archiver tool gets called during package(), which abuild runs
# with libfakeroot.so. Some packages do this, like bootchart2, which
# compresses man pages in its "make install". We can't run the native
# binary here due to the LD_PRELOAD, so run the foreign arch one.
export PATH="/usr/bin:/usr/sbin:/sbin:/bin"
exec "$BASENAME" "$@"
fi
# Try /native first, then the foreign arch paths. Never try
# /native/usr/lib/crossdirect as this would result in a loop.
UNWRAPPED_PATH="/native/usr/bin:/native/usr/sbin:/native/sbin:/native/bin:/usr/bin:/usr/sbin:/sbin:/bin"
UNWRAPPED_BIN="$(PATH="$UNWRAPPED_PATH" command -v "$BASENAME")"
case "$UNWRAPPED_BIN" in
/native/*)
export LD_LIBRARY_PATH="/native/usr/lib:/native/lib"
export PATH="$UNWRAPPED_PATH"
;;
esac
exec "$UNWRAPPED_BIN" "$@"
@@ -1,130 +0,0 @@
From 824eae920f0f64dd7687c969a2436b129161fdc9 Mon Sep 17 00:00:00 2001
From: Jinyang He <hejinyang@loongson.cn>
Date: Wed, 29 Oct 2025 16:07:35 +0800
Subject: [PATCH] LoongArch: Only allow valid binary op when optimize
conditional move
It is wrong that optimize from `if (cond) dest op= 1 << shift` to
`dest op= (cond ? 1 : 0) << shift` when `dest op 0 != dest`.
Like `and`, `mul` or `div`.
And in this optimization `mul` and `div` is optimized to shift.
gcc/ChangeLog:
* config/loongarch/loongarch.cc
(loongarch_expand_conditional_move): Only allow valid binary
op when optimize conditional move.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/conditional-move-opt-1.c: Remove mul.
* gcc.target/loongarch/conditional-move-opt-2.c: Remove and.
* gcc.target/loongarch/conditional-move-opt-3.c: New test.
Co-Authored-By: Peng Fan <fanpeng@loongson.cn>
---
gcc/config/loongarch/loongarch.cc | 26 ++++++++++++++++---
.../loongarch/conditional-move-opt-1.c | 4 +--
.../loongarch/conditional-move-opt-2.c | 2 +-
.../loongarch/conditional-move-opt-3.c | 14 ++++++++++
4 files changed, 40 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/loongarch/conditional-move-opt-3.c
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index bdf290654..740c8611a 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -5533,12 +5533,32 @@ loongarch_expand_conditional_move (rtx *operands)
}
}
+ auto is_binary_op_0_keep_orig = [](enum rtx_code code)
+ {
+ switch (code)
+ {
+ case PLUS:
+ case MINUS:
+ case IOR:
+ case XOR:
+ case ROTATE:
+ case ROTATERT:
+ case ASHIFT:
+ case ASHIFTRT:
+ case LSHIFTRT:
+ return true;
+ default:
+ return false;
+ }
+ };
+
/* Check if the optimization conditions are met. */
if (value_if_true_insn
&& value_if_false_insn
- /* Make sure that value_if_false and var are the same. */
- && BINARY_P (value_if_true_insn_src
- = SET_SRC (single_set (value_if_true_insn)))
+ /* Make sure that the orig value OP 0 keep orig. */
+ && (value_if_true_insn_src
+ = SET_SRC (single_set (value_if_true_insn)))
+ && is_binary_op_0_keep_orig ( GET_CODE (value_if_true_insn_src))
/* Make sure that both value_if_true and value_if_false
has the same var. */
&& rtx_equal_p (XEXP (value_if_true_insn_src, 0),
diff --git a/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-1.c b/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-1.c
index ed13471aa..47802aa96 100644
--- a/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-1.c
+++ b/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-1.c
@@ -27,7 +27,7 @@ void
test_lt ()
{
if (lm < ln)
- lr *= (1 << 16);
+ lr += (1 << 16);
lr += lm;
}
@@ -35,7 +35,7 @@ void
test_le ()
{
if (lm <= ln)
- lr = lm * ((long)1 << 32);
+ lr = lm + ((long)1 << 32);
else
lr = lm;
lr += lm;
diff --git a/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-2.c b/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-2.c
index ac72d4d93..743fd5e67 100644
--- a/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-2.c
+++ b/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-2.c
@@ -29,7 +29,7 @@ void
test_lez ()
{
if (lm <= 0)
- lr &= (1 << 16);
+ lr |= (1 << 16);
lr += lm;
}
diff --git a/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-3.c b/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-3.c
new file mode 100644
index 000000000..95887980c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/conditional-move-opt-3.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler "maskeqz" } } */
+/* { dg-final { scan-assembler "masknez" } } */
+
+extern long lm, ln, lr;
+
+void
+test_and ()
+{
+ if (lm < 0)
+ lr &= (1 << 16);
+ lr += lm;
+}
--
2.51.1
+4 -4
View File
@@ -1,14 +1,14 @@
From 94cf7d2b3514ed3a4401861a519ead450e022afc Mon Sep 17 00:00:00 2001
From 47b4bd4deb2c356bb07d2a96f22127aefafec3a4 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Fri, 26 Jan 2018 20:32:50 +0000
Subject: [PATCH] posix_memalign
Subject: [PATCH 01/35] posix_memalign
---
gcc/config/i386/pmm_malloc.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h
index d1d79a32fc9..069c3bb8324 100644
index 3527283693b..c4071b64b53 100644
--- a/gcc/config/i386/pmm_malloc.h
+++ b/gcc/config/i386/pmm_malloc.h
@@ -27,12 +27,13 @@
@@ -38,5 +38,5 @@ index d1d79a32fc9..069c3bb8324 100644
else
return NULL;
--
2.50.1
2.41.0
@@ -1,77 +0,0 @@
From 21b7d08714c4964403848db4144003835ff5245a Mon Sep 17 00:00:00 2001
From: Linsen Zhou <i@lin.moe>
Date: Fri, 17 Oct 2025 11:05:04 +0800
Subject: [PATCH] tree-object-size.cc: Fix assert constant offset in
check_for_plus_in_loops [PR122012]
After commit 51b85dfeb19652bf3e0aaec08828ba7cee1e641c, when the
pointer offset is a variable in the loop, the object size of the
pointer may also need to be reexamined.
Which make gcc_assert in the check_for_plus_in_loops failed.
gcc/ChangeLog:
PR tree-optimization/122012
* tree-object-size.cc (check_for_plus_in_loops): Skip check
for the variable offset
gcc/testsuite/ChangeLog:
PR tree-optimization/122012
* gcc.dg/torture/pr122012.c: New test.
Signed-off-by: Linsen Zhou <i@lin.moe>
(cherry picked from commit 82cefc4898d4ccabe76e28d6626b91ca9e998923)
---
gcc/testsuite/gcc.dg/torture/pr122012.c | 18 ++++++++++++++++++
gcc/tree-object-size.cc | 7 +++----
2 files changed, 21 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr122012.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr122012.c b/gcc/testsuite/gcc.dg/torture/pr122012.c
new file mode 100644
index 00000000000..055915a1e98
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr122012.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+#include <stdlib.h>
+
+void foo();
+
+void test(size_t step) {
+ char *buf = malloc(64);
+ char *p = buf;
+ size_t i;
+
+ for(i = 0; i < 64; ++i) {
+ p += 4;
+ if (__builtin_object_size (p, 2) != 0)
+ foo();
+ p += step;
+ }
+ free(buf);
+}
diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc
index 2d13ab79a84..76dc2446059 100644
--- a/gcc/tree-object-size.cc
+++ b/gcc/tree-object-size.cc
@@ -2153,12 +2153,11 @@ check_for_plus_in_loops (struct object_size_info *osi, tree var)
&& gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR)
{
tree basevar = gimple_assign_rhs1 (stmt);
- tree cst = gimple_assign_rhs2 (stmt);
-
- gcc_assert (TREE_CODE (cst) == INTEGER_CST);
+ tree offset = gimple_assign_rhs2 (stmt);
/* Skip non-positive offsets. */
- if (integer_zerop (cst) || compare_tree_int (cst, offset_limit) > 0)
+ if (TREE_CODE (offset) != INTEGER_CST
+ || integer_zerop (offset) || compare_tree_int (offset, offset_limit) > 0)
return;
osi->depths[SSA_NAME_VERSION (basevar)] = 1;
--
2.51.0
@@ -1,7 +1,7 @@
From 0d5e04099a3d2609105719f7396a4ff941b873b6 Mon Sep 17 00:00:00 2001
From 4fa620d8c3e6730211bfb071eb4c817320491bd0 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 23 Jan 2025 17:12:51 -0800
Subject: [PATCH] gcc: poison-system-directories
Date: Fri, 29 Mar 2013 08:59:00 +0400
Subject: [PATCH 02/35] gcc: poison-system-directories
Add /sw/include and /opt/include based on the original
zecke-no-host-includes.patch patch. The original patch checked for
@@ -11,25 +11,25 @@ aborted.
Instead, we add the two missing items to the current scan. If the user
wants this to be a failure, they can add "-Werror=poison-system-directories".
Upstream-Status: Inappropriate [OE configuration]
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: sunil dora <sunilkumar.dora@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Upstream-Status: Pending
---
gcc/common.opt | 4 ++++
gcc/config.in | 10 ++++++++++
gcc/configure | 19 +++++++++++++++++++
gcc/configure.ac | 16 ++++++++++++++++
gcc/config.in | 6 ++++++
gcc/configure | 16 ++++++++++++++++
gcc/configure.ac | 10 ++++++++++
gcc/doc/invoke.texi | 9 +++++++++
gcc/gcc.cc | 12 ++++++++++--
gcc/incpath.cc | 25 +++++++++++++++++++++++++
7 files changed, 93 insertions(+), 2 deletions(-)
gcc/gcc.cc | 2 ++
gcc/incpath.cc | 21 +++++++++++++++++++++
7 files changed, 68 insertions(+)
diff --git a/gcc/common.opt b/gcc/common.opt
index e3fa0dacec4..bea1adc0940 100644
index 862c474d3c8..64c4277c991 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -729,6 +729,10 @@ Wreturn-local-addr
@@ -711,6 +711,10 @@ Wreturn-local-addr
Common Var(warn_return_local_addr) Init(1) Warning
Warn about returning a pointer/reference to a local or temporary variable.
@@ -41,10 +41,10 @@ index e3fa0dacec4..bea1adc0940 100644
Common Var(warn_shadow) Warning
Warn when one variable shadows another. Same as -Wshadow=global.
diff --git a/gcc/config.in b/gcc/config.in
index a79c51adb2b..8a531ed591c 100644
index 4cad077bfbe..0679fbbf4c6 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -249,6 +249,16 @@
@@ -236,6 +236,12 @@
#endif
@@ -52,28 +52,24 @@ index a79c51adb2b..8a531ed591c 100644
+#ifndef USED_FOR_TARGET
+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
+#endif
+/* Define to warn for use of native system header directories */
+#ifndef USED_FOR_TARGET
+#undef POISON_BY_DEFAULT
+#endif
+
+
/* Define if you want all operations on RTL (the basic data structure of the
optimizer and back end) to be checked for dynamic type safety at runtime.
This is quite expensive. */
diff --git a/gcc/configure b/gcc/configure
index 16965953f05..0f4a5d52c30 100755
index c7b26d1927d..8c46369f73f 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -1051,6 +1051,7 @@ enable_maintainer_mode
@@ -1026,6 +1026,7 @@ enable_maintainer_mode
enable_link_mutex
enable_link_serialization
enable_version_specific_runtime_libs
+enable_poison_system_directories
enable_plugin
enable_host_shared
enable_host_pie
@@ -1828,6 +1829,8 @@ Optional Features:
enable_libquadmath_support
@@ -1788,6 +1789,8 @@ Optional Features:
--enable-version-specific-runtime-libs
specify that runtime libraries should be installed
in a compiler-specific directory
@@ -81,8 +77,8 @@ index 16965953f05..0f4a5d52c30 100755
+ warn for use of native system header directories
--enable-plugin enable plugin support
--enable-host-shared build host code as shared libraries
--enable-host-pie build host code as PIE
@@ -34027,6 +34030,22 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
--disable-libquadmath-support
@@ -31753,6 +31756,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
fi
@@ -93,12 +89,9 @@ index 16965953f05..0f4a5d52c30 100755
+ enable_poison_system_directories=no
+fi
+
+if test "x${enable_poison_system_directories}" != "xno"; then
+if test "x${enable_poison_system_directories}" = "xyes"; then
+
+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
+if test "$enable_poison_system_directories" = "error"; then
+$as_echo "#define POISON_BY_DEFAULT 1" >>confdefs.h
+fi
+
+fi
+
@@ -106,47 +99,41 @@ index 16965953f05..0f4a5d52c30 100755
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 9f67e62950a..b0e3615e5aa 100644
index 09082e8ccae..5504bf6eb01 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7502,6 +7502,22 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
@@ -7292,6 +7292,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
[specify that runtime libraries should be
installed in a compiler-specific directory])])
+AC_ARG_ENABLE([poison-system-directories],
+ AS_HELP_STRING([--enable-poison-system-directories],
+ [warn for use of native system header directories (no/yes/error)]),,
+ [warn for use of native system header directories]),,
+ [enable_poison_system_directories=no])
+AC_MSG_NOTICE([poisoned directories $enable_poison_system_directories])
+if test "x${enable_poison_system_directories}" != "xno"; then
+ AC_MSG_NOTICE([poisoned directories enabled])
+if test "x${enable_poison_system_directories}" = "xyes"; then
+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
+ [1],
+ [Define to warn for use of native system header directories])
+ if test $enable_poison_system_directories = "error"; then
+ AC_MSG_NOTICE([poisoned directories are fatal])
+ AC_DEFINE([POISON_BY_DEFAULT], [1], [Define to make poison warnings errors])
+ fi
+fi
+
# Substitute configuration variables
AC_SUBST(subdirs)
AC_SUBST(srcdir)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 72009c33cd0..29aea724731 100644
index af0e5933fdb..b6731a4673c 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -405,6 +405,7 @@ Objective-C and Objective-C++ Dialects}.
@@ -384,6 +384,7 @@ Objective-C and Objective-C++ Dialects}.
-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
-Wparentheses -Wno-pedantic-ms-format
-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
+-Wno-poison-system-directories
-Wno-pragmas -Wno-pragma-once-outside-header -Wno-prio-ctor-dtor
-Wno-psabi
-Wredundant-decls -Wrestrict
@@ -10727,6 +10728,14 @@ an error. @option{Wint-to-pointer-cast} is enabled by default.
Suppress warnings from casts from a pointer to an integer type of a
different size.
-Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls
-Wrestrict -Wno-return-local-addr -Wreturn-type
-Wno-scalar-storage-order -Wsequence-point
@@ -8426,6 +8427,14 @@ made up of data only and thus requires no special treatment. But, for
most targets, it is made up of code and thus requires the stack to be
made executable in order for the program to work properly.
+@opindex Wno-poison-system-directories
+@item -Wno-poison-system-directories
@@ -156,28 +143,15 @@ index 72009c33cd0..29aea724731 100644
+directories contain the correct headers and libraries for the target
+system rather than the host.
+
@opindex Winvalid-pch
@opindex Wno-invalid-pch
@item -Winvalid-pch
@opindex Wfloat-equal
@opindex Wno-float-equal
@item -Wfloat-equal
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 4fd87f2c4a1..79d4920a047 100644
index 16bb07f2cdc..33b56e721d2 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -909,6 +909,12 @@ proper position among the other output files. */
#define ASM_MAP ""
#endif
+#ifdef POISON_BY_DEFAULT
+#define POISON_IS_ERROR " -Werror=poison-system-directories"
+#else
+#define POISON_IS_ERROR
+#endif
+
/* Assembler options for compressed debug sections. */
#if HAVE_LD_COMPRESS_DEBUG == 0
/* Reject if the linker cannot write compressed debug sections. */
@@ -1166,6 +1172,8 @@ proper position among the other output files. */
"%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
@@ -1177,6 +1187,8 @@ proper position among the other output files. */
"-z now " \
"%X %{o*} %{e*} %{N} %{n} %{r}\
%{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
+ %{Wno-poison-system-directories:--no-poison-system-directories} \
@@ -185,26 +159,8 @@ index 4fd87f2c4a1..79d4920a047 100644
%{static|no-pie|static-pie:} %@{L*} %(link_libgcc) " \
VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \
%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
@@ -1268,7 +1276,7 @@ static const char *cpp_options =
"%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
%{f*} %{g*:%{%:debug-level-gt(0):%{g*}\
%{!fno-working-directory:-fworking-directory}}} %{O*}\
- %{undef} %{save-temps*:-fpch-preprocess}";
+ %{undef} %{save-temps*:-fpch-preprocess}" POISON_IS_ERROR;
/* Pass -d* flags, possibly modifying -dumpdir, -dumpbase et al.
@@ -1297,7 +1305,7 @@ static const char *cc1_options =
%{coverage:-fprofile-arcs -ftest-coverage}\
%{fprofile-arcs|fcondition-coverage|fpath-coverage|fprofile-generate*|coverage:\
%{!fprofile-update=single:\
- %{pthread:-fprofile-update=prefer-atomic}}}";
+ %{pthread:-fprofile-update=prefer-atomic}}}" POISON_IS_ERROR;
static const char *asm_options =
"%{-target-help:%:print-asm-header()} "
diff --git a/gcc/incpath.cc b/gcc/incpath.cc
index c1bbfd3872a..2cdbebc4c50 100644
index 4d44321183f..0f3f071b44c 100644
--- a/gcc/incpath.cc
+++ b/gcc/incpath.cc
@@ -26,6 +26,7 @@
@@ -215,20 +171,9 @@ index c1bbfd3872a..2cdbebc4c50 100644
/* Microsoft Windows does not natively support inodes.
VMS has non-numeric inodes. */
@@ -273,6 +274,10 @@ remove_duplicates (cpp_reader *pfile, struct cpp_dir *head,
cur->name, xstrerror (errno));
reason = REASON_NOENT;
}
+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
+ pcur = &cur->next;
+ continue;
+#endif
}
else if (!S_ISDIR (st.st_mode))
cpp_error_with_line (pfile, CPP_DL_WARNING, 0, 0,
@@ -411,6 +416,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
fprintf (stderr, _("End of #embed search list.\n"));
@@ -399,6 +400,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
}
fprintf (stderr, _("End of search list.\n"));
}
+
+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
@@ -237,22 +182,22 @@ index c1bbfd3872a..2cdbebc4c50 100644
+ struct cpp_dir *p;
+
+ for (p = heads[INC_QUOTE]; p; p = p->next)
+ {
+ if ((!strncmp (p->name, "/usr/include", 12))
+ || (!strncmp (p->name, "/usr/local/include", 18))
+ || (!strncmp (p->name, "/usr/X11R6/include", 18))
+ || (!strncmp (p->name, "/sw/include", 11))
+ || (!strncmp (p->name, "/opt/include", 12)))
+ warning (OPT_Wpoison_system_directories,
+ "include location \"%s\" is unsafe for "
+ "cross-compilation",
+ p->name);
+ }
+ {
+ if ((!strncmp (p->name, "/usr/include", 12))
+ || (!strncmp (p->name, "/usr/local/include", 18))
+ || (!strncmp (p->name, "/usr/X11R6/include", 18))
+ || (!strncmp (p->name, "/sw/include", 11))
+ || (!strncmp (p->name, "/opt/include", 12)))
+ warning (OPT_Wpoison_system_directories,
+ "include location \"%s\" is unsafe for "
+ "cross-compilation",
+ p->name);
+ }
+ }
+#endif
}
/* Use given -I paths for #include "..." but not #include <...>, and
--
2.50.1
2.41.0
@@ -1,7 +1,7 @@
From 90e8697dd88fd99ce2cf8739e95494853005377e Mon Sep 17 00:00:00 2001
From ff4dd4ce33133e675b7bedc86b73357c04631cb9 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:45:49 +0000
Subject: [PATCH] specs: turn on -Wl,-z,now by default
Subject: [PATCH 03/35] specs: turn on -Wl,-z,now by default
Previously, we also used to turn on -z relro here, but we now build
binutils with --enable-relro, which is functionally equivalent.
@@ -14,10 +14,10 @@ now by default.
2 files changed, 4 insertions(+)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 29aea724731..6fb3ab70cc7 100644
index b6731a4673c..f393c7846c6 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -19477,6 +19477,9 @@ For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
@@ -17961,6 +17961,9 @@ For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
linker. When using the GNU linker, you can also get the same effect with
@option{-Wl,-Map=output.map}.
@@ -28,10 +28,10 @@ index 29aea724731..6fb3ab70cc7 100644
@item -u @var{symbol}
Pretend the symbol @var{symbol} is undefined, to force linking of
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 79d4920a047..74a356fdf5e 100644
index 33b56e721d2..f82fae23c22 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1170,6 +1170,7 @@ proper position among the other output files. */
@@ -1144,6 +1144,7 @@ proper position among the other output files. */
"%{flto|flto=*:%<fcompare-debug*} \
%{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC \
"%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
@@ -40,5 +40,5 @@ index 79d4920a047..74a356fdf5e 100644
%{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
%{Wno-poison-system-directories:--no-poison-system-directories} \
--
2.50.1
2.41.0
@@ -1,8 +1,8 @@
From 17c9cf9272077bc7ac784daffd4c68ba1ce67a0d Mon Sep 17 00:00:00 2001
From 1b315235433701e4a974da259b8d651169ddc7ac Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:46:22 +0000
Subject: [PATCH] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++, ObjC,
ObjC++, if the optimization level is > 0
Subject: [PATCH 04/35] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++,
ObjC, ObjC++, if the optimization level is > 0
---
gcc/c-family/c-cppbuiltin.cc | 4 ++++
@@ -10,10 +10,10 @@ Subject: [PATCH] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++, ObjC,
2 files changed, 10 insertions(+)
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 4589ee4a3a6..9edf095384c 100644
index 5d64625fcd7..868d69506e4 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1581,6 +1581,10 @@ c_cpp_builtins (cpp_reader *pfile)
@@ -1546,6 +1546,10 @@ c_cpp_builtins (cpp_reader *pfile)
builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);
@@ -25,10 +25,10 @@ index 4589ee4a3a6..9edf095384c 100644
if (flag_gnu89_inline)
cpp_define (pfile, "__GNUC_GNU_INLINE__");
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 6fb3ab70cc7..799ce073dbf 100644
index f393c7846c6..ef3c14a189e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -12840,6 +12840,12 @@ also turns on the following optimization flags:
@@ -11868,6 +11868,12 @@ also turns on the following optimization flags:
Please note the warning under @option{-fgcse} about
invoking @option{-O2} on programs that use computed gotos.
@@ -42,5 +42,5 @@ index 6fb3ab70cc7..799ce073dbf 100644
@item -O3
Optimize yet more. @option{-O3} turns on all optimizations specified
--
2.50.1
2.41.0
@@ -1,8 +1,8 @@
From 95d8fac6247b2cba1142261cc95c21063539112a Mon Sep 17 00:00:00 2001
From 67c0f5789630b27149f60ff831999ef7c1dba5d5 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:46:56 +0000
Subject: [PATCH] On linux targets pass --as-needed by default to the linker,
but always link the sanitizer libraries with --no-as-needed.
Subject: [PATCH 05/35] On linux targets pass --as-needed by default to the
linker, but always link the sanitizer libraries with --no-as-needed.
---
gcc/config/aarch64/aarch64-linux.h | 1 +
@@ -12,7 +12,6 @@ Subject: [PATCH] On linux targets pass --as-needed by default to the linker,
gcc/config/i386/gnu-user.h | 2 +-
gcc/config/i386/gnu-user64.h | 1 +
gcc/config/ia64/linux.h | 2 +-
gcc/config/loongarch/gnu-user.h | 2 +-
gcc/config/mips/gnu-user.h | 1 +
gcc/config/riscv/linux.h | 1 +
gcc/config/rs6000/linux64.h | 4 ++--
@@ -20,13 +19,13 @@ Subject: [PATCH] On linux targets pass --as-needed by default to the linker,
gcc/config/s390/linux.h | 2 +-
gcc/config/sparc/linux.h | 2 +-
gcc/gcc.cc | 28 ++++++++++++++++++++--------
15 files changed, 37 insertions(+), 20 deletions(-)
14 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index 116bb4e69f3..daf99f8dce9 100644
index 4277f03da2a..b131983a546 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -39,6 +39,7 @@
@@ -35,6 +35,7 @@
#define CPP_SPEC "%{pthread:-D_REENTRANT}"
#define LINUX_TARGET_LINK_SPEC "%{h*} \
@@ -35,7 +34,7 @@ index 116bb4e69f3..daf99f8dce9 100644
%{shared:-shared} \
%{symbolic:-Bsymbolic} \
diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h
index 3fd3b831166..0b4c2dccebe 100644
index 03f783f2ad1..d946e700dda 100644
--- a/gcc/config/alpha/linux-elf.h
+++ b/gcc/config/alpha/linux-elf.h
@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3. If not see
@@ -48,7 +47,7 @@ index 3fd3b831166..0b4c2dccebe 100644
%{shared:-shared} \
%{!shared: \
diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
index d4d389e2aa8..adccc0b11c2 100644
index 7b7b7cbbe14..49c050c6f2c 100644
--- a/gcc/config/arm/linux-elf.h
+++ b/gcc/config/arm/linux-elf.h
@@ -70,6 +70,7 @@
@@ -60,7 +59,7 @@ index d4d389e2aa8..adccc0b11c2 100644
SUBTARGET_EXTRA_LINK_SPEC
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 4c4e31efa39..3c17ac6eade 100644
index eda8010b133..b26b17f2f2a 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -136,7 +136,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
@@ -88,7 +87,7 @@ index 4c4e31efa39..3c17ac6eade 100644
#undef TARGET_F951_OPTIONS
diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
index 7abfda53049..ceb8f855b7d 100644
index a79b739089d..e0752673dff 100644
--- a/gcc/config/i386/gnu-user.h
+++ b/gcc/config/i386/gnu-user.h
@@ -68,7 +68,7 @@ along with GCC; see the file COPYING3. If not see
@@ -101,7 +100,7 @@ index 7abfda53049..ceb8f855b7d 100644
%{!static: \
%{!static-pie: \
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index abe714711bf..3ca128a79f5 100644
index 3b63b99acf6..759bf0db86f 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -56,6 +56,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
@@ -113,7 +112,7 @@ index abe714711bf..3ca128a79f5 100644
%{!shared: \
%{!static: \
diff --git a/gcc/config/ia64/linux.h b/gcc/config/ia64/linux.h
index a2494c214c4..e1a5d530cdf 100644
index 5dfd428aa17..02656dad7fc 100644
--- a/gcc/config/ia64/linux.h
+++ b/gcc/config/ia64/linux.h
@@ -58,7 +58,7 @@ do { \
@@ -125,21 +124,8 @@ index a2494c214c4..e1a5d530cdf 100644
%{shared:-shared} \
%{!shared: \
%{!static: \
diff --git a/gcc/config/loongarch/gnu-user.h b/gcc/config/loongarch/gnu-user.h
index fbc75a90ad5..adbc4b7733f 100644
--- a/gcc/config/loongarch/gnu-user.h
+++ b/gcc/config/loongarch/gnu-user.h
@@ -44,7 +44,7 @@ along with GCC; see the file COPYING3. If not see
#undef GNU_USER_TARGET_LINK_SPEC
#define GNU_USER_TARGET_LINK_SPEC \
- "%{G*} %{shared} -m " GNU_USER_LINK_EMULATION \
+ "%{G*} %{shared} --as-needed -m " GNU_USER_LINK_EMULATION \
"%{!shared: %{static} " \
"%{!static: %{!static-pie: %{rdynamic:-export-dynamic} " \
"-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} " \
diff --git a/gcc/config/mips/gnu-user.h b/gcc/config/mips/gnu-user.h
index 5a82508c113..6eee7cdc603 100644
index a4e5380b589..3cc61bce69f 100644
--- a/gcc/config/mips/gnu-user.h
+++ b/gcc/config/mips/gnu-user.h
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see
@@ -151,7 +137,7 @@ index 5a82508c113..6eee7cdc603 100644
%{!static: \
%{rdynamic:-export-dynamic} \
diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
index 9060c940a44..282c77b6a7b 100644
index 3e625e0f867..f8c2c351e5a 100644
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see
@@ -161,12 +147,12 @@ index 9060c940a44..282c77b6a7b 100644
+-as-needed \
-melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv" LD_EMUL_SUFFIX " \
%{mno-relax:--no-relax} \
-X \
%{mbig-endian:-EB} \
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 0316d8cb65d..139e1b6796c 100644
index 9e457033d11..08016bf224d 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -378,13 +378,13 @@ extern int dot_symbols;
@@ -377,13 +377,13 @@ extern int dot_symbols;
" -m elf64ppc")
#endif
@@ -183,10 +169,10 @@ index 0316d8cb65d..139e1b6796c 100644
%{rdynamic:-export-dynamic} \
-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index afb5c6ad867..b64638fb25b 100644
index ae932fc22f0..c8ff0c6dc8e 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -781,7 +781,7 @@ GNU_USER_TARGET_CC1_SPEC
@@ -780,7 +780,7 @@ GNU_USER_TARGET_CC1_SPEC
#define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
#endif
@@ -196,7 +182,7 @@ index afb5c6ad867..b64638fb25b 100644
-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h
index 2c3bca5dfcb..b90661247a4 100644
index 02aa1edaff8..64df5801134 100644
--- a/gcc/config/s390/linux.h
+++ b/gcc/config/s390/linux.h
@@ -82,7 +82,7 @@ along with GCC; see the file COPYING3. If not see
@@ -209,7 +195,7 @@ index 2c3bca5dfcb..b90661247a4 100644
%{!shared: \
%{static:-static} \
diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 6d928846895..3cc05bb7240 100644
index 0e33b3cac2c..c2f44546e62 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -81,7 +81,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
@@ -222,10 +208,10 @@ index 6d928846895..3cc05bb7240 100644
%{!shared: \
%{!static: \
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 74a356fdf5e..fc9c7d15b04 100644
index f82fae23c22..da6417dd0d1 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -774,8 +774,11 @@ proper position among the other output files. */
@@ -754,8 +754,11 @@ proper position among the other output files. */
#ifdef LIBASAN_EARLY_SPEC
#define LIBASAN_SPEC STATIC_LIBASAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
@@ -239,7 +225,7 @@ index 74a356fdf5e..fc9c7d15b04 100644
STATIC_LIBASAN_LIBS
#else
#define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS
@@ -810,8 +813,11 @@ proper position among the other output files. */
@@ -790,8 +793,11 @@ proper position among the other output files. */
#ifdef LIBTSAN_EARLY_SPEC
#define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
@@ -253,7 +239,7 @@ index 74a356fdf5e..fc9c7d15b04 100644
STATIC_LIBTSAN_LIBS
#else
#define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS
@@ -828,8 +834,11 @@ proper position among the other output files. */
@@ -808,8 +814,11 @@ proper position among the other output files. */
#ifdef LIBLSAN_EARLY_SPEC
#define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
@@ -267,7 +253,7 @@ index 74a356fdf5e..fc9c7d15b04 100644
STATIC_LIBLSAN_LIBS
#else
#define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS
@@ -844,8 +853,11 @@ proper position among the other output files. */
@@ -824,8 +833,11 @@ proper position among the other output files. */
#define STATIC_LIBUBSAN_LIBS \
" %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}"
#ifdef HAVE_LD_STATIC_DYNAMIC
@@ -282,5 +268,5 @@ index 74a356fdf5e..fc9c7d15b04 100644
#else
#define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS
--
2.50.1
2.41.0
@@ -1,18 +1,18 @@
From 58a94690d4dd7b34543d9d154abc96d2d90d3b32 Mon Sep 17 00:00:00 2001
From bb25e8489384504cd59e4a2538720863da1fb29c Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:47:43 +0000
Subject: [PATCH] Enable -Wformat and -Wformat-security by default.
Subject: [PATCH 06/35] Enable -Wformat and -Wformat-security by default.
---
gcc/c-family/c.opt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 75b6531860e..78830ce4b42 100644
index a75038930ae..b98726f33ed 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -805,7 +805,7 @@ Warn about function calls with format strings that write past the end
of the destination region.
@@ -704,7 +704,7 @@ Warn about function calls with format strings that write past the end
of the destination region. Same as -Wformat-overflow=1.
Wformat-security
-C ObjC C++ ObjC++ Var(warn_format_security) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0)
@@ -20,7 +20,7 @@ index 75b6531860e..78830ce4b42 100644
Warn about possible security problems with format functions.
Wformat-signedness
@@ -830,7 +830,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++
@@ -725,7 +725,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++
Warn about zero-length formats.
Wformat=
@@ -28,7 +28,7 @@ index 75b6531860e..78830ce4b42 100644
+C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2)
Warn about printf/scanf/strftime/strfmon format string anomalies.
Wframe-address
Wformat-overflow=
--
2.50.1
2.41.0
@@ -1,18 +1,18 @@
From b2a755b671d88c34402290d7d769232e01aed350 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Fri, 25 Jul 2025 01:44:20 -0700
Subject: [PATCH] Enable -Wtrampolines by default.
From 4a728ad48a7b437cc6f2697e26603bf648149f86 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:48:24 +0000
Subject: [PATCH 07/35] Enable -Wtrampolines by default.
---
gcc/common.opt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index bea1adc0940..e65a575d9f8 100644
index 64c4277c991..c24839d32bc 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -829,7 +829,7 @@ Common Var(warn_tautological_compare) Warning LangEnabledBy(C ObjC C++ ObjC++,Wa
Warn if a comparison always evaluates to true or false.
@@ -803,7 +803,7 @@ Common Var(warn_system_headers) Warning
Do not suppress warnings from system headers.
Wtrampolines
-Common Var(warn_trampolines) Warning
@@ -21,5 +21,5 @@ index bea1adc0940..e65a575d9f8 100644
Wtrivial-auto-var-init
--
2.50.1
2.41.0
@@ -0,0 +1,53 @@
From 32f24560d0602f7735d5e9efd92fe3151bd72cea Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:49:40 +0000
Subject: [PATCH 08/35] Disable ssp on -nostdlib, -nodefaultlibs and
-ffreestanding Change the buffer size.
---
gcc/gcc.cc | 8 +++++++-
gcc/params.opt | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index da6417dd0d1..b5a6f200635 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -983,6 +983,12 @@ proper position among the other output files. */
#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
#endif
+#ifdef ENABLE_DEFAULT_SSP
+#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
+#else
+#define NO_SSP_SPEC ""
+#endif
+
#ifndef LINK_SSP_SPEC
#ifdef TARGET_LIBC_PROVIDES_SSP
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
@@ -1282,7 +1288,7 @@ static const char *cc1_options =
%{-version:--version}\
%{-help=*:--help=%*}\
%{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
- %{fsyntax-only:-o %j} %{-param*}\
+ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
%{coverage:-fprofile-arcs -ftest-coverage}\
%{fprofile-arcs|fprofile-generate*|coverage:\
%{!fprofile-update=single:\
diff --git a/gcc/params.opt b/gcc/params.opt
index 823cdb2ff85..5b096899b40 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -1006,7 +1006,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim
The maximum number of SSA_NAME assignments to follow in determining a value.
-param=ssp-buffer-size=
-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
+Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
The lower bound for a buffer to be considered for stack smashing protection.
-param=stack-clash-protection-guard-size=
--
2.41.0
@@ -1,39 +0,0 @@
From c355364231395090e7223ec00d8a16065903c2c5 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Fri, 25 Jul 2025 01:49:03 -0700
Subject: [PATCH] gcc: disable SSP on -ffreestanding, -nostdlib and
-nodefaultlibs
---
gcc/gcc.cc | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index fc9c7d15b04..7b0d3d2743b 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1009,6 +1009,12 @@ proper position among the other output files. */
#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
#endif
+#ifdef ENABLE_DEFAULT_SSP
+#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
+#else
+#define NO_SSP_SPEC ""
+#endif
+
#ifndef LINK_SSP_SPEC
#ifdef TARGET_LIBC_PROVIDES_SSP
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
@@ -1314,7 +1320,7 @@ static const char *cc1_options =
%{-version:--version}\
%{-help=*:--help=%*}\
%{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
- %{fsyntax-only:-o %j} %{-param*}\
+ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
%{coverage:-fprofile-arcs -ftest-coverage}\
%{fprofile-arcs|fcondition-coverage|fpath-coverage|fprofile-generate*|coverage:\
%{!fprofile-update=single:\
--
2.50.1
@@ -0,0 +1,54 @@
From c7ec8da7280d7f97f5543eb9ddeca7600aafc43c Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:50:33 +0000
Subject: [PATCH 09/35] Ensure that msgfmt doesn't encounter problems during
gcc bootstrapping.
Solves error messages like the following:
msgfmt: /var/tmp/portage/sys-devel/gcc-4.1.2/work/build/./gcc/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/libstdc++.so.6)
The libgcc_s.so used during build doesn't satisfy the needs of the
libstdc++.so that msgfmt is linked against. On the other hand, msgfmt
is used as a stand-alone application here, and what library it uses
behind the scenes is of no concern to the gcc build process.
Therefore, simply invoking it "as usual", i.e. without any special
library path, will make it work as expected here.
2011-09-19 Martin von Gagern
References:
https://bugs.gentoo.org/372377
https://bugs.gentoo.org/295480
---
libstdc++-v3/po/Makefile.am | 1 +
libstdc++-v3/po/Makefile.in | 1 +
2 files changed, 2 insertions(+)
diff --git a/libstdc++-v3/po/Makefile.am b/libstdc++-v3/po/Makefile.am
index 12d34910830..61b13762b71 100644
--- a/libstdc++-v3/po/Makefile.am
+++ b/libstdc++-v3/po/Makefile.am
@@ -38,6 +38,7 @@ MSGFMT = msgfmt
EXTRA_DIST = string_literals.cc POTFILES.in $(PACKAGE).pot $(LOCALE_IN)
.po.mo:
+ env --unset=LD_LIBRARY_PATH \
$(MSGFMT) -o $@ $<
all-local: all-local-$(USE_NLS)
diff --git a/libstdc++-v3/po/Makefile.in b/libstdc++-v3/po/Makefile.in
index 8e93445acd2..d6ff06e5ddb 100644
--- a/libstdc++-v3/po/Makefile.in
+++ b/libstdc++-v3/po/Makefile.in
@@ -561,6 +561,7 @@ uninstall-am:
.po.mo:
+ env --unset=LD_LIBRARY_PATH \
$(MSGFMT) -o $@ $<
all-local: all-local-$(USE_NLS)
--
2.41.0
@@ -1,25 +0,0 @@
From 5f09842c19d6db976724cd117190a8a6951acf9b Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Fri, 25 Jul 2025 01:50:42 -0700
Subject: [PATCH] gcc: params: set default ssp-buffer-size to 4
---
gcc/params.opt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/params.opt b/gcc/params.opt
index 64e453d29b7..bba3fd574f2 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -1064,7 +1064,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim
The maximum number of SSA_NAME assignments to follow in determining a value.
-param=ssp-buffer-size=
-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
+Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
The lower bound for a buffer to be considered for stack smashing protection.
-param=stack-clash-protection-guard-size=
--
2.50.1
@@ -0,0 +1,28 @@
From aaa029bcee68298695b7c4278c90b6bc320d098c Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:52:07 +0000
Subject: [PATCH 10/35] Don't declare asprintf if defined as a macro.
---
include/libiberty.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/libiberty.h b/include/libiberty.h
index 1d5c779fcff..19e3cb1e31c 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -652,8 +652,11 @@ extern void *bsearch_r (const void *, const void *,
/* Like sprintf but provides a pointer to malloc'd storage, which must
be freed by the caller. */
+/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
+#ifndef asprintf
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
#endif
+#endif
/* Like asprintf but allocates memory without fail. This works like
xmalloc. */
--
2.41.0
@@ -1,54 +0,0 @@
From ee0615536ae0d255f59070b904aa35d6de8fce49 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:50:33 +0000
Subject: [PATCH] Ensure that msgfmt doesn't encounter problems during gcc
bootstrapping.
Solves error messages like the following:
msgfmt: /var/tmp/portage/sys-devel/gcc-4.1.2/work/build/./gcc/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/libstdc++.so.6)
The libgcc_s.so used during build doesn't satisfy the needs of the
libstdc++.so that msgfmt is linked against. On the other hand, msgfmt
is used as a stand-alone application here, and what library it uses
behind the scenes is of no concern to the gcc build process.
Therefore, simply invoking it "as usual", i.e. without any special
library path, will make it work as expected here.
2011-09-19 Martin von Gagern
References:
https://bugs.gentoo.org/372377
https://bugs.gentoo.org/295480
---
libstdc++-v3/po/Makefile.am | 1 +
libstdc++-v3/po/Makefile.in | 1 +
2 files changed, 2 insertions(+)
diff --git a/libstdc++-v3/po/Makefile.am b/libstdc++-v3/po/Makefile.am
index 7f84a99533e..a4c6284f788 100644
--- a/libstdc++-v3/po/Makefile.am
+++ b/libstdc++-v3/po/Makefile.am
@@ -38,6 +38,7 @@ MSGFMT = msgfmt
EXTRA_DIST = string_literals.cc POTFILES.in $(PACKAGE).pot $(LOCALE_IN)
.po.mo:
+ env --unset=LD_LIBRARY_PATH \
$(MSGFMT) -o $@ $<
all-local: all-local-$(USE_NLS)
diff --git a/libstdc++-v3/po/Makefile.in b/libstdc++-v3/po/Makefile.in
index 8e93445acd2..d6ff06e5ddb 100644
--- a/libstdc++-v3/po/Makefile.in
+++ b/libstdc++-v3/po/Makefile.in
@@ -561,6 +561,7 @@ uninstall-am:
.po.mo:
+ env --unset=LD_LIBRARY_PATH \
$(MSGFMT) -o $@ $<
all-local: all-local-$(USE_NLS)
--
2.50.1
@@ -1,28 +0,0 @@
From 62966418472466142a9962892177f4b1f9f56944 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:52:07 +0000
Subject: [PATCH] Don't declare asprintf if defined as a macro.
---
include/libiberty.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/libiberty.h b/include/libiberty.h
index d4e8791b14b..c074980ed80 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -678,8 +678,11 @@ extern void *bsearch_r (const void *, const void *,
/* Like sprintf but provides a pointer to malloc'd storage, which must
be freed by the caller. */
+/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
+#ifndef asprintf
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
#endif
+#endif
/* Like asprintf but allocates memory without fail. This works like
xmalloc. */
--
2.50.1
@@ -0,0 +1,24 @@
From 65e01e749205c9af218b01233cebd0077538d0ee Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:53:00 +0000
Subject: [PATCH 11/35] libiberty: copy PIC objects during build process
---
libiberty/Makefile.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 72608f3e4a7..58356884728 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -265,6 +265,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
$(AR) $(AR_FLAGS) $(TARGETLIB) \
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
$(RANLIB) $(TARGETLIB); \
+ cp $(TARGETLIB) ../ ; \
cd ..; \
else true; fi
--
2.41.0
+57
View File
@@ -0,0 +1,57 @@
From 453a815bf2844971a91eaef800af188d9e86b784 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Sat, 24 Oct 2015 20:09:53 +0000
Subject: [PATCH 12/35] libgcc_s
---
gcc/config/i386/i386-expand.cc | 4 ++--
libgcc/config/i386/cpuinfo.c | 6 +++---
libgcc/config/i386/t-linux | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index 0d817fc3f3b..2e99db00db9 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -12691,10 +12691,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
{
case IX86_BUILTIN_CPU_INIT:
{
- /* Make it call __cpu_indicator_init in libgcc. */
+ /* Make it call __cpu_indicator_init in libgcc.a. */
tree call_expr, fndecl, type;
type = build_function_type_list (integer_type_node, NULL_TREE);
- fndecl = build_fn_decl ("__cpu_indicator_init", type);
+ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
call_expr = build_call_expr (fndecl, 0);
return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
}
diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
index 50b6d8248a2..724ced402a1 100644
--- a/libgcc/config/i386/cpuinfo.c
+++ b/libgcc/config/i386/cpuinfo.c
@@ -63,7 +63,7 @@ __cpu_indicator_init (void)
__cpu_features2);
}
-#if defined SHARED && defined USE_ELF_SYMVER
-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
+#ifndef SHARED
+int __cpu_indicator_init_local (void)
+ __attribute__ ((weak, alias ("__cpu_indicator_init")));
#endif
diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux
index 8506a635790..564296f788e 100644
--- a/libgcc/config/i386/t-linux
+++ b/libgcc/config/i386/t-linux
@@ -3,5 +3,5 @@
# t-slibgcc-elf-ver and t-linux
SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver
-HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER $(CET_FLAGS)
+HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS)
CRTSTUFF_T_CFLAGS += $(CET_FLAGS)
--
2.41.0
@@ -1,24 +0,0 @@
From 0351f4f3dd00bdece780ce5e24d972e97ca1b7ed Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:53:00 +0000
Subject: [PATCH] libiberty: copy PIC objects during build process
---
libiberty/Makefile.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index ce54d88278d..10c212a1ad3 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -266,6 +266,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
$(AR) $(AR_FLAGS) $(TARGETLIB) \
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
$(RANLIB) $(TARGETLIB); \
+ cp $(TARGETLIB) ../ ; \
cd ..; \
else true; fi
--
2.50.1
-57
View File
@@ -1,57 +0,0 @@
From bd7e32d5405b6b4f3994a212a77ff2cd33134c74 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Sat, 24 Oct 2015 20:09:53 +0000
Subject: [PATCH] libgcc_s
---
gcc/config/i386/i386-expand.cc | 4 ++--
libgcc/config/i386/cpuinfo.c | 6 +++---
libgcc/config/i386/t-linux | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index cdfd94d3c73..a3a6c988833 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -13643,10 +13643,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
{
case IX86_BUILTIN_CPU_INIT:
{
- /* Make it call __cpu_indicator_init in libgcc. */
+ /* Make it call __cpu_indicator_init in libgcc.a. */
tree call_expr, fndecl, type;
type = build_function_type_list (integer_type_node, NULL_TREE);
- fndecl = build_fn_decl ("__cpu_indicator_init", type);
+ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
call_expr = build_call_expr (fndecl, 0);
return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
}
diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
index 2484dc839bf..e980030ef23 100644
--- a/libgcc/config/i386/cpuinfo.c
+++ b/libgcc/config/i386/cpuinfo.c
@@ -63,7 +63,7 @@ __cpu_indicator_init (void)
__cpu_features2);
}
-#if defined SHARED && defined USE_ELF_SYMVER
-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
+#ifndef SHARED
+int __cpu_indicator_init_local (void)
+ __attribute__ ((weak, alias ("__cpu_indicator_init")));
#endif
diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux
index 8506a635790..564296f788e 100644
--- a/libgcc/config/i386/t-linux
+++ b/libgcc/config/i386/t-linux
@@ -3,5 +3,5 @@
# t-slibgcc-elf-ver and t-linux
SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver
-HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER $(CET_FLAGS)
+HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS)
CRTSTUFF_T_CFLAGS += $(CET_FLAGS)
--
2.50.1
+85
View File
@@ -0,0 +1,85 @@
From 7d7d12137c666761a8dd61179c9651b85dae9b41 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Sat, 7 Nov 2015 02:08:05 +0000
Subject: [PATCH 13/35] nopie
---
gcc/configure | 27 +++++++++++++++++++++++++++
gcc/configure.ac | 13 +++++++++++++
2 files changed, 40 insertions(+)
diff --git a/gcc/configure b/gcc/configure
index 23da7d55d..f38732bb2 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -34534,6 +34534,29 @@ rm -f core conftest.err conftest.$ac_objext \
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5
$as_echo "$gcc_cv_no_pie" >&6; }
+# Check if -nopie works.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -nopie option" >&5
+$as_echo_n "checking for -nopie option... " >&6; }
+if ${gcc_cv_nopie+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -nopie"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int main(void) {return 0;}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ gcc_cv_nopie=yes
+else
+ gcc_cv_nopie=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$saved_LDFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_nopie" >&5
+$as_echo "$gcc_cv_nopie" >&6; }
if test x$enable_host_shared = xyes; then
PICFLAG=-fPIC
@@ -34551,6 +34574,8 @@ if test x$enable_host_pie = xyes; then
LD_PICFLAG=-pie
elif test x$gcc_cv_no_pie = xyes; then
LD_PICFLAG=-no-pie
+elif test x$gcc_cv_nopie = xyes; then
+ LD_PICFLAG=-nopie
else
LD_PICFLAG=
fi
diff --git a/gcc/configure.ac b/gcc/configure.ac
index d7cf0b92c..db2e2c802 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7781,6 +7781,15 @@ AC_CACHE_CHECK([for -no-pie option],
[gcc_cv_no_pie=yes],
[gcc_cv_no_pie=no])
LDFLAGS="$saved_LDFLAGS"])
+# Check if -nopie works.
+AC_CACHE_CHECK([for -nopie option],
+ [gcc_cv_nopie],
+ [saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -nopie"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
+ [gcc_cv_nopie=yes],
+ [gcc_cv_nopie=no])
+ LDFLAGS="$saved_LDFLAGS"])
if test x$enable_host_shared = xyes; then
PICFLAG=-fPIC
@@ -7798,6 +7807,8 @@ if test x$enable_host_pie = xyes; then
LD_PICFLAG=-pie
elif test x$gcc_cv_no_pie = xyes; then
LD_PICFLAG=-no-pie
+elif test x$gcc_cv_nopie = xyes; then
+ LD_PICFLAG=-nopie
else
LD_PICFLAG=
fi
--
2.41.0
@@ -0,0 +1,42 @@
From dd5bb97c31a9f57034c70a7a18ba6e2e133084c7 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:59:16 +0000
Subject: [PATCH 14/35] ada: fix shared linking
---
gcc/ada/link.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gcc/ada/link.c b/gcc/ada/link.c
index f2126441208..22cfa9c641f 100644
--- a/gcc/ada/link.c
+++ b/gcc/ada/link.c
@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir = "lib";
|| defined (__NetBSD__) || defined (__OpenBSD__) \
|| defined (__QNX__)
const char *__gnat_object_file_option = "-Wl,@";
-const char *__gnat_run_path_option = "-Wl,-rpath,";
-char __gnat_shared_libgnat_default = STATIC;
-char __gnat_shared_libgcc_default = STATIC;
+const char *__gnat_run_path_option = "";
+char __gnat_shared_libgnat_default = SHARED;
+char __gnat_shared_libgcc_default = SHARED;
int __gnat_link_max = 8192;
unsigned char __gnat_objlist_file_supported = 1;
const char *__gnat_object_library_extension = ".a";
@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir = "lib";
#elif defined (__linux__) || defined (__GLIBC__)
const char *__gnat_object_file_option = "-Wl,@";
-const char *__gnat_run_path_option = "-Wl,-rpath,";
-char __gnat_shared_libgnat_default = STATIC;
-char __gnat_shared_libgcc_default = STATIC;
+const char *__gnat_run_path_option = "";
+char __gnat_shared_libgnat_default = SHARED;
+char __gnat_shared_libgcc_default = SHARED;
int __gnat_link_max = 8192;
unsigned char __gnat_objlist_file_supported = 1;
const char *__gnat_object_library_extension = ".a";
--
2.41.0
-85
View File
@@ -1,85 +0,0 @@
From c191dc86f4f7340542066f4156aa57be9cfbf876 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Sat, 7 Nov 2015 02:08:05 +0000
Subject: [PATCH] nopie
---
gcc/configure | 25 +++++++++++++++++++++++++
gcc/configure.ac | 11 +++++++++++
2 files changed, 36 insertions(+)
diff --git a/gcc/configure b/gcc/configure
index 0f4a5d52c30..343563c8948 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -34586,6 +34586,29 @@ rm -f core conftest.err conftest.$ac_objext \
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5
$as_echo "$gcc_cv_no_pie" >&6; }
+# Check if -nopie works.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -nopie option" >&5
+$as_echo_n "checking for -nopie option... " >&6; }
+if ${gcc_cv_nopie+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -nopie"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int main(void) {return 0;}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ gcc_cv_nopie=yes
+else
+ gcc_cv_nopie=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$saved_LDFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_nopie" >&5
+$as_echo "$gcc_cv_nopie" >&6; }
if test x$enable_host_shared = xyes; then
PICFLAG=-fPIC
@@ -34603,6 +34626,8 @@ if test x$enable_host_pie = xyes; then
LD_PICFLAG=-pie
elif test x$gcc_cv_no_pie = xyes; then
LD_PICFLAG=-no-pie
+elif test x$gcc_cv_nopie = xyes; then
+ LD_PICFLAG=-nopie
else
LD_PICFLAG=
fi
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b0e3615e5aa..b3948469d17 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7802,6 +7802,15 @@ AC_CACHE_CHECK([for -no-pie option],
[gcc_cv_no_pie=yes],
[gcc_cv_no_pie=no])
LDFLAGS="$saved_LDFLAGS"])
+# Check if -nopie works.
+AC_CACHE_CHECK([for -nopie option],
+ [gcc_cv_nopie],
+ [saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -nopie"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
+ [gcc_cv_nopie=yes],
+ [gcc_cv_nopie=no])
+ LDFLAGS="$saved_LDFLAGS"])
if test x$enable_host_shared = xyes; then
PICFLAG=-fPIC
@@ -7819,6 +7828,8 @@ if test x$enable_host_pie = xyes; then
LD_PICFLAG=-pie
elif test x$gcc_cv_no_pie = xyes; then
LD_PICFLAG=-no-pie
+elif test x$gcc_cv_nopie = xyes; then
+ LD_PICFLAG=-nopie
else
LD_PICFLAG=
fi
--
2.50.1
@@ -1,42 +0,0 @@
From f1d6c0950e0f12fb8cf2429da570f478a1369286 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:59:16 +0000
Subject: [PATCH] ada: fix shared linking
---
gcc/ada/link.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gcc/ada/link.c b/gcc/ada/link.c
index 9e3385ca94f..2c0cca6e480 100644
--- a/gcc/ada/link.c
+++ b/gcc/ada/link.c
@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir = "lib";
|| defined (__NetBSD__) || defined (__OpenBSD__) \
|| defined (__QNX__)
const char *__gnat_object_file_option = "-Wl,@";
-const char *__gnat_run_path_option = "-Wl,-rpath,";
-char __gnat_shared_libgnat_default = STATIC;
-char __gnat_shared_libgcc_default = STATIC;
+const char *__gnat_run_path_option = "";
+char __gnat_shared_libgnat_default = SHARED;
+char __gnat_shared_libgcc_default = SHARED;
int __gnat_link_max = 8192;
unsigned char __gnat_objlist_file_supported = 1;
const char *__gnat_object_library_extension = ".a";
@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir = "lib";
#elif defined (__linux__) || defined (__GLIBC__)
const char *__gnat_object_file_option = "-Wl,@";
-const char *__gnat_run_path_option = "-Wl,-rpath,";
-char __gnat_shared_libgnat_default = STATIC;
-char __gnat_shared_libgcc_default = STATIC;
+const char *__gnat_run_path_option = "";
+char __gnat_shared_libgnat_default = SHARED;
+char __gnat_shared_libgcc_default = SHARED;
int __gnat_link_max = 8192;
unsigned char __gnat_objlist_file_supported = 1;
const char *__gnat_object_library_extension = ".a";
--
2.50.1
@@ -0,0 +1,24 @@
From 6bb5b7d9161d05f31b001d8211a9c63caf63fd2f Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:59:43 +0000
Subject: [PATCH 15/35] build: fix CXXFLAGS_FOR_BUILD passing
---
Makefile.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/Makefile.in b/Makefile.in
index 06a9398e172..6ff2b3f9925 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -178,6 +178,7 @@ BUILD_EXPORTS = \
# built for the build system to override those in BASE_FLAGS_TO_PASS.
EXTRA_BUILD_FLAGS = \
CFLAGS="$(CFLAGS_FOR_BUILD)" \
+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
LDFLAGS="$(LDFLAGS_FOR_BUILD)"
# This is the list of directories to built for the host system.
--
2.41.0
@@ -0,0 +1,25 @@
From f0d9e00cac06689f64b214de7aee80d7116ef084 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 07:01:06 +0000
Subject: [PATCH 16/35] add fortify-headers paths
---
gcc/config/linux.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/gcc/config/linux.h b/gcc/config/linux.h
index e3aca79cccc..b3537b8fbeb 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -159,6 +159,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#ifdef NATIVE_SYSTEM_HEADER_DIR
#define INCLUDE_DEFAULTS_MUSL_NATIVE \
+ { NATIVE_SYSTEM_HEADER_DIR "/fortify", 0, 0, 0, 1, 2 }, \
+ { NATIVE_SYSTEM_HEADER_DIR "/fortify", 0, 0, 0, 1, 0 }, \
{ NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
{ NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
#else
--
2.41.0
@@ -1,24 +0,0 @@
From 8773e0cf880da9fe80de7f8a662359664bb0b234 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:59:43 +0000
Subject: [PATCH] build: fix CXXFLAGS_FOR_BUILD passing
---
Makefile.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/Makefile.in b/Makefile.in
index b1ed67d3d4f..1e039c20550 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -179,6 +179,7 @@ BUILD_EXPORTS = \
# built for the build system to override those in BASE_FLAGS_TO_PASS.
EXTRA_BUILD_FLAGS = \
CFLAGS="$(CFLAGS_FOR_BUILD)" \
+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
LDFLAGS="$(LDFLAGS_FOR_BUILD)"
# This is the list of directories to built for the host system.
--
2.50.1
@@ -0,0 +1,31 @@
From 857db04f4f1a06e866551b4172fe8f27363f4a92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Fri, 21 Aug 2020 07:03:00 +0000
Subject: [PATCH 17/35] Alpine musl package provides libssp_nonshared.a. We
link to it unconditionally, as otherwise we get link failures if some objects
are -fstack-protector built and final link happens with -fno-stack-protector.
This seems to be the common case when bootstrapping gcc, the piepatches do
not seem to fully fix the crosstoolchain and bootstrap sequence wrt.
stack-protector flag usage.
---
gcc/gcc.cc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index b5a6f200635..6cbb726599b 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -991,8 +991,7 @@ proper position among the other output files. */
#ifndef LINK_SSP_SPEC
#ifdef TARGET_LIBC_PROVIDES_SSP
-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
- "|fstack-protector-strong|fstack-protector-explicit:}"
+#define LINK_SSP_SPEC "-lssp_nonshared"
#else
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
"|fstack-protector-strong|fstack-protector-explicit" \
--
2.41.0
Loaded 100 of 8817 files, more files were not shown because too many files have changed in this diff. Show more