diff --git a/bin/shpkg_ci b/bin/shpkg_ci
index e2d0aaa..38317c0 100755
--- a/bin/shpkg_ci
+++ b/bin/shpkg_ci
@@ -18,11 +18,6 @@ verbose 2 shpkg_upgrade
# Configuration
-: ${SHPKG_CI_DIR:=${SHPKG_DIR}/ci}
-SHPKG_CI_BUILD_DIR="${SHPKG_CI_DIR}/build"
-SHPKG_CI_LOG_DIR="${SHPKG_CI_DIR}/log/${SHPKG_OS_}/${SHPKG_TARGET}"
-SHPKG_CI_STATUS_DIR="${SHPKG_CI_DIR}/status/${SHPKG_OS_}/${SHPKG_TARGET}"
-
log_status () {
STATUS_FILE="${SHPKG_CI_STATUS_DIR}/$(basename "$1" .log).status"
if [ -f "${STATUS_FILE}" ]; then
@@ -79,29 +74,6 @@ logs2html () {
done
}
-shpkg_build_status () {
- shpkg_ci_status "$1.build.status" "$2"
-}
-
-# state machine :
-# any -> running
-# running -> ko, ok
-# additionaly status will be changed to ko if aborted while running
-shpkg_ci_status () {
- if [ "x$2" = "xrunning" ]; then
- echo "$2" > "${SHPKG_CI_STATUS_DIR}/$1"
- trap "shpkg_ci_status_trap $1" EXIT
- elif [ "x$(< "${SHPKG_CI_STATUS_DIR}/$1")" = "xrunning" ]; then
- echo "$2" > "${SHPKG_CI_STATUS_DIR}/$1"
- fi
-}
-
-shpkg_ci_status_trap () {
- if [ "x$(< "${SHPKG_CI_STATUS_DIR}/$1")" = "xrunning" ]; then
- echo ko > "${SHPKG_CI_STATUS_DIR}/$1"
- fi
-}
-
main () {
if ! [ -d "${SHPKG_CI_LOG_DIR}" ]; then
verbose 1 mkdir -p "${SHPKG_CI_LOG_DIR}"
diff --git a/share/shpkg/shpkg.subr b/share/shpkg/shpkg.subr
index cdfadd4..5473e2c 100644
--- a/share/shpkg/shpkg.subr
+++ b/share/shpkg/shpkg.subr
@@ -17,6 +17,13 @@ SHPKG_VAR_DB_DIR="${SHPKG_DIR}/var/db/shpkg"
SHPKG_PREFIX="${SHPKG_DIR}"
+# CI
+
+: ${SHPKG_CI_DIR:=${SHPKG_DIR}/ci}
+SHPKG_CI_BUILD_DIR="${SHPKG_CI_DIR}/build"
+SHPKG_CI_LOG_DIR="${SHPKG_CI_DIR}/log/${SHPKG_OS_}/${SHPKG_TARGET}"
+SHPKG_CI_STATUS_DIR="${SHPKG_CI_DIR}/status/${SHPKG_OS_}/${SHPKG_TARGET}"
+
# Console output
SHPKG_COLOR_BLUE="$(printf '\33[0;34m')"
@@ -396,7 +403,7 @@ shpkg_build () {
if [ "x${SHPKG_REPO_DIR}" = "x" ]; then
err 1 "shpkg_build: unknown repo: $SHPKG_REPO"
fi
- verbose 2 shpkg_build_status "${SHPKG_REPO}" running || true
+ verbose 2 shpkg_ci_status "${SHPKG_REPO}.build.status" running
SHPKG_REPO_OBJ_DIR="${SHPKG_OBJ_DIR}/${SHPKG_REPO_DIR}"
SHPKG_REPO_SRC_DIR="${SHPKG_SRC_DIR}/${SHPKG_REPO_DIR}"
SHPKG_REPO_VERSION="$(shpkg_version "${SHPKG_REPO}")"
@@ -407,16 +414,16 @@ shpkg_build () {
if [ -f "${SHPKG_REPO_SRC_DIR}/Makefile" ]; then
( verbose 1 cd "${SHPKG_REPO_SRC_DIR}"
if verbose 1 make -j "${SHPKG_NCPU}"; then
- verbose 2 shpkg_build_status "${SHPKG_REPO}" ok || true
+ verbose 2 shpkg_ci_status "${SHPKG_REPO}.build.status" ok
else
- verbose 2 shpkg_build_status "${SHPKG_REPO}" ko || true
+ verbose 2 shpkg_ci_status "${SHPKG_REPO}.build.status" ko
false
fi ; )
elif [ -f "${SHPKG_SRC_DIR}/${SHPKG_REPO_DIR}/CMakeLists.txt" ]; then
if verbose 1 cmake -j "${SHPKG_NCPU}" --build "${SHPKG_REPO_OBJ_DIR}"; then
- verbose 2 shpkg_build_status "${SHPKG_REPO}" ok || true
+ verbose 2 shpkg_ci_status "${SHPKG_REPO}.build.status" ok
else
- verbose 2 shpkg_build_status "${SHPKG_REPO}" ko || true
+ verbose 2 shpkg_ci_status "${SHPKG_REPO}.build.status" ko
false
fi
fi
@@ -798,3 +805,24 @@ shpkg_upgrade_shpkg () {
verbose 1 git pull &&
verbose 1 . "${SHPKG_DIR}/share/shpkg/shpkg.subr"; )
}
+
+# CI
+
+# state machine :
+# any -> running
+# running -> ko, ok
+# additionaly status will be changed to ko if aborted while running
+shpkg_ci_status () {
+ if [ "x$2" = "xrunning" ]; then
+ echo "$2" > "${SHPKG_CI_STATUS_DIR}/$1"
+ trap "shpkg_ci_status_trap $1" EXIT
+ elif [ "x$(< "${SHPKG_CI_STATUS_DIR}/$1")" = "xrunning" ]; then
+ echo "$2" > "${SHPKG_CI_STATUS_DIR}/$1"
+ fi
+}
+
+shpkg_ci_status_trap () {
+ if [ "x$(< "${SHPKG_CI_STATUS_DIR}/$1")" = "xrunning" ]; then
+ echo ko > "${SHPKG_CI_STATUS_DIR}/$1"
+ fi
+}