summaryrefslogtreecommitdiff
path: root/tcwg-wip/tcwg-convert-interesting-commits.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tcwg-wip/tcwg-convert-interesting-commits.sh')
-rwxr-xr-xtcwg-wip/tcwg-convert-interesting-commits.sh219
1 files changed, 219 insertions, 0 deletions
diff --git a/tcwg-wip/tcwg-convert-interesting-commits.sh b/tcwg-wip/tcwg-convert-interesting-commits.sh
new file mode 100755
index 00000000..51f08647
--- /dev/null
+++ b/tcwg-wip/tcwg-convert-interesting-commits.sh
@@ -0,0 +1,219 @@
+#!/bin/bash
+
+set -euf -o pipefail
+set -x
+
+old="$HOME/interesting-commits"
+git="git -C $old"
+new="$HOME/interesting"
+
+component_repo ()
+{
+ local c="$1"
+
+ case "$c" in
+ llvm) c="llvm-project" ;;
+ binutils|gdb) c="binutils-gdb" ;;
+ esac
+
+ echo "$HOME/interesting-repos/$c.git"
+}
+
+prepare_git_repos ()
+{
+ local -A interesting_url
+ interesting_url[binutils]=git://sourceware.org/git/binutils-gdb.git
+ interesting_url[gdb]=git://sourceware.org/git/binutils-gdb.git
+ interesting_url[gcc]=https://github.com/gcc-mirror/gcc.git
+ interesting_url[linux]=https://git.linaro.org/kernel-org/linux.git
+ interesting_url[glibc]=git://sourceware.org/git/glibc.git
+ interesting_url[newlib]=git://sourceware.org/git/newlib-cygwin.git
+ interesting_url[llvm]=https://github.com/llvm/llvm-project.git
+ interesting_url[qemu]=https://gitlab.com/qemu-project/qemu.git
+
+ for c in binutils gdb gcc linux glibc newlib llvm qemu; do
+ url="${interesting_url[$c]}"
+ repo=$(component_repo $c)
+ if [ -d $repo ]; then
+ git -C $repo remote update -p
+ else
+ reference_opt=""
+ reference_dir=$(basename "$(component_repo $c)")
+ reference_dir="/home/tcwg-buildslave/snapshots-ref/$reference_dir"
+ if [ -d $reference_dir ]; then
+ reference_opt="--reference $reference_dir"
+ fi
+ git clone --bare $reference_opt $url $repo
+ case "$c" in
+ linux)
+ git -C $repo remote add stable https://git.linaro.org/kernel-org/linux-stable.git
+ git -C $repo remote update -p
+ ;;
+ esac
+ fi
+ done
+
+ $git remote update -p
+ $git reset -q --hard
+ $git clean -fd
+}
+
+prepare_git_repos
+
+declare -A describe_cache
+describe_sha1 ()
+{
+ local component="$1"
+ local sha1="$2"
+
+ if [ x"${describe_cache[$component#$sha1]-unset}" = x"unset" ]; then
+ echo "$component#$sha1" >> $HOME/tmp/miss
+ local -a match=()
+ case "$component" in
+ gcc) match=(--match "basepoints/*" --match "releases/*") ;;
+ binutils) match=(--exclude "users/*") ;;
+ newlib) match=(--match "newlib*") ;;
+ esac
+
+ describe_cache[$component#$sha1]=$(git -C "$(component_repo $component)" describe "${match[@]}" $sha1 || true)
+ fi
+}
+
+update_entry ()
+{
+ local component="$1"
+ local sha1="$2"
+ local ci_project="$3"
+ local ci_config="$4"
+ local bisect_url="$5"
+ local last_good="$6"
+
+ if ! git -C "$(component_repo $component)" rev-parse --verify $sha1 2>/dev/null; then
+ return
+ fi
+
+ describe_sha1 "$component" "$sha1"
+ local describe="${describe_cache[$component#$sha1]}"
+ if ! [ -d $new/$component/sha1/$sha1 ] \
+ && [ x"$describe" != x"" ]; then
+ local d
+ d=$(dirname "$describe")
+ mkdir -p $new/$component/$d
+ local symlink=""
+ while [ x"$d" != x"." ]; do
+ symlink="../$symlink"
+ d=$(dirname "$d")
+ done
+ symlink="${symlink}sha1/$sha1"
+ ln -s $symlink $new/$component/$describe
+ fi
+
+ mkdir -p $new/$component/sha1/$sha1/$ci_project/$ci_config
+ echo "$bisect_url" > $new/$component/sha1/$sha1/$ci_project/$ci_config/build_url
+ if [ x"$last_good" != x"" ]; then
+ echo "$last_good" \
+ > $new/$component/sha1/$sha1/$ci_project/$ci_config/last_good
+ fetch_summary "$bisect_url" \
+ $new/$component/sha1/$sha1/$ci_project/$ci_config
+ if [ x"$describe" = x"" ]; then
+ describe="$ci_project#$sha1"
+ fi
+ generate_status "$describe" $component/sha1/$sha1 $ci_project
+ fi
+}
+
+fetch_dir=$HOME/interesting-repos/fetch-cache
+fetch_summary ()
+{
+ local bisect_url="$1"
+ local out="$2"
+
+ local cache_url="${bisect_url#https://}"
+ if ! [ -f $fetch_dir/$cache_url/summary.txt ]; then
+ mkdir -p $fetch_dir/$cache_url/
+ curl -o $fetch_dir/$cache_url/summary.txt \
+ ${bisect_url}artifact/artifacts/build-first_bad/mail/jira-body.txt \
+ --fail &
+ if wait $!; then
+ sed -i -e "/^[^-]/d" -e "/^\$/d" -e "s/^- //" \
+ $fetch_dir/$cache_url/summary.txt
+ else
+ echo > $fetch_dir/$cache_url/summary.txt
+ fi
+ fi
+ cp $fetch_dir/$cache_url/summary.txt $out/summary.txt
+}
+
+generate_status ()
+{
+ local describe="$1"
+ local subdir="$2"
+ local ci_project="$3"
+ local interesting_commits="$new"
+ local status="$subdir/$ci_project/status.txt"
+
+ local ci_config
+
+ cat > $interesting_commits/$status <<EOF
+Status of $describe commit for $ci_project ci_project:
+EOF
+ for ci_config in $(cd $interesting_commits/$subdir/$ci_project; set +f; echo *); do
+ if ! [ -f "$interesting_commits/$subdir/$ci_project/$ci_config/summary.txt" ]; then
+ continue
+ fi
+ echo "* $ci_config"
+ (
+ cat $interesting_commits/$subdir/$ci_project/$ci_config/summary.txt
+ cat $interesting_commits/$subdir/$ci_project/$ci_config/build_url
+ ) | sed "s/^/** /"
+ done >> $interesting_commits/$status
+}
+
+rm -rf "$new"
+mkdir -p "$new"
+
+while IFS= read -r branch; do
+ $git checkout --detach $branch
+
+ while true; do
+ ci_project=${branch# *origin/linaro-local/ci/}
+ bisect_url=$($git show --pretty=%s --no-patch | sed -e "s/.* from //")
+ pushd $old
+ while read component; do
+ ci_config=""
+ arr=()
+ while read -a arr; do
+ if [ ${#arr[@]} -gt 1 ]; then
+ sha1="${arr[0]}"
+ if [ x"$sha1" != x"e5a9d60317852a7323e46109fa366e630b8b5bae" ]; then
+ #continue
+ :
+ fi
+ for ci_project_config in "${arr[@]:1}"; do
+ ci_project2=${ci_project_config%/*}
+ ci_config=${ci_project_config#*/}
+
+ if [ x"$ci_project" != x"$ci_project2" ]; then
+ echo "ERROR: ci_project mismatch"
+ exit 1
+ fi
+
+ update_entry "$component" "$sha1" "$ci_project" "$ci_config" "$bisect_url" ""
+ done
+ elif [ x"$ci_config" != x"" ]; then
+ if [ x"$sha1" != x"e5a9d60317852a7323e46109fa366e630b8b5bae" ]; then
+ #continue
+ :
+ fi
+ last_good="${arr[0]}"
+ update_entry "$component" "$sha1" "$ci_project" "$ci_config" "$bisect_url" "$last_good"
+ fi
+ done < <(tac $component)
+ done < <(ls)
+ popd
+ if ! $git rev-parse --verify HEAD^ 2>/dev/null; then
+ break
+ fi
+ $git checkout --detach HEAD^
+ done
+done < <($git branch -r --list "origin/linaro-local/*")