File: glibc_download.sh

package info (click to toggle)
chromium-browser 41.0.2272.118-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,189,132 kB
  • sloc: cpp: 9,691,462; ansic: 3,341,451; python: 712,689; asm: 518,779; xml: 208,926; java: 169,820; sh: 119,353; perl: 68,907; makefile: 28,311; yacc: 13,305; objc: 11,385; tcl: 3,186; cs: 2,225; sql: 2,217; lex: 2,215; lisp: 1,349; pascal: 1,256; awk: 407; ruby: 155; sed: 53; php: 14; exp: 11
file content (58 lines) | stat: -rwxr-xr-x 1,890 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Copyright (c) 2011 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This file polls the appspot directory for a fixed time.

# We try to check if the revision we need is already available.  If it is
# then we have a good glibc to use and continue.  If it is not available then
# we check revisions forward - and if one of them is available then we give up:
# this means the revision we need was omitted for some reason and will not be
# ever built.

if ((${#@}<1)); then
  cat <<END
  Usage: $0 path_to_toolchain [max_sleep] [revisions_count]
END
  exit 10
fi
declare -r glibc_url_prefix=http://storage.googleapis.com/nativeclient-archive2/between_builders/x86_glibc/r
declare -r glibc_revision="$("$(dirname "$0")/glibc_revision.sh")"
if [[ "$(uname -s)" == "Darwin" ]]; then
  declare -r tar=gnutar
else
  declare -r tar=tar
fi
max_sleep=10000
if ((${#@}>1)); then
  max_sleep="$2"
fi
revisions_count=100
if ((${#@}>2)); then
  revisions_count="$3"
fi
for ((i=1;i<=max_sleep;)); do
  curl --fail --location --url \
      "$glibc_url_prefix$glibc_revision"/glibc_x86.tar.gz -o "$1/.glibc.tar" &&
  $tar xSvpf "$1/.glibc.tar" -C "$1" &&
  ( rm "$1/.glibc.tar" || ( sleep 30 && rm "$1/.glibc.tar" ) ) &&
  echo "Got glibc from revision $glibc_revision" &&
  exit 0
  for ((j=glibc_revision+1;j<glibc_revision+revisions_count;j++)); do
    echo "Check if revision \"$j\" is available..."
    if curl --fail --location --url \
          "$glibc_url_prefix$j"/glibc_x86.tar.gz > /dev/null; then
      exit 2
    fi
  done
  sleep_time="$i"
  # Chromium buildbot infrastructure won't let us sleep longer than 1000 without
  # producing output.  Limit by 1000 to avoid races.
  if ((i>=1000)); then
    sleep_time=1000
  fi
  sleep "$sleep_time"
  ((i+=sleep_time))
done
exit 1