Admin/download-components
author wenzelm
Fri, 10 Aug 2012 13:15:00 +0200
changeset 48753 5e57a6f24cdb
parent 48593 c895e334162c
child 48788 cea7f88c8084
permissions -rwxr-xr-x
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48593
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
     1
#!/usr/bin/env bash
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
     2
#
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
     3
# Author: Florian Haftmann
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
     4
#
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
     5
# DESCRIPTION: Download and unpack components from central component store
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
     6
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
     7
shopt -s -o errexit
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
     8
shopt -s -o nounset
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
     9
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    10
THIS="$(basename "$0")"
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    11
HERE="$(cd $(dirname "$0"); cd "$(pwd -P)"; pwd)"
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    12
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    13
trap 'echo "Error in ${THIS}" >&2' ERR
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    14
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    15
function fail {
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    16
  echo "$1" >&2
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    17
  exit 1
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    18
}
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    19
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    20
ISABELLE_HOME_USER="$(isabelle getenv -b ISABELLE_HOME_USER)"
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    21
: ${TMP:='/tmp'}
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    22
REMOTE='http://isabelle.in.tum.de/components'
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    23
LOCAL="${ISABELLE_HOME_USER}/contrib"
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    24
SUFFIX='.tar.gz'
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    25
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    26
for COMPONENT in "$@"
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    27
do
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    28
  COMPONENT_ARCHIVE="${COMPONENT}.tar.gz"
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    29
  wget -nd --directory-prefix="${TMP}" "${REMOTE}/${COMPONENT_ARCHIVE}"
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    30
  tar -xzv -f "${TMP}/${COMPONENT_ARCHIVE}" -C "${LOCAL}"
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    31
  rm "${TMP}/${COMPONENT_ARCHIVE}"
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    32
  echo
c895e334162c script for downloading components from central store
haftmann
parents:
diff changeset
    33
done