Merge branch 'master' of git://github.com/alshopov/git-po
[git/raj.git] / ci / util / extract-trash-dirs.sh
blob8e67bec21a271e017d8707655587ec05de0841fc
1 #!/bin/sh
3 error () {
4 echo >&2 "error: $@"
5 exit 1
8 find_embedded_trash () {
9 while read -r line
11 case "$line" in
12 *Start\ of\ trash\ directory\ of\ \'t[0-9][0-9][0-9][0-9]-*\':*)
13 test_name="${line#*\'}"
14 test_name="${test_name%\'*}"
16 return 0
17 esac
18 done
20 return 1
23 extract_embedded_trash () {
24 while read -r line
26 case "$line" in
27 *End\ of\ trash\ directory\ of\ \'$test_name\'*)
28 return
31 printf '%s\n' "$line"
33 esac
34 done
36 error "unexpected end of input"
39 # Raw logs from Linux build jobs have CRLF line endings, while OSX
40 # build jobs mostly have CRCRLF, except an odd line every now and
41 # then that has CRCRCRLF. 'base64 -d' from 'coreutils' doesn't like
42 # CRs and complains about "invalid input", so remove all CRs at the
43 # end of lines.
44 sed -e 's/\r*$//' | \
45 while find_embedded_trash
47 echo "Extracting trash directory of '$test_name'"
49 extract_embedded_trash |base64 -d |tar xzp
50 done