aboutsummaryrefslogblamecommitdiffstats
path: root/time-of-build.sh
blob: fde7689589773556625de28ae83105708e79bc4b (plain) (tree)





















                                                                                   
#!/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
begstr="$(sed -E -n -e '/started "build/s/^.*at (.*)\.$/\1/p' $tempfile)"
endstr="$(sed -E -n -e '/(finished|failed) "build/s/^.*at (.*)\.$/\1/p' $tempfile)"
begtime="$(date --date "$begstr" +%s)"
endtime="$(date --date "$endstr" +%s)"
echo -e "$(( $endtime - $begtime ))\t$pkg"

#  begtime="Tue Dec 13 23:50:13 UTC 2022"
#  endtime="Tue Dec 13 23:50:27 UTC 2022"
#  date --date '2017-08-17 04:00:01' +%s    # "1502938801"
#  date --date '2017-08-17 04:00:01' +%s
#  date --date "$begtime" %s
#  date --date "$begtime" +%s
#  echo $(( $(date --date "$endtime" +%s) - $(date --date "$begtime" +%s) ))