From 2dec667f006f9052bb621ebeaa02a7c3477ee88b Mon Sep 17 00:00:00 2001 From: Stefan Hansson Date: Wed, 13 May 2026 12:17:10 +0200 Subject: [PATCH] CI: Add check for required pmbootstrap version's age While ideally everyone would be running the latest pmbootstrap version, in practice people don't always update right away. And even if they want to, their distribution may not have the latest version packaged yet. Let's enforce some wiggle room here so distributions have time to catch up before we require newer versions. Signed-off-by: Stefan Hansson Part-of: --- .ci/check-pmbootstrap-min-version.sh | 29 ++++++++++++++++++++++++++++ .gitlab-ci.yml | 12 ++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 .ci/check-pmbootstrap-min-version.sh diff --git a/.ci/check-pmbootstrap-min-version.sh b/.ci/check-pmbootstrap-min-version.sh new file mode 100755 index 000000000..35fa5bd6a --- /dev/null +++ b/.ci/check-pmbootstrap-min-version.sh @@ -0,0 +1,29 @@ +#!/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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aa42d4f3e..3f4edbe1b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -172,6 +172,18 @@ mr-settings: - wget -q "https://gitlab.postmarketos.org/postmarketOS/ci-common/-/raw/main/check_mr_settings.py" - python3 ./check_mr_settings.py +pmbootstrap minimum version: + stage: lint + 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: