Hash :
4e0617be
Author :
Thomas de Grivel
Date :
2023-02-16T02:11:38
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#!/bin/sh
set -e
# shpkg
: ${SHPKG_DIR:=~/shpkg}
. "${SHPKG_DIR}/etc/shpkg/profile"
. "${SHPKG_DIR}/share/shpkg/shpkg.subr"
verbose 2 shpkg_config
verbose 2 shpkg_lock shpkg_ci_mux.lock
# Configuration
: ${SHPKG_CI_DIR:=${SHPKG_DIR}/ci}
shpkg_ci_remote () {
verbose 1 ssh "$1" sh -c "\"shpkg/bin/shpkg_ci '$2'\""
if [ "x$2" == "x--clean" ]; then
rm -rf "${SHPKG_CI_DIR}"
else
if [ "x$2" != "x--upgrade" ]; then
verbose 1 rsync -a "$1":shpkg/ci/. "${SHPKG_CI_DIR}/"
fi
fi
}
shpkg_ci_status2png () {
for F in "${SHPKG_CI_DIR}/status"/*.status; do
STATUS="$(cat "$F")"
I="${SHPKG_CI_DIR}/log/$(basename "$F" .status).png"
if ! [ -f "$I" ] ||
[ "$F" -nt "$I" ]; then
verbose 1 cp "${SHPKG_DIR}/share/shpkg/img/status_${STATUS}.64.png" "$I"
fi
done
}
main () {
SHPKG_REPO="$1"
shift
for SHPKG_CI_MUX_HOST; do
shpkg_ci_remote "${SHPKG_CI_MUX_HOST}" "${SHPKG_REPO}" &
done
for SHPKG_CI_MUX_HOST; do
wait
done
if [ "x${SHPKG_REPO}" == "x--upgrade" ] ||
[ "x${SHPKG_REPO}" == "x--clean" ]; then
exit
fi
( cd "${SHPKG_CI_DIR}/status" &&
for S in $(ls */*/*.status | cut -d / -f 3 | sort -u); do
{
if grep -q running */*/"$S"; then
echo running
elif grep -q ko */*/"$S"; then
echo ko
else
echo ok
fi
} > "${SHPKG_CI_DIR}/status/$S"
done; )
}
shpkg_log shpkg_ci_mux main "$@"