blob: a2ec4ecd5e1359ffa84789a5160cbc183073582a (
plain) (
tree)
|
|
#!/bin/sh
set -eu
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
# not a package
[ -r "$package/.osc" ] || exit 0
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
|