aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2022-12-14 14:01:10 +0100
committerMatěj Cepl <mcepl@cepl.eu>2022-12-14 14:21:10 +0100
commit25119e6a5c079082d5b9f2671567a39e6e08845a (patch)
treef5f8ca4aa5cc6345090cc652fb46a81696881ae3
parent73fe33be72d2d22d90a0640e6e79d1e12ed69aa0 (diff)
downloadtime-of-build-25119e6a5c079082d5b9f2671567a39e6e08845a.tar.gz
Take into account multibuild builds.
-rw-r--r--README.md4
-rwxr-xr-xtime-of-build.sh38
2 files changed, 31 insertions, 11 deletions
diff --git a/README.md b/README.md
index 658ad17..cadd895 100644
--- a/README.md
+++ b/README.md
@@ -2,4 +2,6 @@ Calculate number of seconds the package was build in OBS.
Usage:
- $ time-of-build.sh devel:languages:python:flask python-Flask
+ $ time-of-build.sh python-Flask
+
+Requires osc and xmlstarlet.
diff --git a/time-of-build.sh b/time-of-build.sh
index 0ac4016..1446bd9 100755
--- a/time-of-build.sh
+++ b/time-of-build.sh
@@ -1,16 +1,34 @@
#!/bin/sh
set -eu
-projname="$1"
-pkg="$2"
+if [ ! -r .osc/_project ] ; then
+ echo 'This program must be run from an OBS project directory.'
+ exit 42
+fi
+
+projname="$(basename $(pwd))"
+package="$1"
tempfile="$(mktemp -t time-of-build-XXXXXX)"
trap 'rm -rf "$tempfile"' EXIT
-osc rbl $projname $pkg openSUSE_Tumbleweed x86_64 >$tempfile
-# begtime="Tue Dec 13 23:50:13 UTC 2022"
-# \x22 is " character; https://unix.stackexchange.com/a/230354/184648
-begstr="$(sed -E -n -e '/started \x22build/s/^.*at (.*)\.$/\1/p' $tempfile)"
-endstr="$(sed -E -n -e '/(finished|failed) \x22build/s/^.*at (.*)\.$/\1/p' $tempfile)"
-begtime="$(date --date "$begstr" +%s)"
-endtime="$(date --date "$endstr" +%s)"
-printf "%s\t%s\n" $(( endtime - begtime )) $pkg
+process="$package"
+if [ -r "$package/_multibuild" ] ; then
+ for t in $(xmlstarlet sel -t -v '//package' $package/_multibuild) ; do
+ process="$process $package:$t"
+ done
+fi
+
+total_time=0
+for pkg in $process ; do
+ osc rbl $projname $pkg openSUSE_Tumbleweed x86_64 >$tempfile
+ # begtime="Tue Dec 13 23:50:13 UTC 2022"
+ # \x22 is " character; https://unix.stackexchange.com/a/230354/184648
+ begstr="$(sed -E -n -e '/started \x22build/s/^.*at (.*)\.$/\1/p' $tempfile)"
+ endstr="$(sed -E -n -e '/(finished|failed) \x22build/s/^.*at (.*)\.$/\1/p' $tempfile)"
+ begtime="$(date --date "$begstr" +%s)"
+ endtime="$(date --date "$endstr" +%s)"
+ ttime=$(( endtime - begtime ))
+ total_time=$(( total_time + ttime ))
+done
+
+printf "%s\t%s\n" $total_time $package