aboutsummaryrefslogtreecommitdiffstats
path: root/time-of-build.sh
blob: 0ac4016e2de9734070dc8f59838c3f9108c5696b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
set -eu

projname="$1"
pkg="$2"
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