summaryrefslogtreecommitdiffstats
path: root/install/ui/util/prepare-dojo.sh
blob: 78a3d9334172187c46a35fee49929ce14b4d1f49 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/bin/bash

# Authors:
#    Petr Vobornik <pvoborni@redhat.com>
#
#  Copyright (C) 2012 Red Hat
#  see file 'COPYING' for use and warranty information
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

#
# This script prepares working enviroment to use dojo toolkit.
#
# It checkouts public git mirrors of dojo svns then applies custom patches and
# makes symbolic links from install/ui/js/dojo and install/ui/js/util

# freeipa/install/ui absolute path - to use when this script is not run from
# install/ui directory

usage() {
cat <<-__EOF__;
NAME
     prepare-dojo.sh - prepare FreeIPA Web UI developmnent enviroment to work
                       with Dojo Library

SYNOPSIS
     path/to/prepare-dojo.sh [--help] [--all] [other options]

DESCRIPTION
     prepare-dojo.sh is a shell script which prepares FreeIPA Web UI enviroment
     for creating custom Dojo/Dojo or Dojo/Util/Build builds.

OPTIONS
     --help         print the help message

     --clone        clone git repository

     --checkout     checkout git repository

     --patches      applies custom patches, must be used with --checkout

     --links        makes symbolic links from src directory to Dojo directory

     --dojo         work with Dojo

     --util         work with Util

     --all          Do --clone --checkout --patches --links --dojo --util

     --branch <br>  Specify a Dojo branch/tag/hash to checkout, default: 1.8.3

     --dir <dir>    Specify a clone dir, default: freeipa/../dojo/
__EOF__
}

if [ "$#" = "0" ] ; then
    usage
    exit 0
fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# relative path for target dir to checkout dojo
DOJO_DIR=$DIR/../../../../dojo

# working version of Dojo toolkit
BRANCH='1.8.3'
YES='YES'

args=`getopt -q -u -l help,checkout,clone,patches,links,dojo,util,all,branch:,dir: a $*`

if test $? != 0
then
    usage
    exit 1
fi

set -- $args
for i
do
    case "$i" in
        --help)
            shift;
            HELP=$YES
            ;;
        --checkout)
            shift;
            CHECKOUT=$YES
            ;;
        --clone)
            shift;
            CLONE=$YES
            ;;
        --patches)
            shift;
            PATCHES=$YES
            ;;
        --links)
            shift;
            LINKS=$YES
            ;;
        --dojo)
            shift;
            DOJO=$YES
            ;;
        --util)
            shift;
            UTIL=$YES
            ;;
        --all | -a)
            shift;
            CHECKOUT=$YES
            CLONE=$YES
            PATCHES=$YES
            LINKS=$YES
            DOJO=$YES
            UTIL=$YES
            ALL=$YES
            ;;
        --branch)
            shift;
            BRANCH=$1
            shift;
            ;;
        --dir)
            shift;
            DOJO_DIR=$1
            shift;
            ;;
        *)
            ;;
    esac
done

if [[ $HELP = $YES ]] ; then
    usage
    exit 0
fi

if [ ! -d $DOJO_DIR ] ; then
    mkdir $DOJO_DIR
fi

# clone dojo git repositories
pushd $DOJO_DIR

if [[ $DOJO = $YES ]] ; then
    if [[ $CLONE = $YES ]] ; then
        git clone https://github.com/dojo/dojo.git
    fi
    pushd dojo
        if [[ $CHECKOUT = $YES ]] ; then
            git clean -dfx
            git checkout master
            git fetch --tags
            git fetch
            git branch -D $BRANCH
            git checkout $BRANCH
        fi
    popd

    if [[ $LINKS = $YES ]] ; then
        rm -f $DIR/../src/dojo
        ln -s $DOJO_DIR/dojo $DIR/../src/dojo
    fi
fi

if [[ $UTIL = $YES ]] ; then
    if [[ $CLONE = $YES ]] ; then
        git clone https://github.com/dojo/util.git
    fi
    pushd util
        if [[ $CHECKOUT = $YES ]] ; then
            git clean -dfx
            git checkout master
            git fetch --tags
            git fetch
            git branch -D $BRANCH
            git checkout $BRANCH
        fi

        if [[ $PATCHES = $YES ]] ; then
            # apply util custom patches
            git am $DIR/build/patches/*.patch
        fi
    popd

    if [[ $LINKS = $YES ]] ; then
        rm -f $DIR/../src/build
        ln -s $DOJO_DIR/util/build $DIR/../src/build
    fi
fi

popd # $DOJO_DIR