aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/get-prebuilt.sh
blob: 35b2980fa2799fb038549628fc4a31eecf2a8dc8 (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
50
51
52
53
54
#!/bin/sh

url="https://github.com/MailCore/mailcore2-deps"
url_prefix="$url/raw/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
    #echo "$url_prefix/prebuilt.list"
    curl -s -L "$url_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
      if test -d mailcore2-deps ; then
        cd mailcore2-deps
        git pull --rebase
        cd ..
      else
        git clone --depth 1 "$url"
      fi
      # for filename in $files ; do
        #   if test ! -f $filename ; then
        #     echo get $filename
        #     curl -L -O "$url_prefix/$filename"
        #   fi
        # done
        rsync --exclude=.git -av mailcore2-deps/ ../builds/builds/
        popd
      fi
    fi
fi