-
Notifications
You must be signed in to change notification settings - Fork 97
/
verify-build-and-generatelists
executable file
·93 lines (85 loc) · 3.3 KB
/
verify-build-and-generatelists
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
PROJECT=$1
LOG_DIR="/var/log/openSUSE-release-tools/${PROJECT}"
IBS_PRODUCT_PREFIX="SUSE:SLFO:Products:"
GITEA_PRODUCTS_URL="https://src.suse.de/products/"
[ ! -d "${LOG_DIR}" ] && mkdir ${LOG_DIR}
ibs_to_gitea_product() {
printf '%s' "${GITEA_PRODUCTS_URL}$(printf '%s' "${PROJECT}" | sed "s/${IBS_PRODUCT_PREFIX}//" | sed -E 's/:/\#/g')"
}
pkglistgen_extra_args() {
if [[ ${PROJECT} =~ ^${IBS_PRODUCT_PREFIX}.* ]] ; then
printf '%s' "--engine product_composer --git-url $(ibs_to_gitea_product)"
else
printf ''
fi
}
logger() {
date -Is >> ${LOG_DIR}/pkglistgen.log
echo "$1" >> ${LOG_DIR}/pkglistgen.log
}
polling_repo() {
logger "[CHECKING] Checking standard repository from ${PROJECT}"
OUTPUT=$(timeout 3m /usr/share/openSUSE-release-tools/verify-repo-built-successful.py -A ${API_URL} -p ${PROJECT} -r standard $(pkglistgen_extra_args) 2>&1)
RETURNCODE=$?
if [ ${RETURNCODE} -eq 0 ]; then
logger "[READY] Repository is NOT building"
elif [ ${RETURNCODE} -eq 124 ]; then
logger "[TIMEOUT] Verifying repository status reaches a timeout"
else
case ${OUTPUT} in
*"Repository "*" is not yet finished"*)
logger "[BUILDING] Repository is building"
RETURNCODE=3
;;
*"Repository "*" has "*" packages"*)
logger "[FAILED] Repository has package build failed"
RETURNCODE=4
;;
*"Repository "*" has more disabled packages than succeeded"*)
logger "[ERROR] Repository has more disabled packages than succeeded"
RETURNCODE=5
;;
esac
logger "${OUTPUT}"
fi
return ${RETURNCODE}
}
logger "[START] Start osrt-pkglistgen@${PROJECT}.service: polling repository results"
polling_repo
# Check if repository building
if [ $? -eq 3 ]; then
# Repository is building, waiting it finishes
while true; do
logger "[WAITING] Waiting 10min before next repository status check"
sleep 10m
polling_repo
case $? in
0)
# Stop polling repository results: Repository finished building
if systemctl is-active --quiet osrt-relpkggen@${PROJECT}.service; then
logger "[WARNING] osrt-relpkggen@${PROJECT}.service is running"
logger "[WAITING] Waiting for osrt-relpkggen@${PROJECT}.service finishes"
continue
else
logger"[RUNNING] Running osrt-pkglistgen"
/usr/bin/osrt-pkglistgen -A ${API_URL} --debug update_and_solve -p ${PROJECT} -s target --custom-cache-tag product --force >> ${LOG_DIR}/pkglistgen.log 2>&1
exit $?
fi
;;
3)
# Continue polling repository results: Repository is still building
continue
;;
124)
# Retry polling repository results: Verifying repository results reaches a timeout
continue
;;
*)
# Stop polling repository results: Failed polling results
exit 1
;;
esac
done
fi
logger "[FINISH] Finish osrt-pkglistgen@${PROJECT}.service"