Drop the standalone Unit-tests (musl) workflow that ran on an Alpine sandbox spun up by jirutka/setup-alpine, and merge it into unit-tests.yml as a new build-musl job that provisions a postmarketOS tools tree via mkosi and runs the meson build + test suite through 'mkosi box'. postmarketOS is musl-native, so the musl-gcc / -idirafter /usr/include wrappers the Fedora tools tree needed are gone; the linter.yml's own musl build step also goes away since the unit-tests workflow now covers it (and tests it). postmarketOS doesn't ship a downstream systemd packaging spec, so the new tools tree config in mkosi.tools.conf/mkosi.conf.d/postmarketos.conf does not set PrepareScripts and lists build deps manually. mkosi.sync now early-exits when PKG_SUBDIR is unset so the missing pkgenv entry doesn't trip set -u. Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
59 lines
2.2 KiB
Bash
Executable File
59 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
set -e
|
|
set -o nounset
|
|
|
|
if ((${NO_SYNC:-0})) || ((${NO_BUILD:-0})); then
|
|
exit 0
|
|
fi
|
|
|
|
# Distributions without downstream systemd packaging (e.g. postmarketOS) skip the mkosi.pkgenv entry
|
|
# that sets PKG_SUBDIR (and the matching prepare script), so there's nothing to sync.
|
|
if [[ -z "${PKG_SUBDIR:-}" ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
if [[ -d "pkg/$PKG_SUBDIR/.git" ]]; then
|
|
if [[ "$(git -C "pkg/$PKG_SUBDIR" rev-parse HEAD 2>/dev/null)" == "$GIT_COMMIT" ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
if [[ -n "$(git -C "pkg/$PKG_SUBDIR" status --porcelain)" ]]; then
|
|
echo "pkg/$PKG_SUBDIR is dirty, not checking out commit $GIT_COMMIT" >&2
|
|
exit 0
|
|
fi
|
|
|
|
if ! git -C "pkg/$PKG_SUBDIR" show-ref --quiet "origin/$GIT_BRANCH"; then
|
|
git -C "pkg/$PKG_SUBDIR" remote set-url origin "$GIT_URL"
|
|
git -C "pkg/$PKG_SUBDIR" fetch origin "$GIT_BRANCH"
|
|
fi
|
|
|
|
# If work is being done on the packaging rules in a separate branch, don't touch the checkout.
|
|
if [[ -z "$(git -C "pkg/$PKG_SUBDIR" branch --remotes --list "origin/*" --contains HEAD)" ]]; then
|
|
echo "Currently checked out pkg/$PKG_SUBDIR commit is not part of any origin branch, not checking out commit $GIT_COMMIT" >&2
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
if [[ ! -e "pkg/$PKG_SUBDIR" ]] || [[ -z "$(ls --almost-all "pkg/$PKG_SUBDIR")" ]]; then
|
|
# The repository on Salsa has the full upstream sources, so it's a waste of
|
|
# space to redownload and duplicate everything, so do a sparse checkout as
|
|
# we only need the packaging directory anyway.
|
|
if [[ -n "${GIT_SUBDIR:-}" ]]; then
|
|
sparse=(--no-checkout --filter=tree:0)
|
|
else
|
|
sparse=()
|
|
fi
|
|
|
|
git clone "$GIT_URL" --branch "$GIT_BRANCH" "${sparse[@]}" "pkg/$PKG_SUBDIR"
|
|
if [[ -n "${GIT_SUBDIR:-}" ]]; then
|
|
# --no-cone is needed to check out only one top-level directory
|
|
git -C "pkg/$PKG_SUBDIR" sparse-checkout set --no-cone "${GIT_SUBDIR:-}"
|
|
fi
|
|
elif ! git -C "pkg/$PKG_SUBDIR" cat-file -e "$GIT_COMMIT^{commit}" 2>/dev/null; then
|
|
git -C "pkg/$PKG_SUBDIR" remote set-url origin "$GIT_URL"
|
|
git -C "pkg/$PKG_SUBDIR" fetch origin "$GIT_BRANCH"
|
|
fi
|
|
|
|
git -C "pkg/$PKG_SUBDIR" -c advice.detachedHead=false checkout "$GIT_COMMIT"
|