aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/get-prebuilt.sh
blob: d7e8d52da3f9a03d172859f410babf402bb52253 (plain)
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
#!/bin/sh

url="https://github.com/MailCore/mailcore2-deps"
url_prefix="$url/raw/master"
content_prefix="https://raw.githubusercontent.com/MailCore/mailcore2-deps/master"

if test x$1 != xskipprebuilt ; then
  file_timestamp=0
  if test -f prebuilt.list ; then
    file_timestamp=`stat -f '%m' prebuilt.list`
  fi
  timestamp=`ruby -e 'puts Time.now.to_i'`
  age=$((($timestamp-$file_timestamp)/3600)) # in hours
  if test ! -d ../Externals/prebuilt ; then
    age=1
  fi
  if test $age -gt 0 ; then
    networkerror=no
    curl -3 -s -L "$content_prefix/prebuilt.list" > prebuilt.list.tmp
    if test x$? != x0 ; then
      networkerror=yes
    fi
    
    if test x$networkerror = xyes ; then
      echo WARNING: could not get prebuilt.list from repository
      exit 1
    fi
    
    mv prebuilt.list.tmp prebuilt.list
  
    if test -f prebuilt.list ; then
      files=`cat prebuilt.list`
      mkdir -p ../Externals/builds/builds
      mkdir -p ../Externals/prebuilt
      pushd ../Externals/prebuilt
      rm -rf .git
      echo Getting prebuilt libraries...
      if test -d mailcore2-deps ; then
        cd mailcore2-deps
        git pull --rebase
        cd ..
      else
        git clone --depth 1 "$url"
      fi
      rsync --exclude=.git -av mailcore2-deps/ ../builds/builds/
      popd
    fi
  fi
fi