summaryrefslogtreecommitdiff
path: root/build-da-checkout.sh
blob: f914518abb9febdc84db2292f5aa6208657cfa32 (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
57
58
#!/bin/bash

# For Git
FETCH_CMD="git fetch -p"
CHECKOUT_CMD="git checkout -f "

msg_hello()
{
    echo "***********************************************************************"
    echo "*                                                                     *"
    echo "*                         IoTivity Checkout Start.                    *"
    echo "*                                                                     *"
    echo "***********************************************************************"
}

msg_error()
{
    echo ---------------------------------------------------------------------
    echo "Fail to Build, Check Last Step. [$_STEP]"
    echo ---------------------------------------------------------------------
    exit 2
}

error_check()
{
    if [ $? != 0 ]
    then
       msg_error
    fi
}

_STEP=INIT
if [ ! -d resource/csdk ];then
    echo "Please check the pwd."
    msg_error
fi

# Check commit_info
_STEP=COMMIT
if [ "" = "$1" ];then
    msg_error
fi
COMMIT_ID=$(awk '/^commit_id:/{print $2}' "$1")
echo COMMIT ID is $COMMIT_ID
error_check
if [ 0 == ${#COMMIT_ID} ];then
    msg_error
fi

_STEP=FETCH
echo $FETCH_CMD
$FETCH_CMD
error_check

_STEP=CHECKOUT
echo $CHECKOUT_CMD $COMMIT_ID
$CHECKOUT_CMD $COMMIT_ID
error_check