diff --git a/bin/shpkg_ci_mux b/bin/shpkg_ci_mux
index c568916..d2aee04 100755
--- a/bin/shpkg_ci_mux
+++ b/bin/shpkg_ci_mux
@@ -31,7 +31,7 @@ shpkg_ci_remote () {
while read F; do
D="${SHPKG_CI_DIR}/$(dirname "$F")"
mkdir -p "$D"
- verbose 1 rsync "$1":shpkg/ci/"$F" "$D"
+ verbose 1 rsync "$1":shpkg/ci/"$F" "$D/"
done
fi
}
diff --git a/share/shpkg/shpkg.subr b/share/shpkg/shpkg.subr
index 4c7634c..c8ccc27 100644
--- a/share/shpkg/shpkg.subr
+++ b/share/shpkg/shpkg.subr
@@ -206,9 +206,10 @@ shpkg_config () {
# CI
: ${SHPKG_CI_DIR:=~/shpkg/ci}
SHPKG_CI_BUILD_DIR="${SHPKG_CI_DIR}/build"
+ SHPKG_CI_CHANGED_FILES="${SHPKG_CI_DIR}/changed_files"
SHPKG_CI_LOG_DIR="${SHPKG_CI_DIR}/log/${SHPKG_OS_}/${SHPKG_TARGET}"
+ SHPKG_CI_RUNNING="${SHPKG_CI_DIR}/running"
SHPKG_CI_STATUS_DIR="${SHPKG_CI_DIR}/status/${SHPKG_OS_}/${SHPKG_TARGET}"
- SHPKG_CI_CHANGED_FILES="${SHPKG_CI_DIR}/changed_files"
# Directories
if ! [ -d "${SHPKG_CI_LOG_DIR}" ]; then
verbose 1 mkdir -p "${SHPKG_CI_LOG_DIR}"
@@ -228,6 +229,9 @@ shpkg_config () {
if ! [ -d "${SHPKG_VAR_DB_DIR}" ]; then
verbose 1 mkdir -p "${SHPKG_VAR_DB_DIR}"
fi
+ # CI
+ echo -n > "${SHPKG_CI_RUNNING}"
+ trap "shpkg_ci_status_trap" EXIT
}
# Repo index
@@ -296,7 +300,7 @@ shpkg_checkout () {
verbose 1 git submodule update; )
SHPKG_REPO_VERSION_B="$(shpkg_version "${SHPKG_REPO}")"
if [ "x${SHPKG_REPO_VERSION_A}" != "x${SHPKG_REPO_VERSION_B}" ]; then
- ( verbose 2 shpkg_tag_log "${SHPKG_REPO}.checkout"; )
+ ( verbose 2 shpkg_tag_log "${SHPKG_REPO}.checkout.log"; )
fi
done
}
@@ -312,7 +316,7 @@ shpkg_clone () {
SHPKG_REPO_GIT_URL="$(shpkg_git_url "${SHPKG_REPO}")"
SHPKG_REPO_BASENAME="$(basename "${SHPKG_REPO_DIR}")"
if ! [ -d "${SHPKG_SRC_DIR}/${SHPKG_REPO_DIR}" ]; then
- ( verbose 2 shpkg_tag_log "${SHPKG_REPO}.clone"; )
+ ( verbose 2 shpkg_tag_log "${SHPKG_REPO}.clone.log"; )
verbose 1 mkdir -p "${SHPKG_SRC_DIR}/${SHPKG_REPO_PARENT_DIR}"
( verbose 1 cd "${SHPKG_SRC_DIR}/${SHPKG_REPO_PARENT_DIR}" &&
verbose 1 git clone "${SHPKG_REPO_GIT_URL}" -b "${SHPKG_REPO_GIT_BRANCH}" "${SHPKG_REPO_BASENAME}" &&
@@ -508,11 +512,13 @@ shpkg_configure () {
verbose 1 mkdir -p "${SHPKG_REPO_FAKE_DIR}"
fi
if [ -x "${SHPKG_REPO_SRC_DIR}/configure" ]; then
- ( verbose 1 cd "${SHPKG_REPO_SRC_DIR}" &&
- verbose 1 ./configure --prefix "${SHPKG_PREFIX}" || exit 1; ) || exit 1
+ ( set -e
+ verbose 1 cd "${SHPKG_REPO_SRC_DIR}"
+ verbose 1 ./configure --prefix "${SHPKG_PREFIX}" )
elif [ -x "${SHPKG_REPO_SRC_DIR}/configure.sh" ]; then
- ( verbose 1 cd "${SHPKG_REPO_SRC_DIR}" &&
- verbose 1 ./configure.sh --prefix "${SHPKG_PREFIX}" || exit 1; ) || exit 1
+ ( set -e
+ verbose 1 cd "${SHPKG_REPO_SRC_DIR}"
+ verbose 1 ./configure.sh --prefix "${SHPKG_PREFIX}"; )
elif [ -f "${SHPKG_REPO_SRC_DIR}/CMakeLists.txt" ]; then
verbose 1 cmake -S "${SHPKG_REPO_SRC_DIR}" -B "${SHPKG_OBJ_DIR}/${SHPKG_REPO_DIR}" -D CMAKE_INSTALL_PREFIX:PATH="${SHPKG_PREFIX}" -D BUILD_SHARED_LIBS=ON
fi
@@ -714,6 +720,7 @@ shpkg_uninstall () {
fi
SHPKG_REPO_INSTALLED="${SHPKG_VAR_DB_DIR}/installed/${SHPKG_REPO_DIR}"
if [ -f "${SHPKG_REPO_INSTALLED}" ]; then
+ verbose 2 shpkg_ci_status "${SHPKG_REPO}.uninstall.status" running
( verbose 2 shpkg_tag_log "${SHPKG_REPO}.uninstall.log"; )
verbose 1 cd "${SHPKG_DIR}"
grep -v : "${SHPKG_REPO_INSTALLED}" |
@@ -832,7 +839,6 @@ shpkg_upgrade_shpkg () {
cut_prefix () {
LEN=$(echo -n "$1" | wc -c | tr -d ' ')
- echo $LEN >&2
if [ "x$(echo "$2" | cut -c 1-${LEN})" = "x$1" ]; then
echo "$2" | cut -c $((${LEN} + 1))-
fi
@@ -899,7 +905,7 @@ EOF
EOF
} > "$1.html.tmp"
mv "$1.html.tmp" "$1.html"
- verbose 2 shpkg_ci_changed_file "$1.html"
+ shpkg_ci_changed_file "$1.html"
}
logs2html () {
@@ -930,9 +936,6 @@ shpkg_ci_main () {
fi
SHPKG_REPO_GIT_BRANCH="$(shpkg_git_branch "${SHPKG_REPO}")"
SHPKG_REPO_HASH="$(shpkg_hash "${SHPKG_REPO}")"
- verbose 2 shpkg_ci_status "${SHPKG_REPO}.ci.status" running
- verbose 2 shpkg_ci_status "${SHPKG_REPO}.ci.branch_${SHPKG_REPO_GIT_BRANCH}.status" running
- verbose 2 shpkg_ci_status "${SHPKG_REPO}.ci.commit_${SHPKG_REPO_HASH}.status" running
verbose 2 shpkg_tag_log "${SHPKG_REPO}.ci.log"
verbose 2 shpkg_tag_log "${SHPKG_REPO}.ci.branch_${SHPKG_REPO_GIT_BRANCH}.log"
verbose 2 shpkg_tag_log "${SHPKG_REPO}.ci.commit_${SHPKG_REPO_HASH}.log"
@@ -943,13 +946,10 @@ shpkg_ci_main () {
else
# run shpkg upgrade
( . "${SHPKG_REPO_BUILD_DIR}/etc/shpkg/profile"
- verbose 2 shpkg_ci_status "${SHPKG_REPO}.upgrade.status" running
verbose -n 2 shpkg upgrade "${SHPKG_REPO}"
- if ( . "${SHPKG_REPO_BUILD_DIR}/share/shpkg/shpkg.subr";
- shpkg_upgrade "${SHPKG_REPO}"; ); then
- verbose 2 shpkg_ci_status "${SHPKG_REPO}.upgrade.status" ok
- else
- exit 1
+ if ! ( . "${SHPKG_REPO_BUILD_DIR}/share/shpkg/shpkg.subr";
+ shpkg_upgrade "${SHPKG_REPO}"; ); then
+ shpkg_ci_status_ko_grep "^${SHPKG_REPO}[.]"
fi; )
if verbose 1 cp -p "${SHPKG_REPO_BUILD_DIR}/var/log/shpkg/tags/${SHPKG_REPO}".*.log "${SHPKG_CI_LOG_DIR}"; then
verbose 2 logs2html
@@ -958,12 +958,9 @@ shpkg_ci_main () {
fi
( verbose 2 shpkg_bootstrap -f "${SHPKG_REPO_BUILD_DIR}"; )
( . "${SHPKG_REPO_BUILD_DIR}/etc/shpkg/profile"
- verbose 2 shpkg_ci_status "${SHPKG_REPO}.install.status" running
verbose -n 2 shpkg install "${SHPKG_REPO}"
- if ( . "${SHPKG_REPO_BUILD_DIR}/share/shpkg/shpkg.subr";
- shpkg_install "${SHPKG_REPO}"; ); then
- verbose 2 shpkg_ci_status "${SHPKG_REPO}.install.status" ok
- else
+ if ! ( . "${SHPKG_REPO_BUILD_DIR}/share/shpkg/shpkg.subr";
+ shpkg_install "${SHPKG_REPO}"; ); then
exit 1
fi; )
verbose 2 shpkg_ci_status "${SHPKG_REPO}.ci.status" ok
@@ -1001,25 +998,52 @@ shpkg_ci_status () {
verbose -n 2 "Status change: $1: ${SHPKG_CI_STATUS} -> $2"
verbose -n 1 "echo $2 > ${SHPKG_CI_STATUS_FILE}"
echo "$2" > "${SHPKG_CI_STATUS_FILE}"
- verbose 2 shpkg_ci_changed_file "${SHPKG_CI_STATUS_FILE}"
- trap "shpkg_ci_status_trap $1" EXIT
+ shpkg_ci_changed_file "${SHPKG_CI_STATUS_FILE}"
+ echo "$1" >> "${SHPKG_CI_RUNNING}"
+ shpkg_ci_changed_file "${SHPKG_CI_RUNNING}"
elif [ "x${SHPKG_CI_STATUS}" = "xrunning" ]; then
verbose -n 2 "Status change: $1: ${SHPKG_CI_STATUS} -> $2"
verbose -n 1 "echo $2 > ${SHPKG_CI_STATUS_FILE}"
echo "$2" > "${SHPKG_CI_STATUS_FILE}"
- verbose 2 shpkg_ci_changed_file "${SHPKG_CI_STATUS_FILE}"
+ shpkg_ci_changed_file "${SHPKG_CI_STATUS_FILE}"
+ grep -v "^$1\$" "${SHPKG_CI_RUNNING}" > "${SHPKG_CI_RUNNING}.tmp"
+ mv "${SHPKG_CI_RUNNING}.tmp" "${SHPKG_CI_RUNNING}"
+ shpkg_ci_changed_file "${SHPKG_CI_RUNNING}"
else
verbose -n 2 "Status change blocked: $1: ${SHPKG_CI_STATUS} -> $2"
fi
}
shpkg_ci_status_trap () {
- SHPKG_CI_STATUS_FILE="${SHPKG_CI_STATUS_DIR}/$1"
- SHPKG_CI_STATUS="$(cat "${SHPKG_CI_STATUS_FILE}")"
- if [ "x${SHPKG_CI_STATUS}" = "xrunning" ]; then
- verbose -n 1 "echo ko > '${SHPKG_CI_STATUS_FILE}'"
- echo ko > "${SHPKG_CI_STATUS_FILE}"
- verbose -n 2 shpkg_ci_changed_file "${SHPKG_CI_STATUS_FILE}"
+ if [ -f "${SHPKG_CI_RUNNING}" ]; then
+ for F in $(cat "${SHPKG_CI_RUNNING}"); do
+ SHPKG_CI_STATUS_FILE="${SHPKG_CI_STATUS_DIR}/$F"
+ SHPKG_CI_STATUS="$(cat "${SHPKG_CI_STATUS_FILE}")"
+ if ! [ "x${SHPKG_CI_STATUS}" = "xrunning" ]; then
+ err 1 "shpkg_ci_status_trap: status is ${SHPKG_CI_STATUS}"
+ fi
+ verbose -n 1 "echo ko > '${SHPKG_CI_STATUS_FILE}'"
+ echo ko > "${SHPKG_CI_STATUS_FILE}"
+ shpkg_ci_changed_file "${SHPKG_CI_STATUS_FILE}"
+ done
+ rm "${SHPKG_CI_RUNNING}"
+ fi
+}
+
+shpkg_ci_status_trap_grep () {
+ if [ -f "${SHPKG_CI_RUNNING}" ]; then
+ for F in $(grep "$1" "${SHPKG_CI_RUNNING}"); do
+ SHPKG_CI_STATUS_FILE="${SHPKG_CI_STATUS_DIR}/$F"
+ SHPKG_CI_STATUS="$(cat "${SHPKG_CI_STATUS_FILE}")"
+ if ! [ "x${SHPKG_CI_STATUS}" = "xrunning" ]; then
+ err 1 "shpkg_ci_status_trap: status is ${SHPKG_CI_STATUS}"
+ fi
+ verbose -n 1 "echo ko > '${SHPKG_CI_STATUS_FILE}'"
+ echo ko > "${SHPKG_CI_STATUS_FILE}"
+ shpkg_ci_changed_file "${SHPKG_CI_STATUS_FILE}"
+ done
+ echo -n > "${SHPKG_CI_RUNNING}"
+ shpkg_ci_changed_file "${SHPKG_CI_RUNNING}"
fi
}
@@ -1030,7 +1054,7 @@ shpkg_ci_status2png () {
if ! [ -f "$I" ] ||
[ "$F" -nt "$I" ]; then
verbose 1 cp "${SHPKG_DIR}/share/shpkg/img/status_${STATUS}.64.png" "$I"
- verbose 2 shpkg_ci_changed_file "$I"
+ shpkg_ci_changed_file "$I"
fi
done
}