aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2022-12-14 10:30:36 +0100
committerMatěj Cepl <mcepl@cepl.eu>2022-12-14 10:30:36 +0100
commit2ffae67c296ef16f7fe7aacb55cc3ec4fbe44cba (patch)
treeb5ed176e4d578a882599afaccbf117883e9a0757
downloadtime-of-build-2ffae67c296ef16f7fe7aacb55cc3ec4fbe44cba.tar.gz
Initial draft of the script.
-rw-r--r--README.md5
-rwxr-xr-xtime-of-build.sh22
2 files changed, 27 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..658ad17
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
+Calculate number of seconds the package was build in OBS.
+
+Usage:
+
+ $ time-of-build.sh devel:languages:python:flask python-Flask
diff --git a/time-of-build.sh b/time-of-build.sh
new file mode 100755
index 0000000..fde7689
--- /dev/null
+++ b/time-of-build.sh
@@ -0,0 +1,22 @@
+#!/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) ))