summaryrefslogtreecommitdiffstats
path: root/bzr_download.function
blob: 9eab2916f98881c1c670ca6b171d2f9a948db544 (plain) (blame)
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
#---------------------------------------------------------------------
## Handler for downloading from bzr URLs
#---------------------------------------------------------------------
function bzr_download() {
  local URL="${SOURCE_URL%:*}"
  URL="${URL#bzr_}"

  if file_exists $SOURCE_CACHE/$SOURCE
  then
    message "${MESSAGE_COLOR}Unpacking the source...${DEFAULT_COLOR}" &&
    tar xjf $SOURCE_CACHE/$SOURCE -C $(dirname $SOURCE_DIRECTORY) &&
    cd $SOURCE_DIRECTORY &&
    message "${MESSAGE_COLOR}Updating...${DEFAULT_COLOR}" &&
    echo bzr update &&
    bzr update &&
    cd -
  else
    message "${MESSAGE_COLOR}Doing a lightweight checkout...${DEFAULT_COLOR}" &&
    echo bzr checkout --lightweight "$URL" "$SOURCE_DIRECTORY" &&
    bzr checkout --lightweight "$URL" "$SOURCE_DIRECTORY"
  fi &&

  message "${MESSAGE_COLOR}Repacking the source...${DEFAULT_COLOR}" &&
  tar cjf $SOURCE -C $(dirname $SOURCE_DIRECTORY) $(basename $SOURCE_DIRECTORY) &&
  mv $SOURCE $SOURCE_CACHE
}