summaryrefslogtreecommitdiff
path: root/lib/builder-utils.sh
blob: 4cf2c7154188fd1e53e249e44729082e4a92e386 (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
55
56
#############################################
# void retrieve_file (src, dst)
#
# Description: retrieve file from an URL
# 
# Parameter
#  src: source url to get file from
#  dst: path to store file to
#
#############################################
function  retrieve_file() {
    local src=$1
    local dst=$2

    # Check, if the URL is a file URL starting with file://
    if [ -f $dst ] && [ -z ${DIST_FORCE_DOWNLOAD} ]; then
	echo "  Info: File still cached/downloaded. To force a download, set DIST_FORCE_DOWNLOAD=1"
    elif [[ $src == file://* ]]; then
	fileurl=`echo $src | sed "s/^file:\/\///"`
	cp  $fileurl $dst  2>/dev/null
    else
	rm -f $dst
	wget  --tries=1 -O $dst --timeout=5 -q --no-verbose $src
    fi  
}


#############################################
# check if method is available and call it
#############################################
function  call_entry_point() {
    local _resultvar=$1
    local func=$2
      
    # Entry point
    type $func &>/dev/null
    if [ $? == 0 ] ; then 
	$func
	eval $_resultvar="0"
    else
	eval $_resultvar="1"
    fi

}


###################
# Check error
###################
builder_check_error() {
    if [ $? == 1 ] ; then
	echo "FATAL: $1"
	exit 0
    fi
}

Powered by Domaintechnik.at | Hosting - Domain - Webspace