summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2024-04-19 11:47:03 +0200
committerRemi Collet <remi@php.net>2024-04-19 11:47:03 +0200
commit9fc98148d850b35f9e47e33188639424dfa89e48 (patch)
tree65cfd2424ef6ad21ef8ef51d55186d39cbd8e7f1
parent1e7b3ee7cebffc20c1e9e14a97b3225d3315ac1e (diff)
add redis queue to mockit/mockrun
-rwxr-xr-xmockit31
-rwxr-xr-xmockrun41
2 files changed, 67 insertions, 5 deletions
diff --git a/mockit b/mockit
index 783500b..907e79c 100755
--- a/mockit
+++ b/mockit
@@ -7,6 +7,7 @@ fi
BUILD_BASE=1
BUILD_SCLS=1
+REDIS=0
if [ "$1" == "--nobase" -o "$1" == "--scl" ]; then
BUILD_BASE=0
@@ -16,6 +17,12 @@ if [ "$1" == "--noscl" -o "$1" == "--base" ]; then
BUILD_SCLS=0
shift
fi
+if [ "$1" == "--redis" ]; then
+ CHECK=$(redis-cli ping)
+ [ "$CHECK" = "PONG" ] || exit 1
+ REDIS=1
+ shift
+fi
SRPM=$1
DIST=$2
@@ -81,16 +88,30 @@ ID=${QUEUE:-$PPID}
[ $BUILD_BASE -ge 1 ] && for i in $LST
do
if [ 0$i -ge $MIN -a 0$i -le $MAX ]; then
- echo -n "$(date +%X) $i "
- mock -q --configdir=$mocketc --uniqueext=$ID -r ${DIST}${i} rebuild $SRPM "$@" && echo " Ok." || echo " Error !"
+ CMD="mock -q --configdir=$mocketc -r ${DIST}${i} rebuild $SRPM $@"
+ if [ $REDIS -ge 1 ]; then
+ redis-cli sadd mock "$CMD"
+ else
+ echo -n "$(date +%X) $i "
+ $CMD --uniqueext=$ID && echo " Ok." || echo " Error !"
+ fi
fi
done
[ $BUILD_SCLS -ge 1 ] && for i in $SCL
do
if [ 0$i -ge $MIN -a 0$i -le $MAX ]; then
- echo -n "$(date +%X) scl$i "
- mock -q --configdir=$mocketc --uniqueext=$ID -r ${DIST}scl${i} rebuild $SRPM "$@" && echo " Ok." || echo " Error !"
+ CMD="mock -q --configdir=$mocketc -r ${DIST}scl${i} rebuild $SRPM $@"
+ if [ $REDIS -ge 1 ]; then
+ redis-cli sadd mock "$CMD"
+ else
+ echo -n "$(date +%X) scl$i "
+ $CMD --uniqueext=$ID && echo " Ok." || echo " Error !"
+ fi
fi
done
-date +%X
+if [ $REDIS -ge 1 ]; then
+ echo "Queue size: " $(redis-cli scard mock)
+else
+ date +%X
+fi
diff --git a/mockrun b/mockrun
new file mode 100755
index 0000000..a303073
--- /dev/null
+++ b/mockrun
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+CHECK=$(redis-cli ping)
+[ "$CHECK" = "PONG" ] || exit 1
+
+if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ echo "Usage $0 [ option ]"
+ echo " -e --erase to empty the queue"
+ echo " -l --list to list the queue"
+ echo " -p --perm to run permanently"
+
+ exit 0
+
+elif [ "$1" = "-l" -o "$1" = "--list" ]; then
+ redis-cli smembers mock
+ exit 0
+
+elif [ "$1" = "-e" -o "$1" = "--erase" ]; then
+ redis-cli del mock
+ exit 0
+fi
+
+while true
+do
+ CMD=$(redis-cli spop mock)
+ if [ -z "$CMD" ]; then
+ if [ "$1" = "-p" -o "$1" = "--perm" ]; then
+ echo -n .
+ sleep 1
+ continue
+ else
+ break
+ fi
+ fi
+ TXT=$(echo $CMD | sed -e 's/^.*-r //;s/ .*$//')
+ echo -en "\r$(date +%X) $TXT "
+ $CMD --uniqueext=$PPID && echo " Ok." || echo " Error !"
+done
+
+echo "$(date +%X) Done"
+