1#!/bin/bash 2# 3# Plain identify job for Isabelle + AFP 4# 5 6set -e 7 8source "$HOME/.bashrc" 9 10LANG=C 11 12REPOS_DIR="$HOME/cronjob/plain_identify_repos" 13ISABELLE_REPOS_SOURCE="https://isabelle.in.tum.de/repos/isabelle" 14AFP_REPOS_SOURCE="https://bitbucket.org/isa-afp/afp-devel" 15 16function setup_repos () 17{ 18 local NAME="$1" 19 local SOURCE="$2" 20 mkdir -p "$REPOS_DIR" 21 if [ ! -d "$REPOS_DIR/$NAME" ]; then 22 hg clone --noupdate -q "$SOURCE" "$REPOS_DIR/$NAME" 23 fi 24} 25 26function identify_repos () 27{ 28 local NAME="$1" 29 hg pull -R "$REPOS_DIR/$NAME" -q 30 local ID="$(hg tip -R "$REPOS_DIR/$NAME" --template "{node|short}")" 31 echo "$NAME version: $ID" 32} 33 34setup_repos "Isabelle" "$ISABELLE_REPOS_SOURCE" 35setup_repos "AFP" "$AFP_REPOS_SOURCE" 36 37NOW="$(date --rfc-3339=ns)" 38LOG_DIR="$HOME/cronjob/log/$(date -d "$NOW" "+%Y")" 39LOG_SECONDS="$(($(date -d "$NOW" +"%s") - $(date -d 'today 00:00:00' "+%s")))" 40LOG_NAME="plain_identify_$(date -d "$NOW" "+%Y-%m-%d").$(printf "%05d" "$LOG_SECONDS").log" 41 42mkdir -p "$LOG_DIR" 43 44{ 45 echo -n "isabelle_identify: " 46 date -d "$NOW" "+%a %b %-d %H:%M:%S %Z %Y" 47 echo 48 identify_repos "Isabelle" 49 identify_repos "AFP" 50} > "$LOG_DIR/$LOG_NAME" 51