|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +DEBUG=0 |
| 4 | +BASE_STACK=/cvmfs/software.eessi.io/versions/2023.06/software/linux/x86_64/intel/haswell/software |
| 5 | +EB_BOOTSTRAP=4.9.4 |
| 6 | + |
| 7 | +declare -A gcc_to_foss=( ["12.2.0"]="2022b" ["12.3.0"]="2023a" ["13.2.0"]="2023b" ) |
| 8 | + |
| 9 | +if [[ ! -d ${BASE_STACK} ]]; then |
| 10 | + echo "The given base stack (${BASE_STACK}) is not a directory." |
| 11 | + exit 1 |
| 12 | +fi |
| 13 | + |
| 14 | +apps=$(find ${BASE_STACK} -mindepth 2 -maxdepth 2 -type d | head -n 3) |
| 15 | + |
| 16 | +json_output="[" |
| 17 | +for app_dir in $apps; do |
| 18 | + app_version=$(basename ${app_dir}) |
| 19 | + app_name=$(basename $(dirname ${app_dir})) |
| 20 | + |
| 21 | + if [[ ${app_name} == "EESSI-extend" ]]; then |
| 22 | + # Skip EESSI-extend, as it will be installed automatically. |
| 23 | + continue |
| 24 | + fi |
| 25 | + |
| 26 | + easyblocks=${app_dir}/easybuild/reprod/easyblocks/*.py |
| 27 | + easyconfig=${app_dir}/easybuild/reprod/${app_name}-${app_version}.eb |
| 28 | + if [[ ! -f ${easyconfig} ]]; then |
| 29 | + echo "ERROR: cannot find easyconfig for ${app_name}/${app_version}" |
| 30 | + fi |
| 31 | + # If rebuilds would not remove the original log file, we should take the build time from the first log. |
| 32 | + # As we cannot guarantee that at the moment, we are cautious and use the last one. |
| 33 | + log_file=$(ls -1 ${app_dir}/easybuild/easybuild-${app_name}*.log* | tail -n 1) |
| 34 | + build_time_start=$(bzcat ${log_file} | head -n 1 | awk '{print $2 "T" $3}' | cut -d, -f1) |
| 35 | + build_time_end=$(bzcat ${log_file} | tail -n 1 | awk '{print $2 "T" $3}' | cut -d, -f1) |
| 36 | + #build_time_unix=$( date +%s -d ${build_time}) |
| 37 | + build_duration=$(( ($(date +%s -d ${build_time_end}) - $(date +%s -d ${build_time_start}))/60 )) |
| 38 | + |
| 39 | + eb_version=$(bzgrep -oP "This is EasyBuild \K([0-9].[0-9].[0-9])" ${log_file} | head -n 1) |
| 40 | + # Some EB versions have been installed with a temporary EB installation of the same version. |
| 41 | + # If that's the case, use the version specified with ${EB_BOOTSTRAP} instead. |
| 42 | + # This needs to correspond to the version that gets installed initially by EESSI-install-software.sh, |
| 43 | + # which should be the latest EB version available when that script is being run. |
| 44 | + if [[ ${app_name} == "EasyBuild" ]] && [[ ${app_version} == ${eb_version} ]]; then |
| 45 | + eb_version=${EB_BOOTSTRAP} |
| 46 | + fi |
| 47 | + |
| 48 | + if [[ ${app_version} != *-* ]]; then |
| 49 | + toolchain=SYSTEM |
| 50 | + else |
| 51 | + if [[ ${app_version} == *-GCC* ]]; then |
| 52 | + gcc_ver=$(echo ${app_version} | grep -oP "(GCC|GCCcore)-\K.*?(?=-|$)") |
| 53 | + toolchain=${gcc_to_foss[$gcc_ver]} |
| 54 | + else |
| 55 | + toolchain=$(echo ${app_version} | grep -oP "(foss|gfbf|gompi)-\K.*?(?=-|$)") |
| 56 | + fi |
| 57 | + fi |
| 58 | + |
| 59 | + json=$( |
| 60 | + jq --null-input \ |
| 61 | + --arg build_time "${build_time_start}" \ |
| 62 | + --arg build_duration_minutes "${build_duration}" \ |
| 63 | + --arg name "${app_name}" \ |
| 64 | + --arg version "${app_version}" \ |
| 65 | + --arg easybuild "${eb_version}" \ |
| 66 | + --arg toolchain "${toolchain}" \ |
| 67 | + --arg easyconfig "${easyconfig}" \ |
| 68 | + --arg easyblocks "${easyblocks}" \ |
| 69 | + '$ARGS.named' # requires jq 1.7 or newer |
| 70 | + #'{build_time: $build_time, build_duration_minutes: $build_duration, name: $name, version: $version, easybuild: $easybuild, |
| 71 | + # toolchain: $toolchain, easyconfig: $easyconfig, easyblocks: $easyblocks}' |
| 72 | + ) |
| 73 | + |
| 74 | + if [[ ${json_output} == "[" ]]; then |
| 75 | + json_output="${json_output}${json}" |
| 76 | + else |
| 77 | + json_output="${json_output},${json}" |
| 78 | + fi |
| 79 | + [[ ${DEBUG} -ne 0 ]] && echo ${build_time_unix} ${app_name} ${app_version} ${eb_version} ${toolchain} ${easyconfig} ${easyblocks} |
| 80 | +done #| sort -nu |
| 81 | +json_output="${json_output}]" |
| 82 | + |
| 83 | +[[ ${DEBUG} -ne 0 ]] && echo ${json_output} |
| 84 | +echo ${json_output} | jq 'sort_by(.build_time)' |
0 commit comments