#!/bin/sh # $UFP: config/freebsd/E590T/usr/local/etc/synth/hook_pkg_success,v 1.11 2020-09-16 18:50:33 trond Exp $ export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin # Remove all quotation marks that mysteriously became part of these values. DIR_BUILDBASE=$(echo "${DIR_BUILDBASE}" | sed 's|"||g') DIR_DISTFILES=$(echo "${DIR_DISTFILES}" | sed 's|"||g') DIR_LOGS=$(echo "${DIR_LOGS}" | sed 's|"||g') DIR_OPTIONS=$(echo "${DIR_OPTIONS}" | sed 's|"||g') DIR_PACKAGES=$(echo "${DIR_PACKAGES}" | sed 's|"||g') DIR_PORTS=$(echo "${DIR_PORTS}" | sed 's|"||g') DIR_REPOSITORY=$(echo "${DIR_REPOSITORY}" | sed 's|"||g') PROFILE=$(echo "${PROFILE}" | sed 's|"||g') # Split ORIGIN into CATEGORY and PORTNAME. CATEGORY=$(echo ${ORIGIN} | cut -d / -f 1) PORTNAME=$(echo ${ORIGIN} | cut -d / -f 2) # A bug in synth 2.08 leads to FLAVOR having the same value as ORIGIN when an actual flavour is absent. # Note, FLAVOR isn't mentioned in the man page. if [ "${FLAVOR}" = "${ORIGIN}" ]; then FLAVOR= fi # Determine the name of the logfile to examine. if [ -n "${FLAVOR}" ]; then ORIGIN1="${ORIGIN}@${FLAVOR}" else ORIGIN1="${ORIGIN}" fi ORIGIN1=$(echo "${ORIGIN1}" | sed 's|/|___|') LOGFILE="${DIR_LOGS}/${ORIGIN1}.log" # In synth 2.08, the time in the timestamps are always presented as UTC while the date is always presented as local time. # This bug prevails until the date of UTC has catched up with the date of local time for those east of the Greenwich meridian, and vice versa. # Does Ada.Calendar.Clock return local time or UTC? # The function timestamp (...) in portscan.adb should probably be revisited. # # Protip: Always run synth 2.08 with TZ=UTC, as this enforces UTC as the "local" time. # # This happened while TZ=Europe/Oslo: # A build of www/node began at 2020-05-19T23:33:25+0200, which corresponds to 2020-05-19T21:33:25Z, and was recorded by synth as "Started : Tuesday, 19 MAY 2020 at 21:33:25 UTC". # The same build of www/node finished at 2020-05-20T00:40:21+0200, which corresponds to 2020-05-19T22:40:21Z, and was recorded by synth as "Finished: Wednesday, 20 MAY 2020 at 22:40:21 UTC". # The timestamps thus suggest a duration of 25:06:56. # synth thankfully recorded the duration as "Duration: 01:06:56". # START=$(head -n 2 ${LOGFILE} | tail -n 1 | awk '/^Started : / { print $4 "-" $5 "-" $6 " " $8 " zulu"; exit }') FINISHED=$(tail -n 2 ${LOGFILE} | head -n 1 | awk '/^Finished: / { print $3 "-" $4 "-" $5 " " $7 " zulu"; exit }') if [ -n "${FLAVOR}" ]; then INSERT="SELECT insert_pkg ('${CATEGORY}', '${PORTNAME}', '${FLAVOR}', '${PKGNAME}', '${START}', '${FINISHED}');" else INSERT="SELECT insert_pkg ('${CATEGORY}', '${PORTNAME}', '${PKGNAME}', '${START}', '${FINISHED}');" fi if ! pg_isready -U trond -q; then echo ${INSERT} >> /var/synth/portsbuildstats.sql else psql -U trond -c "${INSERT}" -d portsbuildstats -q >/dev/null 2>&1 fi # EOF